@oat-sa/tao-core-ui 1.58.1 → 1.58.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actionbar.js +386 -395
- package/dist/adder.js +21 -19
- package/dist/animable/absorbable/absorbable.js +204 -213
- package/dist/animable/absorbable/css/absorb.css +1 -0
- package/dist/animable/absorbable/css/absorb.css.map +1 -1
- package/dist/animable/pulsable/pulsable.js +168 -177
- package/dist/autocomplete/css/autocomplete.css +1 -0
- package/dist/autocomplete/css/autocomplete.css.map +1 -1
- package/dist/autocomplete.js +68 -66
- package/dist/badge/badge.js +188 -197
- package/dist/badge/css/badge.css +1 -0
- package/dist/badge/css/badge.css.map +1 -1
- package/dist/breadcrumbs.js +275 -284
- package/dist/btngrouper.js +5 -5
- package/dist/bulkActionPopup.js +490 -495
- package/dist/button.js +283 -291
- package/dist/cascadingComboBox.js +249 -258
- package/dist/ckeditor/ckConfigurator.js +26 -19
- package/dist/ckeditor/dtdHandler.js +11 -9
- package/dist/class/selector.js +441 -450
- package/dist/component/resizable.js +1 -1
- package/dist/component/windowed.js +285 -294
- package/dist/component.js +419 -428
- package/dist/contextualPopup.js +417 -426
- package/dist/dashboard.js +300 -309
- package/dist/datalist.js +753 -762
- package/dist/datatable/filterStrategy/multiple.js +1 -1
- package/dist/datatable/filterStrategy/single.js +1 -1
- package/dist/datatable.js +1527 -1550
- package/dist/dateRange/dateRange.js +393 -402
- package/dist/datetime/picker.js +665 -672
- package/dist/deleter.js +368 -377
- package/dist/destination/selector.js +286 -295
- package/dist/dialog/alert.js +3 -3
- package/dist/dialog/confirm.js +1 -1
- package/dist/dialog/confirmDelete.js +216 -225
- package/dist/dialog.js +650 -654
- package/dist/disabler.js +8 -8
- package/dist/documentViewer/providers/pdfViewer/fallback/viewer.js +166 -175
- package/dist/documentViewer/providers/pdfViewer/pdfjs/findBar.js +518 -527
- package/dist/documentViewer/providers/pdfViewer/pdfjs/pageView.js +380 -389
- package/dist/documentViewer/providers/pdfViewer/pdfjs/searchEngine.js +539 -548
- package/dist/documentViewer/providers/pdfViewer/pdfjs/viewer.js +369 -378
- package/dist/documentViewer/providers/pdfViewer.js +184 -193
- package/dist/documentViewer.js +292 -301
- package/dist/dropdown.js +383 -392
- package/dist/durationer.js +5 -5
- package/dist/dynamicComponent.js +597 -598
- package/dist/feedback.js +356 -362
- package/dist/figure/FigureStateActive.js +117 -108
- package/dist/filesender.js +2 -2
- package/dist/filter.js +230 -239
- package/dist/form/dropdownForm.js +355 -357
- package/dist/form/form.js +919 -690
- package/dist/form/simpleForm.js +1 -1
- package/dist/form/validator/renderer.js +233 -235
- package/dist/form/validator/validator.js +257 -189
- package/dist/form/widget/definitions.js +1 -1
- package/dist/form/widget/providers/checkBox.js +254 -259
- package/dist/form/widget/providers/comboBox.js +187 -192
- package/dist/form/widget/providers/default.js +8 -9
- package/dist/form/widget/providers/hidden.js +170 -179
- package/dist/form/widget/providers/hiddenBox.js +262 -267
- package/dist/form/widget/providers/radioBox.js +216 -225
- package/dist/form/widget/providers/textArea.js +187 -196
- package/dist/form/widget/providers/textBox.js +2 -3
- package/dist/form/widget/widget.js +473 -475
- package/dist/formValidator/formValidator.js +1 -1
- package/dist/formValidator/highlighters/message.js +1 -1
- package/dist/generis/form/form.js +314 -323
- package/dist/generis/validator/validator.js +209 -218
- package/dist/generis/widget/checkBox/checkBox.js +218 -227
- package/dist/generis/widget/comboBox/comboBox.js +179 -188
- package/dist/generis/widget/hiddenBox/hiddenBox.js +220 -229
- package/dist/generis/widget/textBox/textBox.js +169 -178
- package/dist/generis/widget/widget.js +246 -255
- package/dist/groupedComboBox.js +222 -231
- package/dist/groupvalidator.js +2 -2
- package/dist/highlighter.js +967 -958
- package/dist/image/ImgStateActive/helper.js +7 -5
- package/dist/image/ImgStateActive/initHelper.js +49 -43
- package/dist/image/ImgStateActive/initMediaEditor.js +24 -20
- package/dist/image/ImgStateActive/mediaSizer.js +14 -12
- package/dist/image/ImgStateActive.js +72 -70
- package/dist/incrementer.js +6 -6
- package/dist/inplacer.js +6 -6
- package/dist/itemButtonList/css/item-button-list.css +1 -0
- package/dist/itemButtonList/css/item-button-list.css.map +1 -1
- package/dist/itemButtonList.js +439 -435
- package/dist/keyNavigation/navigableDomElement.js +51 -38
- package/dist/keyNavigation/navigator.js +85 -70
- package/dist/listbox.js +460 -469
- package/dist/liststyler.js +8 -8
- package/dist/loadingButton/loadingButton.js +209 -218
- package/dist/lock.js +476 -485
- package/dist/login/login.js +475 -484
- package/dist/maths/calculator/basicCalculator.js +235 -244
- package/dist/maths/calculator/calculatorComponent.js +3 -3
- package/dist/maths/calculator/core/board.js +772 -781
- package/dist/maths/calculator/core/expression.js +476 -485
- package/dist/maths/calculator/core/labels.js +228 -237
- package/dist/maths/calculator/core/tokenizer.js +1 -1
- package/dist/maths/calculator/core/tokens.js +163 -170
- package/dist/maths/calculator/plugins/keyboard/templateKeyboard/templateKeyboard.js +244 -253
- package/dist/maths/calculator/plugins/screen/simpleScreen/simpleScreen.js +279 -288
- package/dist/maths/calculator/scientificCalculator.js +327 -336
- package/dist/mediaEditor/mediaEditorComponent.js +238 -245
- package/dist/mediaEditor/plugins/mediaAlignment/helper.js +7 -7
- package/dist/mediaEditor/plugins/mediaAlignment/mediaAlignmentComponent.js +229 -235
- package/dist/mediaEditor/plugins/mediaDimension/mediaDimensionComponent.js +580 -589
- package/dist/mediaplayer/players/html5.js +666 -675
- package/dist/mediaplayer/players/youtube.js +419 -424
- package/dist/mediaplayer/support.js +11 -10
- package/dist/mediaplayer/utils/reminder.js +14 -13
- package/dist/mediaplayer/utils/timeObserver.js +10 -11
- package/dist/mediaplayer/youtubeManager.js +164 -145
- package/dist/mediaplayer.js +1565 -1520
- package/dist/mediasizer.js +669 -678
- package/dist/modal.js +10 -17
- package/dist/pageSizeSelector.js +219 -228
- package/dist/pagination/providers/pages.js +280 -289
- package/dist/pagination/providers/simple.js +192 -201
- package/dist/previewer.js +30 -30
- package/dist/progressbar.js +4 -4
- package/dist/report.js +347 -356
- package/dist/resource/filters.js +271 -280
- package/dist/resource/list.js +1264 -1273
- package/dist/resource/selector.js +865 -874
- package/dist/resource/tree.js +1483 -1492
- package/dist/resourcemgr/fileBrowser.js +564 -569
- package/dist/resourcemgr/filePreview.js +16 -16
- package/dist/resourcemgr/fileSelector.js +515 -524
- package/dist/resourcemgr/util/updatePermissions.js +2 -2
- package/dist/resourcemgr.js +306 -315
- package/dist/searchModal/advancedSearch.js +796 -767
- package/dist/searchModal.js +114 -91
- package/dist/switch/switch.js +298 -307
- package/dist/tabs.js +598 -575
- package/dist/taskQueue/status.js +312 -321
- package/dist/taskQueue/table.js +375 -384
- package/dist/taskQueue/taskQueueModel.js +488 -472
- package/dist/taskQueueButton/taskable.js +264 -273
- package/dist/taskQueueButton/treeButton.js +189 -198
- package/dist/themeLoader.js +24 -23
- package/dist/themes.js +1 -1
- package/dist/toggler.js +3 -3
- package/dist/tooltip.js +295 -304
- package/dist/transformer.js +2 -2
- package/dist/tristateCheckboxGroup.js +311 -320
- package/dist/uploader.js +687 -696
- package/dist/validator/Report.js +1 -1
- package/dist/validator/Validator.js +3 -3
- package/dist/validator/validators.js +9 -9
- package/dist/validator.js +240 -230
- package/dist/waitForMedia.js +1 -1
- package/package.json +3 -3
- package/src/animable/absorbable/css/absorb.css +1 -0
- package/src/animable/absorbable/css/absorb.css.map +1 -1
- package/src/autocomplete/css/autocomplete.css +1 -0
- package/src/autocomplete/css/autocomplete.css.map +1 -1
- package/src/badge/css/badge.css +1 -0
- package/src/badge/css/badge.css.map +1 -1
- package/src/ckeditor/ckConfigurator.js +4 -0
- package/src/itemButtonList/css/item-button-list.css +1 -0
- package/src/itemButtonList/css/item-button-list.css.map +1 -1
- package/src/.DS_Store +0 -0
- package/src/css/basic.css +0 -7826
- package/src/css/basic.css.map +0 -1
- package/src/css/ckeditor/skins/tao/css/dialog.css +0 -950
- package/src/css/ckeditor/skins/tao/css/dialog.css.map +0 -1
- package/src/css/ckeditor/skins/tao/css/editor.css +0 -1850
- package/src/css/ckeditor/skins/tao/css/editor.css.map +0 -1
- package/src/scss/.DS_Store +0 -0
- package/src/scss/basic.scss +0 -16
- package/src/scss/ckeditor/skins/tao/scss/dialog.scss +0 -763
- package/src/scss/ckeditor/skins/tao/scss/editor.scss +0 -111
- package/src/scss/ckeditor/skins/tao/scss/inc/_ck-icons.scss +0 -59
- package/src/scss/ckeditor/skins/tao/scss/inc/_colorpanel.scss +0 -118
- package/src/scss/ckeditor/skins/tao/scss/inc/_elementspath.scss +0 -69
- package/src/scss/ckeditor/skins/tao/scss/inc/_mainui.scss +0 -194
- package/src/scss/ckeditor/skins/tao/scss/inc/_menu.scss +0 -181
- package/src/scss/ckeditor/skins/tao/scss/inc/_panel.scss +0 -200
- package/src/scss/ckeditor/skins/tao/scss/inc/_presets.scss +0 -32
- package/src/scss/ckeditor/skins/tao/scss/inc/_reset.scss +0 -101
- package/src/scss/ckeditor/skins/tao/scss/inc/_richcombo.scss +0 -213
- package/src/scss/ckeditor/skins/tao/scss/inc/_tao.scss +0 -59
- package/src/scss/ckeditor/skins/tao/scss/inc/_toolbar.scss +0 -301
- package/src/scss/font/source-sans-pro/source-sans-pro-italic.eot +0 -0
- package/src/scss/font/source-sans-pro/source-sans-pro-italic.eot.b64 +0 -1
- package/src/scss/font/source-sans-pro/source-sans-pro-italic.woff +0 -0
- package/src/scss/font/source-sans-pro/source-sans-pro-italic.woff.b64 +0 -1
- package/src/scss/font/source-sans-pro/source-sans-pro-regular.eot +0 -0
- package/src/scss/font/source-sans-pro/source-sans-pro-regular.eot.b64 +0 -1
- package/src/scss/font/source-sans-pro/source-sans-pro-regular.woff +0 -0
- package/src/scss/font/source-sans-pro/source-sans-pro-regular.woff.b64 +0 -1
- package/src/scss/font/source-sans-pro/source-sans-pro-semibold-italic.eot +0 -0
- package/src/scss/font/source-sans-pro/source-sans-pro-semibold-italic.eot.b64 +0 -1
- package/src/scss/font/source-sans-pro/source-sans-pro-semibold-italic.woff +0 -0
- package/src/scss/font/source-sans-pro/source-sans-pro-semibold-italic.woff.b64 +0 -1
- package/src/scss/font/source-sans-pro/source-sans-pro-semibold.eot +0 -0
- package/src/scss/font/source-sans-pro/source-sans-pro-semibold.eot.b64 +0 -1
- package/src/scss/font/source-sans-pro/source-sans-pro-semibold.woff +0 -0
- package/src/scss/font/source-sans-pro/source-sans-pro-semibold.woff.b64 +0 -1
- package/src/scss/font/tao/tao.eot +0 -0
- package/src/scss/font/tao/tao.svg +0 -235
- package/src/scss/font/tao/tao.ttf +0 -0
- package/src/scss/font/tao/tao.woff +0 -0
- package/src/scss/inc/_base.scss +0 -496
- package/src/scss/inc/_bootstrap.scss +0 -6
- package/src/scss/inc/_buttons.scss +0 -114
- package/src/scss/inc/_colors.scss +0 -88
- package/src/scss/inc/_feedback.scss +0 -150
- package/src/scss/inc/_flex-grid.scss +0 -15
- package/src/scss/inc/_fonts.scss +0 -4
- package/src/scss/inc/_forms.scss +0 -827
- package/src/scss/inc/_functions.scss +0 -283
- package/src/scss/inc/_grid.scss +0 -66
- package/src/scss/inc/_jquery.nouislider.scss +0 -254
- package/src/scss/inc/_normalize.scss +0 -528
- package/src/scss/inc/_report.scss +0 -68
- package/src/scss/inc/_secondary-properties.scss +0 -89
- package/src/scss/inc/_select2.scss +0 -634
- package/src/scss/inc/_toolbars.scss +0 -155
- package/src/scss/inc/_tooltip.scss +0 -312
- package/src/scss/inc/_variables.scss +0 -21
- package/src/scss/inc/base/_highlight.scss +0 -5
- package/src/scss/inc/base/_list-style.scss +0 -59
- package/src/scss/inc/base/_svg.scss +0 -3
- package/src/scss/inc/base/_table.scss +0 -63
- package/src/scss/inc/fonts/_source-sans-pro.scss +0 -29
- package/src/scss/inc/fonts/_tao-icon-classes.scss +0 -226
- package/src/scss/inc/fonts/_tao-icon-def.scss +0 -12
- package/src/scss/inc/fonts/_tao-icon-vars.scss +0 -240
|
@@ -1,1002 +1,993 @@
|
|
|
1
1
|
define(['jquery', 'lodash', 'i18n', 'ui/component', 'ui/hider', 'ui/class/selector', 'ui/resource/tree', 'ui/resource/list', 'ui/resource/filters', 'handlebars', 'lib/dompurify/purify', 'css!ui/resource/css/selector.css'], function ($$1, _, __, component, hider, classesSelectorFactory, treeFactory, listFactory, filtersFactory, Handlebars, DOMPurify, selector_css) { 'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
3
|
+
$$1 = $$1 && Object.prototype.hasOwnProperty.call($$1, 'default') ? $$1['default'] : $$1;
|
|
4
|
+
_ = _ && Object.prototype.hasOwnProperty.call(_, 'default') ? _['default'] : _;
|
|
5
|
+
__ = __ && Object.prototype.hasOwnProperty.call(__, 'default') ? __['default'] : __;
|
|
6
|
+
component = component && Object.prototype.hasOwnProperty.call(component, 'default') ? component['default'] : component;
|
|
7
|
+
hider = hider && Object.prototype.hasOwnProperty.call(hider, 'default') ? hider['default'] : hider;
|
|
8
|
+
classesSelectorFactory = classesSelectorFactory && Object.prototype.hasOwnProperty.call(classesSelectorFactory, 'default') ? classesSelectorFactory['default'] : classesSelectorFactory;
|
|
9
|
+
treeFactory = treeFactory && Object.prototype.hasOwnProperty.call(treeFactory, 'default') ? treeFactory['default'] : treeFactory;
|
|
10
|
+
listFactory = listFactory && Object.prototype.hasOwnProperty.call(listFactory, 'default') ? listFactory['default'] : listFactory;
|
|
11
|
+
filtersFactory = filtersFactory && Object.prototype.hasOwnProperty.call(filtersFactory, 'default') ? filtersFactory['default'] : filtersFactory;
|
|
12
|
+
Handlebars = Handlebars && Object.prototype.hasOwnProperty.call(Handlebars, 'default') ? Handlebars['default'] : Handlebars;
|
|
13
|
+
DOMPurify = DOMPurify && Object.prototype.hasOwnProperty.call(DOMPurify, 'default') ? DOMPurify['default'] : DOMPurify;
|
|
14
|
+
|
|
15
|
+
function _typeof(obj) {
|
|
16
|
+
"@babel/helpers - typeof";
|
|
17
|
+
|
|
18
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
19
|
+
return typeof obj;
|
|
20
|
+
} : function (obj) {
|
|
21
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
22
|
+
}, _typeof(obj);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function Helpers0 (hb) {
|
|
26
|
+
//register a i18n helper
|
|
27
|
+
hb.registerHelper('__', function (key) {
|
|
28
|
+
return __(key);
|
|
29
|
+
});
|
|
15
30
|
/**
|
|
16
|
-
*
|
|
17
|
-
* modify it under the terms of the GNU General Public License
|
|
18
|
-
* as published by the Free Software Foundation; under version 2
|
|
19
|
-
* of the License (non-upgradable).
|
|
20
|
-
*
|
|
21
|
-
* This program is distributed in the hope that it will be useful,
|
|
22
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
23
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
24
|
-
* GNU General Public License for more details.
|
|
25
|
-
*
|
|
26
|
-
* You should have received a copy of the GNU General Public License
|
|
27
|
-
* along with this program; if not, write to the Free Software
|
|
28
|
-
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
29
|
-
*
|
|
30
|
-
* Copyright (c) 2013-2019 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
|
|
31
|
-
*
|
|
31
|
+
* Register dompurify helper
|
|
32
32
|
*
|
|
33
|
+
* https://github.com/cure53/DOMPurify
|
|
34
|
+
* with config SAFE_FOR_TEMPLATES: true
|
|
35
|
+
* to make output safe for template systems
|
|
33
36
|
*/
|
|
34
|
-
function Helpers0 (hb) {
|
|
35
|
-
//register a i18n helper
|
|
36
|
-
hb.registerHelper('__', function (key) {
|
|
37
|
-
return __(key);
|
|
38
|
-
});
|
|
39
|
-
/**
|
|
40
|
-
* Register dompurify helper
|
|
41
|
-
*
|
|
42
|
-
* https://github.com/cure53/DOMPurify
|
|
43
|
-
* with config SAFE_FOR_TEMPLATES: true
|
|
44
|
-
* to make output safe for template systems
|
|
45
|
-
*/
|
|
46
37
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
hb.registerHelper('join', function (arr, keyValueGlue, fragmentGlue, wrapper) {
|
|
60
|
-
var fragments = [];
|
|
61
|
-
keyValueGlue = typeof keyValueGlue === 'string' ? keyValueGlue : undefined;
|
|
62
|
-
fragmentGlue = typeof fragmentGlue === 'string' ? fragmentGlue : ' ';
|
|
63
|
-
wrapper = typeof wrapper === 'string' ? wrapper : '"';
|
|
38
|
+
hb.registerHelper('dompurify', function (context) {
|
|
39
|
+
return DOMPurify.sanitize(context);
|
|
40
|
+
});
|
|
41
|
+
/**
|
|
42
|
+
* Register join helper
|
|
43
|
+
*
|
|
44
|
+
* Example :
|
|
45
|
+
* var values = {a:v1, b:v2, c:v3};
|
|
46
|
+
* Using {{{join attributes '=' ' ' '"'}}} will return : a="v1" b="v2" c="v3"
|
|
47
|
+
* Using {{{join values null ' or ' '*'}}} will return : *v1* or *v2* or *v3*
|
|
48
|
+
*/
|
|
64
49
|
|
|
65
|
-
|
|
66
|
-
|
|
50
|
+
hb.registerHelper('join', function (arr, keyValueGlue, fragmentGlue, wrapper) {
|
|
51
|
+
var fragments = [];
|
|
52
|
+
keyValueGlue = typeof keyValueGlue === 'string' ? keyValueGlue : undefined;
|
|
53
|
+
fragmentGlue = typeof fragmentGlue === 'string' ? fragmentGlue : ' ';
|
|
54
|
+
wrapper = typeof wrapper === 'string' ? wrapper : '"';
|
|
67
55
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
value = value ? 'true' : 'false';
|
|
71
|
-
} else if (typeof value === 'object') {
|
|
72
|
-
value = _.values(value).join(' ');
|
|
73
|
-
}
|
|
74
|
-
} else {
|
|
75
|
-
value = '';
|
|
76
|
-
}
|
|
56
|
+
_.forIn(arr, function (value, key) {
|
|
57
|
+
var fragment = '';
|
|
77
58
|
|
|
78
|
-
|
|
79
|
-
|
|
59
|
+
if (value !== null || value !== undefined) {
|
|
60
|
+
if (typeof value === 'boolean') {
|
|
61
|
+
value = value ? 'true' : 'false';
|
|
62
|
+
} else if (_typeof(value) === 'object') {
|
|
63
|
+
value = _.values(value).join(' ');
|
|
80
64
|
}
|
|
65
|
+
} else {
|
|
66
|
+
value = '';
|
|
67
|
+
}
|
|
81
68
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
return fragments.join(fragmentGlue);
|
|
87
|
-
}); //register a classic "for loop" helper
|
|
88
|
-
//it also adds a local variable "i" as the index in each iteration loop
|
|
89
|
-
|
|
90
|
-
hb.registerHelper('for', function (startIndex, stopIndex, increment, options) {
|
|
91
|
-
var ret = '';
|
|
92
|
-
startIndex = parseInt(startIndex);
|
|
93
|
-
stopIndex = parseInt(stopIndex);
|
|
94
|
-
increment = parseInt(increment);
|
|
95
|
-
|
|
96
|
-
for (var i = startIndex; i < stopIndex; i += increment) {
|
|
97
|
-
ret += options.fn(_.extend({}, this, {
|
|
98
|
-
i: i
|
|
99
|
-
}));
|
|
69
|
+
if (keyValueGlue !== undefined) {
|
|
70
|
+
fragment += key + keyValueGlue;
|
|
100
71
|
}
|
|
101
72
|
|
|
102
|
-
|
|
73
|
+
fragment += wrapper + value + wrapper;
|
|
74
|
+
fragments.push(fragment);
|
|
103
75
|
});
|
|
104
|
-
hb.registerHelper('equal', function (var1, var2, options) {
|
|
105
|
-
if (var1 == var2) {
|
|
106
|
-
return options.fn(this);
|
|
107
|
-
} else {
|
|
108
|
-
return options.inverse(this);
|
|
109
|
-
}
|
|
110
|
-
}); // register a "get property" helper
|
|
111
|
-
// it gets the named property from the provided context
|
|
112
76
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
// it checks if value is in array
|
|
77
|
+
return fragments.join(fragmentGlue);
|
|
78
|
+
}); //register a classic "for loop" helper
|
|
79
|
+
//it also adds a local variable "i" as the index in each iteration loop
|
|
117
80
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
81
|
+
hb.registerHelper('for', function (startIndex, stopIndex, increment, options) {
|
|
82
|
+
var ret = '';
|
|
83
|
+
startIndex = parseInt(startIndex);
|
|
84
|
+
stopIndex = parseInt(stopIndex);
|
|
85
|
+
increment = parseInt(increment);
|
|
124
86
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
var Template = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
|
|
130
|
-
this.compilerInfo = [4,'>= 1.0.0'];
|
|
131
|
-
helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|
132
|
-
var buffer = "", stack1, helper, functionType="function", escapeExpression=this.escapeExpression, self=this, helperMissing=helpers.helperMissing;
|
|
133
|
-
|
|
134
|
-
function program1(depth0,data) {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
return "multiple";
|
|
87
|
+
for (var i = startIndex; i < stopIndex; i += increment) {
|
|
88
|
+
ret += options.fn(_.extend({}, this, {
|
|
89
|
+
i: i
|
|
90
|
+
}));
|
|
138
91
|
}
|
|
139
92
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
return buffer;
|
|
148
|
-
}
|
|
149
|
-
function program4(depth0,data) {
|
|
150
|
-
|
|
151
|
-
var buffer = "", stack1, helper;
|
|
152
|
-
buffer += "\n <a href=\"#\" data-view-format=\""
|
|
153
|
-
+ escapeExpression(((stack1 = (data == null || data === false ? data : data.key)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
|
|
154
|
-
+ "\" ";
|
|
155
|
-
stack1 = helpers['if'].call(depth0, (depth0 && depth0.active), {hash:{},inverse:self.noop,fn:self.program(5, program5, data),data:data});
|
|
156
|
-
if(stack1 || stack1 === 0) { buffer += stack1; }
|
|
157
|
-
buffer += " ";
|
|
158
|
-
stack1 = helpers['if'].call(depth0, (depth0 && depth0.title), {hash:{},inverse:self.noop,fn:self.program(7, program7, data),data:data});
|
|
159
|
-
if(stack1 || stack1 === 0) { buffer += stack1; }
|
|
160
|
-
buffer += "><span class=\"";
|
|
161
|
-
if (helper = helpers.icon) { stack1 = helper.call(depth0, {hash:{},data:data}); }
|
|
162
|
-
else { helper = (depth0 && depth0.icon); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
|
|
163
|
-
buffer += escapeExpression(stack1)
|
|
164
|
-
+ "\"></span></a>\n ";
|
|
165
|
-
return buffer;
|
|
166
|
-
}
|
|
167
|
-
function program5(depth0,data) {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
return "class=\"active\"";
|
|
93
|
+
return ret;
|
|
94
|
+
});
|
|
95
|
+
hb.registerHelper('equal', function (var1, var2, options) {
|
|
96
|
+
if (var1 == var2) {
|
|
97
|
+
return options.fn(this);
|
|
98
|
+
} else {
|
|
99
|
+
return options.inverse(this);
|
|
171
100
|
}
|
|
101
|
+
}); // register a "get property" helper
|
|
102
|
+
// it gets the named property from the provided context
|
|
172
103
|
|
|
173
|
-
function
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
if (helper = helpers.title) { stack1 = helper.call(depth0, {hash:{},data:data}); }
|
|
178
|
-
else { helper = (depth0 && depth0.title); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
|
|
179
|
-
buffer += escapeExpression(stack1)
|
|
180
|
-
+ "\"";
|
|
181
|
-
return buffer;
|
|
182
|
-
}
|
|
104
|
+
hb.registerHelper('property', function (name, context) {
|
|
105
|
+
return context[name] || '';
|
|
106
|
+
}); // register an 'includes' helper
|
|
107
|
+
// it checks if value is in array
|
|
183
108
|
|
|
184
|
-
function
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
buffer += "\n <nav class=\"selection\">\n <div class=\"search\">\n <input type=\"text\" placeholder=\"";
|
|
188
|
-
if (helper = helpers.searchPlaceholder) { stack1 = helper.call(depth0, {hash:{},data:data}); }
|
|
189
|
-
else { helper = (depth0 && depth0.searchPlaceholder); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
|
|
190
|
-
buffer += escapeExpression(stack1)
|
|
191
|
-
+ "\" />\n ";
|
|
192
|
-
stack1 = helpers['if'].call(depth0, (depth0 && depth0.filters), {hash:{},inverse:self.noop,fn:self.program(10, program10, data),data:data});
|
|
193
|
-
if(stack1 || stack1 === 0) { buffer += stack1; }
|
|
194
|
-
buffer += "\n </div>\n <div class=\"selection-control\">\n <a href=\"#\" class=\"selection-toggle ";
|
|
195
|
-
stack1 = helpers.unless.call(depth0, (depth0 && depth0.switchMode), {hash:{},inverse:self.noop,fn:self.program(12, program12, data),data:data});
|
|
196
|
-
if(stack1 || stack1 === 0) { buffer += stack1; }
|
|
197
|
-
buffer += "\" title=\""
|
|
198
|
-
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Toggle multiple/single selection", options) : helperMissing.call(depth0, "__", "Toggle multiple/single selection", options)))
|
|
199
|
-
+ "\">\n <span class=\"icon-multi-select\"></span>\n </a>\n <label class=\"selection-indicator ";
|
|
200
|
-
stack1 = helpers.unless.call(depth0, (depth0 && depth0.multiple), {hash:{},inverse:self.noop,fn:self.program(12, program12, data),data:data});
|
|
201
|
-
if(stack1 || stack1 === 0) { buffer += stack1; }
|
|
202
|
-
buffer += "\">\n <input type=\"checkbox\">\n <span class=\"icon-checkbox\"></span>\n </label>\n </div>\n ";
|
|
203
|
-
stack1 = helpers['if'].call(depth0, (depth0 && depth0.filters), {hash:{},inverse:self.noop,fn:self.program(14, program14, data),data:data});
|
|
204
|
-
if(stack1 || stack1 === 0) { buffer += stack1; }
|
|
205
|
-
buffer += "\n </nav>\n ";
|
|
206
|
-
return buffer;
|
|
207
|
-
}
|
|
208
|
-
function program10(depth0,data) {
|
|
209
|
-
|
|
210
|
-
var buffer = "", helper, options;
|
|
211
|
-
buffer += "\n <a href=\"#\" class=\"filters-opener\" title=\""
|
|
212
|
-
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Advanced search, add filters", options) : helperMissing.call(depth0, "__", "Advanced search, add filters", options)))
|
|
213
|
-
+ "\"><span class=\"icon-add\"></span></a>\n ";
|
|
214
|
-
return buffer;
|
|
109
|
+
hb.registerHelper('includes', function (haystack, needle, options) {
|
|
110
|
+
if (_.contains(haystack, needle)) {
|
|
111
|
+
return options.fn(this);
|
|
215
112
|
}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (!Helpers0.__initialized) {
|
|
117
|
+
Helpers0(Handlebars);
|
|
118
|
+
Helpers0.__initialized = true;
|
|
119
|
+
}
|
|
120
|
+
var Template = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
|
|
121
|
+
this.compilerInfo = [4,'>= 1.0.0'];
|
|
122
|
+
helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|
123
|
+
var buffer = "", stack1, helper, functionType="function", escapeExpression=this.escapeExpression, self=this, helperMissing=helpers.helperMissing;
|
|
124
|
+
|
|
125
|
+
function program1(depth0,data) {
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
return "multiple";
|
|
129
|
+
}
|
|
216
130
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
131
|
+
function program3(depth0,data) {
|
|
132
|
+
|
|
133
|
+
var buffer = "", stack1;
|
|
134
|
+
buffer += "\n <nav class=\"context\">\n <div class=\"class-context\"></div>\n ";
|
|
135
|
+
stack1 = helpers.each.call(depth0, (depth0 && depth0.formats), {hash:{},inverse:self.noop,fn:self.program(4, program4, data),data:data});
|
|
136
|
+
if(stack1 || stack1 === 0) { buffer += stack1; }
|
|
137
|
+
buffer += "\n </nav>\n ";
|
|
138
|
+
return buffer;
|
|
139
|
+
}
|
|
140
|
+
function program4(depth0,data) {
|
|
141
|
+
|
|
142
|
+
var buffer = "", stack1, helper;
|
|
143
|
+
buffer += "\n <a href=\"#\" data-view-format=\""
|
|
144
|
+
+ escapeExpression(((stack1 = (data == null || data === false ? data : data.key)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
|
|
145
|
+
+ "\" ";
|
|
146
|
+
stack1 = helpers['if'].call(depth0, (depth0 && depth0.active), {hash:{},inverse:self.noop,fn:self.program(5, program5, data),data:data});
|
|
147
|
+
if(stack1 || stack1 === 0) { buffer += stack1; }
|
|
148
|
+
buffer += " ";
|
|
149
|
+
stack1 = helpers['if'].call(depth0, (depth0 && depth0.title), {hash:{},inverse:self.noop,fn:self.program(7, program7, data),data:data});
|
|
150
|
+
if(stack1 || stack1 === 0) { buffer += stack1; }
|
|
151
|
+
buffer += "><span class=\"";
|
|
152
|
+
if (helper = helpers.icon) { stack1 = helper.call(depth0, {hash:{},data:data}); }
|
|
153
|
+
else { helper = (depth0 && depth0.icon); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
|
|
154
|
+
buffer += escapeExpression(stack1)
|
|
155
|
+
+ "\"></span></a>\n ";
|
|
156
|
+
return buffer;
|
|
157
|
+
}
|
|
158
|
+
function program5(depth0,data) {
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
return "class=\"active\"";
|
|
162
|
+
}
|
|
222
163
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
164
|
+
function program7(depth0,data) {
|
|
165
|
+
|
|
166
|
+
var buffer = "", stack1, helper;
|
|
167
|
+
buffer += "title=\"";
|
|
168
|
+
if (helper = helpers.title) { stack1 = helper.call(depth0, {hash:{},data:data}); }
|
|
169
|
+
else { helper = (depth0 && depth0.title); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
|
|
170
|
+
buffer += escapeExpression(stack1)
|
|
171
|
+
+ "\"";
|
|
172
|
+
return buffer;
|
|
173
|
+
}
|
|
228
174
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
175
|
+
function program9(depth0,data) {
|
|
176
|
+
|
|
177
|
+
var buffer = "", stack1, helper, options;
|
|
178
|
+
buffer += "\n <nav class=\"selection\">\n <div class=\"search\">\n <input type=\"text\" placeholder=\"";
|
|
179
|
+
if (helper = helpers.searchPlaceholder) { stack1 = helper.call(depth0, {hash:{},data:data}); }
|
|
180
|
+
else { helper = (depth0 && depth0.searchPlaceholder); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
|
|
181
|
+
buffer += escapeExpression(stack1)
|
|
182
|
+
+ "\" />\n ";
|
|
183
|
+
stack1 = helpers['if'].call(depth0, (depth0 && depth0.filters), {hash:{},inverse:self.noop,fn:self.program(10, program10, data),data:data});
|
|
184
|
+
if(stack1 || stack1 === 0) { buffer += stack1; }
|
|
185
|
+
buffer += "\n </div>\n <div class=\"selection-control\">\n <a href=\"#\" class=\"selection-toggle ";
|
|
186
|
+
stack1 = helpers.unless.call(depth0, (depth0 && depth0.switchMode), {hash:{},inverse:self.noop,fn:self.program(12, program12, data),data:data});
|
|
187
|
+
if(stack1 || stack1 === 0) { buffer += stack1; }
|
|
188
|
+
buffer += "\" title=\""
|
|
189
|
+
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Toggle multiple/single selection", options) : helperMissing.call(depth0, "__", "Toggle multiple/single selection", options)))
|
|
190
|
+
+ "\">\n <span class=\"icon-multi-select\"></span>\n </a>\n <label class=\"selection-indicator ";
|
|
191
|
+
stack1 = helpers.unless.call(depth0, (depth0 && depth0.multiple), {hash:{},inverse:self.noop,fn:self.program(12, program12, data),data:data});
|
|
192
|
+
if(stack1 || stack1 === 0) { buffer += stack1; }
|
|
193
|
+
buffer += "\">\n <input type=\"checkbox\">\n <span class=\"icon-checkbox\"></span>\n </label>\n </div>\n ";
|
|
194
|
+
stack1 = helpers['if'].call(depth0, (depth0 && depth0.filters), {hash:{},inverse:self.noop,fn:self.program(14, program14, data),data:data});
|
|
195
|
+
if(stack1 || stack1 === 0) { buffer += stack1; }
|
|
196
|
+
buffer += "\n </nav>\n ";
|
|
197
|
+
return buffer;
|
|
198
|
+
}
|
|
199
|
+
function program10(depth0,data) {
|
|
200
|
+
|
|
201
|
+
var buffer = "", helper, options;
|
|
202
|
+
buffer += "\n <a href=\"#\" class=\"filters-opener\" title=\""
|
|
203
|
+
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Advanced search, add filters", options) : helperMissing.call(depth0, "__", "Advanced search, add filters", options)))
|
|
204
|
+
+ "\"><span class=\"icon-add\"></span></a>\n ";
|
|
205
|
+
return buffer;
|
|
206
|
+
}
|
|
241
207
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
stack1 = helpers['if'].call(depth0, (depth0 && depth0.showContext), {hash:{},inverse:self.noop,fn:self.program(3, program3, data),data:data});
|
|
247
|
-
if(stack1 || stack1 === 0) { buffer += stack1; }
|
|
248
|
-
buffer += "\n\n ";
|
|
249
|
-
stack1 = helpers['if'].call(depth0, (depth0 && depth0.showSelection), {hash:{},inverse:self.noop,fn:self.program(9, program9, data),data:data});
|
|
250
|
-
if(stack1 || stack1 === 0) { buffer += stack1; }
|
|
251
|
-
buffer += "\n\n <main>\n <span class=\"hidden no-results\">";
|
|
252
|
-
if (helper = helpers.noResultsText) { stack1 = helper.call(depth0, {hash:{},data:data}); }
|
|
253
|
-
else { helper = (depth0 && depth0.noResultsText); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
|
|
254
|
-
buffer += escapeExpression(stack1)
|
|
255
|
-
+ "</span>\n </main>\n\n ";
|
|
256
|
-
stack1 = helpers['if'].call(depth0, (depth0 && depth0.multiple), {hash:{},inverse:self.noop,fn:self.program(16, program16, data),data:data});
|
|
257
|
-
if(stack1 || stack1 === 0) { buffer += stack1; }
|
|
258
|
-
buffer += "\n</div>\n";
|
|
259
|
-
return buffer;
|
|
260
|
-
});
|
|
261
|
-
function selectorTpl(data, options, asString) {
|
|
262
|
-
var html = Template(data, options);
|
|
263
|
-
return (asString || true) ? html : $(html);
|
|
208
|
+
function program12(depth0,data) {
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
return "hidden";
|
|
264
212
|
}
|
|
265
213
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
*
|
|
272
|
-
* This program is distributed in the hope that it will be useful,
|
|
273
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
274
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
275
|
-
* GNU General Public License for more details.
|
|
276
|
-
*
|
|
277
|
-
* You should have received a copy of the GNU General Public License
|
|
278
|
-
* along with this program; if not, write to the Free Software
|
|
279
|
-
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
280
|
-
*
|
|
281
|
-
* Copyright (c) 2017-2019 (original work) Open Assessment Technologies SA ;
|
|
282
|
-
*/
|
|
283
|
-
var labelUri = 'http://www.w3.org/2000/01/rdf-schema#label';
|
|
284
|
-
var nodeTypes = {
|
|
285
|
-
instance: 'instance',
|
|
286
|
-
class: 'class'
|
|
287
|
-
};
|
|
288
|
-
var selectionModes = {
|
|
289
|
-
single: 'single',
|
|
290
|
-
multiple: 'multiple',
|
|
291
|
-
both: 'both'
|
|
292
|
-
};
|
|
293
|
-
var selectAllPolicies = {
|
|
294
|
-
all: 'all',
|
|
295
|
-
// should select 100% of the nodes, but currently not implementable due to lazy loading
|
|
296
|
-
loaded: 'loaded',
|
|
297
|
-
// selects all loaded nodes, whether visible or not
|
|
298
|
-
visible: 'visible' // selects only visible nodes
|
|
214
|
+
function program14(depth0,data) {
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
return "\n <div class=\"filters-container folded\"></div>\n ";
|
|
218
|
+
}
|
|
299
219
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
formats: {
|
|
313
|
-
list: {
|
|
314
|
-
icon: 'icon-ul',
|
|
315
|
-
title: __('View resources as a list'),
|
|
316
|
-
componentFactory: listFactory
|
|
317
|
-
},
|
|
318
|
-
tree: {
|
|
319
|
-
icon: 'icon-tree',
|
|
320
|
-
title: __('View resources as a tree'),
|
|
321
|
-
componentFactory: treeFactory,
|
|
322
|
-
active: true
|
|
323
|
-
}
|
|
324
|
-
},
|
|
325
|
-
limit: 30
|
|
326
|
-
};
|
|
327
|
-
/**
|
|
328
|
-
* Filter and extract classes from a resource tree
|
|
329
|
-
* @param {Object[]} resources - the resource tree
|
|
330
|
-
* @returns {Object[]} contains only classes with URI and label
|
|
331
|
-
*/
|
|
220
|
+
function program16(depth0,data) {
|
|
221
|
+
|
|
222
|
+
var buffer = "", stack1, helper, options;
|
|
223
|
+
buffer += "\n <footer>\n <div class=\"get-selection\">\n <span>"
|
|
224
|
+
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Selected", options) : helperMissing.call(depth0, "__", "Selected", options)))
|
|
225
|
+
+ " ";
|
|
226
|
+
if (helper = helpers.type) { stack1 = helper.call(depth0, {hash:{},data:data}); }
|
|
227
|
+
else { helper = (depth0 && depth0.type); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
|
|
228
|
+
buffer += escapeExpression(stack1)
|
|
229
|
+
+ " : </span><span class=\"selected-num\">0</span>\n </div>\n </footer>\n ";
|
|
230
|
+
return buffer;
|
|
231
|
+
}
|
|
332
232
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
233
|
+
buffer += "<div class=\"resource-selector ";
|
|
234
|
+
stack1 = helpers['if'].call(depth0, (depth0 && depth0.multiple), {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
|
|
235
|
+
if(stack1 || stack1 === 0) { buffer += stack1; }
|
|
236
|
+
buffer += "\">\n\n ";
|
|
237
|
+
stack1 = helpers['if'].call(depth0, (depth0 && depth0.showContext), {hash:{},inverse:self.noop,fn:self.program(3, program3, data),data:data});
|
|
238
|
+
if(stack1 || stack1 === 0) { buffer += stack1; }
|
|
239
|
+
buffer += "\n\n ";
|
|
240
|
+
stack1 = helpers['if'].call(depth0, (depth0 && depth0.showSelection), {hash:{},inverse:self.noop,fn:self.program(9, program9, data),data:data});
|
|
241
|
+
if(stack1 || stack1 === 0) { buffer += stack1; }
|
|
242
|
+
buffer += "\n\n <main>\n <span class=\"hidden no-results\">";
|
|
243
|
+
if (helper = helpers.noResultsText) { stack1 = helper.call(depth0, {hash:{},data:data}); }
|
|
244
|
+
else { helper = (depth0 && depth0.noResultsText); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
|
|
245
|
+
buffer += escapeExpression(stack1)
|
|
246
|
+
+ "</span>\n </main>\n\n ";
|
|
247
|
+
stack1 = helpers['if'].call(depth0, (depth0 && depth0.multiple), {hash:{},inverse:self.noop,fn:self.program(16, program16, data),data:data});
|
|
248
|
+
if(stack1 || stack1 === 0) { buffer += stack1; }
|
|
249
|
+
buffer += "\n</div>\n";
|
|
250
|
+
return buffer;
|
|
251
|
+
});
|
|
252
|
+
function selectorTpl(data, options, asString) {
|
|
253
|
+
var html = Template(data, options);
|
|
254
|
+
return (asString || true) ? html : $(html);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* This program is free software; you can redistribute it and/or
|
|
259
|
+
* modify it under the terms of the GNU General Public License
|
|
260
|
+
* as published by the Free Software Foundation; under version 2
|
|
261
|
+
* of the License (non-upgradable).
|
|
262
|
+
*
|
|
263
|
+
* This program is distributed in the hope that it will be useful,
|
|
264
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
265
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
266
|
+
* GNU General Public License for more details.
|
|
267
|
+
*
|
|
268
|
+
* You should have received a copy of the GNU General Public License
|
|
269
|
+
* along with this program; if not, write to the Free Software
|
|
270
|
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
271
|
+
*
|
|
272
|
+
* Copyright (c) 2017-2019 (original work) Open Assessment Technologies SA ;
|
|
273
|
+
*/
|
|
274
|
+
var labelUri = 'http://www.w3.org/2000/01/rdf-schema#label';
|
|
275
|
+
var nodeTypes = {
|
|
276
|
+
instance: 'instance',
|
|
277
|
+
class: 'class'
|
|
278
|
+
};
|
|
279
|
+
var selectionModes = {
|
|
280
|
+
single: 'single',
|
|
281
|
+
multiple: 'multiple',
|
|
282
|
+
both: 'both'
|
|
283
|
+
};
|
|
284
|
+
var selectAllPolicies = {
|
|
285
|
+
all: 'all',
|
|
286
|
+
// should select 100% of the nodes, but currently not implementable due to lazy loading
|
|
287
|
+
loaded: 'loaded',
|
|
288
|
+
// selects all loaded nodes, whether visible or not
|
|
289
|
+
visible: 'visible' // selects only visible nodes
|
|
290
|
+
|
|
291
|
+
};
|
|
292
|
+
var defaultConfig = {
|
|
293
|
+
type: __('resources'),
|
|
294
|
+
noResultsText: _('No resources found'),
|
|
295
|
+
searchPlaceholder: __('Search'),
|
|
296
|
+
icon: 'item',
|
|
297
|
+
selectionMode: selectionModes.single,
|
|
298
|
+
selectClass: false,
|
|
299
|
+
selectAllPolicy: selectAllPolicies.loaded,
|
|
300
|
+
filters: false,
|
|
301
|
+
showContext: true,
|
|
302
|
+
showSelection: true,
|
|
303
|
+
formats: {
|
|
304
|
+
list: {
|
|
305
|
+
icon: 'icon-ul',
|
|
306
|
+
title: __('View resources as a list'),
|
|
307
|
+
componentFactory: listFactory
|
|
308
|
+
},
|
|
309
|
+
tree: {
|
|
310
|
+
icon: 'icon-tree',
|
|
311
|
+
title: __('View resources as a tree'),
|
|
312
|
+
componentFactory: treeFactory,
|
|
313
|
+
active: true
|
|
314
|
+
}
|
|
315
|
+
},
|
|
316
|
+
limit: 30
|
|
317
|
+
};
|
|
318
|
+
/**
|
|
319
|
+
* Filter and extract classes from a resource tree
|
|
320
|
+
* @param {Object[]} resources - the resource tree
|
|
321
|
+
* @returns {Object[]} contains only classes with URI and label
|
|
322
|
+
*/
|
|
323
|
+
|
|
324
|
+
var filterClasses = function filterClasses(resources) {
|
|
325
|
+
return _(resources).filter({
|
|
326
|
+
type: nodeTypes.class
|
|
327
|
+
}).map(function (resource) {
|
|
328
|
+
var classNode = _.pick(resource, ['uri', 'label', 'state']);
|
|
329
|
+
|
|
330
|
+
if (resource.children) {
|
|
331
|
+
classNode.children = filterClasses(resource.children);
|
|
332
|
+
}
|
|
338
333
|
|
|
339
|
-
|
|
340
|
-
|
|
334
|
+
return classNode;
|
|
335
|
+
}).value();
|
|
336
|
+
};
|
|
337
|
+
/**
|
|
338
|
+
* The factory that creates the resource selector component
|
|
339
|
+
*
|
|
340
|
+
* @param {jQueryElement} $container - where to append the component
|
|
341
|
+
* @param {Object} config - the component config
|
|
342
|
+
* @param {String} config.classUri - the root Class URI
|
|
343
|
+
* @param {Object|[]} [config.classes] - the classes hierarchy for the class selector
|
|
344
|
+
* @param {Object[]} config.formats - the definition of the supported viewer/selector component
|
|
345
|
+
* @param {Object[]} [config.nodes] - the nodes to preload, the format is up to the formatComponent
|
|
346
|
+
* @param {String} [config.icon] - the icon class that represents a resource
|
|
347
|
+
* @param {String} [config.type] - describes the resource type
|
|
348
|
+
* @param {Boolean} [config.selectionMode] - multiple or single selection mode
|
|
349
|
+
* @param {Number} [config.limit = 30] - the default page size for data paging
|
|
350
|
+
* @param {Object|Boolean} [config.filters = false] - false or filters config, see ui/resource/filters
|
|
351
|
+
* @param {Boolean} [config.showContext = true] - show the context bar (class and format switch)
|
|
352
|
+
* @param {Boolean} [config.showSelection = true] - show the selection bar (search, multi switch and select all)
|
|
353
|
+
* @returns {resourceSelector} the component
|
|
354
|
+
*/
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
var resourceSelectorFactory = function resourceSelectorFactory($container, config) {
|
|
358
|
+
var $classContainer;
|
|
359
|
+
var $resultArea;
|
|
360
|
+
var $noResults;
|
|
361
|
+
var $searchField;
|
|
362
|
+
var $viewFormats;
|
|
363
|
+
var $selectNum;
|
|
364
|
+
var $selectCtrl;
|
|
365
|
+
var $selectCtrlLabel;
|
|
366
|
+
var $filterToggle;
|
|
367
|
+
var $filterContainer;
|
|
368
|
+
var $selectionToggle;
|
|
369
|
+
var resourceSelectorApi = {
|
|
370
|
+
/**
|
|
371
|
+
* Empty the selection component
|
|
372
|
+
* @returns {resourceSelector} chains
|
|
373
|
+
* @fires resourceSelector#empty
|
|
374
|
+
*/
|
|
375
|
+
empty: function empty() {
|
|
376
|
+
if (this.is('rendered')) {
|
|
377
|
+
if (this.selectionComponent) {
|
|
378
|
+
this.selectionComponent.destroy();
|
|
379
|
+
this.selectionComponent = null;
|
|
380
|
+
}
|
|
341
381
|
}
|
|
342
382
|
|
|
343
|
-
return
|
|
344
|
-
}
|
|
345
|
-
};
|
|
346
|
-
/**
|
|
347
|
-
* The factory that creates the resource selector component
|
|
348
|
-
*
|
|
349
|
-
* @param {jQueryElement} $container - where to append the component
|
|
350
|
-
* @param {Object} config - the component config
|
|
351
|
-
* @param {String} config.classUri - the root Class URI
|
|
352
|
-
* @param {Object|[]} [config.classes] - the classes hierarchy for the class selector
|
|
353
|
-
* @param {Object[]} config.formats - the definition of the supported viewer/selector component
|
|
354
|
-
* @param {Object[]} [config.nodes] - the nodes to preload, the format is up to the formatComponent
|
|
355
|
-
* @param {String} [config.icon] - the icon class that represents a resource
|
|
356
|
-
* @param {String} [config.type] - describes the resource type
|
|
357
|
-
* @param {Boolean} [config.selectionMode] - multiple or single selection mode
|
|
358
|
-
* @param {Number} [config.limit = 30] - the default page size for data paging
|
|
359
|
-
* @param {Object|Boolean} [config.filters = false] - false or filters config, see ui/resource/filters
|
|
360
|
-
* @param {Boolean} [config.showContext = true] - show the context bar (class and format switch)
|
|
361
|
-
* @param {Boolean} [config.showSelection = true] - show the selection bar (search, multi switch and select all)
|
|
362
|
-
* @returns {resourceSelector} the component
|
|
363
|
-
*/
|
|
383
|
+
return this.trigger('empty');
|
|
384
|
+
},
|
|
364
385
|
|
|
386
|
+
/**
|
|
387
|
+
* Reset the selector
|
|
388
|
+
* @returns {resourceSelector} chains
|
|
389
|
+
* @fires resourceSelector#reset
|
|
390
|
+
*/
|
|
391
|
+
reset: function reset() {
|
|
392
|
+
if (this.is('rendered')) {
|
|
393
|
+
this.empty();
|
|
394
|
+
this.searchQuery = {};
|
|
365
395
|
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
var $noResults;
|
|
370
|
-
var $searchField;
|
|
371
|
-
var $viewFormats;
|
|
372
|
-
var $selectNum;
|
|
373
|
-
var $selectCtrl;
|
|
374
|
-
var $selectCtrlLabel;
|
|
375
|
-
var $filterToggle;
|
|
376
|
-
var $filterContainer;
|
|
377
|
-
var $selectionToggle;
|
|
378
|
-
var resourceSelectorApi = {
|
|
379
|
-
/**
|
|
380
|
-
* Empty the selection component
|
|
381
|
-
* @returns {resourceSelector} chains
|
|
382
|
-
* @fires resourceSelector#empty
|
|
383
|
-
*/
|
|
384
|
-
empty: function empty() {
|
|
385
|
-
if (this.is('rendered')) {
|
|
386
|
-
if (this.selectionComponent) {
|
|
387
|
-
this.selectionComponent.destroy();
|
|
388
|
-
this.selectionComponent = null;
|
|
396
|
+
if (this.config.filters) {
|
|
397
|
+
if (this.filtersComponent) {
|
|
398
|
+
this.filtersComponent.reset();
|
|
389
399
|
}
|
|
400
|
+
|
|
401
|
+
$searchField.val('').attr('title', null).attr('placeholder', this.config.searchPlaceholder);
|
|
390
402
|
}
|
|
403
|
+
}
|
|
391
404
|
|
|
392
|
-
|
|
393
|
-
|
|
405
|
+
return this.trigger('reset');
|
|
406
|
+
},
|
|
394
407
|
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
this.searchQuery = {};
|
|
408
|
+
/**
|
|
409
|
+
* Get the selected nodes
|
|
410
|
+
* @returns {Object?} the selection
|
|
411
|
+
*/
|
|
412
|
+
getSelection: function getSelection() {
|
|
413
|
+
if (this.selectionComponent) {
|
|
414
|
+
return this.selectionComponent.getSelection();
|
|
415
|
+
}
|
|
404
416
|
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
this.filtersComponent.reset();
|
|
408
|
-
}
|
|
417
|
+
return null;
|
|
418
|
+
},
|
|
409
419
|
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
420
|
+
/**
|
|
421
|
+
* Clear the current selection
|
|
422
|
+
* @returns {resourceSelector} chains
|
|
423
|
+
*/
|
|
424
|
+
clearSelection: function clearSelection() {
|
|
425
|
+
if (this.selectionComponent) {
|
|
426
|
+
this.selectionComponent.clearSelection();
|
|
427
|
+
}
|
|
413
428
|
|
|
414
|
-
|
|
415
|
-
|
|
429
|
+
return this;
|
|
430
|
+
},
|
|
416
431
|
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
432
|
+
/**
|
|
433
|
+
* Set the search query
|
|
434
|
+
* @param {String|Object} query - label query if string or property filters
|
|
435
|
+
* @returns {resourceSelector} chains
|
|
436
|
+
*/
|
|
437
|
+
setSearchQuery: function setSearchQuery(query) {
|
|
438
|
+
this.searchQuery = {};
|
|
439
|
+
this.searchQuery[labelUri] = '';
|
|
425
440
|
|
|
426
|
-
|
|
427
|
-
|
|
441
|
+
if (_.isString(query) && !_.isEmpty(query)) {
|
|
442
|
+
this.searchQuery[labelUri] = query;
|
|
443
|
+
}
|
|
428
444
|
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
*/
|
|
433
|
-
clearSelection: function clearSelection() {
|
|
434
|
-
if (this.selectionComponent) {
|
|
435
|
-
this.selectionComponent.clearSelection();
|
|
436
|
-
}
|
|
445
|
+
if (_.isPlainObject(query)) {
|
|
446
|
+
this.searchQuery = query;
|
|
447
|
+
}
|
|
437
448
|
|
|
438
|
-
|
|
439
|
-
|
|
449
|
+
return this;
|
|
450
|
+
},
|
|
440
451
|
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
this.searchQuery = {};
|
|
452
|
+
/**
|
|
453
|
+
* Clear the search query to submit
|
|
454
|
+
* @returns {Object} the query
|
|
455
|
+
*/
|
|
456
|
+
getSearchQuery: function getSearchQuery() {
|
|
457
|
+
if (_.size(this.searchQuery) === 0) {
|
|
448
458
|
this.searchQuery[labelUri] = '';
|
|
459
|
+
}
|
|
449
460
|
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
}
|
|
461
|
+
return this.searchQuery;
|
|
462
|
+
},
|
|
453
463
|
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
464
|
+
/**
|
|
465
|
+
* Ask for a query (forward the event)
|
|
466
|
+
* @param {Object} [params] - the query parameters
|
|
467
|
+
* @param {String} [params.classUri] - the current node class URI
|
|
468
|
+
* @param {String} [params.format] - the selected format
|
|
469
|
+
* @param {String} [params.search] - the search query
|
|
470
|
+
* @param {Number} [params.offset = 0] - for paging
|
|
471
|
+
* @param {Number} [params.limit] - for paging
|
|
472
|
+
* @returns {resourceSelector} chains
|
|
473
|
+
* @fires resourceSelector#query
|
|
474
|
+
*/
|
|
475
|
+
query: function query(params) {
|
|
476
|
+
var defaultParams;
|
|
477
|
+
var search;
|
|
478
|
+
|
|
479
|
+
if (this.is('rendered') && !this.is('loading')) {
|
|
480
|
+
this.setState('loading', true);
|
|
481
|
+
params = params || {};
|
|
482
|
+
search = this.getSearchQuery();
|
|
483
|
+
defaultParams = {
|
|
484
|
+
classUri: this.classUri,
|
|
485
|
+
format: this.format,
|
|
486
|
+
limit: this.config.limit,
|
|
487
|
+
search: _.isObject(search) ? JSON.stringify(search) : ''
|
|
488
|
+
};
|
|
489
|
+
/**
|
|
490
|
+
* Formulate the query
|
|
491
|
+
* @event resourceSelector#query
|
|
492
|
+
* @param {Object} params - see format above
|
|
493
|
+
*/
|
|
457
494
|
|
|
458
|
-
|
|
459
|
-
}
|
|
495
|
+
this.trigger('query', _.defaults(params, defaultParams));
|
|
496
|
+
}
|
|
460
497
|
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
* @returns {Object} the query
|
|
464
|
-
*/
|
|
465
|
-
getSearchQuery: function getSearchQuery() {
|
|
466
|
-
if (_.size(this.searchQuery) === 0) {
|
|
467
|
-
this.searchQuery[labelUri] = '';
|
|
468
|
-
}
|
|
498
|
+
return this;
|
|
499
|
+
},
|
|
469
500
|
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
if (this.is('rendered') && !this.is('loading')) {
|
|
489
|
-
this.setState('loading', true);
|
|
490
|
-
params = params || {};
|
|
491
|
-
search = this.getSearchQuery();
|
|
492
|
-
defaultParams = {
|
|
493
|
-
classUri: this.classUri,
|
|
494
|
-
format: this.format,
|
|
495
|
-
limit: this.config.limit,
|
|
496
|
-
search: _.isObject(search) ? JSON.stringify(search) : ''
|
|
497
|
-
};
|
|
501
|
+
/**
|
|
502
|
+
* Switch the format, so the viewer/selector component
|
|
503
|
+
* @param {String} format - the new format
|
|
504
|
+
* @returns {resourceSelector} chains
|
|
505
|
+
* @fires resourceSelector#formatchange
|
|
506
|
+
*/
|
|
507
|
+
changeFormat: function changeFormat(format) {
|
|
508
|
+
var $viewFormat;
|
|
509
|
+
|
|
510
|
+
if (this.is('rendered') && this.format !== format) {
|
|
511
|
+
$viewFormat = $viewFormats.filter("[data-view-format=\"".concat(format, "\"]"));
|
|
512
|
+
|
|
513
|
+
if ($viewFormat.length === 1 && !$viewFormat.hasClass('active')) {
|
|
514
|
+
$viewFormats.removeClass('active');
|
|
515
|
+
$viewFormat.addClass('active');
|
|
516
|
+
this.empty();
|
|
517
|
+
this.format = format;
|
|
498
518
|
/**
|
|
499
|
-
*
|
|
500
|
-
* @event resourceSelector#
|
|
501
|
-
* @param {
|
|
519
|
+
* The view format has changed
|
|
520
|
+
* @event resourceSelector#formatchange
|
|
521
|
+
* @param {String} format - the new format name
|
|
502
522
|
*/
|
|
503
523
|
|
|
504
|
-
this.trigger('
|
|
524
|
+
this.trigger('formatchange', format);
|
|
505
525
|
}
|
|
526
|
+
}
|
|
506
527
|
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
if (this.is('rendered') && this.format !== format) {
|
|
520
|
-
$viewFormat = $viewFormats.filter(`[data-view-format="${format}"]`);
|
|
521
|
-
|
|
522
|
-
if ($viewFormat.length === 1 && !$viewFormat.hasClass('active')) {
|
|
523
|
-
$viewFormats.removeClass('active');
|
|
524
|
-
$viewFormat.addClass('active');
|
|
525
|
-
this.empty();
|
|
526
|
-
this.format = format;
|
|
527
|
-
/**
|
|
528
|
-
* The view format has changed
|
|
529
|
-
* @event resourceSelector#formatchange
|
|
530
|
-
* @param {String} format - the new format name
|
|
531
|
-
*/
|
|
532
|
-
|
|
533
|
-
this.trigger('formatchange', format);
|
|
534
|
-
}
|
|
528
|
+
return this;
|
|
529
|
+
},
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* Let's you change the selection mode
|
|
533
|
+
* @param {String} newMode - single or multiple
|
|
534
|
+
* @returns {resourceSelector} chains
|
|
535
|
+
*/
|
|
536
|
+
changeSelectionMode: function changeSelectionMode(newMode) {
|
|
537
|
+
if (this.is('rendered') && this.config.selectionMode !== newMode && selectionModes[newMode]) {
|
|
538
|
+
if (this.config.multiple) {
|
|
539
|
+
this.clearSelection();
|
|
535
540
|
}
|
|
536
541
|
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
/**
|
|
541
|
-
* Let's you change the selection mode
|
|
542
|
-
* @param {String} newMode - single or multiple
|
|
543
|
-
* @returns {resourceSelector} chains
|
|
544
|
-
*/
|
|
545
|
-
changeSelectionMode: function changeSelectionMode(newMode) {
|
|
546
|
-
if (this.is('rendered') && this.config.selectionMode !== newMode && selectionModes[newMode]) {
|
|
547
|
-
if (this.config.multiple) {
|
|
548
|
-
this.clearSelection();
|
|
549
|
-
}
|
|
542
|
+
this.config.multiple = newMode === selectionModes.multiple;
|
|
543
|
+
this.selectionComponent.setState('multiple', this.config.multiple);
|
|
544
|
+
this.setState('multiple', this.config.multiple);
|
|
550
545
|
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
546
|
+
if (this.config.multiple) {
|
|
547
|
+
hider.show($selectCtrlLabel);
|
|
548
|
+
} else {
|
|
549
|
+
hider.hide($selectCtrlLabel);
|
|
550
|
+
}
|
|
551
|
+
/**
|
|
552
|
+
* The selection mode has changed
|
|
553
|
+
* @event resourceSelector#selectionmodechange
|
|
554
|
+
* @param {String} newMode - the new selection mode
|
|
555
|
+
*/
|
|
554
556
|
|
|
555
|
-
if (this.config.multiple) {
|
|
556
|
-
hider.show($selectCtrlLabel);
|
|
557
|
-
} else {
|
|
558
|
-
hider.hide($selectCtrlLabel);
|
|
559
|
-
}
|
|
560
|
-
/**
|
|
561
|
-
* The selection mode has changed
|
|
562
|
-
* @event resourceSelector#selectionmodechange
|
|
563
|
-
* @param {String} newMode - the new selection mode
|
|
564
|
-
*/
|
|
565
557
|
|
|
558
|
+
this.trigger('selectionmodechange', newMode);
|
|
559
|
+
}
|
|
566
560
|
|
|
567
|
-
|
|
568
|
-
|
|
561
|
+
return this;
|
|
562
|
+
},
|
|
569
563
|
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
update: function update(resources, params) {
|
|
583
|
-
var self = this;
|
|
584
|
-
var componentFactory;
|
|
585
|
-
|
|
586
|
-
if (this.is('rendered') && this.format) {
|
|
587
|
-
componentFactory = this.config.formats[this.format] && this.config.formats[this.format].componentFactory;
|
|
588
|
-
|
|
589
|
-
if (!_.isFunction(componentFactory)) {
|
|
590
|
-
return this.trigger('error', new TypeError(`Unable to load the component for the format ${this.format}`));
|
|
591
|
-
}
|
|
564
|
+
/**
|
|
565
|
+
* Update the component with the given resources
|
|
566
|
+
* @param {Object[]} resources - the data, with at least a URI as key and as property
|
|
567
|
+
* @param {Object} params - the query parameters
|
|
568
|
+
* @returns {resourceSelector} chains
|
|
569
|
+
* @fires resourceSelector#update
|
|
570
|
+
* @fires resourceSelector#change
|
|
571
|
+
* @fires resourceSelector#error
|
|
572
|
+
*/
|
|
573
|
+
update: function update(resources, params) {
|
|
574
|
+
var self = this;
|
|
575
|
+
var componentFactory;
|
|
592
576
|
|
|
593
|
-
|
|
577
|
+
if (this.is('rendered') && this.format) {
|
|
578
|
+
componentFactory = this.config.formats[this.format] && this.config.formats[this.format].componentFactory;
|
|
594
579
|
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
580
|
+
if (!_.isFunction(componentFactory)) {
|
|
581
|
+
return this.trigger('error', new TypeError("Unable to load the component for the format ".concat(this.format)));
|
|
582
|
+
}
|
|
598
583
|
|
|
599
|
-
|
|
600
|
-
this.selectionComponent = componentFactory($resultArea, _.defaults({
|
|
601
|
-
classUri: this.classUri,
|
|
602
|
-
nodes: resources
|
|
603
|
-
}, this.config)).on('query', function (queryParams) {
|
|
604
|
-
self.query(queryParams);
|
|
605
|
-
}).on('update', function () {
|
|
606
|
-
if (_.size(this.getNodes()) === 0 && $$1('li', $resultArea).length === 0) {
|
|
607
|
-
hider.show($noResults);
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
self.trigger('update');
|
|
611
|
-
}).on('change', function (selected, onlyVisible) {
|
|
612
|
-
self.trigger('change', selected, onlyVisible);
|
|
613
|
-
}).on('error', function (err) {
|
|
614
|
-
self.trigger('error', err);
|
|
615
|
-
});
|
|
616
|
-
} else {
|
|
617
|
-
this.selectionComponent.update(resources, params);
|
|
618
|
-
}
|
|
584
|
+
hider.hide($noResults);
|
|
619
585
|
|
|
620
|
-
|
|
586
|
+
if (params.updateClasses && this.classSelector) {
|
|
587
|
+
this.classSelector.updateNodes(filterClasses(resources));
|
|
621
588
|
}
|
|
622
589
|
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
590
|
+
if (!this.selectionComponent) {
|
|
591
|
+
this.selectionComponent = componentFactory($resultArea, _.defaults({
|
|
592
|
+
classUri: this.classUri,
|
|
593
|
+
nodes: resources
|
|
594
|
+
}, this.config)).on('query', function (queryParams) {
|
|
595
|
+
self.query(queryParams);
|
|
596
|
+
}).on('update', function () {
|
|
597
|
+
if (_.size(this.getNodes()) === 0 && $$1('li', $resultArea).length === 0) {
|
|
598
|
+
hider.show($noResults);
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
self.trigger('update');
|
|
602
|
+
}).on('change', function (selected, onlyVisible) {
|
|
603
|
+
self.trigger('change', selected, onlyVisible);
|
|
604
|
+
}).on('error', function (err) {
|
|
605
|
+
self.trigger('error', err);
|
|
606
|
+
});
|
|
607
|
+
} else {
|
|
608
|
+
this.selectionComponent.update(resources, params);
|
|
634
609
|
}
|
|
635
610
|
|
|
636
|
-
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
/**
|
|
640
|
-
* Remove a given node, from the selection component and the node list.
|
|
641
|
-
*
|
|
642
|
-
* @param {Object|String} node - the node or the node URI
|
|
643
|
-
* @param {String} [node.uri]
|
|
644
|
-
* @returns {resourceSelector} chains
|
|
645
|
-
*/
|
|
646
|
-
removeNode: function removeNode(node) {
|
|
647
|
-
var uri = _.isString(node) ? node : node.uri;
|
|
648
|
-
|
|
649
|
-
if (this.hasNode(uri)) {
|
|
650
|
-
//update the class selector
|
|
651
|
-
if (this.getNodeType(node) === nodeTypes.class && this.classSelector) {
|
|
652
|
-
this.classSelector.removeNode(node);
|
|
653
|
-
}
|
|
611
|
+
this.setState('loading', false);
|
|
612
|
+
}
|
|
654
613
|
|
|
655
|
-
|
|
656
|
-
|
|
614
|
+
return this;
|
|
615
|
+
},
|
|
657
616
|
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
if (this.getNodeType(node) === nodeTypes.class && this.classSelector) {
|
|
687
|
-
this.classSelector.addNode(node, parentUri);
|
|
688
|
-
}
|
|
689
|
-
}
|
|
617
|
+
/**
|
|
618
|
+
* Update the filters component
|
|
619
|
+
* @param {Object?} filterConfig - the new filter configuration
|
|
620
|
+
* @returns {resourceSelector} chains
|
|
621
|
+
*/
|
|
622
|
+
updateFilters: function updateFilters(filterConfig) {
|
|
623
|
+
if (this.is('rendered') && filterConfig !== false && this.filtersComponent) {
|
|
624
|
+
this.filtersComponent.update(filterConfig);
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
return this;
|
|
628
|
+
},
|
|
629
|
+
|
|
630
|
+
/**
|
|
631
|
+
* Remove a given node, from the selection component and the node list.
|
|
632
|
+
*
|
|
633
|
+
* @param {Object|String} node - the node or the node URI
|
|
634
|
+
* @param {String} [node.uri]
|
|
635
|
+
* @returns {resourceSelector} chains
|
|
636
|
+
*/
|
|
637
|
+
removeNode: function removeNode(node) {
|
|
638
|
+
var uri = _.isString(node) ? node : node.uri;
|
|
639
|
+
|
|
640
|
+
if (this.hasNode(uri)) {
|
|
641
|
+
//update the class selector
|
|
642
|
+
if (this.getNodeType(node) === nodeTypes.class && this.classSelector) {
|
|
643
|
+
this.classSelector.removeNode(node);
|
|
690
644
|
}
|
|
691
645
|
|
|
692
|
-
|
|
693
|
-
}
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
646
|
+
this.selectionComponent.removeNode(uri);
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
return this;
|
|
650
|
+
},
|
|
651
|
+
|
|
652
|
+
/**
|
|
653
|
+
* Add manually a node.
|
|
654
|
+
*
|
|
655
|
+
* @param {Object} node - the node to add
|
|
656
|
+
* @param {String} node.uri
|
|
657
|
+
* @param {String} node.label
|
|
658
|
+
* @param {String} [node.type=instance] - instance or class
|
|
659
|
+
* @param {String} [parentUri] - where to append the new node
|
|
660
|
+
* @returns {resourceSelector} chains
|
|
661
|
+
*/
|
|
662
|
+
addNode: function addNode(node, parentUri) {
|
|
663
|
+
if (this.is('rendered') && node && node.uri && this.selectionComponent) {
|
|
664
|
+
if (!this.selectionComponent.hasNode(node.uri)) {
|
|
665
|
+
if (!node.type) {
|
|
666
|
+
node.type = nodeTypes.instance;
|
|
667
|
+
} //update the selection component
|
|
668
|
+
|
|
669
|
+
|
|
670
|
+
this.selectionComponent.update([node], {
|
|
671
|
+
classUri: parentUri || this.classUri,
|
|
672
|
+
format: this.format,
|
|
673
|
+
limit: this.config.limit,
|
|
674
|
+
updateCount: node.type === nodeTypes.instance ? 1 : false
|
|
675
|
+
}); //update the class selector
|
|
676
|
+
|
|
677
|
+
if (this.getNodeType(node) === nodeTypes.class && this.classSelector) {
|
|
708
678
|
this.classSelector.addNode(node, parentUri);
|
|
709
679
|
}
|
|
710
680
|
}
|
|
681
|
+
}
|
|
711
682
|
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
/**
|
|
716
|
-
* Does the given node exists ?
|
|
717
|
-
*
|
|
718
|
-
* @param {Object|String} node - the node or directly the URI
|
|
719
|
-
* @param {String} [node.uri]
|
|
720
|
-
* @returns {Boolean}
|
|
721
|
-
*/
|
|
722
|
-
hasNode: function hasNode(node) {
|
|
723
|
-
var uri;
|
|
724
|
-
|
|
725
|
-
if (node && this.is('rendered') && this.selectionComponent) {
|
|
726
|
-
uri = _.isString(node) ? node : node.uri;
|
|
727
|
-
return this.selectionComponent.hasNode(uri);
|
|
728
|
-
}
|
|
683
|
+
return this;
|
|
684
|
+
},
|
|
729
685
|
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
if (node && this.is('rendered') && this.selectionComponent) {
|
|
745
|
-
uri = _.isString(node) ? node : node.uri;
|
|
746
|
-
foundNode = this.selectionComponent.getNode(uri);
|
|
747
|
-
return foundNode && foundNode.type;
|
|
686
|
+
/**
|
|
687
|
+
* Add class to classSelector, no update of selectionComponent
|
|
688
|
+
*
|
|
689
|
+
* @param {Object} node - the class node to add
|
|
690
|
+
* @param {String} node.uri
|
|
691
|
+
* @param {String} node.label
|
|
692
|
+
* @param {String} parentUri - where to append the new node
|
|
693
|
+
* @returns {resourceSelector} chains
|
|
694
|
+
*/
|
|
695
|
+
addClassNode: function addClassNode(node, parentUri) {
|
|
696
|
+
if (this.is('rendered') && node && node.uri && this.classSelector) {
|
|
697
|
+
if (!this.classSelector.hasNode(node.uri) && this.classSelector.hasNode(parentUri)) {
|
|
698
|
+
//add node to the class selector
|
|
699
|
+
this.classSelector.addNode(node, parentUri);
|
|
748
700
|
}
|
|
701
|
+
}
|
|
749
702
|
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
/**
|
|
754
|
-
* Select a node manually
|
|
755
|
-
*
|
|
756
|
-
* @param {Object|String} node - the node to select or directly the URI
|
|
757
|
-
* @param {String} [node.uri]
|
|
758
|
-
* @returns {resourceSelector} chains
|
|
759
|
-
*/
|
|
760
|
-
select: function select(node) {
|
|
761
|
-
var uri = _.isString(node) ? node : node.uri;
|
|
762
|
-
|
|
763
|
-
if (this.hasNode(uri)) {
|
|
764
|
-
if (!this.is('multiple')) {
|
|
765
|
-
this.selectionComponent.clearSelection();
|
|
766
|
-
}
|
|
703
|
+
return this;
|
|
704
|
+
},
|
|
767
705
|
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
706
|
+
/**
|
|
707
|
+
* Does the given node exists ?
|
|
708
|
+
*
|
|
709
|
+
* @param {Object|String} node - the node or directly the URI
|
|
710
|
+
* @param {String} [node.uri]
|
|
711
|
+
* @returns {Boolean}
|
|
712
|
+
*/
|
|
713
|
+
hasNode: function hasNode(node) {
|
|
714
|
+
var uri;
|
|
773
715
|
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
* Select the default node, then fallback to 1st instance then 1st class
|
|
779
|
-
*
|
|
780
|
-
* @param {Object|String} node - the node to select or directly the URI
|
|
781
|
-
* @param {String} [node.uri]
|
|
782
|
-
* @param {Boolean} [fallback=true] - apply the fallback ?
|
|
783
|
-
* @returns {resourceSelector} chains
|
|
784
|
-
*/
|
|
785
|
-
selectDefaultNode: function selectDefaultNode(node, fallback) {
|
|
786
|
-
var $resource;
|
|
787
|
-
|
|
788
|
-
if (this.is('rendered')) {
|
|
789
|
-
if (this.hasNode(node)) {
|
|
790
|
-
this.select(node);
|
|
791
|
-
} else if (fallback !== false) {
|
|
792
|
-
$resource = this.getElement().find(`.${nodeTypes.instance}`);
|
|
793
|
-
|
|
794
|
-
if (!$resource.length) {
|
|
795
|
-
$resource = this.getElement().find(`.${nodeTypes.class}`);
|
|
796
|
-
}
|
|
716
|
+
if (node && this.is('rendered') && this.selectionComponent) {
|
|
717
|
+
uri = _.isString(node) ? node : node.uri;
|
|
718
|
+
return this.selectionComponent.hasNode(uri);
|
|
719
|
+
}
|
|
797
720
|
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
}
|
|
801
|
-
}
|
|
802
|
-
}
|
|
721
|
+
return false;
|
|
722
|
+
},
|
|
803
723
|
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
724
|
+
/**
|
|
725
|
+
* Get the type of a node, usually instance or class
|
|
726
|
+
*
|
|
727
|
+
* @param {Object|String} node - the node or directly the URI
|
|
728
|
+
* @param {String} [node.uri]
|
|
729
|
+
* @returns {String|Boolean} one of the nodeTypes or false
|
|
730
|
+
*/
|
|
731
|
+
getNodeType: function getNodeType(node) {
|
|
732
|
+
var uri;
|
|
733
|
+
var foundNode;
|
|
734
|
+
|
|
735
|
+
if (node && this.is('rendered') && this.selectionComponent) {
|
|
736
|
+
uri = _.isString(node) ? node : node.uri;
|
|
737
|
+
foundNode = this.selectionComponent.getNode(uri);
|
|
738
|
+
return foundNode && foundNode.type;
|
|
739
|
+
}
|
|
818
740
|
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
this.off('update.refresh');
|
|
822
|
-
this.selectDefaultNode(node);
|
|
823
|
-
});
|
|
741
|
+
return false;
|
|
742
|
+
},
|
|
824
743
|
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
744
|
+
/**
|
|
745
|
+
* Select a node manually
|
|
746
|
+
*
|
|
747
|
+
* @param {Object|String} node - the node to select or directly the URI
|
|
748
|
+
* @param {String} [node.uri]
|
|
749
|
+
* @returns {resourceSelector} chains
|
|
750
|
+
*/
|
|
751
|
+
select: function select(node) {
|
|
752
|
+
var uri = _.isString(node) ? node : node.uri;
|
|
828
753
|
|
|
829
|
-
|
|
754
|
+
if (this.hasNode(uri)) {
|
|
755
|
+
if (!this.is('multiple')) {
|
|
756
|
+
this.selectionComponent.clearSelection();
|
|
830
757
|
}
|
|
831
758
|
|
|
832
|
-
|
|
759
|
+
this.selectionComponent.select(uri);
|
|
760
|
+
$$1("[data-uri=\"".concat(uri, "\"]"), $resultArea)[0].scrollIntoView({
|
|
761
|
+
behavior: 'smooth'
|
|
762
|
+
});
|
|
833
763
|
}
|
|
834
|
-
|
|
764
|
+
|
|
765
|
+
return this;
|
|
766
|
+
},
|
|
767
|
+
|
|
835
768
|
/**
|
|
836
|
-
*
|
|
837
|
-
*
|
|
769
|
+
* Select the default node, then fallback to 1st instance then 1st class
|
|
770
|
+
*
|
|
771
|
+
* @param {Object|String} node - the node to select or directly the URI
|
|
772
|
+
* @param {String} [node.uri]
|
|
773
|
+
* @param {Boolean} [fallback=true] - apply the fallback ?
|
|
774
|
+
* @returns {resourceSelector} chains
|
|
838
775
|
*/
|
|
776
|
+
selectDefaultNode: function selectDefaultNode(node, fallback) {
|
|
777
|
+
var $resource;
|
|
839
778
|
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
});
|
|
846
|
-
this.config.switchMode = this.config.selectionMode === selectionModes.both;
|
|
847
|
-
this.config.multiple = this.config.selectionMode === selectionModes.multiple;
|
|
848
|
-
this.setState('multiple', this.config.multiple);
|
|
849
|
-
this.render($container);
|
|
850
|
-
}).on('render', function () {
|
|
851
|
-
var self = this; //we ensure the sub-components are rendered
|
|
852
|
-
|
|
853
|
-
return new Promise(function (resolve) {
|
|
854
|
-
var $component = self.getElement();
|
|
855
|
-
$classContainer = $$1('.class-context', $component);
|
|
856
|
-
$resultArea = $$1('main', $component);
|
|
857
|
-
$noResults = $$1('.no-results', $resultArea);
|
|
858
|
-
$searchField = $$1('.search input', $component);
|
|
859
|
-
$filterToggle = $$1('.filters-opener', $component);
|
|
860
|
-
$filterContainer = $$1('.filters-container', $component);
|
|
861
|
-
$viewFormats = $$1('.context > a', $component);
|
|
862
|
-
$selectNum = $$1('.selected-num', $component);
|
|
863
|
-
$selectCtrl = $$1('.selection-control input', $component);
|
|
864
|
-
$selectCtrlLabel = $$1('.selection-control label', $component);
|
|
865
|
-
$selectionToggle = $$1('.selection-toggle', $component); //the search field
|
|
866
|
-
|
|
867
|
-
$searchField.on('keyup', _.debounce(function (e) {
|
|
868
|
-
var value = $$1(this).val().trim();
|
|
869
|
-
|
|
870
|
-
if (value.length > 2 || value.length === 0 || e.which === 13) {
|
|
871
|
-
if (self.config.filters) {
|
|
872
|
-
//reset the placeholder
|
|
873
|
-
$$1(this).attr('title', null).attr('placeholder', self.config.searchPlaceholder);
|
|
874
|
-
}
|
|
779
|
+
if (this.is('rendered')) {
|
|
780
|
+
if (this.hasNode(node)) {
|
|
781
|
+
this.select(node);
|
|
782
|
+
} else if (fallback !== false) {
|
|
783
|
+
$resource = this.getElement().find(".".concat(nodeTypes.instance));
|
|
875
784
|
|
|
876
|
-
|
|
785
|
+
if (!$resource.length) {
|
|
786
|
+
$resource = this.getElement().find(".".concat(nodeTypes.class));
|
|
877
787
|
}
|
|
878
|
-
}, 300)); //the format switcher
|
|
879
788
|
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
}); //mode switcher (multiple/single)
|
|
886
|
-
|
|
887
|
-
if (self.config.selectionMode === selectionModes.both) {
|
|
888
|
-
//click the toggler
|
|
889
|
-
$selectionToggle.on('click', function (e) {
|
|
890
|
-
e.preventDefault();
|
|
891
|
-
self.changeSelectionMode(self.config.multiple ? selectionModes.single : selectionModes.multiple);
|
|
892
|
-
}); //CTRL-Click
|
|
893
|
-
|
|
894
|
-
$resultArea.on('mousedown', function (e) {
|
|
895
|
-
if (e.ctrlKey && !self.config.multiple) {
|
|
896
|
-
self.changeSelectionMode(selectionModes.multiple);
|
|
897
|
-
}
|
|
898
|
-
}); //switch back to sinlge
|
|
789
|
+
if ($resource.length) {
|
|
790
|
+
this.select($resource.first().data('uri'));
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
}
|
|
899
794
|
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
});
|
|
903
|
-
} //the select all control
|
|
795
|
+
return this;
|
|
796
|
+
},
|
|
904
797
|
|
|
798
|
+
/**
|
|
799
|
+
* Refresh and select the given node
|
|
800
|
+
*
|
|
801
|
+
* @param {Object|String} node - the node to select or directly the URI
|
|
802
|
+
* @param {String} [node.uri]
|
|
803
|
+
* @returns {resourceSelector} chains
|
|
804
|
+
*/
|
|
805
|
+
refresh: function refresh(node) {
|
|
806
|
+
var queryParams = {
|
|
807
|
+
updateClasses: true
|
|
808
|
+
};
|
|
809
|
+
|
|
810
|
+
if (this.is('rendered')) {
|
|
811
|
+
this.on('update.refresh', function () {
|
|
812
|
+
this.off('update.refresh');
|
|
813
|
+
this.selectDefaultNode(node);
|
|
814
|
+
});
|
|
815
|
+
|
|
816
|
+
if (node && node.uri) {
|
|
817
|
+
queryParams.selectedUri = node.uri;
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
this.reset().query(queryParams);
|
|
821
|
+
}
|
|
905
822
|
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
823
|
+
return this;
|
|
824
|
+
}
|
|
825
|
+
};
|
|
826
|
+
/**
|
|
827
|
+
* The resource selector component
|
|
828
|
+
* @typedef {ui/component} resourceSelector
|
|
829
|
+
*/
|
|
830
|
+
|
|
831
|
+
var resourceSelector = component(resourceSelectorApi, defaultConfig).setTemplate(selectorTpl).on('init', function () {
|
|
832
|
+
this.searchQuery = {};
|
|
833
|
+
this.classUri = this.config.classUri;
|
|
834
|
+
this.format = this.config.format || _.findKey(this.config.formats, {
|
|
835
|
+
active: true
|
|
836
|
+
});
|
|
837
|
+
this.config.switchMode = this.config.selectionMode === selectionModes.both;
|
|
838
|
+
this.config.multiple = this.config.selectionMode === selectionModes.multiple;
|
|
839
|
+
this.setState('multiple', this.config.multiple);
|
|
840
|
+
this.render($container);
|
|
841
|
+
}).on('render', function () {
|
|
842
|
+
var self = this; //we ensure the sub-components are rendered
|
|
843
|
+
|
|
844
|
+
return new Promise(function (resolve) {
|
|
845
|
+
var $component = self.getElement();
|
|
846
|
+
$classContainer = $$1('.class-context', $component);
|
|
847
|
+
$resultArea = $$1('main', $component);
|
|
848
|
+
$noResults = $$1('.no-results', $resultArea);
|
|
849
|
+
$searchField = $$1('.search input', $component);
|
|
850
|
+
$filterToggle = $$1('.filters-opener', $component);
|
|
851
|
+
$filterContainer = $$1('.filters-container', $component);
|
|
852
|
+
$viewFormats = $$1('.context > a', $component);
|
|
853
|
+
$selectNum = $$1('.selected-num', $component);
|
|
854
|
+
$selectCtrl = $$1('.selection-control input', $component);
|
|
855
|
+
$selectCtrlLabel = $$1('.selection-control label', $component);
|
|
856
|
+
$selectionToggle = $$1('.selection-toggle', $component); //the search field
|
|
857
|
+
|
|
858
|
+
$searchField.on('keyup', _.debounce(function (e) {
|
|
859
|
+
var value = $$1(this).val().trim();
|
|
860
|
+
|
|
861
|
+
if (value.length > 2 || value.length === 0 || e.which === 13) {
|
|
862
|
+
if (self.config.filters) {
|
|
863
|
+
//reset the placeholder
|
|
864
|
+
$$1(this).attr('title', null).attr('placeholder', self.config.searchPlaceholder);
|
|
913
865
|
}
|
|
914
|
-
}); //the advanced filters
|
|
915
|
-
|
|
916
|
-
if (self.config.filters !== false) {
|
|
917
|
-
self.filtersComponent = filtersFactory($filterContainer, {
|
|
918
|
-
classUri: self.classUri,
|
|
919
|
-
data: self.config.filters
|
|
920
|
-
}).on('change', function (values) {
|
|
921
|
-
var textualQuery = this.getTextualQuery();
|
|
922
|
-
$searchField.val('').attr('title', textualQuery).attr('placeholder', textualQuery);
|
|
923
|
-
self.empty().changeFormat('list').setSearchQuery(values).query();
|
|
924
|
-
$filterContainer.addClass('folded');
|
|
925
|
-
});
|
|
926
|
-
$filterToggle.on('click', function (e) {
|
|
927
|
-
var searchVal;
|
|
928
|
-
e.preventDefault();
|
|
929
866
|
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
867
|
+
self.empty().changeFormat('list').setSearchQuery(value).query();
|
|
868
|
+
}
|
|
869
|
+
}, 300)); //the format switcher
|
|
870
|
+
|
|
871
|
+
$viewFormats.on('click', function (e) {
|
|
872
|
+
var $target = $$1(this);
|
|
873
|
+
var format = $target.data('view-format');
|
|
874
|
+
e.preventDefault();
|
|
875
|
+
self.reset().changeFormat(format).query();
|
|
876
|
+
}); //mode switcher (multiple/single)
|
|
877
|
+
|
|
878
|
+
if (self.config.selectionMode === selectionModes.both) {
|
|
879
|
+
//click the toggler
|
|
880
|
+
$selectionToggle.on('click', function (e) {
|
|
881
|
+
e.preventDefault();
|
|
882
|
+
self.changeSelectionMode(self.config.multiple ? selectionModes.single : selectionModes.multiple);
|
|
883
|
+
}); //CTRL-Click
|
|
933
884
|
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
885
|
+
$resultArea.on('mousedown', function (e) {
|
|
886
|
+
if (e.ctrlKey && !self.config.multiple) {
|
|
887
|
+
self.changeSelectionMode(selectionModes.multiple);
|
|
888
|
+
}
|
|
889
|
+
}); //switch back to sinlge
|
|
937
890
|
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
});
|
|
943
|
-
} //initialize the class selector
|
|
891
|
+
$resultArea.on('click', function () {
|
|
892
|
+
self.changeSelectionMode(selectionModes.single);
|
|
893
|
+
});
|
|
894
|
+
} //the select all control
|
|
944
895
|
|
|
945
896
|
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
897
|
+
$selectCtrl.on('change', function () {
|
|
898
|
+
if ($$1(this).prop('checked') === false) {
|
|
899
|
+
self.selectionComponent.clearSelection();
|
|
900
|
+
} else if (self.config.selectAllPolicy === selectAllPolicies.visible) {
|
|
901
|
+
self.selectionComponent.selectVisible();
|
|
902
|
+
} else if (self.config.selectAllPolicy === selectAllPolicies.loaded) {
|
|
903
|
+
self.selectionComponent.selectAll();
|
|
904
|
+
}
|
|
905
|
+
}); //the advanced filters
|
|
906
|
+
|
|
907
|
+
if (self.config.filters !== false) {
|
|
908
|
+
self.filtersComponent = filtersFactory($filterContainer, {
|
|
909
|
+
classUri: self.classUri,
|
|
910
|
+
data: self.config.filters
|
|
911
|
+
}).on('change', function (values) {
|
|
912
|
+
var textualQuery = this.getTextualQuery();
|
|
913
|
+
$searchField.val('').attr('title', textualQuery).attr('placeholder', textualQuery);
|
|
914
|
+
self.empty().changeFormat('list').setSearchQuery(values).query();
|
|
915
|
+
$filterContainer.addClass('folded');
|
|
916
|
+
});
|
|
917
|
+
$filterToggle.on('click', function (e) {
|
|
918
|
+
var searchVal;
|
|
919
|
+
e.preventDefault();
|
|
950
920
|
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
/**
|
|
955
|
-
* When the component's root class URI changes
|
|
956
|
-
* @event resourceSelector#classchange
|
|
957
|
-
* @param {String} classUri - the new class URI
|
|
958
|
-
*/
|
|
921
|
+
if ($filterContainer.hasClass('folded')) {
|
|
922
|
+
//if a value is in the search field, we add it to the label
|
|
923
|
+
searchVal = $searchField.val().trim();
|
|
959
924
|
|
|
925
|
+
if (!_.isEmpty(searchVal)) {
|
|
926
|
+
self.filtersComponent.setValue(labelUri, searchVal);
|
|
927
|
+
}
|
|
960
928
|
|
|
961
|
-
|
|
962
|
-
|
|
929
|
+
$filterContainer.removeClass('folded');
|
|
930
|
+
} else {
|
|
931
|
+
$filterContainer.addClass('folded');
|
|
963
932
|
}
|
|
964
933
|
});
|
|
965
|
-
|
|
966
|
-
});
|
|
967
|
-
}).on('change', function (selected, onlyVisible) {
|
|
968
|
-
var selectedCount = _.size(selected);
|
|
934
|
+
} //initialize the class selector
|
|
969
935
|
|
|
970
|
-
var nodesCount = onlyVisible ? selectedCount : _.size(this.selectionComponent.getNodes()); //the number selected at the bottom
|
|
971
936
|
|
|
972
|
-
$
|
|
937
|
+
self.classSelector = classesSelectorFactory($classContainer, self.config);
|
|
938
|
+
self.classSelector.on('render', resolve).on('change', function (uri) {
|
|
939
|
+
if (uri && uri !== self.classUri) {
|
|
940
|
+
self.classUri = uri; //close the filters
|
|
941
|
+
|
|
942
|
+
if ($filterContainer.length) {
|
|
943
|
+
$filterContainer.addClass('folded');
|
|
944
|
+
}
|
|
945
|
+
/**
|
|
946
|
+
* When the component's root class URI changes
|
|
947
|
+
* @event resourceSelector#classchange
|
|
948
|
+
* @param {String} classUri - the new class URI
|
|
949
|
+
*/
|
|
973
950
|
|
|
974
|
-
if (selectedCount === 0) {
|
|
975
|
-
$selectCtrlLabel.attr('title', __('Select loaded %s', this.config.type));
|
|
976
|
-
$selectCtrl.prop('checked', false).prop('indeterminate', false); // if all of the nodes are selected (or more in the closed subclasses)
|
|
977
|
-
} else if (selectedCount >= nodesCount) {
|
|
978
|
-
$selectCtrlLabel.attr('title', __('Clear selection'));
|
|
979
|
-
$selectCtrl.prop('checked', true).prop('indeterminate', false);
|
|
980
|
-
} else {
|
|
981
|
-
$selectCtrlLabel.attr('title', __('Select loaded %s', this.config.type));
|
|
982
|
-
$selectCtrl.prop('checked', false).prop('indeterminate', true);
|
|
983
|
-
}
|
|
984
|
-
});
|
|
985
951
|
|
|
986
|
-
|
|
987
|
-
|
|
952
|
+
self.trigger('classchange', uri);
|
|
953
|
+
self.reset().query();
|
|
954
|
+
}
|
|
955
|
+
});
|
|
956
|
+
self.query();
|
|
988
957
|
});
|
|
958
|
+
}).on('change', function (selected, onlyVisible) {
|
|
959
|
+
var selectedCount = _.size(selected);
|
|
960
|
+
|
|
961
|
+
var nodesCount = onlyVisible ? selectedCount : _.size(this.selectionComponent.getNodes()); //the number selected at the bottom
|
|
962
|
+
|
|
963
|
+
$selectNum.text(selectedCount); //update the state of the "Select All" checkbox
|
|
964
|
+
|
|
965
|
+
if (selectedCount === 0) {
|
|
966
|
+
$selectCtrlLabel.attr('title', __('Select loaded %s', this.config.type));
|
|
967
|
+
$selectCtrl.prop('checked', false).prop('indeterminate', false); // if all of the nodes are selected (or more in the closed subclasses)
|
|
968
|
+
} else if (selectedCount >= nodesCount) {
|
|
969
|
+
$selectCtrlLabel.attr('title', __('Clear selection'));
|
|
970
|
+
$selectCtrl.prop('checked', true).prop('indeterminate', false);
|
|
971
|
+
} else {
|
|
972
|
+
$selectCtrlLabel.attr('title', __('Select loaded %s', this.config.type));
|
|
973
|
+
$selectCtrl.prop('checked', false).prop('indeterminate', true);
|
|
974
|
+
}
|
|
975
|
+
});
|
|
976
|
+
|
|
977
|
+
_.defer(function () {
|
|
978
|
+
resourceSelector.init(config);
|
|
979
|
+
});
|
|
989
980
|
|
|
990
|
-
|
|
991
|
-
|
|
981
|
+
return resourceSelector;
|
|
982
|
+
}; //Exposes the selection modes
|
|
992
983
|
|
|
993
984
|
|
|
994
|
-
|
|
985
|
+
resourceSelectorFactory.selectionModes = selectionModes; //Exposes the selectAllPolicies
|
|
995
986
|
|
|
996
|
-
|
|
987
|
+
resourceSelectorFactory.selectAllPolicies = selectAllPolicies; //Exposes the node types
|
|
997
988
|
|
|
998
|
-
|
|
989
|
+
resourceSelectorFactory.nodeTypes = nodeTypes;
|
|
999
990
|
|
|
1000
|
-
|
|
991
|
+
return resourceSelectorFactory;
|
|
1001
992
|
|
|
1002
993
|
});
|