vue_crud 0.2.0.2 → 0.2.0.3

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: 3747e8931eb49c0b4f5b5b56a96a98fef50eeb80
4
- data.tar.gz: eb8417916e46870d8f4579ed0234abb7bf4bc8ac
3
+ metadata.gz: fa7649e34ace82b2f070560a061948bbf1f964f0
4
+ data.tar.gz: 39c905037c25eb6e932dababd1506ac30c0469c8
5
5
  SHA512:
6
- metadata.gz: af4619fb1c1579eae0f36c4cadb1cfc2d9a8e10cf23a2bfddb37eea0ccd81c64dc1a12b3ec0a0050e86687ef638be1cab24156662838e16b96a8755966e7e847
7
- data.tar.gz: 7211245f480c1d67a8cae72d0da2086510803afbefe3e76d22e377791518ee3c5544169df871605fe07237d2bc21b23d01a9cdf9420bbf990dad03e365cdb2f1
6
+ metadata.gz: 63dffe3f65609f8bcd478c29825d3bb139ed343092e3e1807ca1a7f547376986156eca0196a647405fd7544a2d09d8bfc6cf0ea7144a91549e4991259c760acd
7
+ data.tar.gz: fc770a277eb7504f26a0e8c4ce86ac7a99fa6b8ddd019ab11836905802513b31db1b86cf6d1f01d0325c157996c10a5d95d3c96dc34880a4de00499059f528fc
@@ -1,3 +1,3 @@
1
1
  module VueCrud
2
- VERSION = "0.2.0.2"
2
+ VERSION = "0.2.0.3"
3
3
  end
@@ -13,7 +13,7 @@ Pace.on('done', function() {
13
13
  });
14
14
  var event_hub = new Vue();
15
15
  var modal_mixin = {};
16
- var models_mixin = {};
16
+ var model_mixin = {};
17
17
  var root_mixin = {};
18
18
  function sleep(time) {
19
19
  return new Promise((resolve) => setTimeout(resolve, time));
@@ -94,7 +94,7 @@ function vueCRUD_init(params = {}) {
94
94
  return new Date(value).toLocaleString();
95
95
  })
96
96
  Vue.filter('boolean', function (value) {
97
- return value? '是':'否';
97
+ return value? '是':'否';
98
98
  })
99
99
  var default_options = {
100
100
  column_type: 'card',
@@ -146,7 +146,7 @@ function vueCRUD_init(params = {}) {
146
146
  }
147
147
  },
148
148
  mounted: function() {
149
- // Sync errors and model from modelsComponent
149
+ // Sync errors and model from modelComponent
150
150
  event_hub.$on('update_error', function(errors) {
151
151
  this.errors = errors;
152
152
  }.bind(this));
@@ -222,9 +222,9 @@ function vueCRUD_init(params = {}) {
222
222
  }
223
223
  })
224
224
 
225
- var modelsComponent = Vue.component('models', {
226
- mixins: [models_mixin],
227
- template: '#models-' + options.column_type,
225
+ var modelComponent = Vue.component('model', {
226
+ mixins: [model_mixin],
227
+ template: '#model-' + options.column_type,
228
228
  props: {
229
229
  original_model: Object,
230
230
  selected_attribute: String,
@@ -391,36 +391,14 @@ function vueCRUD_init(params = {}) {
391
391
  },
392
392
  mounted: function() {
393
393
  var that = this;
394
- $.ajax({
395
- url: options.info_url,
396
- success: function(res) {
397
- that.info = res;
398
- that.model = {};
399
- var default_url = that.info.actions.index.url + that.info.actions.index.suffix + location.search;
400
- default_url = removeParam("p", default_url);
401
- default_url = removeParam("q", default_url);
402
- default_url = removeParam("mp", default_url);
403
- default_url = removeParam("sa", default_url);
404
- default_url = removeParam("st", default_url);
405
- that.default_url = default_url;
406
- $.ajax({
407
- url: urlParser(that.info.actions.index.url, that.model, that.info.actions.index.suffix),
408
- success: function(res) {
409
- that.models = res;
410
- }
411
- });
412
- }
413
- });
414
- event_hub.$on('update_progress', function(progress) {
415
- this.progress = progress;
416
- }.bind(this));
394
+ that.load_instance(options.info_url);
395
+
417
396
  event_hub.$on('restoreCreate', function(model) {
418
397
  this.model = model;
419
398
  this.restoreModel();
420
399
  }.bind(this));
421
- $('#form-progress').change(function(){
422
- event_hub.$emit('update_progress', $(this).val());
423
- });
400
+
401
+ // delegate filter dropdown click event
424
402
  $(document).delegate('.attribute_option', 'click', function(event) {
425
403
  var selected_attribute = $('.attribute_select').find('.item.selected').attr('target') || "Attribute";
426
404
  var selected_text = $('.attribute_select').find('.item.selected').attr('target_text') || "欄位";
@@ -429,6 +407,81 @@ function vueCRUD_init(params = {}) {
429
407
  updateQueryStringParam('sa', that.selected_attribute);
430
408
  updateQueryStringParam('st', that.selected_text);
431
409
  });
410
+
411
+ // binding PACE progress with Vue
412
+ event_hub.$on('update_progress', function(progress) {
413
+ this.progress = progress;
414
+ }.bind(this));
415
+
416
+ $('#form-progress').change(function(){
417
+ event_hub.$emit('update_progress', $(this).val());
418
+ });
419
+ },
420
+ methods: {
421
+ load_instance: function(info_url) {
422
+ var that = this;
423
+ $.ajax({
424
+ url: info_url,
425
+ success: function(res) {
426
+ that.info = res;
427
+ that.model = {};
428
+ var default_url = that.info.actions.index.url + that.info.actions.index.suffix + location.search;
429
+ default_url = removeParam("p", default_url);
430
+ default_url = removeParam("q", default_url);
431
+ default_url = removeParam("mp", default_url);
432
+ default_url = removeParam("sa", default_url);
433
+ default_url = removeParam("st", default_url);
434
+ that.default_url = default_url;
435
+ $.ajax({
436
+ url: urlParser(that.info.actions.index.url, that.model, that.info.actions.index.suffix),
437
+ success: function(res) {
438
+ that.models = res;
439
+ }
440
+ });
441
+ }
442
+ });
443
+ },
444
+ addModel: function(action_name) {
445
+ event_hub.$emit('openModal');
446
+ event_hub.$emit('update_model_attributes', this.info.model_attributes);
447
+ event_hub.$emit('update_model', this.model);
448
+ event_hub.$emit('update_action_name', action_name + this.info.titles.display_name);
449
+ event_hub.$on('modalSubmit', function() {
450
+ this.createModel();
451
+ }.bind(this));
452
+ },
453
+ setPage: function(idx){
454
+ if( idx <= 0 || idx > this.totalPage ){
455
+ return;
456
+ }
457
+ this.currentPage = idx;
458
+
459
+ updateQueryStringParam('p', this.currentPage);
460
+ },
461
+ createModel: function () {
462
+ var that = this;
463
+ $.ajax({
464
+ method: that.info.actions.create.method,
465
+ data: obj_to_json(that.model),
466
+ url: urlParser(that.info.actions.create.url, that.model, that.info.actions.create.suffix),
467
+ beforeSend: function() {
468
+ console.log(obj_to_json(that.model));
469
+ event_hub.$emit('dimmerOn');
470
+ $('.progress-bar').css('width', '0');
471
+ },
472
+ success: function(res) {
473
+ event_hub.$emit('closeModal');
474
+ event_hub.$emit('dimmerOff');
475
+ that.errors = {};
476
+ that.model = {};
477
+ that.models.push(res);
478
+ },
479
+ error: function(res) {
480
+ event_hub.$emit('update_error', res.responseJSON.errors);
481
+ event_hub.$emit('dimmerOff');
482
+ }
483
+ });
484
+ }
432
485
  },
433
486
  computed: {
434
487
  searchStatus: function() {
@@ -474,49 +527,6 @@ function vueCRUD_init(params = {}) {
474
527
  updateQueryStringParam('q', this.searchQuery);
475
528
  updateQueryStringParam('p', 1);
476
529
  }
477
- },
478
- methods: {
479
- addModel: function(action_name) {
480
- event_hub.$emit('openModal');
481
- event_hub.$emit('update_model_attributes', this.info.model_attributes);
482
- event_hub.$emit('update_model', this.model);
483
- event_hub.$emit('update_action_name', action_name + this.info.titles.display_name);
484
- event_hub.$on('modalSubmit', function() {
485
- this.createModel();
486
- }.bind(this));
487
- },
488
- setPage: function(idx){
489
- if( idx <= 0 || idx > this.totalPage ){
490
- return;
491
- }
492
- this.currentPage = idx;
493
-
494
- updateQueryStringParam('p', this.currentPage);
495
- },
496
- createModel: function () {
497
- var that = this;
498
- $.ajax({
499
- method: that.info.actions.create.method,
500
- data: obj_to_json(that.model),
501
- url: urlParser(that.info.actions.create.url, that.model, that.info.actions.create.suffix),
502
- beforeSend: function() {
503
- console.log(obj_to_json(that.model));
504
- event_hub.$emit('dimmerOn');
505
- $('.progress-bar').css('width', '0');
506
- },
507
- success: function(res) {
508
- event_hub.$emit('closeModal');
509
- event_hub.$emit('dimmerOff');
510
- that.errors = {};
511
- that.model = {};
512
- that.models.push(res);
513
- },
514
- error: function(res) {
515
- event_hub.$emit('update_error', res.responseJSON.errors);
516
- event_hub.$emit('dimmerOff');
517
- }
518
- });
519
- }
520
530
  }
521
531
  })
522
532
  }
@@ -7,6 +7,9 @@
7
7
  width: 100% !important;
8
8
  height: auto !important;
9
9
  }
10
+ #vue_crud .ui.header {
11
+ margin-top: 0;
12
+ }
10
13
  #vue_crud .is_deleted {
11
14
  opacity: 0.7;
12
15
  }
@@ -35,24 +38,36 @@
35
38
  #vue_crud .ui.table td img {
36
39
  max-width: 100%;
37
40
  }
38
- .ui.toggle.checkbox {
41
+ #vue_crud pre {
42
+ background: #fffcd3;
43
+ text-align: center;
44
+ padding: 10px 0;
45
+ margin: 10px 0 0 0;
46
+ border: 1px solid #fff1d7;
47
+ border-radius: 3px;
48
+ }
49
+ #vue_crud span.display_name {
50
+ font-weight: bold;
51
+ color: black;
52
+ }
53
+ #vue_crud .ui.toggle.checkbox {
39
54
  margin: 10px 0;
40
55
  }
41
- .summary.highlight {
42
- border: 2px solid #a90000;
56
+ #vue_crud .item.highlight span.display_name {
57
+ color: #a90000 !important;
43
58
  }
44
- th.highlight {
59
+ #vue_crud th.highlight {
45
60
  border: 2px solid #a90000 !important;
46
61
  }
47
- td.highlight {
62
+ #vue_crud td.highlight {
48
63
  border-left: 2px solid #a90000 !important;
49
64
  border-right: 2px solid #a90000;
50
65
  }
51
- tbody tr:last-child td.highlight {
66
+ #vue_crud tbody tr:last-child td.highlight {
52
67
  border-left: 2px solid #a90000 !important;
53
68
  border-right: 2px solid #a90000;
54
69
  border-bottom: 2px solid #a90000;
55
70
  }
56
- .inline-block {
71
+ #vue_crud .inline-block {
57
72
  display: inline-block;
58
73
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vue_crud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0.2
4
+ version: 0.2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Donald Chiang
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-01-16 00:00:00.000000000 Z
11
+ date: 2017-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler