]>
git.proxmox.com Git - pmg-gui.git/blob - js/UserEdit.js
e3ab5a296970680e4dee4a3e6c5838e674b732eb
2 /*jslint confusion: true*/
3 /* submitvalue is string and bool */
4 Ext
.define('PMG.UserEdit', {
5 extend
: 'Proxmox.window.Edit',
6 alias
: 'widget.pmgUserEdit',
7 mixins
: ['Proxmox.Mixin.CBind'],
13 subject
: gettext('User'),
15 fieldDefaults
: { labelWidth
: 120 },
17 cbindData: function(initialConfig
) {
20 var userid
= initialConfig
.userid
;
21 var baseurl
= '/api2/extjs/access/users';
23 me
.isCreate
= !userid
;
24 me
.url
= userid
? baseurl
+ '/' + userid
: baseurl
;
25 me
.method
= userid
? 'PUT' : 'POST';
26 me
.autoLoad
= userid
? true : false;
29 useridXType
: userid
? 'displayfield' : 'textfield',
30 isSuperUser
: userid
=== 'root@pam'
40 fieldLabel
: gettext('User name'),
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
]);