]>
git.proxmox.com Git - pmg-gui.git/blob - js/UserEdit.js
1 Ext
.define('PMG.UserEdit', {
2 extend
: 'Proxmox.window.Edit',
3 alias
: 'widget.pmgUserEdit',
4 mixins
: ['Proxmox.Mixin.CBind'],
5 onlineHelp
: 'pmgconfig_localuser',
11 subject
: gettext('User'),
13 fieldDefaults
: { labelWidth
: 120 },
15 cbindData: function(initialConfig
) {
18 var userid
= initialConfig
.userid
;
19 var baseurl
= '/api2/extjs/access/users';
21 me
.isCreate
= !userid
;
22 me
.url
= userid
? baseurl
+ '/' + userid
: baseurl
;
23 me
.method
= userid
? 'PUT' : 'POST';
24 me
.autoLoad
= !!userid
;
27 useridXType
: userid
? 'displayfield' : 'textfield',
28 isSuperUser
: userid
=== 'root@pam',
38 fieldLabel
: gettext('User name'),
39 renderer
: Ext
.htmlEncode
,
43 submitValue
: '{isCreate}',
44 xtype
: '{useridXType}',
49 inputType
: 'password',
50 fieldLabel
: gettext('Password'),
55 change: function(field
) {
56 field
.next().validate();
58 blur: function(field
) {
59 field
.next().validate();
63 hidden
: '{!isCreate}',
64 disabled
: '{!isCreate}',
69 inputType
: 'password',
70 fieldLabel
: gettext('Confirm password'),
71 name
: 'verifypassword',
73 initialPassField
: 'password',
77 hidden
: '{!isCreate}',
78 disabled
: '{!isCreate}',
82 xtype
: 'pmgRoleSelector',
85 fieldLabel
: gettext('Role'),
87 disabled
: '{isSuperUser}',
93 emptyText
: Proxmox
.Utils
.neverText
,
96 fieldLabel
: gettext('Expire'),
98 disabled
: '{isSuperUser}',
102 xtype
: 'proxmoxcheckbox',
103 fieldLabel
: gettext('Enabled'),
109 disabled
: '{isSuperUser}',
116 xtype
: 'proxmoxtextfield',
118 fieldLabel
: gettext('First Name'),
120 deleteEmpty
: '{!isCreate}',
124 xtype
: 'proxmoxtextfield',
126 fieldLabel
: gettext('Last Name'),
128 deleteEmpty
: '{!isCreate}',
132 xtype
: 'proxmoxtextfield',
134 fieldLabel
: gettext('E-Mail'),
135 vtype
: 'proxmoxMail',
137 deleteEmpty
: '{!isCreate}',
144 xtype
: 'proxmoxtextfield',
146 fieldLabel
: gettext('Comment'),
148 disabled
: '{isSuperUser}',
149 deleteEmpty
: '{!isCreate}',
153 xtype
: 'proxmoxtextfield',
155 fieldLabel
: gettext('Key IDs'),
157 deleteEmpty
: '{!isCreate}',
163 getValues: function(dirtyOnly
) {
166 var values
= me
.callParent(arguments
);
168 // hack: ExtJS datefield does not submit 0, so we need to set that
169 if (!values
.expire
) {
174 values
.userid
= values
.username
+ '@pmg';
177 delete values
.username
;
179 if (!values
.password
) {
180 delete values
.password
;
186 setValues: function(values
) {
189 if (Ext
.isDefined(values
.expire
)) {
191 values
.expire
= new Date(values
.expire
* 1000);
193 // display 'never' instead of '1970-01-01'
194 values
.expire
= null;
198 me
.callParent([values
]);