vue_crud 0.1.10.8.1 → 0.1.10.8.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b8c349fa0bacbe31044a9fcc06ff8dd89d3fb2d5
4
- data.tar.gz: 8ef1d77f86d941020ed6a7c5805ae11dd1df0611
3
+ metadata.gz: 0d97a3b73c315fef985c78e9f9e6d83a4b051a08
4
+ data.tar.gz: e1afbcba32bae987e929b7a0554f31b062cb8330
5
5
  SHA512:
6
- metadata.gz: 3deebc20543bc55bf122a6775bcc0eb09f94e374ecf411edbef16bf13aca164723adfe3ccaa85f5e99a9cdd147f5d2b6e0491ab25688505039e26e393058d43f
7
- data.tar.gz: db220e80e754a81a8fd042bf478b418ce3fba0a6706e4ac710664e41587309585a7dace10acc9b4f7349875973a6f95a2c767fe6bcf5f6ece41c906ac2e06329
6
+ metadata.gz: ba8d4e5708461e9f1e82ff6521f042a157faa64f15eb03547b22a678d66e30a5ca98d8796ab62ac9783a2402a4d285f48578f59222066b955290447e4120e396
7
+ data.tar.gz: fda38526ca19fd9d4b763e6de1f34f796e3d5e9fdfd4d40c19162812ec19adbc9fcd527c1130d00d2676204bf6f843bd389080d5f29f506bf23f67d9c4011184
@@ -1,3 +1,3 @@
1
1
  module VueCrud
2
- VERSION = "0.1.10.8.1"
2
+ VERSION = "0.1.10.8.2"
3
3
  end
@@ -116,8 +116,8 @@ function vueCRUD_init(params = {}) {
116
116
  }
117
117
  },
118
118
  mounted: function() {
119
- event_hub.$on('update_error', function(error) {
120
- this.error = error;
119
+ event_hub.$on('update_error', function(errors) {
120
+ this.errors = errors;
121
121
  }.bind(this));
122
122
  event_hub.$on('update_action_name', function(action_name) {
123
123
  this.action_name = action_name;
@@ -177,13 +177,14 @@ function vueCRUD_init(params = {}) {
177
177
  observeChanges: true,
178
178
  transition: 'fade down',
179
179
  onShow: function() {
180
- // $('.needRefresh').froalaEditor('reset');
180
+ that.errors = {};
181
+ $('.needRefresh').froalaEditor('reset');
181
182
  $(this).find('select.ui.dropdown').dropdown();
182
183
  $(this).find('.ui.checkbox').checkbox();
183
184
  if(typeof modalOpen !== "undefined") modalOpen(this);
184
185
  },
185
186
  onVisible: function() {
186
- // $('.needRefresh').froalaEditor('refresh');
187
+ $('.needRefresh').froalaEditor('refresh');
187
188
  },
188
189
  onHide: function() {
189
190
  event_hub.$emit('cancel_customMode');
@@ -263,28 +264,26 @@ function vueCRUD_init(params = {}) {
263
264
  }.bind(this));
264
265
  event_hub.$emit('openModal');
265
266
  },
266
- restoreModel: function () {
267
- var that = this;
268
- $.ajax({
269
- method: 'POST',
270
- data: JSON.stringify(that.model),
271
- url: that.info.url_prefix + options.suffix + location.search,
272
- success: function(res) {
273
- that.model = res;
274
- that.deleteMode = false;
275
- that.is_deleted = false;
276
- that.is_success = true;
277
- sleep(1500).then(() => {
278
- that.is_success = false;
279
- });
280
- },
281
- error: function(res) {
282
- that.is_deleted = false;
283
- that.is_restore_failed = true;
284
- alert('復原失敗,請記錄資料並重新建立');
285
- }
286
- });
287
- },
267
+ var that = this;
268
+ $.ajax({
269
+ method: 'POST',
270
+ data: obj_to_json(that.model),
271
+ url: that.info.url_prefix + options.suffix + location.search,
272
+ success: function(res) {
273
+ that.model = res;
274
+ that.deleteMode = false;
275
+ that.is_deleted = false;
276
+ that.is_success = true;
277
+ sleep(1500).then(() => {
278
+ that.is_success = false;
279
+ });
280
+ },
281
+ error: function(res) {
282
+ that.is_deleted = false;
283
+ that.is_restore_failed = true;
284
+ alert('復原失敗,請記錄資料並重新建立');
285
+ }
286
+ });
288
287
  // restoreModel: function() {
289
288
  // if(confirm("Are you sure?") == true) {
290
289
  // event_hub.$emit('restoreCreate', this.model);
@@ -296,25 +295,27 @@ function vueCRUD_init(params = {}) {
296
295
  deleteModel: function () {
297
296
  var that = this;
298
297
  that.deleteMode = true;
298
+ var id = that.model.ID || that.model.id;
299
+
299
300
  if(confirm("Are you sure?") == true) {
300
301
  $.ajax({
301
302
  method: 'DELETE',
302
- url: that.info.url_prefix + '/' + that.model.ID + options.suffix + location.search,
303
+ url: that.info.url_prefix + '/' + id + options.suffix + location.search,
303
304
  success: function(res) {
304
305
  that.is_deleted = true;
305
- event_hub.$on('toggleRestoreSuccess', function() {
306
- that.deleteMode = false;
307
- that.is_deleted = false;
308
- that.is_success = true;
309
- sleep(1500).then(() => {
310
- that.is_success = false;
311
- });
312
- }.bind(this));
313
- event_hub.$on('toggleRestoreFail', function() {
314
- that.is_deleted = false;
315
- that.is_restore_failed = true;
316
- alert('復原失敗,請記錄資料並重新建立');
317
- }.bind(this));
306
+ // event_hub.$on('toggleRestoreSuccess', function() {
307
+ // that.deleteMode = false;
308
+ // that.is_deleted = false;
309
+ // that.is_success = true;
310
+ // sleep(1500).then(() => {
311
+ // that.is_success = false;
312
+ // });
313
+ // }.bind(this));
314
+ // event_hub.$on('toggleRestoreFail', function() {
315
+ // that.is_deleted = false;
316
+ // that.is_restore_failed = true;
317
+ // alert('復原失敗,請記錄資料並重新建立');
318
+ // }.bind(this));
318
319
  },
319
320
  error: function(res) {
320
321
  that.deleteMode = false;
@@ -327,12 +328,12 @@ function vueCRUD_init(params = {}) {
327
328
  },
328
329
  updateModel: function() {
329
330
  var that = this;
331
+ var id = that.model.ID || that.model.id;
330
332
  $.ajax({
331
333
  method: 'PATCH',
332
- data: JSON.stringify(that.model),
333
- url: that.info.url_prefix + '/' + that.model.ID + options.suffix + location.search,
334
+ data: obj_to_json(that.model),
335
+ url: that.info.url_prefix + '/' + id + options.suffix + location.search,
334
336
  beforeSend: function() {
335
- console.log(JSON.stringify(that.model));
336
337
  event_hub.$emit('dimmerOn');
337
338
  $('.progress-bar').css('width', '0');
338
339
  },
@@ -487,7 +488,7 @@ function vueCRUD_init(params = {}) {
487
488
  // var that = this;
488
489
  // $.ajax({
489
490
  // method: 'POST',
490
- // data: JSON.stringify(that.model),
491
+ // data: obj_to_json(that.model),
491
492
  // url: that.info.url_prefix + options.suffix + location.search,
492
493
  // success: function(res) {
493
494
  // event_hub.$emit('toggleRestoreSuccess');
@@ -501,10 +502,10 @@ function vueCRUD_init(params = {}) {
501
502
  var that = this;
502
503
  $.ajax({
503
504
  method: 'POST',
504
- data: JSON.stringify(that.model),
505
+ data: obj_to_json(that.model),
505
506
  url: that.info.url_prefix + options.suffix + location.search,
506
507
  beforeSend: function() {
507
- console.log(JSON.stringify(that.model));
508
+ console.log(obj_to_json(that.model));
508
509
  event_hub.$emit('dimmerOn');
509
510
  $('.progress-bar').css('width', '0');
510
511
  },
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vue_crud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10.8.1
4
+ version: 0.1.10.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Donald Chiang