|
34 |
"dojo/_base/lang", |
34 |
"dojo/_base/lang", |
35 |
"dojo/_base/array", |
35 |
"dojo/_base/array", |
36 |
"dojo/topic", |
36 |
"dojo/topic", |
|
|
37 |
"dojo/string", |
38 |
"umc/tools", |
37 |
"umc/widgets/TextBox", |
39 |
"umc/widgets/TextBox", |
38 |
"umc/widgets/ComboBox", |
40 |
"umc/widgets/ComboBox", |
39 |
"umc/modules/schoolwizards/UserWizard", |
41 |
"umc/modules/schoolwizards/UserWizard", |
|
|
42 |
"umc/modules/schoolwizards/UserCopyWizard", |
40 |
"umc/modules/schoolwizards/Grid", |
43 |
"umc/modules/schoolwizards/Grid", |
41 |
"umc/i18n!umc/modules/schoolwizards" |
44 |
"umc/i18n!umc/modules/schoolwizards" |
42 |
], function(declare, lang, array, topic, TextBox, ComboBox, UserWizard, Grid, _) { |
45 |
], function(declare, lang, array, topic, string, tools, TextBox, ComboBox, UserWizard, UserCopyWizard, Grid, _) { |
43 |
|
46 |
|
44 |
return declare("umc.modules.schoolwizards.UserGrid", [Grid], { |
47 |
return declare("umc.modules.schoolwizards.UserGrid", [Grid], { |
45 |
|
48 |
|
|
49 |
objectNameSingular: _('school user'), |
52 |
objectNameSingular: _('school user'), |
50 |
firstObject: _('the first school user'), |
53 |
firstObject: _('the first school user'), |
51 |
createObjectWizard: UserWizard, |
54 |
createObjectWizard: UserWizard, |
|
|
55 |
copyObjectWizard: UserCopyWizard, |
56 |
sortFields: ['name'], |
52 |
|
57 |
|
|
|
58 |
getGridColumnsWithSchool: function() { |
59 |
return this.getGridColumns(); |
60 |
}, |
61 |
|
62 |
getGridActions: function() { |
63 |
return this.inherited(arguments).concat(this.getGridCopyToSchoolAction()); |
64 |
}, |
65 |
|
66 |
getGridCopyToSchoolAction: function() { |
67 |
return { |
68 |
name: 'copyToSchool', |
69 |
label: _('Copy a user to your school'), |
70 |
description: _('Copy a %s to your school', this.objectNameSingular), |
71 |
iconClass: 'umcIconAdd', |
72 |
isContextAction: false, |
73 |
isStandardAction: true, |
74 |
callback: lang.hitch(this, 'copyObject') |
75 |
}; |
76 |
}, |
77 |
|
78 |
copyObject: function() { |
79 |
this.copyWizard({ |
80 |
editMode: false, |
81 |
$dn$: null, |
82 |
school: this.getSelectedSchool(), |
83 |
type: this.getSelectedType(), |
84 |
itemType: tools.capitalize(this.objectNameSingular), |
85 |
objectType: null |
86 |
}); |
87 |
}, |
88 |
|
89 |
copyWizard: function(props) { |
90 |
var wizard = new this.copyObjectWizard(lang.mixin({ |
91 |
udmLinkEnabled: this.udmLinkEnabled, |
92 |
store: this._grid.moduleStore, |
93 |
schools: this.schools, |
94 |
umcpCommand: lang.hitch(this, 'umcpCommand') |
95 |
}, props)); |
96 |
this.module.addChild(wizard); |
97 |
this.module.selectChild(wizard); |
98 |
var closeWizard = lang.hitch(this, function() { |
99 |
this.module.selectChild(this); |
100 |
this.module.removeChild(wizard); |
101 |
}); |
102 |
wizard.on('cancel', closeWizard); |
103 |
wizard.on('finished', closeWizard); |
104 |
|
105 |
// TODO: test if still works... why does it exists? |
106 |
if (!props.editMode && 'onShow' in wizard) { |
107 |
// send a reload command to wizard |
108 |
this.module.on('show', lang.hitch(this, function(evt) { |
109 |
wizard.onShow(); |
110 |
})); |
111 |
} |
112 |
}, |
113 |
|
53 |
getGridColumns: function() { |
114 |
getGridColumns: function() { |
54 |
return [{ |
115 |
return [{ |
55 |
name: 'display_name', |
116 |
name: 'display_name', |
|
72 |
// label: _('E-Mail address'), |
133 |
// label: _('E-Mail address'), |
73 |
// description: _('E-Mail address of the %s.', this.objectNameSingular) |
134 |
// description: _('E-Mail address of the %s.', this.objectNameSingular) |
74 |
}, { |
135 |
}, { |
|
|
136 |
name: 'schools', |
137 |
label: _('School'), |
138 |
formatter: lang.hitch(this, function(schools, id) { |
139 |
var escaped_schools_str = string.escape(schools.join(', ')); |
140 |
return '<span title="' + escaped_schools_str + '">' + escaped_schools_str + '</span>'; |
141 |
}), |
142 |
styles: 'white-space: nowrap; text-overflow: ellipsis;', |
143 |
}, { |
75 |
name: 'empty', // workaround: EnhancedGrid |
144 |
name: 'empty', // workaround: EnhancedGrid |
76 |
label: ' ', |
145 |
label: ' ', |
77 |
width: '10px', |
146 |
width: '10px', |