@oat-sa/tao-core-ui 3.23.0 → 3.24.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.
Files changed (31) hide show
  1. package/dist/figure/FigureStateActive.js +64 -32
  2. package/dist/image/ImgStateActive/initHelper.js +64 -32
  3. package/dist/image/ImgStateActive.js +64 -32
  4. package/dist/previewer.js +1 -1
  5. package/dist/resourcemgr/assetSearch.js +793 -0
  6. package/dist/resourcemgr/assetSearchContract.js +477 -0
  7. package/dist/resourcemgr/css/resourcemgr.css +1230 -97
  8. package/dist/resourcemgr/css/resourcemgr.css.map +1 -1
  9. package/dist/resourcemgr/fileBrowser.js +815 -83
  10. package/dist/resourcemgr/filePreview.js +82 -7
  11. package/dist/resourcemgr/fileSelector.js +377 -92
  12. package/dist/resourcemgr.js +314 -57
  13. package/dist/searchModal/advancedSearch.js +233 -31
  14. package/package.json +15 -6
  15. package/src/image/ImgStateActive/initHelper.js +69 -31
  16. package/src/previewer.js +1 -1
  17. package/src/resourcemgr/assetSearch.js +847 -0
  18. package/src/resourcemgr/assetSearchContract.js +489 -0
  19. package/src/resourcemgr/css/resourcemgr.css +1230 -97
  20. package/src/resourcemgr/css/resourcemgr.css.map +1 -1
  21. package/src/resourcemgr/fileBrowser.js +872 -92
  22. package/src/resourcemgr/filePreview.js +89 -8
  23. package/src/resourcemgr/fileSelector.js +356 -46
  24. package/src/resourcemgr/scss/resourcemgr.scss +1450 -89
  25. package/src/resourcemgr/tpl/advanced-search.tpl +10 -0
  26. package/src/resourcemgr/tpl/fileSelect.tpl +25 -28
  27. package/src/resourcemgr/tpl/folder.tpl +4 -1
  28. package/src/resourcemgr/tpl/layout.tpl +125 -54
  29. package/src/resourcemgr/tpl/rootFolder.tpl +3 -1
  30. package/src/resourcemgr.js +294 -47
  31. package/src/searchModal/advancedSearch.js +242 -31
@@ -5,7 +5,25 @@ define(['jquery', 'lodash', 'util/bytes', 'context', 'ui/previewer'], function (
5
5
  bytes = bytes && Object.prototype.hasOwnProperty.call(bytes, 'default') ? bytes['default'] : bytes;
6
6
  context = context && Object.prototype.hasOwnProperty.call(context, 'default') ? context['default'] : context;
7
7
 
8
+ /**
9
+ * This program is free software; you can redistribute it and/or
10
+ * modify it under the terms of the GNU General Public License
11
+ * as published by the Free Software Foundation; under version 2
12
+ * of the License (non-upgradable).
13
+ *
14
+ * This program is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ * GNU General Public License for more details.
18
+ *
19
+ * You should have received a copy of the GNU General Public License
20
+ * along with this program; if not, write to the Free Software
21
+ * Foundation, Inc., 31 Milk St # 960789 Boston, MA 02196 USA.
22
+ *
23
+ * Copyright (c) 2018-2026 (original work) Open Assessment Technologies SA;
24
+ */
8
25
  const ns = 'resourcemgr';
26
+ const EMPTY_META = '-';
9
27
  function filePreview (options) {
10
28
  const $container = options.$target;
11
29
  const $filePreview = $('.file-preview', $container);
@@ -38,16 +56,73 @@ define(['jquery', 'lodash', 'util/bytes', 'context', 'ui/previewer'], function (
38
56
  }
39
57
  $container.trigger(`select.${ns}`, [[data]]);
40
58
  });
59
+
60
+ /**
61
+ * @param {*} value
62
+ * @returns {string}
63
+ */
64
+ function metaOrDash(value) {
65
+ if (value === null || typeof value === 'undefined' || value === '') {
66
+ return EMPTY_META;
67
+ }
68
+ return String(value);
69
+ }
70
+
71
+ /**
72
+ * Row markup uses data-download for permission flag (boolean), not the URL.
73
+ * @param {*} file
74
+ * @returns {string}
75
+ */
76
+ function downloadHref(file) {
77
+ if (typeof file.downloadUrl === 'string' && file.downloadUrl) {
78
+ return file.downloadUrl;
79
+ }
80
+ if (typeof file.url === 'string' && file.url) {
81
+ const query = file.url.split('#')[0].split('?')[1] || '';
82
+ const hasSvgzSupport = query.split('&').some(param => param.split('=')[0] === 'svgzsupport');
83
+ return hasSvgzSupport ? file.url : `${file.url}&svgzsupport=true`;
84
+ }
85
+ if (typeof file.download === 'string' && file.download) {
86
+ return file.download;
87
+ }
88
+ return '';
89
+ }
90
+
91
+ /**
92
+ * @param {*} file
93
+ * @returns {string}
94
+ */
95
+ function downloadFilename(file) {
96
+ if (typeof file.display === 'string' && file.display) {
97
+ return file.display;
98
+ }
99
+ const path = file.file || '';
100
+ const idx = path.lastIndexOf('/');
101
+ return idx >= 0 ? path.slice(idx + 1) : path;
102
+ }
41
103
  function startPreview(file, preview, download, select) {
42
104
  if (preview) {
43
105
  $previewer.previewer(file);
44
- $propType.text(`${file.type} (${file.mime})`);
45
- $propSize.text(bytes.hrSize(file.size));
106
+ if (file.type || file.mime) {
107
+ $propType.text(file.type && file.mime ? `${file.type} (${file.mime})` : metaOrDash(file.type || file.mime));
108
+ } else {
109
+ $propType.text(EMPTY_META);
110
+ }
111
+ $propSize.text(file.size === null || typeof file.size === 'undefined' || file.size === '' ? EMPTY_META : bytes.hrSize(file.size));
112
+ } else {
113
+ $propType.text(EMPTY_META);
114
+ $propSize.text(EMPTY_META);
46
115
  }
47
116
  if (download) {
48
- $link.attr('href', file.download).attr('download', file.file);
49
- if ($link.hasClass('hidden')) {
50
- $link.removeClass('hidden');
117
+ const href = downloadHref(file);
118
+ if (href) {
119
+ $link.attr('href', href).attr('download', downloadFilename(file));
120
+ if ($link.hasClass('hidden')) {
121
+ $link.removeClass('hidden');
122
+ }
123
+ } else {
124
+ $link.attr('href', '#').removeAttr('download');
125
+ $link.addClass('hidden');
51
126
  }
52
127
  } else {
53
128
  $link.attr('href', '#').attr('download', '#');
@@ -61,8 +136,8 @@ define(['jquery', 'lodash', 'util/bytes', 'context', 'ui/previewer'], function (
61
136
  $previewer.previewer('update', {
62
137
  url: false
63
138
  });
64
- $propType.empty();
65
- $propSize.empty();
139
+ $propType.text(EMPTY_META);
140
+ $propSize.text(EMPTY_META);
66
141
  $('a', $propUrl).addClass('hidden');
67
142
  $selectButton.attr('disabled', 'disabled');
68
143
  }