adapt-authoring-ui 1.2.3 → 1.4.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.
@@ -80,17 +80,20 @@ define([
80
80
  }
81
81
  const callbacks = {
82
82
  success: data => this.onSaveSuccess(data),
83
- error: (model, xhr) => {
84
- if(typeof xhr === 'string') xhr = model;
85
- this.onSaveError(xhr.responseJSON && xhr.responseJSON.message || xhr.statusText);
83
+ error: error => {
84
+ this.onSaveError(error.message);
86
85
  }
87
86
  };
88
- if($('input[name="file"]').val()) { // handle file upload
89
- this.form.$el.ajaxSubmit(Object.assign({
87
+ if(document.querySelector('input[name="file"]').value) { // handle file upload
88
+ const submitData = {
90
89
  method: this.model.isNew() ? 'POST' : 'PATCH',
91
- url: `/api/assets/${this.model.get('_id') ? this.model.get('_id') : ''}`,
92
- beforeSubmit: this.sanitiseData,
93
- }, callbacks));
90
+ data: this.sanitiseData(new FormData(this.form)),
91
+ };
92
+ fetch(`/api/assets/${this.model.get('_id') ? this.model.get('_id') : ''}`,
93
+ submitData)
94
+ .then(res => res.json())
95
+ .then(callbacks.success)
96
+ .catch(callbacks.error);
94
97
  return;
95
98
  }
96
99
  this.form.commit();
@@ -121,7 +121,7 @@ define(function(require){
121
121
  Origin.trigger('editorView:itemDeleted', model);
122
122
  this.remove()
123
123
  }, this),
124
- error: () => Origin.Notify.alert({ type: 'error', text: 'app.errordelete' })
124
+ error: (model, jqXhr) => Origin.Notify.alert({ type: 'error', text: jqXhr.responseJSON.message })
125
125
  });
126
126
  },
127
127
 
@@ -107,10 +107,10 @@ define(function(require) {
107
107
  newMenuItemView.$el.removeClass('syncing');
108
108
  this.setHeight();
109
109
  }, this),
110
- error: function(error) {
110
+ error: function(model, jqXhr) {
111
111
  // fade out menu item and alert
112
112
  newMenuItemView.$el.removeClass('syncing').addClass('not-synced');
113
- Origin.Notify.alert({ type: 'error', text: Origin.l10n.t('app.errormenueditorbody') });
113
+ Origin.Notify.alert({ type: 'error', text: jqXhr.responseJSON.message });
114
114
  _.delay(newMenuItemView.remove, 3000);
115
115
  }
116
116
  });
@@ -135,11 +135,11 @@ define(function(require) {
135
135
  _parentId: model.get('_id'),
136
136
  _courseId: Origin.editor.data.course.get('_id')
137
137
  }, {
138
- error: function() {
138
+ error: function(model, jqXhr) {
139
139
  newMenuItemView.$el.removeClass('syncing').addClass('not-synced');
140
140
  Origin.Notify.alert({
141
141
  type: 'error',
142
- text: Origin.l10n.t('app.errormenueditorbody'),
142
+ text: jqXhr.responseJSON.message
143
143
  });
144
144
  _.delay(newMenuItemView.remove, 3000);
145
145
  },
@@ -122,7 +122,7 @@ define(function(require){
122
122
  this.addBlockView(model, true);
123
123
  Origin.trigger('editor:refreshData');
124
124
  },
125
- error: () => Origin.Notify.alert({ type: 'error', text: Origin.l10n.t('app.erroraddingblock') })
125
+ error: (model, jqXhr) => Origin.Notify.alert({ type: 'error', text: jqXhr.responseJSON.message })
126
126
  });
127
127
  },
128
128
 
@@ -149,7 +149,7 @@ define(function(require){
149
149
 
150
150
  this.model.destroy({
151
151
  success: () => this.remove(),
152
- error: () => Origin.Notify.alert({ type: 'error', text: Origin.l10n.t('app.errorgeneric') })
152
+ error: (model, jqXhr) => Origin.Notify.alert({ type: 'error', text: jqXhr.responseJSON.message })
153
153
  });
154
154
  },
155
155
 
@@ -119,7 +119,7 @@ define(function(require){
119
119
  deleteBlock: function(event) {
120
120
  this.model.destroy({
121
121
  success: () => this.remove(),
122
- error: () => Origin.Notify.alert({ type: 'error', text: Origin.l10n.t('app.errorgeneric') })
122
+ error: (model, jqXhr) => Origin.Notify.alert({ type: 'error', text: jqXhr.responseJSON.message })
123
123
  });
124
124
  },
125
125
 
@@ -267,7 +267,7 @@ define(function(require){
267
267
  this.children.push(model);
268
268
  this.render();
269
269
  }, this),
270
- error: () => Origin.Notify.alert({ type: 'error', text: 'app.errorfetchingdata' })
270
+ error: (model, jqXhr) => Origin.Notify.alert({ type: 'error', text: jqXhr.responseJSON.message })
271
271
  });
272
272
  }
273
273
 
@@ -114,7 +114,7 @@ define(function(require){
114
114
  articleView._skipRender = true; // prevent render of blocks in postRender
115
115
  articleView.addBlock();
116
116
  },
117
- error: () => Origin.Notify.alert({ type: 'error', text: Origin.l10n.t('app.erroraddingarticle') })
117
+ error: (model, jqXhr) => Origin.Notify.alert({ type: 'error', text: jqXhr.responseJSON.message })
118
118
  });
119
119
  },
120
120
 
@@ -67,6 +67,8 @@ define(function(require) {
67
67
  filter: { createdBy: isMine ? meId : { $ne: meId } },
68
68
  _type: 'course'
69
69
  });
70
+ collection.queryOptions.source = 'dashboard';
71
+
70
72
  Origin.trigger('contentHeader:updateTitle', {
71
73
  breadcrumbs: ['dashboard'],
72
74
  title: Origin.l10n.t(`app.${isMine ? 'myprojects' : 'sharedprojects'}`)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adapt-authoring-ui",
3
- "version": "1.2.3",
3
+ "version": "1.4.0",
4
4
  "description": "Front-end application for the Adapt authoring tool",
5
5
  "homepage": "https://github.com/adapt-security/adapt-authoring-ui",
6
6
  "license": "GPL-3.0",