@oat-sa/tao-core-ui 3.6.0 → 3.7.1
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/resourcemgr/fileSelector.js +39 -11
- package/dist/taskQueue/taskQueueModel.js +10 -3
- package/package.json +1 -1
- package/scss/inc/_tooltip.scss +0 -0
- package/src/feedback/feedback.tpl +0 -0
- package/src/feedback.js +0 -0
- package/src/resourcemgr/fileBrowser.js +0 -0
- package/src/resourcemgr/filePreview.js +0 -0
- package/src/resourcemgr/fileSelector.js +39 -2
- package/src/resourcemgr/scss/resourcemgr.scss +0 -0
- package/src/resourcemgr/tpl/fileSelect.tpl +7 -7
- package/src/resourcemgr/tpl/layout.tpl +0 -0
- package/src/taskQueue/taskQueueModel.js +5 -3
- package/src/validator/Report.js +0 -0
- package/src/validator/Validator.js +0 -0
- package/src/validator/validators.js +0 -0
|
@@ -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 = {};
|
|
@@ -449,9 +449,16 @@ define(['jquery', 'lodash', 'i18n', 'core/eventifier', 'core/polling', 'core/dat
|
|
|
449
449
|
if (!config.url || !config.url.download) {
|
|
450
450
|
throw new TypeError('config.url.download is not configured while download() is being called');
|
|
451
451
|
}
|
|
452
|
-
return this.getCached(taskId).then(function (
|
|
453
|
-
let
|
|
454
|
-
|
|
452
|
+
return this.getCached(taskId).then(function () {
|
|
453
|
+
let taskData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
454
|
+
const {
|
|
455
|
+
redirectUrl,
|
|
456
|
+
category
|
|
457
|
+
} = taskData;
|
|
458
|
+
|
|
459
|
+
// if the task is an update task, we should not use redirectUrl for download
|
|
460
|
+
// it only uses for DOCX file download (export category)
|
|
461
|
+
if (redirectUrl && category !== 'update') {
|
|
455
462
|
return new Promise(function (resolve) {
|
|
456
463
|
$.fileDownload(redirectUrl, {
|
|
457
464
|
httpMethod: 'GET',
|
package/package.json
CHANGED
package/scss/inc/_tooltip.scss
CHANGED
|
File without changes
|
|
File without changes
|
package/src/feedback.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -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 = {};
|
|
File without changes
|
|
@@ -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}}
|
|
File without changes
|
|
@@ -496,10 +496,12 @@ export default function taskQueueModel(config) {
|
|
|
496
496
|
throw new TypeError('config.url.download is not configured while download() is being called');
|
|
497
497
|
}
|
|
498
498
|
|
|
499
|
-
return this.getCached(taskId).then(function (taskData) {
|
|
500
|
-
|
|
499
|
+
return this.getCached(taskId).then(function (taskData = {}) {
|
|
500
|
+
const { redirectUrl, category } = taskData;
|
|
501
501
|
|
|
502
|
-
if
|
|
502
|
+
// if the task is an update task, we should not use redirectUrl for download
|
|
503
|
+
// it only uses for DOCX file download (export category)
|
|
504
|
+
if (redirectUrl && category !== 'update') {
|
|
503
505
|
return new Promise(function (resolve) {
|
|
504
506
|
$.fileDownload(redirectUrl, {
|
|
505
507
|
httpMethod: 'GET',
|
package/src/validator/Report.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|