View | Details | Raw Unified | Return to bug 41293 | Differences between
and this patch

Collapse All | Expand All

(-)umc/js/schoolwizards/Grid.js (-1 / +1 lines)
 Lines 181-187    Link Here 
181
					label: _('School')
181
					label: _('School')
182
				});
182
				});
183
			}
183
			}
184
			columns = columns.concat(this.getGridColumns());
184
			columns = this.getGridColumns().concat(columns);
185
			return columns;
185
			return columns;
186
		},
186
		},
187
187
(-)umc/js/schoolwizards/UserCopyWizard.js (+121 lines)
Line 0    Link Here 
1
/*
2
 * Copyright 2012-2016 Univention GmbH
3
 *
4
 * http://www.univention.de/
5
 *
6
 * All rights reserved.
7
 *
8
 * The source code of this program is made available
9
 * under the terms of the GNU Affero General Public License version 3
10
 * (GNU AGPL V3) as published by the Free Software Foundation.
11
 *
12
 * Binary versions of this program provided by Univention to you as
13
 * well as other copyrighted, protected or trademarked materials like
14
 * Logos, graphics, fonts, specific documentations and configurations,
15
 * cryptographic keys etc. are subject to a license agreement between
16
 * you and Univention and not subject to the GNU AGPL V3.
17
 *
18
 * In the case you use this program under the terms of the GNU AGPL V3,
19
 * the program is provided in the hope that it will be useful,
20
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
 * GNU Affero General Public License for more details.
23
 *
24
 * You should have received a copy of the GNU Affero General Public
25
 * License with the Debian GNU/Linux or Univention distribution in file
26
 * /usr/share/common-licenses/AGPL-3; if not, see
27
 * <http://www.gnu.org/licenses/>.
28
 */
29
30
/*global define*/
31
32
define([
33
	"dojo/_base/declare",
34
	"dojo/_base/lang",
35
	"dojo/_base/array",
36
	"dojo/topic",
37
	"umc/tools",
38
	"umc/widgets/TextBox",
39
	"umc/widgets/Text",
40
	"umc/widgets/ComboBox",
41
	"umc/widgets/MultiSelect",
42
	"umc/widgets/PasswordInputBox",
43
	"umc/modules/schoolwizards/Wizard",
44
	"umc/i18n!umc/modules/schoolwizards"
45
], function(declare, lang, array, topic, tools, TextBox, Text, ComboBox, MultiSelect, PasswordInputBox, Wizard, _) {
46
47
	return declare("umc.modules.schoolwizards.UserCopyWizard", [Wizard], {
48
		description: _('Copy a user from a different school'),
49
50
		getGeneralPage: function() {
51
			return {
52
				name: 'general',
53
				headerText: this.description,
54
				widgets: [{
55
					type: TextBox,
56
					name: 'firstname',
57
					label: _('Firstname'),
58
				}, {
59
					type: TextBox,
60
					name: 'lastname',
61
					label: _('Lastname'),
62
				}, {
63
					type: TextBox,
64
					name: 'name',
65
					label: _('Username'),
66
				}],
67
				layout: [['firstname', 'lastname'],['name']]
68
			};
69
		},
70
71
		getItemPage: function() {
72
			return {
73
				name: 'item',
74
				headerText: this.description,
75
				helpText: _('Choose a user to copy'),
76
				widgets: [{
77
					type: ComboBox,
78
					name: 'username',
79
					label: _('Username')
80
				}, {
81
					type: ComboBox,
82
					name: 'school',
83
					label: _('School')
84
				}],
85
				layout: [
86
					['username'],['school']
87
				]
88
			};
89
		},
90
91
		restart: function() {
92
			tools.forIn(this.getPage('item')._form._widgets, function(iname, iwidget) {
93
				if (iname === 'password') {
94
					iwidget._setValueAttr(null);
95
				} else if (iname !== 'school_class') {
96
					iwidget.reset();
97
				}
98
			});
99
			this.inherited(arguments);
100
		},
101
102
		addNote: function() {
103
			var name = this.getWidget('item', 'name').get('value');
104
			var message = _('User "%s" has been successfully created. Continue to create another user or press "Cancel" to close this wizard.', name);
105
			this.getPage('item').clearNotes();
106
			this.getPage('item').addNote(message);
107
		},
108
109
		onShow: function() {
110
		},
111
112
		getValues: function() {
113
			var values = this.inherited(arguments);
114
			if (!this.hasClassWidget()) {
115
				delete values.school_class;
116
			}
117
			return values;
118
		},
119
	});
120
});
121
(-)umc/js/schoolwizards/UserGrid.js (-1 / +70 lines)
 Lines 34-45    Link Here 
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
 Lines 49-55    Link Here 
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',
 Lines 72-77    Link Here 
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: '&nbsp;',
145
				label: '&nbsp;',
77
				width: '10px',
146
				width: '10px',
(-)umc/js/schoolwizards/UserWizard.js (-2 / +13 lines)
 Lines 38-47    Link Here 
38
	"umc/widgets/TextBox",
38
	"umc/widgets/TextBox",
39
	"umc/widgets/Text",
39
	"umc/widgets/Text",
40
	"umc/widgets/ComboBox",
40
	"umc/widgets/ComboBox",
41
	"umc/widgets/MultiSelect",
41
	"umc/widgets/PasswordInputBox",
42
	"umc/widgets/PasswordInputBox",
42
	"umc/modules/schoolwizards/Wizard",
43
	"umc/modules/schoolwizards/Wizard",
43
	"umc/i18n!umc/modules/schoolwizards"
44
	"umc/i18n!umc/modules/schoolwizards"
44
], function(declare, lang, array, topic, tools, TextBox, Text, ComboBox, PasswordInputBox, Wizard, _) {
45
], function(declare, lang, array, topic, tools, TextBox, Text, ComboBox, MultiSelect, PasswordInputBox, Wizard, _) {
45
46
46
	return declare("umc.modules.schoolwizards.UserWizard", [Wizard], {
47
	return declare("umc.modules.schoolwizards.UserWizard", [Wizard], {
47
		description: _('Create a new user'),
48
		description: _('Create a new user'),
 Lines 151-156    Link Here 
151
						// ...and another one for Bug #30109
152
						// ...and another one for Bug #30109
152
						return this.getWidget('item', 'password').isValid();
153
						return this.getWidget('item', 'password').isValid();
153
					})
154
					})
155
				}, {
156
					type: MultiSelect,
157
					name: 'schools',
158
					label: _('School'),
159
					_setValueAttr: function(values) {
160
						this.set('dynamicValues', function() {return values;});
161
						return;
162
					},
163
					plugins: null
154
				}],
164
				}],
155
				layout: [
165
				layout: [
156
					['firstname', 'lastname'],
166
					['firstname', 'lastname'],
 Lines 157-163    Link Here 
157
					['name'],
167
					['name'],
158
					['school_class', 'newClass'],
168
					['school_class', 'newClass'],
159
					['email'],
169
					['email'],
160
					['password']
170
					['password'],
171
					['schools']
161
				]
172
				]
162
			};
173
			};
163
		},
174
		},

Return to bug 41293