Index: umc/js/schoolwizards/Grid.js
===================================================================
--- umc/js/schoolwizards/Grid.js (Revision 69403)
+++ umc/js/schoolwizards/Grid.js (Arbeitskopie)
@@ -181,7 +181,7 @@
label: _('School')
});
}
- columns = columns.concat(this.getGridColumns());
+ columns = this.getGridColumns().concat(columns);
return columns;
},
Index: umc/js/schoolwizards/UserCopyWizard.js
===================================================================
--- umc/js/schoolwizards/UserCopyWizard.js (nicht existent)
+++ umc/js/schoolwizards/UserCopyWizard.js (Arbeitskopie)
@@ -0,0 +1,121 @@
+/*
+ * Copyright 2012-2016 Univention GmbH
+ *
+ * http://www.univention.de/
+ *
+ * All rights reserved.
+ *
+ * The source code of this program is made available
+ * under the terms of the GNU Affero General Public License version 3
+ * (GNU AGPL V3) as published by the Free Software Foundation.
+ *
+ * Binary versions of this program provided by Univention to you as
+ * well as other copyrighted, protected or trademarked materials like
+ * Logos, graphics, fonts, specific documentations and configurations,
+ * cryptographic keys etc. are subject to a license agreement between
+ * you and Univention and not subject to the GNU AGPL V3.
+ *
+ * In the case you use this program under the terms of the GNU AGPL V3,
+ * the program is provided in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License with the Debian GNU/Linux or Univention distribution in file
+ * /usr/share/common-licenses/AGPL-3; if not, see
+ * .
+ */
+
+/*global define*/
+
+define([
+ "dojo/_base/declare",
+ "dojo/_base/lang",
+ "dojo/_base/array",
+ "dojo/topic",
+ "umc/tools",
+ "umc/widgets/TextBox",
+ "umc/widgets/Text",
+ "umc/widgets/ComboBox",
+ "umc/widgets/MultiSelect",
+ "umc/widgets/PasswordInputBox",
+ "umc/modules/schoolwizards/Wizard",
+ "umc/i18n!umc/modules/schoolwizards"
+], function(declare, lang, array, topic, tools, TextBox, Text, ComboBox, MultiSelect, PasswordInputBox, Wizard, _) {
+
+ return declare("umc.modules.schoolwizards.UserCopyWizard", [Wizard], {
+ description: _('Copy a user from a different school'),
+
+ getGeneralPage: function() {
+ return {
+ name: 'general',
+ headerText: this.description,
+ widgets: [{
+ type: TextBox,
+ name: 'firstname',
+ label: _('Firstname'),
+ }, {
+ type: TextBox,
+ name: 'lastname',
+ label: _('Lastname'),
+ }, {
+ type: TextBox,
+ name: 'name',
+ label: _('Username'),
+ }],
+ layout: [['firstname', 'lastname'],['name']]
+ };
+ },
+
+ getItemPage: function() {
+ return {
+ name: 'item',
+ headerText: this.description,
+ helpText: _('Choose a user to copy'),
+ widgets: [{
+ type: ComboBox,
+ name: 'username',
+ label: _('Username')
+ }, {
+ type: ComboBox,
+ name: 'school',
+ label: _('School')
+ }],
+ layout: [
+ ['username'],['school']
+ ]
+ };
+ },
+
+ restart: function() {
+ tools.forIn(this.getPage('item')._form._widgets, function(iname, iwidget) {
+ if (iname === 'password') {
+ iwidget._setValueAttr(null);
+ } else if (iname !== 'school_class') {
+ iwidget.reset();
+ }
+ });
+ this.inherited(arguments);
+ },
+
+ addNote: function() {
+ var name = this.getWidget('item', 'name').get('value');
+ var message = _('User "%s" has been successfully created. Continue to create another user or press "Cancel" to close this wizard.', name);
+ this.getPage('item').clearNotes();
+ this.getPage('item').addNote(message);
+ },
+
+ onShow: function() {
+ },
+
+ getValues: function() {
+ var values = this.inherited(arguments);
+ if (!this.hasClassWidget()) {
+ delete values.school_class;
+ }
+ return values;
+ },
+ });
+});
+
Index: umc/js/schoolwizards/UserGrid.js
===================================================================
--- umc/js/schoolwizards/UserGrid.js (Revision 69403)
+++ umc/js/schoolwizards/UserGrid.js (Arbeitskopie)
@@ -34,12 +34,15 @@
"dojo/_base/lang",
"dojo/_base/array",
"dojo/topic",
+ "dojo/string",
+ "umc/tools",
"umc/widgets/TextBox",
"umc/widgets/ComboBox",
"umc/modules/schoolwizards/UserWizard",
+ "umc/modules/schoolwizards/UserCopyWizard",
"umc/modules/schoolwizards/Grid",
"umc/i18n!umc/modules/schoolwizards"
-], function(declare, lang, array, topic, TextBox, ComboBox, UserWizard, Grid, _) {
+], function(declare, lang, array, topic, string, tools, TextBox, ComboBox, UserWizard, UserCopyWizard, Grid, _) {
return declare("umc.modules.schoolwizards.UserGrid", [Grid], {
@@ -49,7 +52,65 @@
objectNameSingular: _('school user'),
firstObject: _('the first school user'),
createObjectWizard: UserWizard,
+ copyObjectWizard: UserCopyWizard,
+ sortFields: ['name'],
+ getGridColumnsWithSchool: function() {
+ return this.getGridColumns();
+ },
+
+ getGridActions: function() {
+ return this.inherited(arguments).concat(this.getGridCopyToSchoolAction());
+ },
+
+ getGridCopyToSchoolAction: function() {
+ return {
+ name: 'copyToSchool',
+ label: _('Copy a user to your school'),
+ description: _('Copy a %s to your school', this.objectNameSingular),
+ iconClass: 'umcIconAdd',
+ isContextAction: false,
+ isStandardAction: true,
+ callback: lang.hitch(this, 'copyObject')
+ };
+ },
+
+ copyObject: function() {
+ this.copyWizard({
+ editMode: false,
+ $dn$: null,
+ school: this.getSelectedSchool(),
+ type: this.getSelectedType(),
+ itemType: tools.capitalize(this.objectNameSingular),
+ objectType: null
+ });
+ },
+
+ copyWizard: function(props) {
+ var wizard = new this.copyObjectWizard(lang.mixin({
+ udmLinkEnabled: this.udmLinkEnabled,
+ store: this._grid.moduleStore,
+ schools: this.schools,
+ umcpCommand: lang.hitch(this, 'umcpCommand')
+ }, props));
+ this.module.addChild(wizard);
+ this.module.selectChild(wizard);
+ var closeWizard = lang.hitch(this, function() {
+ this.module.selectChild(this);
+ this.module.removeChild(wizard);
+ });
+ wizard.on('cancel', closeWizard);
+ wizard.on('finished', closeWizard);
+
+ // TODO: test if still works... why does it exists?
+ if (!props.editMode && 'onShow' in wizard) {
+ // send a reload command to wizard
+ this.module.on('show', lang.hitch(this, function(evt) {
+ wizard.onShow();
+ }));
+ }
+ },
+
getGridColumns: function() {
return [{
name: 'display_name',
@@ -72,6 +133,14 @@
// label: _('E-Mail address'),
// description: _('E-Mail address of the %s.', this.objectNameSingular)
}, {
+ name: 'schools',
+ label: _('School'),
+ formatter: lang.hitch(this, function(schools, id) {
+ var escaped_schools_str = string.escape(schools.join(', '));
+ return '' + escaped_schools_str + '';
+ }),
+ styles: 'white-space: nowrap; text-overflow: ellipsis;',
+ }, {
name: 'empty', // workaround: EnhancedGrid
label: ' ',
width: '10px',
Index: umc/js/schoolwizards/UserWizard.js
===================================================================
--- umc/js/schoolwizards/UserWizard.js (Revision 69403)
+++ umc/js/schoolwizards/UserWizard.js (Arbeitskopie)
@@ -38,10 +38,11 @@
"umc/widgets/TextBox",
"umc/widgets/Text",
"umc/widgets/ComboBox",
+ "umc/widgets/MultiSelect",
"umc/widgets/PasswordInputBox",
"umc/modules/schoolwizards/Wizard",
"umc/i18n!umc/modules/schoolwizards"
-], function(declare, lang, array, topic, tools, TextBox, Text, ComboBox, PasswordInputBox, Wizard, _) {
+], function(declare, lang, array, topic, tools, TextBox, Text, ComboBox, MultiSelect, PasswordInputBox, Wizard, _) {
return declare("umc.modules.schoolwizards.UserWizard", [Wizard], {
description: _('Create a new user'),
@@ -151,6 +152,15 @@
// ...and another one for Bug #30109
return this.getWidget('item', 'password').isValid();
})
+ }, {
+ type: MultiSelect,
+ name: 'schools',
+ label: _('School'),
+ _setValueAttr: function(values) {
+ this.set('dynamicValues', function() {return values;});
+ return;
+ },
+ plugins: null
}],
layout: [
['firstname', 'lastname'],
@@ -157,7 +167,8 @@
['name'],
['school_class', 'newClass'],
['email'],
- ['password']
+ ['password'],
+ ['schools']
]
};
},