Index: umc/js/schoolwizards/Grid.js
===================================================================
--- umc/js/schoolwizards/Grid.js (Revision 69658)
+++ 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/UserGrid.js
===================================================================
--- umc/js/schoolwizards/UserGrid.js (Revision 69658)
+++ umc/js/schoolwizards/UserGrid.js (Arbeitskopie)
@@ -32,14 +32,13 @@
define([
"dojo/_base/declare",
"dojo/_base/lang",
- "dojo/_base/array",
- "dojo/topic",
+ "dojo/string",
"umc/widgets/TextBox",
"umc/widgets/ComboBox",
"umc/modules/schoolwizards/UserWizard",
"umc/modules/schoolwizards/Grid",
"umc/i18n!umc/modules/schoolwizards"
-], function(declare, lang, array, topic, TextBox, ComboBox, UserWizard, Grid, _) {
+], function(declare, lang, string, TextBox, ComboBox, UserWizard, Grid, _) {
return declare("umc.modules.schoolwizards.UserGrid", [Grid], {
@@ -49,7 +48,12 @@
objectNameSingular: _('school user'),
firstObject: _('the first school user'),
createObjectWizard: UserWizard,
+ sortFields: ['name'],
+ getGridColumnsWithSchool: function() {
+ return this.getGridColumns();
+ },
+
getGridColumns: function() {
return [{
name: 'display_name',
@@ -72,6 +76,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/UserGridChooseSchool.js
===================================================================
--- umc/js/schoolwizards/UserGridChooseSchool.js (Revision 0)
+++ umc/js/schoolwizards/UserGridChooseSchool.js (Arbeitskopie)
@@ -0,0 +1,134 @@
+/*
+ * 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",
+ "umc/widgets/Form",
+ "umc/widgets/ContainerWidget",
+ "umc/widgets/Button",
+ "umc/widgets/ComboBox",
+ "umc/widgets/Text",
+ "umc/modules/schoolwizards/UserGrid",
+ "umc/i18n!umc/modules/schoolwizards"
+], function(declare, lang, array, Form, ContainerWidget, Button, ComboBox, Text, UserGrid, _) {
+
+ return declare("umc.modules.schoolwizards.UserGridChooseSchool", [ContainerWidget], {
+ userGrid: null,
+ baseTitle: null,
+ _form: null,
+
+ postMixInProperties: function() {
+ this.baseTitle = this.module.get('title');
+ },
+
+ buildRendering: function() {
+ this.inherited(arguments);
+
+ var headerTextWidget = this.createHeader();
+ this._form = this.createForm();
+ this._form.on('submit', lang.hitch(this, 'buildGrid'));
+
+ this.addChild(headerTextWidget);
+ this.addChild(this._form);
+ },
+
+ createHeader: function() {
+ var headerText = _("Select a school on which you like to work on");
+ return new Text({
+ content: _('
' + headerText + ''),
+ 'class': 'umcPageHeader'
+ });
+ },
+
+ createForm: function() {
+ return new Form({
+ widgets: [{
+ type: ComboBox,
+ name: 'schools',
+ label: _('School'),
+ size: 'OneThirds',
+ staticValues: this.schools
+ }],
+ buttons: [{
+ name: 'submit',
+ label: _('Next')
+ }],
+ layout: [
+ ['schools', 'submit'],
+ ]
+ });
+ },
+
+ buildGrid: function() {
+ var selectedSchool = array.filter(this.schools, lang.hitch(this, function(school) {
+ return school.id === this._form.getWidget('schools').getValue();
+ }))[0];
+ var _backToSchool = new Button({
+ name: 'back',
+ label: 'Back',
+ region: 'footer',
+ onClick: lang.hitch(this, 'chooseDifferentSchool')
+ });
+ var userGrid = new UserGrid({
+ description: this.description,
+ schools: [selectedSchool],
+ udmLinkEnabled: this.udmLinkEnabled,
+ autoSearch: this.autoSearch,
+ umcpCommand: lang.hitch(this, 'umcpCommand'),
+ moduleFlavor: this.moduleFlavor,
+ module: this.module
+ });
+
+ //add UserGrid to module
+ userGrid.addChild(_backToSchool);
+ this.module.addChild(userGrid);
+ this.module.selectChild(userGrid);
+
+ //append title with the selected school
+ var titleAppendix = lang.replace(": {0}", [selectedSchool.label]);
+ this.module.set('title', this.baseTitle + titleAppendix);
+
+ this.userGrid = userGrid;
+ },
+
+ chooseDifferentSchool: function() {
+ this.module.removeChild(this.userGrid);
+ this.userGrid.destroyRecursive();
+
+ this.module.set('title', this.baseTitle);
+
+ this.module.selectChild(this);
+ }
+ });
+});
+
Index: umc/js/schoolwizards/UserWizard.js
===================================================================
--- umc/js/schoolwizards/UserWizard.js (Revision 69658)
+++ 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']
]
};
},
Index: umc/js/schoolwizards.js
===================================================================
--- umc/js/schoolwizards.js (Revision 69658)
+++ umc/js/schoolwizards.js (Arbeitskopie)
@@ -37,12 +37,13 @@
"umc/tools",
"umc/dialog",
"umc/widgets/Module",
+ "umc/modules/schoolwizards/UserGridChooseSchool",
"umc/modules/schoolwizards/UserGrid",
"umc/modules/schoolwizards/ClassGrid",
"umc/modules/schoolwizards/ComputerGrid",
"umc/modules/schoolwizards/SchoolGrid",
"umc/i18n!umc/modules/schoolwizards"
-], function(declare, lang, all, topic, tools, dialog, Module, UserGrid, ClassGrid, ComputerGrid, SchoolGrid, _) {
+], function(declare, lang, all, topic, tools, dialog, Module, UserGridChooseSchool, UserGrid, ClassGrid, ComputerGrid, SchoolGrid, _) {
var grids = {
'schoolwizards/users': UserGrid,
'schoolwizards/classes': ClassGrid,
@@ -98,9 +99,21 @@
},
_getGrid: function() {
- var Grid = grids[this.moduleFlavor];
+ var gridOptions = this._getGridOptions();
- return new Grid({
+ //if the user opens the Users (schools) module and there are more than one school
+ //show an extra page where the user has to choose a school
+ var usersModuleSelected = this.moduleFlavor === 'schoolwizards/users';
+ if (usersModuleSelected && this.schools.length > 1) {
+ return new UserGridChooseSchool(gridOptions);
+ } else {
+ var Grid = grids[this.moduleFlavor];
+ return new Grid(gridOptions);
+ }
+ },
+
+ _getGridOptions: function() {
+ return {
description: this.description,
schools: this.schools,
udmLinkEnabled: this.udmLinkEnabled,
@@ -108,7 +121,7 @@
umcpCommand: lang.hitch(this, 'umcpCommand'),
moduleFlavor: this.moduleFlavor,
module: this
- });
+ };
}
});
});