@oat-sa/tao-core-ui 1.48.0 → 1.49.3
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 +5 -11
- package/dist/animable/absorbable/absorbable.js +5 -11
- package/dist/animable/pulsable/pulsable.js +5 -11
- package/dist/badge/badge.js +5 -11
- package/dist/breadcrumbs.js +5 -11
- package/dist/bulkActionPopup.js +5 -11
- package/dist/button.js +5 -11
- package/dist/cascadingComboBox.js +5 -11
- package/dist/ckeditor/ckConfigurator.js +22 -6
- package/dist/class/selector.js +5 -11
- package/dist/component/windowed.js +5 -11
- package/dist/component.js +5 -11
- package/dist/contextualPopup.js +5 -11
- package/dist/dashboard.js +5 -11
- package/dist/datalist.js +5 -11
- package/dist/datatable.js +5 -11
- package/dist/dateRange/dateRange.js +5 -11
- package/dist/datetime/picker.js +5 -11
- package/dist/deleter.js +5 -11
- package/dist/destination/selector.js +5 -11
- package/dist/dialog/confirmDelete.js +5 -11
- package/dist/dialog.js +5 -11
- package/dist/documentViewer/providers/pdfViewer/fallback/viewer.js +5 -11
- package/dist/documentViewer/providers/pdfViewer/pdfjs/findBar.js +5 -11
- package/dist/documentViewer/providers/pdfViewer/pdfjs/pageView.js +5 -11
- package/dist/documentViewer/providers/pdfViewer/pdfjs/searchEngine.js +5 -11
- package/dist/documentViewer/providers/pdfViewer/pdfjs/viewer.js +5 -11
- package/dist/documentViewer/providers/pdfViewer.js +5 -11
- package/dist/documentViewer.js +5 -11
- package/dist/dropdown.js +5 -11
- package/dist/dynamicComponent.js +5 -11
- package/dist/feedback.js +5 -11
- package/dist/filter.js +5 -11
- package/dist/form/dropdownForm.js +5 -11
- package/dist/form/form.js +5 -11
- package/dist/form/validator/renderer.js +5 -11
- package/dist/form/widget/providers/checkBox.js +5 -11
- package/dist/form/widget/providers/comboBox.js +5 -11
- package/dist/form/widget/providers/hidden.js +5 -11
- package/dist/form/widget/providers/hiddenBox.js +5 -11
- package/dist/form/widget/providers/radioBox.js +5 -11
- package/dist/form/widget/providers/textArea.js +5 -11
- package/dist/form/widget/widget.js +5 -11
- package/dist/generis/form/form.js +5 -11
- package/dist/generis/validator/validator.js +5 -11
- package/dist/generis/widget/checkBox/checkBox.js +5 -11
- package/dist/generis/widget/comboBox/comboBox.js +5 -11
- package/dist/generis/widget/hiddenBox/hiddenBox.js +5 -11
- package/dist/generis/widget/textBox/textBox.js +5 -11
- package/dist/generis/widget/widget.js +5 -11
- package/dist/groupedComboBox.js +5 -11
- package/dist/highlighter.js +5 -11
- package/dist/image/ImgStateActive/initHelper.js +1 -1
- package/dist/image/ImgStateActive.js +1 -1
- package/dist/itemButtonList.js +5 -11
- package/dist/listbox.js +5 -11
- package/dist/loadingButton/loadingButton.js +5 -11
- package/dist/lock.js +5 -11
- package/dist/login/login.js +5 -11
- package/dist/maths/calculator/basicCalculator.js +5 -11
- package/dist/maths/calculator/core/board.js +5 -11
- package/dist/maths/calculator/core/expression.js +5 -11
- package/dist/maths/calculator/core/labels.js +7 -13
- package/dist/maths/calculator/core/tokens.js +5 -11
- package/dist/maths/calculator/plugins/keyboard/templateKeyboard/templateKeyboard.js +5 -11
- package/dist/maths/calculator/plugins/screen/simpleScreen/simpleScreen.js +5 -11
- package/dist/maths/calculator/scientificCalculator.js +5 -11
- package/dist/mediaEditor/mediaEditorComponent.js +5 -11
- package/dist/mediaEditor/plugins/mediaAlignment/mediaAlignmentComponent.js +5 -11
- package/dist/mediaEditor/plugins/mediaDimension/mediaDimensionComponent.js +5 -11
- package/dist/mediaplayer/players/html5.js +5 -11
- package/dist/mediaplayer/players/youtube.js +5 -11
- package/dist/mediaplayer.js +5 -11
- package/dist/mediasizer.js +5 -11
- package/dist/pageSizeSelector.js +5 -11
- package/dist/pagination/providers/pages.js +5 -11
- package/dist/pagination/providers/simple.js +5 -11
- package/dist/report.js +5 -11
- package/dist/resource/filters.js +5 -11
- package/dist/resource/list.js +5 -11
- package/dist/resource/selector.js +5 -11
- package/dist/resource/tree.js +5 -11
- package/dist/resourcemgr/fileBrowser.js +5 -11
- package/dist/resourcemgr/fileSelector.js +5 -11
- package/dist/resourcemgr.js +5 -11
- package/dist/searchModal/advancedSearch.js +53 -24
- package/dist/searchModal.js +14 -32
- package/dist/switch/switch.js +5 -11
- package/dist/tabs.js +5 -11
- package/dist/taskQueue/status.js +5 -11
- package/dist/taskQueue/table.js +5 -11
- package/dist/taskQueueButton/taskable.js +5 -11
- package/dist/taskQueueButton/treeButton.js +5 -11
- package/dist/tooltip.js +5 -11
- package/dist/tristateCheckboxGroup.js +5 -11
- package/dist/uploader.js +5 -11
- package/dist/validator.js +5 -11
- package/package.json +2 -3
- package/src/ckeditor/ckConfigurator.js +46 -26
- package/src/image/ImgStateActive/initHelper.js +1 -1
- package/src/maths/calculator/core/labels.js +2 -2
- package/src/searchModal/advancedSearch.js +53 -18
package/dist/uploader.js
CHANGED
|
@@ -12,17 +12,11 @@ define(['jquery', 'lodash', 'i18n', 'async', 'core/pluginifier', 'util/bytes', '
|
|
|
12
12
|
function _typeof(obj) {
|
|
13
13
|
"@babel/helpers - typeof";
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
_typeof = function (obj) {
|
|
21
|
-
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return _typeof(obj);
|
|
15
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
16
|
+
return typeof obj;
|
|
17
|
+
} : function (obj) {
|
|
18
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
19
|
+
}, _typeof(obj);
|
|
26
20
|
}
|
|
27
21
|
|
|
28
22
|
function Helpers0 (hb) {
|
package/dist/validator.js
CHANGED
|
@@ -8,17 +8,11 @@ define(['jquery', 'lodash', 'ui/validator/Report', 'ui/validator/Validator'], fu
|
|
|
8
8
|
function _typeof(obj) {
|
|
9
9
|
"@babel/helpers - typeof";
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
_typeof = function (obj) {
|
|
17
|
-
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return _typeof(obj);
|
|
11
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
12
|
+
return typeof obj;
|
|
13
|
+
} : function (obj) {
|
|
14
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
15
|
+
}, _typeof(obj);
|
|
22
16
|
}
|
|
23
17
|
|
|
24
18
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oat-sa/tao-core-ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.49.3",
|
|
4
4
|
"displayName": "TAO Core UI",
|
|
5
5
|
"description": "UI libraries of TAO",
|
|
6
6
|
"scripts": {
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@oat-sa/rollup-plugin-wildcard-external": "^0.1.0",
|
|
52
52
|
"@oat-sa/tao-core-libs": "^0.4.4",
|
|
53
53
|
"@oat-sa/tao-core-sdk": "^1.8.1",
|
|
54
|
-
"@oat-sa/tao-core-shared-libs": "1.0.
|
|
54
|
+
"@oat-sa/tao-core-shared-libs": "^1.0.5",
|
|
55
55
|
"@oat-sa/tao-qunit-testrunner": "^1.0.3",
|
|
56
56
|
"async": "^0.2.10",
|
|
57
57
|
"autoprefixer": "^9.5.1",
|
|
@@ -61,7 +61,6 @@
|
|
|
61
61
|
"dompurify": "^1.0.10",
|
|
62
62
|
"eslint": "^7.32.0",
|
|
63
63
|
"eslint-plugin-jsdoc": "^36.1.0",
|
|
64
|
-
"eve": "git+https://github.com/adobe-webplatform/eve.git#eef80ed",
|
|
65
64
|
"flatpickr": "4.5.7",
|
|
66
65
|
"fs-extra": "^8.0.1",
|
|
67
66
|
"gamp": "^0.2.1",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* along with this program; if not, write to the Free Software
|
|
14
14
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
15
15
|
*
|
|
16
|
-
* Copyright (c) 2015 (original work) Open Assessment Technologies SA ;
|
|
16
|
+
* Copyright (c) 2015-2022 (original work) Open Assessment Technologies SA ;
|
|
17
17
|
*/
|
|
18
18
|
import $ from 'jquery';
|
|
19
19
|
import _ from 'lodash';
|
|
@@ -23,23 +23,23 @@ import 'ckeditor';
|
|
|
23
23
|
/**
|
|
24
24
|
* Cache original config
|
|
25
25
|
*/
|
|
26
|
-
|
|
26
|
+
const originalConfig = _.cloneDeep(window.CKEDITOR.config);
|
|
27
27
|
|
|
28
28
|
function getUserLanguage() {
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
const documentLang = window.document.documentElement.getAttribute('lang');
|
|
30
|
+
const documentLocale = documentLang && documentLang.split('-')[0];
|
|
31
31
|
|
|
32
32
|
return documentLocale;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
const lang = getUserLanguage();
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
const ckConfigurator = (function () {
|
|
38
38
|
/**
|
|
39
39
|
* Toolbar presets that you normally never would need to change, they can however be overridden with options.toolbar.
|
|
40
40
|
* The argument 'toolbarType' determines which toolbar to use
|
|
41
41
|
*/
|
|
42
|
-
|
|
42
|
+
const toolbarPresets = {
|
|
43
43
|
inline: [
|
|
44
44
|
{
|
|
45
45
|
name: 'basicstyles',
|
|
@@ -166,13 +166,31 @@ var ckConfigurator = (function() {
|
|
|
166
166
|
name: 'insert',
|
|
167
167
|
items: ['Link', 'SpecialChar']
|
|
168
168
|
}
|
|
169
|
+
],
|
|
170
|
+
table: [
|
|
171
|
+
{
|
|
172
|
+
name: 'basicstyles',
|
|
173
|
+
items: ['Bold', 'Italic', 'Subscript', 'Superscript']
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
name: 'insert',
|
|
177
|
+
items: ['SpecialChar', 'TaoQtiTable', 'TaoTooltip']
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
name: 'links',
|
|
181
|
+
items: ['Link']
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
name: 'paragraph',
|
|
185
|
+
items: ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock']
|
|
186
|
+
}
|
|
169
187
|
]
|
|
170
188
|
};
|
|
171
189
|
|
|
172
190
|
/**
|
|
173
191
|
* defaults for editor configuration
|
|
174
192
|
*/
|
|
175
|
-
|
|
193
|
+
const ckConfigDefault = {
|
|
176
194
|
disableAutoInline: true,
|
|
177
195
|
entities: false,
|
|
178
196
|
entities_processNumerical: true,
|
|
@@ -416,11 +434,11 @@ var ckConfigurator = (function() {
|
|
|
416
434
|
/**
|
|
417
435
|
* Insert positioned plugins at position specified in options.positionedPlugins
|
|
418
436
|
*
|
|
419
|
-
* @param ckConfig
|
|
420
|
-
* @param positionedPlugins
|
|
437
|
+
* @param {Object} ckConfig
|
|
438
|
+
* @param {Object} positionedPlugins
|
|
421
439
|
*/
|
|
422
|
-
|
|
423
|
-
|
|
440
|
+
const _updatePlugins = function (ckConfig, positionedPlugins) {
|
|
441
|
+
let itCnt,
|
|
424
442
|
tbCnt = ckConfig.toolbar.length,
|
|
425
443
|
itLen,
|
|
426
444
|
method,
|
|
@@ -435,9 +453,9 @@ var ckConfigurator = (function() {
|
|
|
435
453
|
positionedPlugins = positionedPlugins || {};
|
|
436
454
|
|
|
437
455
|
// add positioned plugins to extraPlugins and let CKEDITOR take care of their registration
|
|
438
|
-
ckConfig.extraPlugins = (function(positionedPluginArr, extraPlugins) {
|
|
439
|
-
|
|
440
|
-
|
|
456
|
+
ckConfig.extraPlugins = (function (positionedPluginArr, extraPlugins) {
|
|
457
|
+
let pluginIndex = positionedPluginArr.length;
|
|
458
|
+
let extraPluginArr = extraPlugins.split(',');
|
|
441
459
|
|
|
442
460
|
while (pluginIndex--) {
|
|
443
461
|
positionedPluginArr[pluginIndex] = positionedPluginArr[pluginIndex].toLowerCase();
|
|
@@ -460,8 +478,8 @@ var ckConfigurator = (function() {
|
|
|
460
478
|
|
|
461
479
|
// add positioned plugins to toolbar
|
|
462
480
|
for (plugin in positionedPlugins) {
|
|
463
|
-
method = (function(pluginProps) {
|
|
464
|
-
|
|
481
|
+
method = (function (pluginProps) {
|
|
482
|
+
let propIndex = pluginProps.length;
|
|
465
483
|
while (propIndex--) {
|
|
466
484
|
if (pluginProps[propIndex].indexOf('insert') === 0 || pluginProps[propIndex] === 'replace') {
|
|
467
485
|
return pluginProps[propIndex];
|
|
@@ -511,7 +529,7 @@ var ckConfigurator = (function() {
|
|
|
511
529
|
}
|
|
512
530
|
};
|
|
513
531
|
|
|
514
|
-
|
|
532
|
+
const _switchDtd = function _switchDtd(dtdMode) {
|
|
515
533
|
dtdHandler.setMode(dtdMode);
|
|
516
534
|
window.CKEDITOR.dtd = dtdHandler.getDtd();
|
|
517
535
|
};
|
|
@@ -536,13 +554,13 @@ var ckConfigurator = (function() {
|
|
|
536
554
|
*
|
|
537
555
|
* @see http://docs.ckeditor.com/#!/api/CKEDITOR.config
|
|
538
556
|
*/
|
|
539
|
-
|
|
540
|
-
|
|
557
|
+
const getConfig = function (editor, toolbarType, options) {
|
|
558
|
+
let toolbar, toolbars, config, dtdMode;
|
|
541
559
|
|
|
542
560
|
// This is different from CKEDITOR.config.extraPlugins since it also allows to position the button
|
|
543
561
|
// Valid positioning keys are insertAfter | insertBefore | replace followed by the button name, e.g. 'Anchor'
|
|
544
562
|
// separator bool, defaults to false
|
|
545
|
-
|
|
563
|
+
let positionedPlugins = {};
|
|
546
564
|
|
|
547
565
|
if (toolbarType === 'reset') {
|
|
548
566
|
return originalConfig;
|
|
@@ -555,6 +573,8 @@ var ckConfigurator = (function() {
|
|
|
555
573
|
toolbars = _.clone(toolbarPresets, true);
|
|
556
574
|
dtdMode = options.dtdMode || 'html';
|
|
557
575
|
|
|
576
|
+
const ckConfig = _.clone(ckConfigDefault, true);
|
|
577
|
+
|
|
558
578
|
// modify DTD to either comply with QTI or XHTML
|
|
559
579
|
if (dtdMode === 'qti' || toolbarType.indexOf('qti') === 0) {
|
|
560
580
|
toolbarType = toolbarType.slice(3).toLowerCase();
|
|
@@ -597,7 +617,7 @@ var ckConfigurator = (function() {
|
|
|
597
617
|
|
|
598
618
|
// add toolbars to config
|
|
599
619
|
for (toolbar in toolbars) {
|
|
600
|
-
if (
|
|
620
|
+
if (Object.prototype.hasOwnProperty.call(toolbars, toolbar)) {
|
|
601
621
|
ckConfig['toolbar_' + toolbar] = toolbars[toolbar];
|
|
602
622
|
}
|
|
603
623
|
}
|
|
@@ -640,7 +660,7 @@ var ckConfigurator = (function() {
|
|
|
640
660
|
|
|
641
661
|
// toggle global DTD depending on the CK instance which is receiving the focus
|
|
642
662
|
// I know that this is rather ugly <= don't worry, we'll keep this a secret ;)
|
|
643
|
-
editor.on('focus', function() {
|
|
663
|
+
editor.on('focus', function () {
|
|
644
664
|
_switchDtd(dtdMode);
|
|
645
665
|
// should be 1 on html, undefined on qti
|
|
646
666
|
// console.log(CKEDITOR.dtd.pre.img)
|
|
@@ -648,13 +668,13 @@ var ckConfigurator = (function() {
|
|
|
648
668
|
|
|
649
669
|
// remove title 'Rich Text Editor, instance n' that CKE sets by default
|
|
650
670
|
// ref: http://tinyurl.com/keedruc
|
|
651
|
-
editor.on('instanceReady', function(e) {
|
|
671
|
+
editor.on('instanceReady', function (e) {
|
|
652
672
|
$(e.editor.element.$).removeAttr('title');
|
|
653
673
|
});
|
|
654
674
|
|
|
655
675
|
// This fixes bug #2855. Unfortunately this can be done on the global object only, not on the instance
|
|
656
|
-
window.CKEDITOR.on('dialogDefinition', function(e) {
|
|
657
|
-
|
|
676
|
+
window.CKEDITOR.on('dialogDefinition', function (e) {
|
|
677
|
+
let linkTypes, wanted, linkIndex;
|
|
658
678
|
|
|
659
679
|
if (e.data.name !== 'link') {
|
|
660
680
|
return;
|
|
@@ -85,7 +85,7 @@ export const initUpload = function (widget) {
|
|
|
85
85
|
cancel = confirmBox.find('.cancel');
|
|
86
86
|
save = confirmBox.find('.save');
|
|
87
87
|
|
|
88
|
-
$('.alt-text', confirmBox).html(`"${$alt.val()}"<br
|
|
88
|
+
$('.alt-text', confirmBox).html(`"${$alt.val()}"<br>${__('with')}<br>"${alt}" ?`);
|
|
89
89
|
|
|
90
90
|
confirmBox.modal({ width: 500 });
|
|
91
91
|
|
|
@@ -98,8 +98,8 @@ export default {
|
|
|
98
98
|
ASINH: __('sinh') + '<sup>\u207B1</sup>',
|
|
99
99
|
ACOSH: __('cosh') + '<sup>\u207B1</sup>',
|
|
100
100
|
ATANH: __('tanh') + '<sup>\u207B1</sup>',
|
|
101
|
-
LN:
|
|
102
|
-
LOG:
|
|
101
|
+
LN: 'ln',
|
|
102
|
+
LOG: 'log<sub>10</sub>',
|
|
103
103
|
ABS: __('abs'),
|
|
104
104
|
RAND: __('random'),
|
|
105
105
|
|
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
|
|
19
19
|
import $ from 'jquery';
|
|
20
20
|
import _ from 'lodash';
|
|
21
|
-
import __ from 'i18n';
|
|
22
21
|
import context from 'context';
|
|
23
22
|
import advancedSearchTpl from 'ui/searchModal/tpl/advanced-search';
|
|
24
23
|
import textCriterionTpl from 'ui/searchModal/tpl/text-criterion';
|
|
@@ -99,7 +98,7 @@ export default function advancedSearchFactory(config) {
|
|
|
99
98
|
$advancedCriteriaContainer.empty();
|
|
100
99
|
_.forEach(criteriaState, criterion => {
|
|
101
100
|
criterion.rendered = false;
|
|
102
|
-
criterion.value =
|
|
101
|
+
criterion.value = null;
|
|
103
102
|
});
|
|
104
103
|
},
|
|
105
104
|
/**
|
|
@@ -154,6 +153,17 @@ export default function advancedSearchFactory(config) {
|
|
|
154
153
|
$advancedCriteriaContainer.on('scroll', _.throttle(animateScroll, 100));
|
|
155
154
|
}
|
|
156
155
|
|
|
156
|
+
/**
|
|
157
|
+
* Lookup for characters in text to highlight
|
|
158
|
+
* @param {String} text - text to lookup
|
|
159
|
+
* @param {String} highlight - character(s) to be highlighted
|
|
160
|
+
* @param {regExp|String} match - match to be applied in the text
|
|
161
|
+
* @returns {String} - highlighted text
|
|
162
|
+
*/
|
|
163
|
+
function highlightCharacter(text, highlight, match) {
|
|
164
|
+
return text.replace(match, `<b>${highlight}</b>`);
|
|
165
|
+
}
|
|
166
|
+
|
|
157
167
|
/**
|
|
158
168
|
* Inits select2 on criteria select and its UX logic
|
|
159
169
|
*/
|
|
@@ -174,8 +184,18 @@ export default function advancedSearchFactory(config) {
|
|
|
174
184
|
escapeMarkup: function(markup) {
|
|
175
185
|
return markup;
|
|
176
186
|
},
|
|
177
|
-
formatResult: function formatResult(result, container, query
|
|
178
|
-
|
|
187
|
+
formatResult: function formatResult(result, container, query) {
|
|
188
|
+
const label = result.element[0].getAttribute('label');
|
|
189
|
+
const sublabel = result.element[0].getAttribute('sublabel');
|
|
190
|
+
const match = new RegExp(query.term, 'ig');
|
|
191
|
+
let template = highlightCharacter(label, query.term, match);
|
|
192
|
+
|
|
193
|
+
// Add sublabel
|
|
194
|
+
if(sublabel && sublabel.length) {
|
|
195
|
+
template = template + `<span class="class-path"> / ${highlightCharacter(sublabel, query.term, match)}</span>`;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return template;
|
|
179
199
|
}
|
|
180
200
|
});
|
|
181
201
|
|
|
@@ -209,12 +229,12 @@ export default function advancedSearchFactory(config) {
|
|
|
209
229
|
/**
|
|
210
230
|
* inits criteriaState loading it from the store (if present) or empty object.
|
|
211
231
|
* If there is a stored criteriaState, those criteria that were rendered
|
|
212
|
-
* but with
|
|
232
|
+
* but with null value are updated to not being rendered
|
|
213
233
|
*/
|
|
214
234
|
function initCriteriaState() {
|
|
215
235
|
if (instance.config.advancedCriteria) {
|
|
216
236
|
_.forEach(instance.config.advancedCriteria, criterion => {
|
|
217
|
-
if (criterion.rendered === true && criterion.value ===
|
|
237
|
+
if (criterion.rendered === true && criterion.value === null) {
|
|
218
238
|
criterion.rendered = false;
|
|
219
239
|
}
|
|
220
240
|
});
|
|
@@ -304,7 +324,7 @@ export default function advancedSearchFactory(config) {
|
|
|
304
324
|
};
|
|
305
325
|
},
|
|
306
326
|
results: (response) => ({
|
|
307
|
-
|
|
327
|
+
results: response.data.map(option => ({ id: valueMapping === 'uri' ? option.uri : option.label, text: option.label }))
|
|
308
328
|
})
|
|
309
329
|
},
|
|
310
330
|
initSelection: function (element, callback) {
|
|
@@ -341,14 +361,14 @@ export default function advancedSearchFactory(config) {
|
|
|
341
361
|
return criterion.value.map(v => ({
|
|
342
362
|
id: v,
|
|
343
363
|
text: (data.find(d => d.uri === v) || {}).label
|
|
344
|
-
}))
|
|
364
|
+
}));
|
|
345
365
|
}
|
|
346
|
-
let c = (data.find(d => d.uri === criterion.value) || {})
|
|
366
|
+
let c = (data.find(d => d.uri === criterion.value) || {});
|
|
347
367
|
return {
|
|
348
368
|
text: c.label,
|
|
349
369
|
id: criterion.value,
|
|
350
|
-
}
|
|
351
|
-
})
|
|
370
|
+
};
|
|
371
|
+
});
|
|
352
372
|
}
|
|
353
373
|
|
|
354
374
|
/**
|
|
@@ -363,7 +383,7 @@ export default function advancedSearchFactory(config) {
|
|
|
363
383
|
$('input', $criterionContainer).val(criterion.value);
|
|
364
384
|
// set event to bind input value to critariaState
|
|
365
385
|
$('input', $criterionContainer).on('change', function () {
|
|
366
|
-
criterion.value = $(this).val() ||
|
|
386
|
+
criterion.value = $(this).val() || null;
|
|
367
387
|
});
|
|
368
388
|
} else if (criterion.type === criteriaTypes.list && criterion.uri) {
|
|
369
389
|
// set initial value
|
|
@@ -409,7 +429,7 @@ export default function advancedSearchFactory(config) {
|
|
|
409
429
|
|
|
410
430
|
// reset criterion values on criteriaState
|
|
411
431
|
criteriaState[criterionKey].rendered = false;
|
|
412
|
-
criteriaState[criterionKey].value =
|
|
432
|
+
criteriaState[criterionKey].value = null;
|
|
413
433
|
|
|
414
434
|
// check if advanced criteria container is no longer scrollable
|
|
415
435
|
if ($advancedCriteriaContainer.get(0).scrollHeight <= $advancedCriteriaContainer.outerHeight()) {
|
|
@@ -520,7 +540,7 @@ export default function advancedSearchFactory(config) {
|
|
|
520
540
|
// if new criterion was not on criteriaState we add it
|
|
521
541
|
criteriaState[criteriaStateId] = criterion;
|
|
522
542
|
criteriaState[criteriaStateId].rendered = false;
|
|
523
|
-
criteriaState[criteriaStateId].value =
|
|
543
|
+
criteriaState[criteriaStateId].value = null;
|
|
524
544
|
}
|
|
525
545
|
|
|
526
546
|
// create new option element to criteria select
|
|
@@ -531,18 +551,33 @@ export default function advancedSearchFactory(config) {
|
|
|
531
551
|
}
|
|
532
552
|
|
|
533
553
|
/**
|
|
554
|
+
* Creates a new option element
|
|
555
|
+
* with attributes to use in select2 markup
|
|
534
556
|
* @param {Object} criterion
|
|
535
|
-
* @returns
|
|
557
|
+
* @returns {HTMLOptionElement} Single option criteria
|
|
536
558
|
*/
|
|
537
559
|
function createCriteriaOption(criterion) {
|
|
538
|
-
|
|
560
|
+
let label = criterion.label;
|
|
561
|
+
let sublabel = '';
|
|
562
|
+
let option;
|
|
563
|
+
let optionText = label;
|
|
564
|
+
|
|
565
|
+
if(criterion.isDuplicated) {
|
|
566
|
+
sublabel = criterion.class.label;
|
|
567
|
+
optionText = `${label} / ${sublabel}`;
|
|
568
|
+
}
|
|
539
569
|
|
|
540
|
-
|
|
541
|
-
|
|
570
|
+
option = new Option(
|
|
571
|
+
optionText,
|
|
542
572
|
getCriterionStateId(criterion),
|
|
543
573
|
false,
|
|
544
574
|
false
|
|
545
575
|
);
|
|
576
|
+
|
|
577
|
+
option.setAttribute('label', label);
|
|
578
|
+
option.setAttribute('sublabel', sublabel);
|
|
579
|
+
|
|
580
|
+
return option;
|
|
546
581
|
}
|
|
547
582
|
|
|
548
583
|
/**
|