@dejwcake/craftable 0.0.1 → 0.0.3
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/dist/admin/Admin.js +33 -35
- package/dist/auth/Form.js +6 -13
- package/dist/base-components/Form/BaseForm.js +56 -88
- package/dist/base-components/Form/BaseUpload.js +112 -84
- package/dist/base-components/Form/bootstrap.js +11 -15
- package/dist/base-components/Listing/BaseListing.js +438 -425
- package/dist/base-components/Listing/components/Pagination.js +90 -95
- package/dist/base-components/Listing/components/Sortable.js +34 -41
- package/dist/base-components/Listing/components/UserDetailTooltip.js +49 -50
- package/dist/index.js +23 -38
- package/dist/overrides/trumbowyg.edit-embed-template.js +63 -67
- package/dist/overrides/trumbowyg.reupload.js +123 -141
- package/dist/overrides/trumbowyg.template.js +56 -59
- package/dist/translation/Form.js +6 -13
- package/dist/translation/Listing.js +255 -266
- package/dist/ui/index.js +27 -28
- package/package.json +7 -7
|
@@ -1,454 +1,467 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
4
|
+
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
|
-
var _moment = require(
|
|
8
|
-
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
require(
|
|
12
|
-
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
var _Pagination2 = _interopRequireDefault(_Pagination);
|
|
16
|
-
|
|
17
|
-
var _Sortable = require('./components/Sortable');
|
|
18
|
-
|
|
19
|
-
var _Sortable2 = _interopRequireDefault(_Sortable);
|
|
20
|
-
|
|
21
|
-
var _vTooltip = require('v-tooltip');
|
|
22
|
-
|
|
23
|
-
var _UserDetailTooltip = require('./components/UserDetailTooltip');
|
|
24
|
-
|
|
25
|
-
var _UserDetailTooltip2 = _interopRequireDefault(_UserDetailTooltip);
|
|
26
|
-
|
|
27
|
-
var _lodash = require('lodash');
|
|
28
|
-
|
|
29
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
30
|
-
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
var _moment = _interopRequireDefault(require("moment"));
|
|
8
|
+
require("moment-timezone");
|
|
9
|
+
var _Pagination = _interopRequireDefault(require("./components/Pagination"));
|
|
10
|
+
var _Sortable = _interopRequireDefault(require("./components/Sortable"));
|
|
11
|
+
var _vTooltip = require("v-tooltip");
|
|
12
|
+
var _UserDetailTooltip = _interopRequireDefault(require("./components/UserDetailTooltip"));
|
|
13
|
+
var _lodash = require("lodash");
|
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
31
15
|
Vue.directive('tooltip', _vTooltip.VTooltip);
|
|
32
16
|
Vue.directive('close-popover', _vTooltip.VClosePopover);
|
|
33
17
|
Vue.component('v-popover', _vTooltip.VPopover);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
18
|
+
var _default2 = exports["default"] = {
|
|
19
|
+
data: function data() {
|
|
20
|
+
return {
|
|
21
|
+
pagination: {
|
|
22
|
+
state: {
|
|
23
|
+
per_page: this.$cookie.get('per_page') || 10,
|
|
24
|
+
// required
|
|
25
|
+
current_page: 1,
|
|
26
|
+
// required
|
|
27
|
+
last_page: 1,
|
|
28
|
+
// required
|
|
29
|
+
from: 1,
|
|
30
|
+
to: 10 // required
|
|
31
|
+
},
|
|
32
|
+
options: {
|
|
33
|
+
alwaysShowPrevNext: true
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
orderBy: {
|
|
37
|
+
column: 'id',
|
|
38
|
+
direction: 'asc'
|
|
39
|
+
},
|
|
40
|
+
filters: {},
|
|
41
|
+
search: '',
|
|
42
|
+
collection: null,
|
|
43
|
+
now: (0, _moment["default"])().tz(this.timezone).format('YYYY-MM-DD HH:mm:ss'),
|
|
44
|
+
datetimePickerConfig: {
|
|
45
|
+
enableTime: true,
|
|
46
|
+
time_24hr: true,
|
|
47
|
+
enableSeconds: true,
|
|
48
|
+
dateFormat: 'Y-m-d H:i:S',
|
|
49
|
+
altInput: true,
|
|
50
|
+
altFormat: 'd.m.Y H:i:S',
|
|
51
|
+
locale: null,
|
|
52
|
+
inline: true
|
|
53
|
+
},
|
|
54
|
+
bulkItems: {},
|
|
55
|
+
bulkCheckingAllLoader: false,
|
|
56
|
+
dummy: null
|
|
57
|
+
};
|
|
58
|
+
},
|
|
59
|
+
props: {
|
|
60
|
+
'url': {
|
|
61
|
+
type: String,
|
|
62
|
+
required: true
|
|
63
|
+
},
|
|
64
|
+
'data': {
|
|
65
|
+
type: Object,
|
|
66
|
+
"default": function _default() {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
'timezone': {
|
|
71
|
+
type: String,
|
|
72
|
+
required: false,
|
|
73
|
+
"default": function _default() {
|
|
74
|
+
return "UTC";
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
'trans': {
|
|
78
|
+
required: false,
|
|
79
|
+
"default": function _default() {
|
|
37
80
|
return {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
datetimePickerConfig: {
|
|
59
|
-
enableTime: true,
|
|
60
|
-
time_24hr: true,
|
|
61
|
-
enableSeconds: true,
|
|
62
|
-
dateFormat: 'Y-m-d H:i:S',
|
|
63
|
-
altInput: true,
|
|
64
|
-
altFormat: 'd.m.Y H:i:S',
|
|
65
|
-
locale: null,
|
|
66
|
-
inline: true
|
|
67
|
-
},
|
|
68
|
-
bulkItems: {},
|
|
69
|
-
bulkCheckingAllLoader: false,
|
|
70
|
-
dummy: null
|
|
81
|
+
duplicateDialog: {
|
|
82
|
+
title: 'Warning!',
|
|
83
|
+
text: 'Do you really want to duplicate this item?',
|
|
84
|
+
yes: 'Yes, duplicate.',
|
|
85
|
+
no: 'No, cancel.',
|
|
86
|
+
success_title: 'Success!',
|
|
87
|
+
success: 'Item successfully duplicated.',
|
|
88
|
+
error_title: 'Error!',
|
|
89
|
+
error: 'An error has occured.'
|
|
90
|
+
},
|
|
91
|
+
deleteDialog: {
|
|
92
|
+
title: 'Warning!',
|
|
93
|
+
text: 'Do you really want to delete this item?',
|
|
94
|
+
yes: 'Yes, delete.',
|
|
95
|
+
no: 'No, cancel.',
|
|
96
|
+
success_title: 'Success!',
|
|
97
|
+
success: 'Item successfully deleted.',
|
|
98
|
+
error_title: 'Error!',
|
|
99
|
+
error: 'An error has occured.'
|
|
100
|
+
}
|
|
71
101
|
};
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
components: {
|
|
106
|
+
'pagination': _Pagination["default"],
|
|
107
|
+
'sortable': _Sortable["default"],
|
|
108
|
+
'user-detail-tooltip': _UserDetailTooltip["default"]
|
|
109
|
+
},
|
|
110
|
+
watch: {
|
|
111
|
+
pagination: {
|
|
112
|
+
handler: function handler() {
|
|
113
|
+
this.dummy = Math.random();
|
|
114
|
+
},
|
|
115
|
+
deep: true
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
created: function created() {
|
|
119
|
+
if (this.data != null) {
|
|
120
|
+
this.populateCurrentStateAndData(this.data);
|
|
121
|
+
} else {
|
|
122
|
+
this.loadData();
|
|
123
|
+
}
|
|
124
|
+
var _this = this;
|
|
125
|
+
setInterval(function () {
|
|
126
|
+
_this.now = (0, _moment["default"])().tz(_this.timezone).format('YYYY-MM-DD HH:mm:ss');
|
|
127
|
+
}, 1000);
|
|
128
|
+
},
|
|
129
|
+
computed: {
|
|
130
|
+
isClickedAll: {
|
|
131
|
+
get: function get() {
|
|
132
|
+
var dummy = this.dummy; //we hack pagination watcher don't recalculate computed property
|
|
133
|
+
return this.clickedBulkItemsCount >= this.pagination.state.to - this.pagination.state.from + 1 && this.clickedBulkItemsCount > 0 && this.allClickedItemsAreSame();
|
|
134
|
+
},
|
|
135
|
+
set: function set(clicked) {}
|
|
72
136
|
},
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
required: false,
|
|
87
|
-
default: function _default() {
|
|
88
|
-
return "UTC";
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
|
-
'trans': {
|
|
92
|
-
required: false,
|
|
93
|
-
default: function _default() {
|
|
94
|
-
return {
|
|
95
|
-
duplicateDialog: {
|
|
96
|
-
title: 'Warning!',
|
|
97
|
-
text: 'Do you really want to duplicate this item?',
|
|
98
|
-
yes: 'Yes, duplicate.',
|
|
99
|
-
no: 'No, cancel.',
|
|
100
|
-
success_title: 'Success!',
|
|
101
|
-
success: 'Item successfully duplicated.',
|
|
102
|
-
error_title: 'Error!',
|
|
103
|
-
error: 'An error has occured.'
|
|
104
|
-
},
|
|
105
|
-
deleteDialog: {
|
|
106
|
-
title: 'Warning!',
|
|
107
|
-
text: 'Do you really want to delete this item?',
|
|
108
|
-
yes: 'Yes, delete.',
|
|
109
|
-
no: 'No, cancel.',
|
|
110
|
-
success_title: 'Success!',
|
|
111
|
-
success: 'Item successfully deleted.',
|
|
112
|
-
error_title: 'Error!',
|
|
113
|
-
error: 'An error has occured.'
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
}
|
|
137
|
+
clickedBulkItemsCount: function clickedBulkItemsCount() {
|
|
138
|
+
return Object.values(this.bulkItems).filter(function (item) {
|
|
139
|
+
return item === true;
|
|
140
|
+
}).length;
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
filters: {
|
|
144
|
+
date: function date(_date) {
|
|
145
|
+
var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'YYYY-MM-DD';
|
|
146
|
+
return function (_date) {
|
|
147
|
+
var _date = (0, _moment["default"])(_date);
|
|
148
|
+
return _date.isValid() ? _date.format(format) : "";
|
|
149
|
+
}(_date);
|
|
118
150
|
},
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
151
|
+
datetime: function datetime(_datetime) {
|
|
152
|
+
var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'YYYY-MM-DD HH:mm:ss';
|
|
153
|
+
var date = (0, _moment["default"])(_datetime);
|
|
154
|
+
return date.isValid() ? date.format(format) : "";
|
|
123
155
|
},
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
156
|
+
time: function time(_time) {
|
|
157
|
+
var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'HH:mm:ss';
|
|
158
|
+
// '2000-01-01' is here just because momentjs needs a date
|
|
159
|
+
var date = (0, _moment["default"])('2000-01-01 ' + _time);
|
|
160
|
+
return date.isValid() ? date.format(format) : "";
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
methods: {
|
|
164
|
+
allClickedItemsAreSame: function allClickedItemsAreSame() {
|
|
165
|
+
var itemsInPaginationIds = Object.values(this.collection).map(function (_ref) {
|
|
166
|
+
var id = _ref.id;
|
|
167
|
+
return id;
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
//for loop is used because you can't return false in .forEach() method
|
|
171
|
+
for (var i = 0; i < itemsInPaginationIds.length; i++) {
|
|
172
|
+
var itemInPaginationId = itemsInPaginationIds[i];
|
|
173
|
+
if (this.bulkItems[itemInPaginationId] === undefined || this.bulkItems[itemInPaginationId] === false) {
|
|
174
|
+
return false;
|
|
131
175
|
}
|
|
176
|
+
}
|
|
177
|
+
return true;
|
|
132
178
|
},
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
if (this.data != null) {
|
|
136
|
-
this.populateCurrentStateAndData(this.data);
|
|
137
|
-
} else {
|
|
138
|
-
this.loadData();
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
var _this = this;
|
|
142
|
-
setInterval(function () {
|
|
143
|
-
_this.now = (0, _moment2.default)().tz(_this.timezone).format('YYYY-MM-DD HH:mm:ss');
|
|
144
|
-
}, 1000);
|
|
179
|
+
onBulkItemClicked: function onBulkItemClicked(id) {
|
|
180
|
+
this.bulkItems[id] === undefined ? Vue.set(this.bulkItems, id, true) : this.bulkItems[id] = !this.bulkItems[id];
|
|
145
181
|
},
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
return this.clickedBulkItemsCount >= this.pagination.state.to - this.pagination.state.from + 1 && this.clickedBulkItemsCount > 0 && this.allClickedItemsAreSame();
|
|
152
|
-
},
|
|
153
|
-
set: function set(clicked) {}
|
|
154
|
-
},
|
|
155
|
-
clickedBulkItemsCount: function clickedBulkItemsCount() {
|
|
156
|
-
return Object.values(this.bulkItems).filter(function (item) {
|
|
157
|
-
return item === true;
|
|
158
|
-
}).length;
|
|
182
|
+
onBulkItemsClickedAll: function onBulkItemsClickedAll(url) {
|
|
183
|
+
var _this2 = this;
|
|
184
|
+
var options = {
|
|
185
|
+
params: {
|
|
186
|
+
bulk: true
|
|
159
187
|
}
|
|
188
|
+
};
|
|
189
|
+
this.bulkCheckingAllLoader = true;
|
|
190
|
+
Object.assign(options.params, this.filters);
|
|
191
|
+
axios.get(url, options).then(function (response) {
|
|
192
|
+
_this2.checkAllItems(response.data.bulkItems);
|
|
193
|
+
}, function (error) {
|
|
194
|
+
_this2.$notify({
|
|
195
|
+
type: 'error',
|
|
196
|
+
title: 'Error!',
|
|
197
|
+
text: error.response.data.message ? error.response.data.message : 'An error has occured.'
|
|
198
|
+
});
|
|
199
|
+
})["finally"](function () {
|
|
200
|
+
_this2.bulkCheckingAllLoader = false;
|
|
201
|
+
});
|
|
160
202
|
},
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
return date.isValid() ? date.format(format) : "";
|
|
174
|
-
},
|
|
175
|
-
time: function time(_time) {
|
|
176
|
-
var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'HH:mm:ss';
|
|
177
|
-
|
|
178
|
-
// '2000-01-01' is here just because momentjs needs a date
|
|
179
|
-
var date = (0, _moment2.default)('2000-01-01 ' + _time);
|
|
180
|
-
return date.isValid() ? date.format(format) : "";
|
|
181
|
-
}
|
|
203
|
+
onBulkItemsClickedAllWithPagination: function onBulkItemsClickedAllWithPagination() {
|
|
204
|
+
var itemsInPagination = Object.values(this.collection).map(function (_ref2) {
|
|
205
|
+
var id = _ref2.id;
|
|
206
|
+
return id;
|
|
207
|
+
});
|
|
208
|
+
if (!this.isClickedAll) {
|
|
209
|
+
this.bulkCheckingAllLoader = true;
|
|
210
|
+
this.checkAllItems(itemsInPagination);
|
|
211
|
+
this.bulkCheckingAllLoader = false;
|
|
212
|
+
} else {
|
|
213
|
+
this.onBulkItemsClickedAllUncheck(itemsInPagination);
|
|
214
|
+
}
|
|
182
215
|
},
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
axios.
|
|
217
|
-
|
|
216
|
+
checkAllItems: function checkAllItems(itemsToCheck) {
|
|
217
|
+
var _this3 = this;
|
|
218
|
+
itemsToCheck.forEach(function (itemId) {
|
|
219
|
+
Vue.set(_this3.bulkItems, itemId, true);
|
|
220
|
+
});
|
|
221
|
+
},
|
|
222
|
+
onBulkItemsClickedAllUncheck: function onBulkItemsClickedAllUncheck() {
|
|
223
|
+
var _this4 = this;
|
|
224
|
+
var bulkItemsToUncheck = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
225
|
+
if (bulkItemsToUncheck === null) {
|
|
226
|
+
this.bulkItems = {};
|
|
227
|
+
} else {
|
|
228
|
+
Object.values(this.collection).map(function (_ref3) {
|
|
229
|
+
var id = _ref3.id;
|
|
230
|
+
return id;
|
|
231
|
+
}).forEach(function (itemsInPaginationIds) {
|
|
232
|
+
_this4.bulkItems[itemsInPaginationIds] = false;
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
bulkDelete: function bulkDelete(url) {
|
|
237
|
+
var _this5 = this;
|
|
238
|
+
var itemsToDelete = (0, _lodash.keys)((0, _lodash.pickBy)(this.bulkItems));
|
|
239
|
+
var self = this;
|
|
240
|
+
this.$modal.show('dialog', {
|
|
241
|
+
title: 'Warning!',
|
|
242
|
+
text: "Do you really want to delete ".concat(this.clickedBulkItemsCount, " selected items ?"),
|
|
243
|
+
buttons: [{
|
|
244
|
+
title: 'No, cancel.'
|
|
245
|
+
}, {
|
|
246
|
+
title: '<span class="btn-dialog btn-danger">Yes, delete.<span>',
|
|
247
|
+
handler: function handler() {
|
|
248
|
+
_this5.$modal.hide('dialog');
|
|
249
|
+
axios.post(url, {
|
|
250
|
+
data: {
|
|
251
|
+
'ids': itemsToDelete
|
|
252
|
+
}
|
|
253
|
+
}).then(function (response) {
|
|
254
|
+
self.bulkItems = {};
|
|
255
|
+
_this5.loadData();
|
|
256
|
+
_this5.$notify({
|
|
257
|
+
type: 'success',
|
|
258
|
+
title: 'Success!',
|
|
259
|
+
text: response.data.message ? response.data.message : 'Item successfully deleted.'
|
|
260
|
+
});
|
|
218
261
|
}, function (error) {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
onBulkItemsClickedAllWithPagination: function onBulkItemsClickedAllWithPagination() {
|
|
225
|
-
var itemsInPagination = Object.values(this.collection).map(function (_ref2) {
|
|
226
|
-
var id = _ref2.id;
|
|
227
|
-
return id;
|
|
262
|
+
_this5.$notify({
|
|
263
|
+
type: 'error',
|
|
264
|
+
title: 'Error!',
|
|
265
|
+
text: error.response.data.message ? error.response.data.message : 'An error has occured.'
|
|
266
|
+
});
|
|
228
267
|
});
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
page: this.pagination.state.current_page,
|
|
295
|
-
orderBy: this.orderBy.column,
|
|
296
|
-
orderDirection: this.orderBy.direction
|
|
297
|
-
}
|
|
298
|
-
};
|
|
299
|
-
|
|
300
|
-
if (resetCurrentPage === true) {
|
|
301
|
-
options.params.page = 1;
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
Object.assign(options.params, this.filters);
|
|
305
|
-
|
|
306
|
-
axios.get(this.url, options).then(function (response) {
|
|
307
|
-
return _this6.populateCurrentStateAndData(response.data.data);
|
|
268
|
+
}
|
|
269
|
+
}]
|
|
270
|
+
});
|
|
271
|
+
},
|
|
272
|
+
loadData: function loadData(resetCurrentPage) {
|
|
273
|
+
var _this6 = this;
|
|
274
|
+
var options = {
|
|
275
|
+
params: {
|
|
276
|
+
per_page: this.pagination.state.per_page,
|
|
277
|
+
page: this.pagination.state.current_page,
|
|
278
|
+
orderBy: this.orderBy.column,
|
|
279
|
+
orderDirection: this.orderBy.direction
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
if (resetCurrentPage === true) {
|
|
283
|
+
options.params.page = 1;
|
|
284
|
+
}
|
|
285
|
+
Object.assign(options.params, this.filters);
|
|
286
|
+
axios.get(this.url, options).then(function (response) {
|
|
287
|
+
return _this6.populateCurrentStateAndData(response.data.data);
|
|
288
|
+
}, function (error) {
|
|
289
|
+
// TODO handle error
|
|
290
|
+
});
|
|
291
|
+
},
|
|
292
|
+
filter: function filter(column, value) {
|
|
293
|
+
if (value == '') {
|
|
294
|
+
delete this.filters[column];
|
|
295
|
+
} else {
|
|
296
|
+
this.filters[column] = value;
|
|
297
|
+
}
|
|
298
|
+
// when we change filter, we must reset pagination, because the total items count may has changed
|
|
299
|
+
this.loadData(true);
|
|
300
|
+
},
|
|
301
|
+
populateCurrentStateAndData: function populateCurrentStateAndData(object) {
|
|
302
|
+
if (object.current_page > object.last_page && object.total > 0) {
|
|
303
|
+
this.pagination.state.current_page = object.last_page;
|
|
304
|
+
this.loadData();
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
this.collection = object.data;
|
|
308
|
+
this.pagination.state.current_page = object.current_page;
|
|
309
|
+
this.pagination.state.last_page = object.last_page;
|
|
310
|
+
this.pagination.state.total = object.total;
|
|
311
|
+
this.pagination.state.per_page = object.per_page;
|
|
312
|
+
this.pagination.state.to = object.to;
|
|
313
|
+
this.pagination.state.from = object.from;
|
|
314
|
+
},
|
|
315
|
+
deleteItem: function deleteItem(url) {
|
|
316
|
+
var _this7 = this;
|
|
317
|
+
this.$modal.show('dialog', {
|
|
318
|
+
title: 'Warning!',
|
|
319
|
+
text: 'Do you really want to delete this item?',
|
|
320
|
+
buttons: [{
|
|
321
|
+
title: 'No, cancel.'
|
|
322
|
+
}, {
|
|
323
|
+
title: '<span class="btn-dialog btn-danger">Yes, delete.<span>',
|
|
324
|
+
handler: function handler() {
|
|
325
|
+
_this7.$modal.hide('dialog');
|
|
326
|
+
axios["delete"](url).then(function (response) {
|
|
327
|
+
_this7.loadData();
|
|
328
|
+
_this7.$notify({
|
|
329
|
+
type: 'success',
|
|
330
|
+
title: 'Success!',
|
|
331
|
+
text: response.data.message ? response.data.message : 'Item successfully deleted.'
|
|
332
|
+
});
|
|
308
333
|
}, function (error) {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
delete this.filters[column];
|
|
315
|
-
} else {
|
|
316
|
-
this.filters[column] = value;
|
|
317
|
-
}
|
|
318
|
-
// when we change filter, we must reset pagination, because the total items count may has changed
|
|
319
|
-
this.loadData(true);
|
|
320
|
-
},
|
|
321
|
-
populateCurrentStateAndData: function populateCurrentStateAndData(object) {
|
|
322
|
-
|
|
323
|
-
if (object.current_page > object.last_page && object.total > 0) {
|
|
324
|
-
this.pagination.state.current_page = object.last_page;
|
|
325
|
-
this.loadData();
|
|
326
|
-
return;
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
this.collection = object.data;
|
|
330
|
-
this.pagination.state.current_page = object.current_page;
|
|
331
|
-
this.pagination.state.last_page = object.last_page;
|
|
332
|
-
this.pagination.state.total = object.total;
|
|
333
|
-
this.pagination.state.per_page = object.per_page;
|
|
334
|
-
this.pagination.state.to = object.to;
|
|
335
|
-
this.pagination.state.from = object.from;
|
|
336
|
-
},
|
|
337
|
-
deleteItem: function deleteItem(url) {
|
|
338
|
-
var _this7 = this;
|
|
339
|
-
|
|
340
|
-
this.$modal.show('dialog', {
|
|
341
|
-
title: 'Warning!',
|
|
342
|
-
text: 'Do you really want to delete this item?',
|
|
343
|
-
buttons: [{ title: 'No, cancel.' }, {
|
|
344
|
-
title: '<span class="btn-dialog btn-danger">Yes, delete.<span>',
|
|
345
|
-
handler: function handler() {
|
|
346
|
-
_this7.$modal.hide('dialog');
|
|
347
|
-
axios.delete(url).then(function (response) {
|
|
348
|
-
_this7.loadData();
|
|
349
|
-
_this7.$notify({ type: 'success', title: 'Success!', text: response.data.message ? response.data.message : 'Item successfully deleted.' });
|
|
350
|
-
}, function (error) {
|
|
351
|
-
_this7.$notify({ type: 'error', title: 'Error!', text: error.response.data.message ? error.response.data.message : 'An error has occured.' });
|
|
352
|
-
});
|
|
353
|
-
}
|
|
354
|
-
}]
|
|
334
|
+
_this7.$notify({
|
|
335
|
+
type: 'error',
|
|
336
|
+
title: 'Error!',
|
|
337
|
+
text: error.response.data.message ? error.response.data.message : 'An error has occured.'
|
|
338
|
+
});
|
|
355
339
|
});
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
340
|
+
}
|
|
341
|
+
}]
|
|
342
|
+
});
|
|
343
|
+
},
|
|
344
|
+
toggleSwitch: function toggleSwitch(url, col, row) {
|
|
345
|
+
var _this8 = this;
|
|
346
|
+
axios.post(url, row).then(function (response) {
|
|
347
|
+
_this8.$notify({
|
|
348
|
+
type: 'success',
|
|
349
|
+
title: 'Success!',
|
|
350
|
+
text: response.data.message ? response.data.message : 'Item successfully changed.'
|
|
351
|
+
});
|
|
352
|
+
}, function (error) {
|
|
353
|
+
row[col] = !row[col];
|
|
354
|
+
_this8.$notify({
|
|
355
|
+
type: 'error',
|
|
356
|
+
title: 'Error!',
|
|
357
|
+
text: error.response.data.message ? error.response.data.message : 'An error has occured.'
|
|
358
|
+
});
|
|
359
|
+
});
|
|
360
|
+
},
|
|
361
|
+
publishNow: function publishNow(url, row, dialogType) {
|
|
362
|
+
var _this = this;
|
|
363
|
+
if (!dialogType) dialogType = 'publishNowDialog';
|
|
364
|
+
this.$modal.show('dialog', {
|
|
365
|
+
title: _this.trans[dialogType].title,
|
|
366
|
+
text: _this.trans[dialogType].text,
|
|
367
|
+
buttons: [{
|
|
368
|
+
title: _this.trans[dialogType].no
|
|
369
|
+
}, {
|
|
370
|
+
title: '<span class="btn-dialog btn-success">' + _this.trans[dialogType].yes + '<span>',
|
|
371
|
+
handler: function handler() {
|
|
372
|
+
_this.$modal.hide('dialog');
|
|
373
|
+
axios.post(url, {
|
|
374
|
+
publish_now: true
|
|
375
|
+
}).then(function (response) {
|
|
376
|
+
row.published_at = response.data.object.published_at;
|
|
377
|
+
_this.$notify({
|
|
378
|
+
type: 'success',
|
|
379
|
+
title: 'Success!',
|
|
380
|
+
text: response.data.message ? response.data.message : _this.trans[dialogType].success
|
|
381
|
+
});
|
|
362
382
|
}, function (error) {
|
|
363
|
-
|
|
364
|
-
|
|
383
|
+
_this.$notify({
|
|
384
|
+
type: 'error',
|
|
385
|
+
title: 'Error!',
|
|
386
|
+
text: error.response.data.message ? error.response.data.message : _this.trans[dialogType].error
|
|
387
|
+
});
|
|
365
388
|
});
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
389
|
+
}
|
|
390
|
+
}]
|
|
391
|
+
});
|
|
392
|
+
},
|
|
393
|
+
unpublishNow: function unpublishNow(url, row, additionalWarning) {
|
|
394
|
+
var _this = this;
|
|
395
|
+
var dialogType = 'unpublishNowDialog';
|
|
396
|
+
this.$modal.show('dialog', {
|
|
397
|
+
title: _this.trans[dialogType].title,
|
|
398
|
+
text: _this.trans[dialogType].text + (additionalWarning ? '<br /><span class="text-danger">' + additionalWarning + '</span>' : ''),
|
|
399
|
+
buttons: [{
|
|
400
|
+
title: _this.trans[dialogType].no
|
|
401
|
+
}, {
|
|
402
|
+
title: '<span class="btn-dialog btn-danger">' + _this.trans[dialogType].yes + '<span>',
|
|
403
|
+
handler: function handler() {
|
|
404
|
+
_this.$modal.hide('dialog');
|
|
405
|
+
axios.post(url, {
|
|
406
|
+
unpublish_now: true
|
|
407
|
+
}).then(function (response) {
|
|
408
|
+
row.published_at = response.data.object.published_at;
|
|
409
|
+
row.published_to = response.data.object.published_to;
|
|
410
|
+
_this.$notify({
|
|
411
|
+
type: 'success',
|
|
412
|
+
title: 'Success!',
|
|
413
|
+
text: response.data.message ? response.data.message : _this.trans[dialogType].success
|
|
414
|
+
});
|
|
415
|
+
}, function (error) {
|
|
416
|
+
_this.$notify({
|
|
417
|
+
type: 'error',
|
|
418
|
+
title: 'Error!',
|
|
419
|
+
text: error.response.data.message ? error.response.data.message : _this.trans[dialogType].error
|
|
420
|
+
});
|
|
390
421
|
});
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
422
|
+
}
|
|
423
|
+
}]
|
|
424
|
+
});
|
|
425
|
+
},
|
|
426
|
+
publishLater: function publishLater(url, row, dialogType) {
|
|
427
|
+
var _this = this;
|
|
428
|
+
if (!dialogType) dialogType = 'publishLaterDialog';
|
|
429
|
+
this.$modal.show({
|
|
430
|
+
template: "\n <div class=\"vue-dialog\">\n <div class=\"card-body\">\n <p>{{ trans.text }}</p>\n <div class=\"form-group row align-items-center\">\n <div class=\"col\">\n <datetime \n \n v-model=\"mutablePublishedAt\"\n :config=\"datetimePickerConfig\" \n v-validate=\"'date_format:yyyy-MM-dd HH:mm:ss'\" \n class=\"flatpickr\" \n >\n </datetime>\n </div>\n </div>\n <div class=\"row\">\n <div class=\"col\">\n <button class=\"col btn btn-secondary\" @click=\"$emit('close')\">{{trans.no}}</button> \n </div>\n <div class=\"col\">\n <button class=\"col btn btn-success\" type=\"button\" @click=\"save(mutablePublishedAt)\">{{trans.yes}}</button>\n </div>\n </div>\n </div> \n </div> \n ",
|
|
431
|
+
props: ['trans', 'published_at', 'datetimePickerConfig', 'save'],
|
|
432
|
+
data: function data() {
|
|
433
|
+
return {
|
|
434
|
+
mutablePublishedAt: row.published_at
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
}, {
|
|
438
|
+
published_at: row.published_at,
|
|
439
|
+
datetimePickerConfig: _this.datetimePickerConfig,
|
|
440
|
+
trans: _this.trans[dialogType],
|
|
441
|
+
save: function save(mutablePublishedAt) {
|
|
442
|
+
_this.$modal.hide('PublishLaterDialog');
|
|
443
|
+
axios.post(url, {
|
|
444
|
+
published_at: mutablePublishedAt
|
|
445
|
+
}).then(function (response) {
|
|
446
|
+
row.published_at = response.data.object.published_at;
|
|
447
|
+
_this.$notify({
|
|
448
|
+
type: 'success',
|
|
449
|
+
title: 'Success!',
|
|
450
|
+
text: response.data.message ? response.data.message : _this.trans[dialogType].success
|
|
415
451
|
});
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
this.$modal.show({
|
|
423
|
-
template: '\n <div class="vue-dialog">\n <div class="card-body">\n <p>{{ trans.text }}</p>\n <div class="form-group row align-items-center">\n <div class="col">\n <datetime \n \n v-model="mutablePublishedAt"\n :config="datetimePickerConfig" \n v-validate="\'date_format:yyyy-MM-dd HH:mm:ss\'" \n class="flatpickr" \n >\n </datetime>\n </div>\n </div>\n <div class="row">\n <div class="col">\n <button class="col btn btn-secondary" @click="$emit(\'close\')">{{trans.no}}</button> \n </div>\n <div class="col">\n <button class="col btn btn-success" type="button" @click="save(mutablePublishedAt)">{{trans.yes}}</button>\n </div>\n </div>\n </div> \n </div> \n ',
|
|
424
|
-
props: ['trans', 'published_at', 'datetimePickerConfig', 'save'],
|
|
425
|
-
data: function data() {
|
|
426
|
-
return {
|
|
427
|
-
mutablePublishedAt: row.published_at
|
|
428
|
-
};
|
|
429
|
-
}
|
|
430
|
-
}, {
|
|
431
|
-
published_at: row.published_at,
|
|
432
|
-
datetimePickerConfig: _this.datetimePickerConfig,
|
|
433
|
-
trans: _this.trans[dialogType],
|
|
434
|
-
save: function save(mutablePublishedAt) {
|
|
435
|
-
_this.$modal.hide('PublishLaterDialog');
|
|
436
|
-
|
|
437
|
-
axios.post(url, { published_at: mutablePublishedAt }).then(function (response) {
|
|
438
|
-
row.published_at = response.data.object.published_at;
|
|
439
|
-
_this.$notify({ type: 'success', title: 'Success!', text: response.data.message ? response.data.message : _this.trans[dialogType].success });
|
|
440
|
-
}, function (error) {
|
|
441
|
-
|
|
442
|
-
_this.$notify({ type: 'error', title: 'Error!', text: error.response.data.message ? error.response.data.message : _this.trans[dialogType].error });
|
|
443
|
-
});
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
}, {
|
|
447
|
-
width: 350,
|
|
448
|
-
height: 'auto',
|
|
449
|
-
name: 'PublishLaterDialog'
|
|
452
|
+
}, function (error) {
|
|
453
|
+
_this.$notify({
|
|
454
|
+
type: 'error',
|
|
455
|
+
title: 'Error!',
|
|
456
|
+
text: error.response.data.message ? error.response.data.message : _this.trans[dialogType].error
|
|
450
457
|
});
|
|
458
|
+
});
|
|
451
459
|
}
|
|
460
|
+
}, {
|
|
461
|
+
width: 350,
|
|
462
|
+
height: 'auto',
|
|
463
|
+
name: 'PublishLaterDialog'
|
|
464
|
+
});
|
|
452
465
|
}
|
|
453
|
-
|
|
466
|
+
}
|
|
454
467
|
};
|