@widgetic/editor 3.10.47 → 3.10.49
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/package.json
CHANGED
|
@@ -11,6 +11,7 @@ class File {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
File.defaults = {
|
|
14
|
+
lastModified: undefined,
|
|
14
15
|
state: 'complete',
|
|
15
16
|
thumbnail: undefined,
|
|
16
17
|
url: undefined,
|
|
@@ -67,7 +68,10 @@ export default class UploadService extends EventsMixin(Service) {
|
|
|
67
68
|
return Promise.resolve(this.files.filter(f => f.type === type));
|
|
68
69
|
|
|
69
70
|
return this._fetch(type)
|
|
70
|
-
.then(files =>
|
|
71
|
+
.then(files => {
|
|
72
|
+
// console.log('fetched files:', files)
|
|
73
|
+
return this.files.push.apply(this.files, files)
|
|
74
|
+
})
|
|
71
75
|
.then(this._broadcast.update)
|
|
72
76
|
.then(_ => this.files.filter(f => f.type === type));
|
|
73
77
|
}
|
|
@@ -77,12 +81,15 @@ export default class UploadService extends EventsMixin(Service) {
|
|
|
77
81
|
}
|
|
78
82
|
|
|
79
83
|
upload(uploadFile) {
|
|
84
|
+
// console.log("upload file:", uploadFile);
|
|
85
|
+
|
|
80
86
|
this.files.push(
|
|
81
87
|
new File({
|
|
82
88
|
state: 'new',
|
|
83
89
|
size: uploadFile.size,
|
|
84
90
|
name: uploadFile.name,
|
|
85
91
|
type: parseType(uploadFile.type),
|
|
92
|
+
// lastModified: uploadFile.lastModified,
|
|
86
93
|
uploadFile,
|
|
87
94
|
})
|
|
88
95
|
);
|
|
@@ -91,9 +98,12 @@ export default class UploadService extends EventsMixin(Service) {
|
|
|
91
98
|
}
|
|
92
99
|
|
|
93
100
|
uploadComplete(uploadFile, instanceId) {
|
|
101
|
+
// console.log("uploadComplete file:", uploadFile);
|
|
94
102
|
if (uploadFile.status === 'error') return;
|
|
95
|
-
const response = JSON.parse(uploadFile.xhr.response);
|
|
96
103
|
|
|
104
|
+
// read metadata(id here) from the file that's on the server
|
|
105
|
+
const response = JSON.parse(uploadFile.xhr.response);
|
|
106
|
+
// console.log("uploadComplete file on the server:", response.files.data[0])
|
|
97
107
|
const id = response.files.data[0].id;
|
|
98
108
|
|
|
99
109
|
// read quota from response
|
|
@@ -105,6 +115,7 @@ export default class UploadService extends EventsMixin(Service) {
|
|
|
105
115
|
f.id = id;
|
|
106
116
|
f.path = response.files.data[0].path;
|
|
107
117
|
f.url = response.hostUrl + f.path;
|
|
118
|
+
// f.lastModified = uploadFile.lastModified;
|
|
108
119
|
});
|
|
109
120
|
|
|
110
121
|
this._broadcast.complete([this.get(id), instanceId]);
|
|
@@ -165,6 +176,7 @@ export default class UploadService extends EventsMixin(Service) {
|
|
|
165
176
|
headers: this.getAuthHeaders(),
|
|
166
177
|
})
|
|
167
178
|
.then(response => {
|
|
179
|
+
// console.log("fetched files response:", response);
|
|
168
180
|
this.refreshed[type] = true;
|
|
169
181
|
|
|
170
182
|
// read quota from response
|
|
@@ -172,10 +184,14 @@ export default class UploadService extends EventsMixin(Service) {
|
|
|
172
184
|
this.used = response.quota.used;
|
|
173
185
|
|
|
174
186
|
return response.files.data.map(file => {
|
|
187
|
+
|
|
188
|
+
// console.log("fetched file:", file);
|
|
189
|
+
|
|
175
190
|
const type = parseType(file.mime);
|
|
176
191
|
const url = response.hostUrl + file.path;
|
|
177
192
|
const thumbnail = type === 'image' ? url : undefined;
|
|
178
193
|
|
|
194
|
+
// return a new File instance
|
|
179
195
|
return new File({
|
|
180
196
|
id: file.id,
|
|
181
197
|
type,
|
|
@@ -184,6 +200,7 @@ export default class UploadService extends EventsMixin(Service) {
|
|
|
184
200
|
path: file.path,
|
|
185
201
|
name: file.name,
|
|
186
202
|
size: file.size,
|
|
203
|
+
lastModified: file.lastModified,
|
|
187
204
|
});
|
|
188
205
|
});
|
|
189
206
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<Service ref:Uploads
|
|
2
2
|
service="Uploads"
|
|
3
|
-
on:update="
|
|
3
|
+
on:update="_onUpdate(event)"
|
|
4
4
|
on:complete="_onUploadComplete(event)"
|
|
5
5
|
/>
|
|
6
6
|
|
|
@@ -44,8 +44,10 @@
|
|
|
44
44
|
{{/if}}
|
|
45
45
|
</div>
|
|
46
46
|
<section class="{{ dragging ? 'dropzone--dragging' : '' }}">
|
|
47
|
+
|
|
48
|
+
<!-- Uploaded Content List -->
|
|
47
49
|
{{#if files.length}}
|
|
48
|
-
<ScrollPane ref:scrollPane>
|
|
50
|
+
<ScrollPane ref:scrollPane class="content-list">
|
|
49
51
|
{{#each files as file}}
|
|
50
52
|
<File
|
|
51
53
|
file="{{file}}"
|
|
@@ -63,12 +65,13 @@
|
|
|
63
65
|
</div>
|
|
64
66
|
{{/if}}
|
|
65
67
|
|
|
68
|
+
<!-- Dropzone -->
|
|
66
69
|
<div class="dropzone_plchldr {{ !files.length ? 'dropzone--large' : '' }}">
|
|
67
70
|
<Dropzone
|
|
68
71
|
ref:dropzone
|
|
69
|
-
on:new="
|
|
72
|
+
on:new="_onDropZoneNewUpload(event)"
|
|
73
|
+
on:upload="_onDropZoneUpload( event )"
|
|
70
74
|
on:dragging="set({ dragging: event })"
|
|
71
|
-
on:upload="toggle( event )"
|
|
72
75
|
on:error="fire( 'error', event )"
|
|
73
76
|
filetypes="{{ filetypes }}/*"
|
|
74
77
|
maxFilesize="{{ maxFilesize }}"
|
|
@@ -214,6 +217,8 @@ export default {
|
|
|
214
217
|
oncreate() {
|
|
215
218
|
this.Uploads = this.refs.Uploads.instance();
|
|
216
219
|
this.set({ maxFilesize: this.Uploads.getMaxFileSize() });
|
|
220
|
+
|
|
221
|
+
// load uploaded files
|
|
217
222
|
this.refresh();
|
|
218
223
|
},
|
|
219
224
|
ondestroy() {
|
|
@@ -221,7 +226,15 @@ export default {
|
|
|
221
226
|
},
|
|
222
227
|
|
|
223
228
|
methods: {
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* CONTENT LIST HANDLERS
|
|
232
|
+
*/
|
|
233
|
+
|
|
234
|
+
// on selecting a file square
|
|
224
235
|
toggle(file) {
|
|
236
|
+
console.log("on toggle file:", file);
|
|
237
|
+
|
|
225
238
|
if (file.error) {
|
|
226
239
|
this.Uploads.remove(file);
|
|
227
240
|
return this.refresh();
|
|
@@ -238,10 +251,40 @@ export default {
|
|
|
238
251
|
},
|
|
239
252
|
|
|
240
253
|
refresh(ev) {
|
|
254
|
+
console.log("refreshing...");
|
|
241
255
|
if (ev) ev.preventDefault();
|
|
242
256
|
|
|
243
257
|
return this.Uploads.getFiles(this.get('filetypes'))
|
|
244
|
-
.then(files =>
|
|
258
|
+
.then(files => {
|
|
259
|
+
// console.log("uploadedFiles: ", files);
|
|
260
|
+
|
|
261
|
+
// sort files by id
|
|
262
|
+
// files = files.sort((a, b) => {
|
|
263
|
+
// // console.log("a & b: ", a.id, b.id);
|
|
264
|
+
// if(!a.id.indexOf) return -1;
|
|
265
|
+
// let noIdA = a.id.substr(a.id.indexOf('_t')+2, 4);
|
|
266
|
+
// let noIdB = b.id.substr(a.id.indexOf('_t')+2, 4);
|
|
267
|
+
// // console.log("noIdA & noIdB: ", noIdA, noIdB, (noIdA >= noIdB));
|
|
268
|
+
// return noIdA - noIdB;
|
|
269
|
+
// });
|
|
270
|
+
// console.log("uploadedFiles after sort: ", files);
|
|
271
|
+
|
|
272
|
+
// sort files by last modified date
|
|
273
|
+
files = files.sort((a, b) => {
|
|
274
|
+
let x = a.lastModified;
|
|
275
|
+
if(!x) x = 0;
|
|
276
|
+
|
|
277
|
+
let y = b.lastModified;
|
|
278
|
+
if(!y) y = 0;
|
|
279
|
+
|
|
280
|
+
// console.log("x & y: ", x, y);
|
|
281
|
+
|
|
282
|
+
return x - y;
|
|
283
|
+
});
|
|
284
|
+
console.log("uploadedFiles after sort: ", files);
|
|
285
|
+
|
|
286
|
+
return this.set({ files })
|
|
287
|
+
})
|
|
245
288
|
.then(this.activate.bind(this))
|
|
246
289
|
.catch(this._reportError.bind(this))
|
|
247
290
|
.then(_ => this.set({ loading: false, error: null }));
|
|
@@ -294,14 +337,39 @@ export default {
|
|
|
294
337
|
this.fire('error', processedError);
|
|
295
338
|
},
|
|
296
339
|
|
|
297
|
-
|
|
340
|
+
/**
|
|
341
|
+
* DROPZONE HANDLERS
|
|
342
|
+
*/
|
|
343
|
+
|
|
344
|
+
_onDropZoneNewUpload(event) {
|
|
345
|
+
console.log("on DropZone New Upload:", event);
|
|
298
346
|
this.refs.scrollPane && this.refs.scrollPane.scrollBottom();
|
|
299
347
|
},
|
|
300
348
|
|
|
349
|
+
_onDropZoneUpload(event) {
|
|
350
|
+
console.log("on DropZone Upload:", event);
|
|
351
|
+
this.toggle( event );
|
|
352
|
+
},
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* BROWSER HANDLERS
|
|
356
|
+
*/
|
|
357
|
+
|
|
358
|
+
_onUpdate(event) {
|
|
359
|
+
// console.log("on Update Content:", event);
|
|
360
|
+
|
|
361
|
+
// re-load uploaded files
|
|
362
|
+
this.refresh();
|
|
363
|
+
},
|
|
364
|
+
|
|
301
365
|
_onUploadComplete([file, instanceId]) {
|
|
366
|
+
// console.log("on Upload Complete:", file, instanceId);
|
|
367
|
+
|
|
302
368
|
// toggle the file only if it's upload originated from this instance
|
|
303
|
-
if (instanceId === this.get('instanceId'))
|
|
304
|
-
|
|
369
|
+
if (instanceId === this.get('instanceId')) this._toggleSelect(file, { afterUpload: true });
|
|
370
|
+
|
|
371
|
+
// reload files by upload date
|
|
372
|
+
// this.refresh();
|
|
305
373
|
},
|
|
306
374
|
},
|
|
307
375
|
};
|
|
@@ -100,6 +100,8 @@ class Content extends Tabs
|
|
|
100
100
|
@listenTo ContentModel, 'create', @_onItemCreate
|
|
101
101
|
@listenTo ContentModel, 'change', => @el.toggleClass 'has-reached-max', @composition.maxContentReached()
|
|
102
102
|
|
|
103
|
+
# console.log('Editor Content initialized:', ContentModel, @composition, @browsers);
|
|
104
|
+
|
|
103
105
|
# activate the first tab
|
|
104
106
|
@children()[0].active()
|
|
105
107
|
|