vue_crud 0.1.9.9 → 0.1.10.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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: abae5940ab3389b7e2048b209e5fab59f7887d1b
|
4
|
+
data.tar.gz: 0e8044954b536c4535835c0dbb7cf1e223f35730
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4baf2d67fb5fa2ccc416fc60947d6ea5345a09732e1b1251d2a03f9bb0c6227e2e1537d6288ac026addca6156b66160e64b78820d833d359b40dc3c880e83fcd
|
7
|
+
data.tar.gz: b67c9f5ce30ecc5cb0e5a6148c263aabd31b7d37a2405a11340beacc2c4e2a96b51cb2305df78cc1419e09c186ca5eada222424d8b67ded207965a185741639d
|
@@ -146,7 +146,7 @@ $(document).ready(function() {
|
|
146
146
|
</script>
|
147
147
|
<!-- NOTE: Templates -->
|
148
148
|
<script type="text/x-template" id="models-table">
|
149
|
-
<tr>
|
149
|
+
<tr :class="{'is_deleted': is_deleted}">
|
150
150
|
<td v-for="(attribute, i) in info.model_attributes" v-if="attribute.visible" :class="{'sort-here': i == 0, highlight: attribute.model_prefix + '.' + attribute.name == selected_attribute}">
|
151
151
|
<p v-if="attribute.model_prefix">
|
152
152
|
<span v-if="attribute.type != 'img'">
|
@@ -170,12 +170,19 @@ $(document).ready(function() {
|
|
170
170
|
</p>
|
171
171
|
</td>
|
172
172
|
<td style="position: relative;">
|
173
|
-
<a @click="
|
173
|
+
<a @click="restoreModel" onclick="return false" class="ui red right corner label" v-show="is_deleted" title="您已刪除,點擊復原">
|
174
|
+
<i class="repeat icon"></i>
|
175
|
+
</a>
|
176
|
+
<a @click="restoreModel" onclick="return false" class="ui red right corner label" v-show="is_restore_failed" title="復原失敗">
|
177
|
+
<i class="warning circle icon"></i>
|
178
|
+
</a>
|
179
|
+
<a @click="updateModel" onclick="return false" class="ui orange right corner label" v-show="modified" title="您有尚未儲存的變更">
|
174
180
|
<i class="save icon"></i>
|
175
181
|
</a>
|
176
182
|
<a class="ui green right corner label" v-show="is_success" title="儲存成功">
|
177
183
|
<i class="check icon"></i>
|
178
184
|
</a>
|
185
|
+
|
179
186
|
<!-- NOTE: Custom action -->
|
180
187
|
<div class="inline-block custom_action"></div>
|
181
188
|
<div class="ui animated fade blue button" @click="openModal('編輯')" tabindex="0">
|
@@ -237,8 +244,10 @@ $(document).ready(function() {
|
|
237
244
|
</div>
|
238
245
|
</div>
|
239
246
|
<div class="extra content">
|
240
|
-
<div class="ui
|
247
|
+
<div class="ui red right ribbon label" v-show="is_deleted">您已刪除,點擊<a href="#" @click="restoreModel" onclick="return false" class="save_now">復原</a></div>
|
248
|
+
<div class="ui orange right ribbon label" v-show="modified">您有尚未儲存的變更,<a href="#" @click="updateModel" onclick="return false" class="save_now">立即儲存</a></div>
|
241
249
|
<div class="ui teal right ribbon label" v-show="is_success">儲存成功</div>
|
250
|
+
<div class="ui red right ribbon label" v-show="is_restore_failed">復原失敗</div>
|
242
251
|
<div class="ui divider"></div>
|
243
252
|
<!-- NOTE: Custom action -->
|
244
253
|
<div class="inline-block custom_action"></div>
|
data/lib/vue_crud/version.rb
CHANGED
@@ -83,6 +83,7 @@ function vueCRUD_init(params = {}) {
|
|
83
83
|
Vue.directive('sortable', {
|
84
84
|
inserted: function (el) {
|
85
85
|
if(options.sortable) {
|
86
|
+
filter: '.is_deleted';
|
86
87
|
var sortable = new Sortable(el, {
|
87
88
|
onUpdate: function (evt) {
|
88
89
|
event_hub.$emit('updateSort');
|
@@ -205,7 +206,9 @@ function vueCRUD_init(params = {}) {
|
|
205
206
|
errors: {},
|
206
207
|
modified: false,
|
207
208
|
deleteMode: false,
|
208
|
-
is_success: false
|
209
|
+
is_success: false,
|
210
|
+
is_deleted: false,
|
211
|
+
is_restore_failed: false
|
209
212
|
}
|
210
213
|
},
|
211
214
|
watch: {
|
@@ -250,6 +253,14 @@ function vueCRUD_init(params = {}) {
|
|
250
253
|
}.bind(this));
|
251
254
|
event_hub.$emit('openModal');
|
252
255
|
},
|
256
|
+
restoreModel: function() {
|
257
|
+
if(confirm("Are you sure?") == true) {
|
258
|
+
event_hub.$emit('restoreCreate', this.model);
|
259
|
+
}
|
260
|
+
else {
|
261
|
+
|
262
|
+
}
|
263
|
+
},
|
253
264
|
deleteModel: function () {
|
254
265
|
var that = this;
|
255
266
|
that.deleteMode = true;
|
@@ -258,7 +269,20 @@ function vueCRUD_init(params = {}) {
|
|
258
269
|
method: 'DELETE',
|
259
270
|
url: that.info.url_prefix + '/' + that.model.id + options.suffix + location.search,
|
260
271
|
success: function(res) {
|
261
|
-
|
272
|
+
that.is_deleted = true;
|
273
|
+
event_hub.$on('toggleRestoreSuccess', function() {
|
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
|
+
}.bind(this));
|
281
|
+
event_hub.$on('toggleRestoreFail', function() {
|
282
|
+
that.is_deleted = false;
|
283
|
+
that.is_restore_failed = true;
|
284
|
+
alert('復原失敗,請記錄資料並重新建立');
|
285
|
+
}.bind(this));
|
262
286
|
},
|
263
287
|
error: function(res) {
|
264
288
|
that.deleteMode = false;
|
@@ -352,6 +376,10 @@ function vueCRUD_init(params = {}) {
|
|
352
376
|
event_hub.$on('update_progress', function(progress) {
|
353
377
|
this.progress = progress;
|
354
378
|
}.bind(this));
|
379
|
+
event_hub.$on('restoreCreate', function(model) {
|
380
|
+
this.model = model;
|
381
|
+
this.restoreModel();
|
382
|
+
}.bind(this));
|
355
383
|
$('#form-progress').change(function(){
|
356
384
|
event_hub.$emit('update_progress', $(this).val());
|
357
385
|
});
|
@@ -404,9 +432,6 @@ function vueCRUD_init(params = {}) {
|
|
404
432
|
setTimeout(function () {
|
405
433
|
that.is_calculating = false
|
406
434
|
}, 500)
|
407
|
-
// TODO: Order by sort after refresh, now computed will not wait for
|
408
|
-
// TODO: the component to finish done the update ajax
|
409
|
-
//.sort((a, b) => a.sort > b.sort ? 1 : -1)
|
410
435
|
return result.slice(
|
411
436
|
that.pageStart,
|
412
437
|
that.countOfPage + that.pageStart
|
@@ -437,6 +462,22 @@ function vueCRUD_init(params = {}) {
|
|
437
462
|
this.currentPage = idx;
|
438
463
|
updateQueryStringParam('p', this.currentPage);
|
439
464
|
},
|
465
|
+
restoreModel: function () {
|
466
|
+
var that = this;
|
467
|
+
$.ajax({
|
468
|
+
method: 'POST',
|
469
|
+
data: {
|
470
|
+
model: that.model,
|
471
|
+
},
|
472
|
+
url: that.info.url_prefix + options.suffix + location.search,
|
473
|
+
success: function(res) {
|
474
|
+
event_hub.$emit('toggleRestoreSuccess');
|
475
|
+
},
|
476
|
+
error: function(res) {
|
477
|
+
event_hub.$emit('toggleRestoreFail');
|
478
|
+
}
|
479
|
+
});
|
480
|
+
},
|
440
481
|
createModel: function () {
|
441
482
|
var that = this;
|
442
483
|
$.ajax({
|
@@ -465,21 +506,3 @@ function vueCRUD_init(params = {}) {
|
|
465
506
|
}
|
466
507
|
})
|
467
508
|
}
|
468
|
-
// $(document).ready(function() {
|
469
|
-
// // $(document).delegate('[data-modal]', 'click', function(event) {
|
470
|
-
// // var target = $(this).data('modal');
|
471
|
-
// // $(target).modal({
|
472
|
-
// // observeChanges: true,
|
473
|
-
// // transition: 'fade down',
|
474
|
-
// // onShow: function() {
|
475
|
-
// // $(this).find('select.ui.dropdown').dropdown();
|
476
|
-
// // $(this).find('.ui.checkbox').checkbox();
|
477
|
-
// // if(typeof modalOpen !== "undefined") modalOpen(this);
|
478
|
-
// // },
|
479
|
-
// // onHide: function() {
|
480
|
-
// // event_hub.$emit('cancel_customMode');
|
481
|
-
// // if(typeof modalClose !== "undefined") modalClose(this);
|
482
|
-
// // }
|
483
|
-
// // }).modal('show');
|
484
|
-
// // });
|
485
|
-
// });
|
@@ -1,5 +1,16 @@
|
|
1
|
-
#vue_crud
|
2
|
-
color:
|
1
|
+
#vue_crud a.save_now {
|
2
|
+
color: white !important;
|
3
|
+
opacity: 1 !important;
|
4
|
+
text-decoration: underline !important;
|
5
|
+
}
|
6
|
+
#vue_crud .ui.feed > .event > .content .summary img {
|
7
|
+
width: 100% !important;
|
8
|
+
height: auto !important;
|
9
|
+
}
|
10
|
+
#vue_crud .is_deleted {
|
11
|
+
opacity: 0.7;
|
12
|
+
}
|
13
|
+
#vue_crud .is_deleted:hover {
|
3
14
|
opacity: 1;
|
4
15
|
}
|
5
16
|
#vue_crud .card .progress {
|
Binary file
|
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.
|
4
|
+
version: 0.1.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Donald Chiang
|
@@ -213,6 +213,7 @@ files:
|
|
213
213
|
- vendor/assets/stylesheets/vue_crud.css
|
214
214
|
- vue_crud-0.1.9.7.gem
|
215
215
|
- vue_crud-0.1.9.8.gem
|
216
|
+
- vue_crud-0.1.9.9.gem
|
216
217
|
- vue_crud.gemspec
|
217
218
|
homepage: http://www.mynet.com.tw
|
218
219
|
licenses:
|