|
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 |
"umc/widgets/Form", |
| 37 |
"umc/widgets/Page", |
| 38 |
"umc/widgets/Button", |
| 39 |
"umc/widgets/ComboBox", |
| 40 |
"umc/widgets/Text", |
| 41 |
"umc/modules/schoolwizards/UserGrid", |
| 42 |
"umc/i18n!umc/modules/schoolwizards" |
| 43 |
], function(declare, lang, array, Form, Page, Button, ComboBox, Text, UserGrid, _) { |
| 44 |
|
| 45 |
return declare("umc.modules.schoolwizards.UserGridChooseSchool", [Page], { |
| 46 |
userGrid: null, |
| 47 |
baseTitle: null, |
| 48 |
_form: null, |
| 49 |
|
| 50 |
postMixInProperties: function() { |
| 51 |
this.baseTitle = this.module.get('title'); |
| 52 |
}, |
| 53 |
|
| 54 |
buildRendering: function() { |
| 55 |
this.inherited(arguments); |
| 56 |
|
| 57 |
var headerTextWidget = this.createHeader(); |
| 58 |
this._form = this.createForm(); |
| 59 |
this._form.on('submit', lang.hitch(this, 'buildGrid')); |
| 60 |
|
| 61 |
this.addChild(headerTextWidget); |
| 62 |
this.addChild(this._form); |
| 63 |
}, |
| 64 |
|
| 65 |
createHeader: function() { |
| 66 |
var headerText = _("Select a school on which you like to work on"); |
| 67 |
return new Text({ |
| 68 |
content: _('<h1>' + headerText + '<h1>'), |
| 69 |
'class': 'umcPageHeader' |
| 70 |
}); |
| 71 |
}, |
| 72 |
|
| 73 |
createForm: function() { |
| 74 |
return new Form({ |
| 75 |
widgets: [{ |
| 76 |
type: ComboBox, |
| 77 |
name: 'schools', |
| 78 |
label: _('School'), |
| 79 |
size: 'OneThirds', |
| 80 |
staticValues: this.schools |
| 81 |
}], |
| 82 |
buttons: [{ |
| 83 |
name: 'submit', |
| 84 |
label: _('Next') |
| 85 |
}], |
| 86 |
layout: [ |
| 87 |
['schools', 'submit'], |
| 88 |
] |
| 89 |
}); |
| 90 |
}, |
| 91 |
|
| 92 |
buildGrid: function() { |
| 93 |
var selectedSchool = array.filter(this.schools, lang.hitch(this, function(school) { |
| 94 |
return school.id === this._form.getWidget('schools').getValue(); |
| 95 |
}))[0]; |
| 96 |
var _backToSchool = new Button({ |
| 97 |
name: 'back', |
| 98 |
label: _('Back'), |
| 99 |
region: 'footer', |
| 100 |
onClick: lang.hitch(this, 'chooseDifferentSchool') |
| 101 |
}); |
| 102 |
var userGrid = new UserGrid({ |
| 103 |
description: this.description, |
| 104 |
schools: [selectedSchool], |
| 105 |
udmLinkEnabled: this.udmLinkEnabled, |
| 106 |
autoSearch: this.autoSearch, |
| 107 |
umcpCommand: lang.hitch(this, 'umcpCommand'), |
| 108 |
moduleFlavor: this.moduleFlavor, |
| 109 |
module: this.module |
| 110 |
}); |
| 111 |
|
| 112 |
//add UserGrid to module |
| 113 |
userGrid.addChild(_backToSchool); |
| 114 |
this.module.addChild(userGrid); |
| 115 |
this.module.selectChild(userGrid); |
| 116 |
|
| 117 |
//append title with the selected school |
| 118 |
var titleAppendix = lang.replace(": {0}", [selectedSchool.label]); |
| 119 |
this.module.set('title', this.baseTitle + titleAppendix); |
| 120 |
|
| 121 |
this.userGrid = userGrid; |
| 122 |
}, |
| 123 |
|
| 124 |
chooseDifferentSchool: function() { |
| 125 |
this.module.removeChild(this.userGrid); |
| 126 |
this.userGrid.destroyRecursive(); |
| 127 |
|
| 128 |
this.module.set('title', this.baseTitle); |
| 129 |
|
| 130 |
this.module.selectChild(this); |
| 131 |
} |
| 132 |
}); |
| 133 |
}); |
| 134 |
|