@oat-sa/tao-core-ui 3.6.0 → 3.8.0
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/datatable.js +11 -1
- package/dist/resourcemgr/fileSelector.js +39 -11
- package/package.json +1 -1
- package/src/datatable/tpl/button.tpl +1 -1
- package/src/datatable/tpl/layout.tpl +2 -2
- package/src/datatable.js +2 -1
- package/src/resourcemgr/fileSelector.js +39 -2
- package/src/resourcemgr/tpl/fileSelect.tpl +7 -7
package/dist/datatable.js
CHANGED
|
@@ -426,6 +426,8 @@ define(['jquery', 'lodash', 'i18n', 'core/pluginifier', 'handlebars', 'lib/handl
|
|
|
426
426
|
|
|
427
427
|
var buffer = "", stack1;
|
|
428
428
|
buffer += "\n <button class=\"btn-info small "
|
|
429
|
+
+ escapeExpression(((stack1 = (depth2 && depth2.cls)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
|
|
430
|
+
+ " "
|
|
429
431
|
+ escapeExpression(((stack1 = (depth2 && depth2.id)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
|
|
430
432
|
+ "\"\n ";
|
|
431
433
|
stack1 = helpers['if'].call(depth0, (depth2 && depth2.title), {hash:{},inverse:self.noop,fn:self.programWithDepth(71, program71, data, depth2),data:data});
|
|
@@ -549,6 +551,8 @@ define(['jquery', 'lodash', 'i18n', 'core/pluginifier', 'handlebars', 'lib/handl
|
|
|
549
551
|
|
|
550
552
|
var buffer = "", stack1;
|
|
551
553
|
buffer += "\n <button class=\"btn-info small "
|
|
554
|
+
+ escapeExpression(((stack1 = (depth2 && depth2.cls)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
|
|
555
|
+
+ " "
|
|
552
556
|
+ escapeExpression(((stack1 = (depth2 && depth2.id)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
|
|
553
557
|
+ "\"\n ";
|
|
554
558
|
stack1 = helpers['if'].call(depth0, (depth2 && depth2.title), {hash:{},inverse:self.noop,fn:self.programWithDepth(71, program71, data, depth2),data:data});
|
|
@@ -686,6 +690,10 @@ define(['jquery', 'lodash', 'i18n', 'core/pluginifier', 'handlebars', 'lib/handl
|
|
|
686
690
|
}
|
|
687
691
|
|
|
688
692
|
buffer += "<button class=\"btn-info small ";
|
|
693
|
+
if (helper = helpers.cls) { stack1 = helper.call(depth0, {hash:{},data:data}); }
|
|
694
|
+
else { helper = (depth0 && depth0.cls); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
|
|
695
|
+
buffer += escapeExpression(stack1)
|
|
696
|
+
+ " ";
|
|
689
697
|
if (helper = helpers.id) { stack1 = helper.call(depth0, {hash:{},data:data}); }
|
|
690
698
|
else { helper = (depth0 && depth0.id); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
|
|
691
699
|
buffer += escapeExpression(stack1)
|
|
@@ -1486,12 +1494,14 @@ define(['jquery', 'lodash', 'i18n', 'core/pluginifier', 'handlebars', 'lib/handl
|
|
|
1486
1494
|
const disabled = getPropertyValue('disabled', action, nextData);
|
|
1487
1495
|
const icon = getPropertyValue('icon', action, nextData);
|
|
1488
1496
|
const label = getPropertyValue('label', action, nextData);
|
|
1497
|
+
const cls = getPropertyValue('cls', action, nextData);
|
|
1489
1498
|
const $actionButton = $$1(buttonTpl({
|
|
1490
1499
|
id,
|
|
1491
1500
|
icon,
|
|
1492
1501
|
label,
|
|
1493
1502
|
title,
|
|
1494
|
-
disabled
|
|
1503
|
+
disabled,
|
|
1504
|
+
cls
|
|
1495
1505
|
}));
|
|
1496
1506
|
if (!hidden) {
|
|
1497
1507
|
$actionCell.append('\n').append($actionButton);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
define(['jquery', 'lodash', 'async', 'i18n', 'core/mimetype', 'handlebars', 'lib/handlebars/helpers', 'ui/feedback', 'context', 'ui/uploader'], function ($$1, _, async, __, mimeType, Handlebars, Helpers0, feedback, context, uploader) { 'use strict';
|
|
1
|
+
define(['jquery', 'lodash', 'async', 'i18n', 'core/mimetype', 'handlebars', 'lib/handlebars/helpers', 'ui/feedback', 'context', 'ui/uploader', 'core/logger'], function ($$1, _, async, __, mimeType, Handlebars, Helpers0, feedback, context, uploader, loggerFactory) { 'use strict';
|
|
2
2
|
|
|
3
3
|
$$1 = $$1 && Object.prototype.hasOwnProperty.call($$1, 'default') ? $$1['default'] : $$1;
|
|
4
4
|
_ = _ && Object.prototype.hasOwnProperty.call(_, 'default') ? _['default'] : _;
|
|
@@ -9,6 +9,7 @@ define(['jquery', 'lodash', 'async', 'i18n', 'core/mimetype', 'handlebars', 'lib
|
|
|
9
9
|
Helpers0 = Helpers0 && Object.prototype.hasOwnProperty.call(Helpers0, 'default') ? Helpers0['default'] : Helpers0;
|
|
10
10
|
feedback = feedback && Object.prototype.hasOwnProperty.call(feedback, 'default') ? feedback['default'] : feedback;
|
|
11
11
|
context = context && Object.prototype.hasOwnProperty.call(context, 'default') ? context['default'] : context;
|
|
12
|
+
loggerFactory = loggerFactory && Object.prototype.hasOwnProperty.call(loggerFactory, 'default') ? loggerFactory['default'] : loggerFactory;
|
|
12
13
|
|
|
13
14
|
if (!Helpers0.__initialized) {
|
|
14
15
|
Helpers0(Handlebars);
|
|
@@ -26,27 +27,27 @@ define(['jquery', 'lodash', 'async', 'i18n', 'core/mimetype', 'handlebars', 'lib
|
|
|
26
27
|
if (helper = helpers.type) { stack1 = helper.call(depth0, {hash:{},data:data}); }
|
|
27
28
|
else { helper = (depth0 && depth0.type); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
|
|
28
29
|
buffer += escapeExpression(stack1)
|
|
29
|
-
+ "\"
|
|
30
|
+
+ "\"\n data-file=\"";
|
|
30
31
|
if (helper = helpers.uri) { stack1 = helper.call(depth0, {hash:{},data:data}); }
|
|
31
32
|
else { helper = (depth0 && depth0.uri); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
|
|
32
33
|
buffer += escapeExpression(stack1)
|
|
33
|
-
+ "\"
|
|
34
|
+
+ "\"\n data-display=\"";
|
|
34
35
|
if (helper = helpers.display) { stack1 = helper.call(depth0, {hash:{},data:data}); }
|
|
35
36
|
else { helper = (depth0 && depth0.display); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
|
|
36
37
|
buffer += escapeExpression(stack1)
|
|
37
|
-
+ "\"
|
|
38
|
+
+ "\"\n data-mime=\"";
|
|
38
39
|
if (helper = helpers.mime) { stack1 = helper.call(depth0, {hash:{},data:data}); }
|
|
39
40
|
else { helper = (depth0 && depth0.mime); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
|
|
40
41
|
buffer += escapeExpression(stack1)
|
|
41
|
-
+ "\"
|
|
42
|
+
+ "\"\n data-size=\"";
|
|
42
43
|
if (helper = helpers.size) { stack1 = helper.call(depth0, {hash:{},data:data}); }
|
|
43
44
|
else { helper = (depth0 && depth0.size); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
|
|
44
45
|
buffer += escapeExpression(stack1)
|
|
45
|
-
+ "\"
|
|
46
|
+
+ "\"\n data-url=\"";
|
|
46
47
|
if (helper = helpers.viewUrl) { stack1 = helper.call(depth0, {hash:{},data:data}); }
|
|
47
48
|
else { helper = (depth0 && depth0.viewUrl); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
|
|
48
49
|
buffer += escapeExpression(stack1)
|
|
49
|
-
+ "\"
|
|
50
|
+
+ "\"\n ";
|
|
50
51
|
stack1 = helpers['if'].call(depth0, ((stack1 = (depth0 && depth0.permissions)),stack1 == null || stack1 === false ? stack1 : stack1.download), {hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data});
|
|
51
52
|
if(stack1 || stack1 === 0) { buffer += stack1; }
|
|
52
53
|
buffer += "\n ";
|
|
@@ -131,9 +132,9 @@ define(['jquery', 'lodash', 'async', 'i18n', 'core/mimetype', 'handlebars', 'lib
|
|
|
131
132
|
function program13(depth0,data) {
|
|
132
133
|
|
|
133
134
|
var buffer = "", helper, options;
|
|
134
|
-
buffer += "\n <a href=\"#\" class=\"tlb-button-off\" title=\""
|
|
135
|
+
buffer += "\n <a href=\"#\" class=\"tlb-button-off delete\" title=\""
|
|
135
136
|
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Remove this file", options) : helperMissing.call(depth0, "__", "Remove this file", options)))
|
|
136
|
-
+ "\"
|
|
137
|
+
+ "\"><span class=\"icon-bin\"></span></a>\n ";
|
|
137
138
|
return buffer;
|
|
138
139
|
}
|
|
139
140
|
|
|
@@ -214,10 +215,11 @@ define(['jquery', 'lodash', 'async', 'i18n', 'core/mimetype', 'handlebars', 'lib
|
|
|
214
215
|
* along with this program; if not, write to the Free Software
|
|
215
216
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
216
217
|
*
|
|
217
|
-
* Copyright (c) 2015 (original work) Open Assessment Technologies SA;
|
|
218
|
+
* Copyright (c) 2015-2024 (original work) Open Assessment Technologies SA;
|
|
218
219
|
*
|
|
219
220
|
*/
|
|
220
|
-
|
|
221
|
+
const ns = 'resourcemgr';
|
|
222
|
+
const logger = loggerFactory(`ui/${ns}`);
|
|
221
223
|
function shortenPath(path) {
|
|
222
224
|
let tokens = path.replace(/\/$/, '').split('/');
|
|
223
225
|
let start = tokens.length - 3;
|
|
@@ -325,6 +327,32 @@ define(['jquery', 'lodash', 'async', 'i18n', 'core/mimetype', 'handlebars', 'lib
|
|
|
325
327
|
});
|
|
326
328
|
|
|
327
329
|
//delete a file
|
|
330
|
+
$$1(parentSelector).off('click', '.files li a.delete').on('click', '.files li a.delete', function (e) {
|
|
331
|
+
// This function replaces ui/deleter and must follow the same logic.
|
|
332
|
+
// The main difference is that it insert a confirmation dialog before deleting the file.
|
|
333
|
+
e.preventDefault();
|
|
334
|
+
const $elt = $$1(e.target);
|
|
335
|
+
if ($elt.hasClass(options.disableClass)) {
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
const $target = $elt.closest('li');
|
|
339
|
+
const path = $target.data('file');
|
|
340
|
+
const hooks = [];
|
|
341
|
+
if (options.hooks && 'function' === typeof options.hooks.deleteFile) {
|
|
342
|
+
hooks.push(options.hooks.deleteFile(path));
|
|
343
|
+
}
|
|
344
|
+
Promise.all(hooks).then(() => {
|
|
345
|
+
$$1(this).trigger('delete.deleter', [$target]);
|
|
346
|
+
$target.trigger('delete', [false]);
|
|
347
|
+
$target.detach();
|
|
348
|
+
$target.remove();
|
|
349
|
+
$fileContainer.trigger('deleted.deleter', [$target]);
|
|
350
|
+
}).catch(err => {
|
|
351
|
+
if (err instanceof Error) {
|
|
352
|
+
logger.error(err);
|
|
353
|
+
}
|
|
354
|
+
});
|
|
355
|
+
});
|
|
328
356
|
$fileContainer.on('delete.deleter', function (e, $target) {
|
|
329
357
|
let path,
|
|
330
358
|
params = {};
|
package/package.json
CHANGED
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
{{#if id}}
|
|
98
98
|
{{#with ../../../../this}}
|
|
99
99
|
{{#unless ../hidden}}
|
|
100
|
-
<button class="btn-info small {{../../id}}"
|
|
100
|
+
<button class="btn-info small {{../../cls}} {{../../id}}"
|
|
101
101
|
{{#if ../../title}} title="{{../../../title}}"{{/if}}
|
|
102
102
|
{{#if ../../disabled}} disabled="disabled"{{/if}}>
|
|
103
103
|
{{#if ../../icon}}<span class="icon-{{../../../icon}}"></span>{{/if}}
|
|
@@ -128,7 +128,7 @@
|
|
|
128
128
|
{{#if id}}
|
|
129
129
|
{{#with ../../../this}}
|
|
130
130
|
{{#unless ../hidden}}
|
|
131
|
-
<button class="btn-info small {{../../id}}"
|
|
131
|
+
<button class="btn-info small {{../../cls}} {{../../id}}"
|
|
132
132
|
{{#if ../../title}} title="{{../../../title}}"{{/if}}
|
|
133
133
|
{{#if ../../disabled}} disabled="disabled"{{/if}}>
|
|
134
134
|
{{#if ../../icon}}<span class="icon-{{../../../icon}}"></span>{{/if}}
|
package/src/datatable.js
CHANGED
|
@@ -887,7 +887,8 @@ const dataTable = {
|
|
|
887
887
|
const disabled = getPropertyValue('disabled', action, nextData);
|
|
888
888
|
const icon = getPropertyValue('icon', action, nextData);
|
|
889
889
|
const label = getPropertyValue('label', action, nextData);
|
|
890
|
-
const
|
|
890
|
+
const cls = getPropertyValue('cls', action, nextData);
|
|
891
|
+
const $actionButton = $(buttonTpl({ id, icon, label, title, disabled, cls }));
|
|
891
892
|
|
|
892
893
|
if (!hidden) {
|
|
893
894
|
$actionCell.append('\n').append($actionButton);
|
|
@@ -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-2024 (original work) Open Assessment Technologies SA;
|
|
17
17
|
*
|
|
18
18
|
*/
|
|
19
19
|
|
|
@@ -31,8 +31,10 @@ import feedback from 'ui/feedback';
|
|
|
31
31
|
import context from 'context';
|
|
32
32
|
import 'ui/uploader';
|
|
33
33
|
import updatePermissions from './util/updatePermissions';
|
|
34
|
+
import loggerFactory from 'core/logger';
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
const ns = 'resourcemgr';
|
|
37
|
+
const logger = loggerFactory(`ui/${ns}`);
|
|
36
38
|
|
|
37
39
|
function shortenPath(path) {
|
|
38
40
|
let tokens = path.replace(/\/$/, '').split('/');
|
|
@@ -161,6 +163,41 @@ export default function (options) {
|
|
|
161
163
|
});
|
|
162
164
|
|
|
163
165
|
//delete a file
|
|
166
|
+
$(parentSelector)
|
|
167
|
+
.off('click', '.files li a.delete')
|
|
168
|
+
.on('click', '.files li a.delete', function (e) {
|
|
169
|
+
// This function replaces ui/deleter and must follow the same logic.
|
|
170
|
+
// The main difference is that it insert a confirmation dialog before deleting the file.
|
|
171
|
+
e.preventDefault();
|
|
172
|
+
const $elt = $(e.target);
|
|
173
|
+
if ($elt.hasClass(options.disableClass)) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const $target = $elt.closest('li');
|
|
178
|
+
const path = $target.data('file');
|
|
179
|
+
const hooks = [];
|
|
180
|
+
|
|
181
|
+
if (options.hooks && 'function' === typeof options.hooks.deleteFile) {
|
|
182
|
+
hooks.push(options.hooks.deleteFile(path));
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
Promise.all(hooks)
|
|
186
|
+
.then(() => {
|
|
187
|
+
$(this).trigger('delete.deleter', [$target]);
|
|
188
|
+
$target.trigger('delete', [false]);
|
|
189
|
+
|
|
190
|
+
$target.detach();
|
|
191
|
+
$target.remove();
|
|
192
|
+
|
|
193
|
+
$fileContainer.trigger('deleted.deleter', [$target]);
|
|
194
|
+
})
|
|
195
|
+
.catch(err => {
|
|
196
|
+
if (err instanceof Error) {
|
|
197
|
+
logger.error(err);
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
});
|
|
164
201
|
$fileContainer.on('delete.deleter', function (e, $target) {
|
|
165
202
|
let path,
|
|
166
203
|
params = {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{{#each files}}
|
|
2
|
-
<li data-type="{{type}}"
|
|
3
|
-
data-file="{{uri}}"
|
|
4
|
-
data-display="{{display}}"
|
|
5
|
-
data-mime="{{mime}}"
|
|
6
|
-
data-size="{{size}}"
|
|
7
|
-
data-url="{{viewUrl}}"
|
|
2
|
+
<li data-type="{{type}}"
|
|
3
|
+
data-file="{{uri}}"
|
|
4
|
+
data-display="{{display}}"
|
|
5
|
+
data-mime="{{mime}}"
|
|
6
|
+
data-size="{{size}}"
|
|
7
|
+
data-url="{{viewUrl}}"
|
|
8
8
|
{{#if permissions.download}} data-download="true" {{/if}}
|
|
9
9
|
{{#if permissions.preview}} data-preview="true" {{/if}}
|
|
10
10
|
{{#if permissions.read}} data-select="true" {{/if}}
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
<a href="{{downloadUrl}}" download="{{name}}" target="_blank" class="tlb-button-off download" title="{{__ 'Download this file'}}"><span class="icon-download"></span></a>
|
|
26
26
|
{{/if}}
|
|
27
27
|
{{#if permissions.delete }}
|
|
28
|
-
<a href="#" class="tlb-button-off" title="{{__ 'Remove this file'}}"
|
|
28
|
+
<a href="#" class="tlb-button-off delete" title="{{__ 'Remove this file'}}"><span class="icon-bin"></span></a>
|
|
29
29
|
{{/if}}
|
|
30
30
|
</span>
|
|
31
31
|
{{/if}}
|