|
1
|
|
|
define([ |
|
2
|
|
|
'dojo/_base/declare', |
|
3
|
|
|
'dojo/_base/lang', |
|
4
|
|
|
'dojo/topic', |
|
5
|
|
|
'dojo/dom-attr', |
|
6
|
|
|
'dojo/on', |
|
7
|
|
|
'dijit/Dialog', |
|
8
|
|
|
'dijit/_Widget', |
|
9
|
|
|
'dijit/_TemplatedMixin', |
|
10
|
|
|
'dijit/_WidgetsInTemplateMixin', |
|
11
|
|
|
'../../utils/DomUtils', |
|
12
|
|
|
'../managers/LabelManager', |
|
13
|
|
|
'../managers/NoteManager', |
|
14
|
|
|
'../managers/SourcesManager', |
|
15
|
|
|
'../../utils/DomUtils', |
|
16
|
|
|
'dojo/text!./templates/ManageSchemeDialog.html', |
|
17
|
|
|
'dijit/layout/TabContainer', |
|
18
|
|
|
'dijit/layout/ContentPane' |
|
19
|
|
|
], function ( |
|
20
|
|
|
declare, |
|
21
|
|
|
lang, |
|
22
|
|
|
topic, |
|
23
|
|
|
domAttr, |
|
24
|
|
|
on, |
|
25
|
|
|
Dialog, |
|
26
|
|
|
_Widget, |
|
27
|
|
|
_TemplatedMixin, |
|
28
|
|
|
_WidgetsInTemplateMixin, |
|
29
|
|
|
DomUtils, |
|
30
|
|
|
LabelManager, |
|
31
|
|
|
NoteManager, |
|
32
|
|
|
SourcesManager, |
|
33
|
|
|
domUtils, |
|
34
|
|
|
template |
|
35
|
|
|
) { |
|
36
|
|
|
return declare([_Widget, _TemplatedMixin, _WidgetsInTemplateMixin], { |
|
37
|
|
|
|
|
38
|
|
|
templateString: template, |
|
39
|
|
|
baseClass: 'edit-scheme-dialog', |
|
40
|
|
|
dialog: null, |
|
41
|
|
|
parent: null, |
|
42
|
|
|
scheme: null, |
|
43
|
|
|
languageController: null, |
|
44
|
|
|
listController: null, |
|
45
|
|
|
conceptSchemeController: null, |
|
46
|
|
|
_mode: 'edit', |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* Standaard widget functie |
|
50
|
|
|
*/ |
|
51
|
|
|
postCreate: function () { |
|
52
|
|
|
this.inherited(arguments); |
|
53
|
|
|
this.dialog = new Dialog({ |
|
54
|
|
|
title: 'Edit scheme', |
|
55
|
|
|
style: 'width: 1000px; min-height: 650px;' |
|
56
|
|
|
//onHide: lang.hitch(this, function() { |
|
57
|
|
|
// this.parent._closeAddDialog(); |
|
58
|
|
|
//}) |
|
59
|
|
|
}); |
|
60
|
|
|
this.dialog.closeText.innerHTML = '<i class="fa fa-times"></i>'; |
|
61
|
|
|
this.dialog.set('content', this); |
|
62
|
|
|
|
|
63
|
|
|
this._createLabelsTab(); |
|
64
|
|
|
this._createNotesTab(); |
|
65
|
|
|
this._createSourcesTab(); |
|
66
|
|
|
}, |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* Standaard widget functie |
|
70
|
|
|
*/ |
|
71
|
|
|
startup: function () { |
|
72
|
|
|
this.inherited(arguments); |
|
73
|
|
|
this.tabContainer.layout(); |
|
74
|
|
|
this.dialog.resize(); |
|
75
|
|
|
}, |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* Toont het dialog |
|
79
|
|
|
*/ |
|
80
|
|
|
showDialog: function (scheme, mode) { |
|
81
|
|
|
if (mode) { |
|
82
|
|
|
this.mode = mode; |
|
83
|
|
|
} |
|
84
|
|
|
if (scheme) { |
|
85
|
|
|
if (scheme.id) { |
|
86
|
|
|
this.dialog.set('title', 'Edit <strong>' + scheme.label + '</strong>'); |
|
87
|
|
|
} |
|
88
|
|
|
this.sourcesManager.setConcept(scheme); |
|
89
|
|
|
this.labelManager.setConcept(scheme); |
|
90
|
|
|
this.noteManager.setConcept(scheme); |
|
91
|
|
|
this.scheme = scheme; |
|
92
|
|
|
} |
|
93
|
|
|
this.dialog.show(); |
|
94
|
|
|
this.tabContainer.selectChild(this.tabLabels); |
|
95
|
|
|
this.tabContainer.layout(); |
|
96
|
|
|
this.dialog.resize(); |
|
97
|
|
|
}, |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* Sluit het dialog |
|
101
|
|
|
* @private |
|
102
|
|
|
*/ |
|
103
|
|
|
_close: function () { |
|
104
|
|
|
this._reset(); |
|
105
|
|
|
this.dialog.hide(); |
|
106
|
|
|
}, |
|
107
|
|
|
|
|
108
|
|
|
_saveScheme: function(evt) { |
|
109
|
|
|
evt ? evt.preventDefault() : null; |
|
110
|
|
|
var scheme = {}; |
|
111
|
|
|
|
|
112
|
|
|
if (this.scheme) { |
|
113
|
|
|
scheme.id = this.scheme.id || undefined; |
|
114
|
|
|
scheme.uri = this.scheme.uri || undefined; |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
//// mixin tab data |
|
118
|
|
|
var labelData = this.labelManager.getData(); |
|
119
|
|
|
lang.mixin(scheme, labelData); |
|
120
|
|
|
|
|
121
|
|
|
var noteData = this.noteManager.getData(); |
|
122
|
|
|
lang.mixin(scheme, noteData); |
|
123
|
|
|
|
|
124
|
|
|
var sourceData = this.sourcesManager.getData(); |
|
125
|
|
|
lang.mixin(scheme, sourceData); |
|
126
|
|
|
|
|
127
|
|
|
if (this._mode === 'add') { |
|
128
|
|
|
// emit save event |
|
129
|
|
|
this.emit('new.scheme.save', { |
|
130
|
|
|
scheme: scheme |
|
131
|
|
|
}); |
|
132
|
|
|
} else { |
|
133
|
|
|
this.emit('scheme.save', { |
|
134
|
|
|
scheme: scheme |
|
135
|
|
|
}); |
|
136
|
|
|
} |
|
137
|
|
|
}, |
|
138
|
|
|
|
|
139
|
|
|
_cancel: function(evt) { |
|
140
|
|
|
evt ? evt.preventDefault() : null; |
|
141
|
|
|
this._close(); |
|
142
|
|
|
}, |
|
143
|
|
|
|
|
144
|
|
|
_reset: function() { |
|
145
|
|
|
this.labelManager.reset(); |
|
146
|
|
|
this.noteManager.reset(); |
|
147
|
|
|
this.sourcesManager.reset(); |
|
148
|
|
|
}, |
|
149
|
|
|
|
|
150
|
|
|
_createLabelsTab: function(scheme) { |
|
151
|
|
|
this.languageController.getLanguageStore().fetch().then(lang.hitch(this, function(languages) { |
|
152
|
|
|
this.labelManager = new LabelManager({ |
|
153
|
|
|
languageController: this.languageController, |
|
154
|
|
|
listController: this.listController, |
|
155
|
|
|
concept: scheme, |
|
156
|
|
|
languageList: languages |
|
157
|
|
|
}, this.labelsNode); |
|
158
|
|
|
this.labelManager.startup(); |
|
159
|
|
|
})); |
|
160
|
|
|
}, |
|
161
|
|
|
|
|
162
|
|
|
_createNotesTab: function(scheme) { |
|
163
|
|
|
this.languageController.getLanguageStore().fetch().then(lang.hitch(this, function(languages) { |
|
164
|
|
|
this.noteManager = new NoteManager({ |
|
165
|
|
|
languageController: this.languageController, |
|
166
|
|
|
listController: this.listController, |
|
167
|
|
|
concept: scheme, |
|
168
|
|
|
languageList: languages |
|
169
|
|
|
}, this.notesNode); |
|
170
|
|
|
this.noteManager.startup(); |
|
171
|
|
|
})); |
|
172
|
|
|
}, |
|
173
|
|
|
|
|
174
|
|
|
_createSourcesTab: function(scheme) { |
|
175
|
|
|
this.sourcesManager = new SourcesManager({ |
|
176
|
|
|
listController: this.listController, |
|
177
|
|
|
concept: scheme |
|
178
|
|
|
}, this.sourcesNode); |
|
179
|
|
|
this.sourcesManager.startup(); |
|
180
|
|
|
} |
|
181
|
|
|
}); |
|
182
|
|
|
}); |