@widgetic/editor 3.10.47 → 3.10.48

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@widgetic/editor",
3
- "version": "3.10.47",
3
+ "version": "3.10.48",
4
4
  "scripts": {
5
5
  "start": "webpack --config webpack.config.js --watch --progress",
6
6
  "build": "webpack --config webpack.config.js",
@@ -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 => this.files.push.apply(this.files, 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="refresh()"
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="_onNewUpload()"
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,30 @@ 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 => this.set({ 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) => { return a.lastModified - b.lastModified; });
274
+ console.log("uploadedFiles after sort: ", files);
275
+
276
+ return this.set({ files })
277
+ })
245
278
  .then(this.activate.bind(this))
246
279
  .catch(this._reportError.bind(this))
247
280
  .then(_ => this.set({ loading: false, error: null }));
@@ -294,14 +327,39 @@ export default {
294
327
  this.fire('error', processedError);
295
328
  },
296
329
 
297
- _onNewUpload() {
330
+ /**
331
+ * DROPZONE HANDLERS
332
+ */
333
+
334
+ _onDropZoneNewUpload(event) {
335
+ console.log("on DropZone New Upload:", event);
298
336
  this.refs.scrollPane && this.refs.scrollPane.scrollBottom();
299
337
  },
300
338
 
339
+ _onDropZoneUpload(event) {
340
+ console.log("on DropZone Upload:", event);
341
+ this.toggle( event );
342
+ },
343
+
344
+ /**
345
+ * BROWSER HANDLERS
346
+ */
347
+
348
+ _onUpdate(event) {
349
+ console.log("on Update Content:", event);
350
+
351
+ // re-load uploaded files
352
+ this.refresh();
353
+ },
354
+
301
355
  _onUploadComplete([file, instanceId]) {
356
+ console.log("on Upload Complete:", file, instanceId);
357
+
302
358
  // toggle the file only if it's upload originated from this instance
303
- if (instanceId === this.get('instanceId'))
304
- this._toggleSelect(file, { afterUpload: true });
359
+ if (instanceId === this.get('instanceId')) this._toggleSelect(file, { afterUpload: true });
360
+
361
+ // sort files by upload date
362
+ // this.refresh();
305
363
  },
306
364
  },
307
365
  };
@@ -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