@dejwcake/craftable 0.0.2 → 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.
@@ -1,283 +1,272 @@
1
- 'use strict';
2
-
3
- var _vue = require('vue');
4
-
5
- var _vue2 = _interopRequireDefault(_vue);
6
-
7
- var _BaseListing = require('../base-components/Listing/BaseListing');
8
-
9
- var _BaseListing2 = _interopRequireDefault(_BaseListing);
10
-
11
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1
+ "use strict";
12
2
 
3
+ var _vue = _interopRequireDefault(require("vue"));
4
+ var _BaseListing = _interopRequireDefault(require("../base-components/Listing/BaseListing"));
5
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
13
6
  $(document).ready(function ($) {
14
- $(document).on('click', '.close_button', function (e) {
15
- $(this).closest('.show').removeClass('show');
16
- });
17
-
18
- $(document).on('click', '.dropdown-menu.dropdown-menu-dont-auto-close', function (e) {
19
- e.stopPropagation();
20
- });
7
+ $(document).on('click', '.close_button', function (e) {
8
+ $(this).closest('.show').removeClass('show');
9
+ });
10
+ $(document).on('click', '.dropdown-menu.dropdown-menu-dont-auto-close', function (e) {
11
+ e.stopPropagation();
12
+ });
21
13
  });
22
-
23
- _vue2.default.component('translation-listing', {
24
-
25
- mixins: [_BaseListing2.default],
26
-
27
- props: {
28
- label: {
29
- type: String,
30
- default: function _default() {
31
- return 'All groups';
32
- }
33
- },
34
- stepCount: {
35
- type: Number,
36
- default: function _default() {
37
- return 3;
38
- }
39
- },
40
- locales: {}
14
+ _vue["default"].component('translation-listing', {
15
+ mixins: [_BaseListing["default"]],
16
+ props: {
17
+ label: {
18
+ type: String,
19
+ "default": function _default() {
20
+ return 'All groups';
21
+ }
41
22
  },
42
-
43
- data: function data() {
44
- var exportMultiselect = {};
45
- Object.values(this.locales).forEach(function (value) {
46
- exportMultiselect[value] = true;
23
+ stepCount: {
24
+ type: Number,
25
+ "default": function _default() {
26
+ return 3;
27
+ }
28
+ },
29
+ locales: {}
30
+ },
31
+ data: function data() {
32
+ var exportMultiselect = {};
33
+ Object.values(this.locales).forEach(function (value) {
34
+ exportMultiselect[value] = true;
35
+ });
36
+ return {
37
+ templateChecked: false,
38
+ exportMultiselect: exportMultiselect,
39
+ languagesToExport: this.locales,
40
+ importLanguage: '',
41
+ file: null,
42
+ onlyMissing: false,
43
+ currentStep: 1,
44
+ scanning: false,
45
+ filters: {
46
+ group: null
47
+ },
48
+ translationId: null,
49
+ translationDefault: '',
50
+ numberOfSuccessfullyImportedTranslations: 0,
51
+ numberOfSuccessfullyUpdatedTranslations: 0,
52
+ numberOfFoundTranslations: 0,
53
+ numberOfTranslationsToReview: 0,
54
+ translationsToImport: null,
55
+ translations: {},
56
+ importedFile: null
57
+ };
58
+ },
59
+ watch: {
60
+ exportMultiselect: {
61
+ handler: function handler(newVal, oldVal) {
62
+ var _this = this;
63
+ this.languagesToExport = [];
64
+ Object.keys(newVal).forEach(function (key) {
65
+ if (newVal[key]) {
66
+ _this.languagesToExport.push(key);
67
+ }
47
68
  });
48
- return {
49
- templateChecked: false,
50
- exportMultiselect: exportMultiselect,
51
- languagesToExport: this.locales,
52
- importLanguage: '',
53
- file: null,
54
- onlyMissing: false,
55
- currentStep: 1,
56
- scanning: false,
57
- filters: {
58
- group: null
59
- },
60
- translationId: null,
61
- translationDefault: '',
62
- numberOfSuccessfullyImportedTranslations: 0,
63
- numberOfSuccessfullyUpdatedTranslations: 0,
64
- numberOfFoundTranslations: 0,
65
- numberOfTranslationsToReview: 0,
66
- translationsToImport: null,
67
- translations: {},
68
- importedFile: null
69
- };
69
+ },
70
+ deep: true
71
+ }
72
+ },
73
+ computed: {
74
+ filteredGroup: function filteredGroup() {
75
+ return this.filters.group === null ? this.label : this.filters.group;
70
76
  },
71
-
72
- watch: {
73
- exportMultiselect: {
74
- handler: function handler(newVal, oldVal) {
75
- var _this = this;
76
-
77
- this.languagesToExport = [];
78
-
79
- Object.keys(newVal).forEach(function (key) {
80
- if (newVal[key]) {
81
- _this.languagesToExport.push(key);
82
- }
83
- });
84
- },
85
-
86
- deep: true
87
- }
77
+ lastStep: function lastStep() {
78
+ return this.currentStep === this.stepCount;
79
+ }
80
+ },
81
+ methods: {
82
+ rescan: function rescan(url) {
83
+ var _this2 = this;
84
+ this.scanning = true;
85
+ axios.post(url).then(function (response) {
86
+ _this2.scanning = false;
87
+ _this2.loadData(true);
88
+ }, function (error) {
89
+ _this2.scanning = false;
90
+ _this2.$notify({
91
+ type: 'error',
92
+ title: 'Error!',
93
+ text: 'An error has occured.'
94
+ });
95
+ });
88
96
  },
89
- computed: {
90
- filteredGroup: function filteredGroup() {
91
- return this.filters.group === null ? this.label : this.filters.group;
92
- },
93
- lastStep: function lastStep() {
94
- return this.currentStep === this.stepCount;
95
- }
97
+ filterGroup: function filterGroup(group) {
98
+ this.filters.group = group;
99
+ this.loadData(true);
96
100
  },
97
- methods: {
98
- rescan: function rescan(url) {
99
- var _this2 = this;
100
-
101
- this.scanning = true;
102
- axios.post(url).then(function (response) {
103
- _this2.scanning = false;
104
- _this2.loadData(true);
105
- }, function (error) {
106
- _this2.scanning = false;
107
- _this2.$notify({ type: 'error', title: 'Error!', text: 'An error has occured.' });
101
+ resetGroup: function resetGroup() {
102
+ this.filters.group = null;
103
+ this.loadData(true);
104
+ },
105
+ editTranslation: function editTranslation(item) {
106
+ this.$modal.show('edit-translation', item);
107
+ },
108
+ showImport: function showImport() {
109
+ this.$modal.show('import-translation');
110
+ },
111
+ showExport: function showExport() {
112
+ this.$modal.show('export-translation');
113
+ },
114
+ nextStep: function nextStep() {
115
+ var _this3 = this;
116
+ if (this.currentStep === 1) {
117
+ return this.$validator.validateAll().then(function (result) {
118
+ if (!result) {
119
+ _this3.$notify({
120
+ type: 'error',
121
+ title: 'Error!',
122
+ text: 'The form contains invalid fields.'
108
123
  });
109
- },
110
- filterGroup: function filterGroup(group) {
111
- this.filters.group = group;
112
- this.loadData(true);
113
- },
114
- resetGroup: function resetGroup() {
115
- this.filters.group = null;
116
- this.loadData(true);
117
- },
118
- editTranslation: function editTranslation(item) {
119
- this.$modal.show('edit-translation', item);
120
- },
121
- showImport: function showImport() {
122
- this.$modal.show('import-translation');
123
- },
124
- showExport: function showExport() {
125
- this.$modal.show('export-translation');
126
- },
127
- nextStep: function nextStep() {
128
- var _this3 = this;
129
-
130
- if (this.currentStep === 1) {
131
- return this.$validator.validateAll().then(function (result) {
132
- if (!result) {
133
- _this3.$notify({ type: 'error', title: 'Error!', text: 'The form contains invalid fields.' });
134
- return false;
135
- }
136
-
137
- var url = '/admin/translations/import';
138
- var formData = new FormData();
139
-
140
- formData.append('fileImport', _this3.file);
141
- formData.append('importLanguage', _this3.importLanguage);
142
- formData.append('onlyMissing', _this3.onlyMissing);
143
-
144
- axios.post(url, formData, {
145
- headers: {
146
- 'Content-Type': 'multipart/form-data'
147
- }
148
- }).then(function (response) {
149
- if (response.data.hasOwnProperty('numberOfImportedTranslations') && response.data.hasOwnProperty('numberOfUpdatedTranslations')) {
150
- _this3.currentStep = 3;
151
- _this3.numberOfSuccessfullyImportedTranslations = response.data.numberOfImportedTranslations;
152
- _this3.numberOfSuccessfullyUpdatedTranslations = response.data.numberOfUpdatedTranslations;
153
- _this3.loadData();
154
- } else {
155
- _this3.currentStep = 2;
156
- _this3.numberOfFoundTranslations = Object.keys(response.data).length;
157
- _this3.translationsToImport = response.data;
158
-
159
- for (var i = 0; i < _this3.translationsToImport.length; i++) {
160
- if (_this3.translationsToImport[i].hasOwnProperty('has_conflict')) {
161
- if (_this3.translationsToImport[i].has_conflict) {
162
- _this3.numberOfTranslationsToReview++;
163
- }
164
- }
165
- }
166
- }
167
- }, function (error) {
168
- if (error.response.data === "Wrong syntax in your import") _this3.$notify({ type: 'error', title: 'Error!', text: 'Wrong syntax in your import.' });else if (error.response.data === "Unsupported file type") _this3.$notify({ type: 'error', title: 'Error!', text: 'Unsupported file type.' });else _this3.$notify({ type: 'error', title: 'Error!', text: 'An error has occured.' });
169
- });
170
- });
171
- } else if (this.currentStep === 2) {
172
- return this.$validator.validateAll().then(function (result) {
173
- if (!result) {
174
- _this3.$notify({ type: 'error', title: 'Error!', text: 'The form contains invalid fields.' });
175
- return false;
176
- }
177
-
178
- for (var i = 0; i < _this3.translationsToImport.length; i++) {
179
- if (_this3.translationsToImport[i].hasOwnProperty('checkedCurrent')) {
180
- if (_this3.translationsToImport[i].checkedCurrent) {
181
- _this3.translationsToImport[i][_this3.importLanguage.toLowerCase()] = _this3.translationsToImport[i].current_value;
182
- }
183
- }
184
- }
185
-
186
- var url = '/admin/translations/import/conflicts';
187
- var data = {
188
- importLanguage: _this3.importLanguage,
189
- resolvedTranslations: _this3.translationsToImport
190
- };
191
-
192
- axios.post(url, data).then(function (response) {
193
- _this3.currentStep = 3;
194
- _this3.numberOfSuccessfullyImportedTranslations = response.data.numberOfImportedTranslations;
195
- _this3.numberOfSuccessfullyUpdatedTranslations = response.data.numberOfUpdatedTranslations;
196
- _this3.loadData();
197
- }, function (error) {
198
- _this3.$notify({ type: 'error', title: 'Error!', text: 'An error has occured.' });
199
- });
200
- });
124
+ return false;
125
+ }
126
+ var url = '/admin/translations/import';
127
+ var formData = new FormData();
128
+ formData.append('fileImport', _this3.file);
129
+ formData.append('importLanguage', _this3.importLanguage);
130
+ formData.append('onlyMissing', _this3.onlyMissing);
131
+ axios.post(url, formData, {
132
+ headers: {
133
+ 'Content-Type': 'multipart/form-data'
201
134
  }
202
- },
203
- previousStep: function previousStep() {
204
- this.currentStep--;
205
- },
206
- beforeModalOpen: function beforeModalOpen(_ref) {
207
- var params = _ref.params;
208
-
209
- this.translationId = params.id;
210
- this.translationDefault = params.key;
211
- this.translations = {};
212
- var _iteratorNormalCompletion = true;
213
- var _didIteratorError = false;
214
- var _iteratorError = undefined;
215
-
216
- try {
217
- for (var _iterator = Object.keys(params.text)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
218
- var key = _step.value;
219
-
220
- this.translations[key] = params.text[key];
221
- }
222
- } catch (err) {
223
- _didIteratorError = true;
224
- _iteratorError = err;
225
- } finally {
226
- try {
227
- if (!_iteratorNormalCompletion && _iterator.return) {
228
- _iterator.return();
229
- }
230
- } finally {
231
- if (_didIteratorError) {
232
- throw _iteratorError;
233
- }
135
+ }).then(function (response) {
136
+ if (response.data.hasOwnProperty('numberOfImportedTranslations') && response.data.hasOwnProperty('numberOfUpdatedTranslations')) {
137
+ _this3.currentStep = 3;
138
+ _this3.numberOfSuccessfullyImportedTranslations = response.data.numberOfImportedTranslations;
139
+ _this3.numberOfSuccessfullyUpdatedTranslations = response.data.numberOfUpdatedTranslations;
140
+ _this3.loadData();
141
+ } else {
142
+ _this3.currentStep = 2;
143
+ _this3.numberOfFoundTranslations = Object.keys(response.data).length;
144
+ _this3.translationsToImport = response.data;
145
+ for (var i = 0; i < _this3.translationsToImport.length; i++) {
146
+ if (_this3.translationsToImport[i].hasOwnProperty('has_conflict')) {
147
+ if (_this3.translationsToImport[i].has_conflict) {
148
+ _this3.numberOfTranslationsToReview++;
149
+ }
234
150
  }
151
+ }
235
152
  }
236
- },
237
- onSubmit: function onSubmit() {
238
- var _this4 = this;
239
-
240
- var url = '/admin/translations/' + this.translationId;
241
- var data = {
242
- text: this.translations
243
- };
244
-
245
- axios.post(url, data).then(function (response) {
246
- _this4.$modal.hide('edit-translation');
247
- _this4.$notify({ type: 'success', title: 'Success!', text: 'Item successfully changed.' });
248
- _this4.loadData();
249
- }, function (error) {
250
- _this4.$notify({ type: 'error', title: 'Error!', text: 'An error has occured.' });
153
+ }, function (error) {
154
+ if (error.response.data === "Wrong syntax in your import") _this3.$notify({
155
+ type: 'error',
156
+ title: 'Error!',
157
+ text: 'Wrong syntax in your import.'
158
+ });else if (error.response.data === "Unsupported file type") _this3.$notify({
159
+ type: 'error',
160
+ title: 'Error!',
161
+ text: 'Unsupported file type.'
162
+ });else _this3.$notify({
163
+ type: 'error',
164
+ title: 'Error!',
165
+ text: 'An error has occured.'
251
166
  });
252
- },
253
- onSubmitExport: function onSubmitExport() {
254
- var _this5 = this;
255
-
256
- return this.$validator.validateAll().then(function (result) {
257
- if (!result) {
258
- _this5.$notify({ type: 'error', title: 'Error!', text: 'The form contains invalid fields.' });
259
- return false;
260
- }
261
-
262
- var data = {
263
- exportLanguages: _this5.languagesToExport
264
- };
265
-
266
- var url = '/admin/translations/export?' + $.param(data);
267
- window.location = url;
268
- _this5.$modal.hide('export-translation');
167
+ });
168
+ });
169
+ } else if (this.currentStep === 2) {
170
+ return this.$validator.validateAll().then(function (result) {
171
+ if (!result) {
172
+ _this3.$notify({
173
+ type: 'error',
174
+ title: 'Error!',
175
+ text: 'The form contains invalid fields.'
176
+ });
177
+ return false;
178
+ }
179
+ for (var i = 0; i < _this3.translationsToImport.length; i++) {
180
+ if (_this3.translationsToImport[i].hasOwnProperty('checkedCurrent')) {
181
+ if (_this3.translationsToImport[i].checkedCurrent) {
182
+ _this3.translationsToImport[i][_this3.importLanguage.toLowerCase()] = _this3.translationsToImport[i].current_value;
183
+ }
184
+ }
185
+ }
186
+ var url = '/admin/translations/import/conflicts';
187
+ var data = {
188
+ importLanguage: _this3.importLanguage,
189
+ resolvedTranslations: _this3.translationsToImport
190
+ };
191
+ axios.post(url, data).then(function (response) {
192
+ _this3.currentStep = 3;
193
+ _this3.numberOfSuccessfullyImportedTranslations = response.data.numberOfImportedTranslations;
194
+ _this3.numberOfSuccessfullyUpdatedTranslations = response.data.numberOfUpdatedTranslations;
195
+ _this3.loadData();
196
+ }, function (error) {
197
+ _this3.$notify({
198
+ type: 'error',
199
+ title: 'Error!',
200
+ text: 'An error has occured.'
269
201
  });
270
- },
271
- handleImportFileUpload: function handleImportFileUpload(e) {
272
- this.file = this.$refs.file.files[0];
273
- this.importedFile = e.target.files[0];
274
- },
275
- onCloseImportModal: function onCloseImportModal() {
276
- this.currentStep = 1;
277
- this.importedFile = '';
278
- this.importLanguage = '';
279
- this.onlyMissing = false;
280
- this.translationsToImport = null;
202
+ });
203
+ });
204
+ }
205
+ },
206
+ previousStep: function previousStep() {
207
+ this.currentStep--;
208
+ },
209
+ beforeModalOpen: function beforeModalOpen(_ref) {
210
+ var params = _ref.params;
211
+ this.translationId = params.id;
212
+ this.translationDefault = params.key;
213
+ this.translations = {};
214
+ for (var _i = 0, _Object$keys = Object.keys(params.text); _i < _Object$keys.length; _i++) {
215
+ var key = _Object$keys[_i];
216
+ this.translations[key] = params.text[key];
217
+ }
218
+ },
219
+ onSubmit: function onSubmit() {
220
+ var _this4 = this;
221
+ var url = '/admin/translations/' + this.translationId;
222
+ var data = {
223
+ text: this.translations
224
+ };
225
+ axios.post(url, data).then(function (response) {
226
+ _this4.$modal.hide('edit-translation');
227
+ _this4.$notify({
228
+ type: 'success',
229
+ title: 'Success!',
230
+ text: 'Item successfully changed.'
231
+ });
232
+ _this4.loadData();
233
+ }, function (error) {
234
+ _this4.$notify({
235
+ type: 'error',
236
+ title: 'Error!',
237
+ text: 'An error has occured.'
238
+ });
239
+ });
240
+ },
241
+ onSubmitExport: function onSubmitExport() {
242
+ var _this5 = this;
243
+ return this.$validator.validateAll().then(function (result) {
244
+ if (!result) {
245
+ _this5.$notify({
246
+ type: 'error',
247
+ title: 'Error!',
248
+ text: 'The form contains invalid fields.'
249
+ });
250
+ return false;
281
251
  }
252
+ var data = {
253
+ exportLanguages: _this5.languagesToExport
254
+ };
255
+ var url = '/admin/translations/export?' + $.param(data);
256
+ window.location = url;
257
+ _this5.$modal.hide('export-translation');
258
+ });
259
+ },
260
+ handleImportFileUpload: function handleImportFileUpload(e) {
261
+ this.file = this.$refs.file.files[0];
262
+ this.importedFile = e.target.files[0];
263
+ },
264
+ onCloseImportModal: function onCloseImportModal() {
265
+ this.currentStep = 1;
266
+ this.importedFile = '';
267
+ this.importLanguage = '';
268
+ this.onlyMissing = false;
269
+ this.translationsToImport = null;
282
270
  }
271
+ }
283
272
  });
package/dist/ui/index.js CHANGED
@@ -1,33 +1,32 @@
1
- 'use strict';
2
-
3
- require('popper.js');
4
-
5
- require('bootstrap');
6
-
7
- require('@coreui/coreui');
1
+ "use strict";
8
2
 
3
+ require("popper.js");
4
+ require("bootstrap");
5
+ require("@coreui/coreui");
9
6
  $(function () {
10
- // spinner buttons
11
- $('.btn-spinner').on('click', function (e) {
12
- if (!(e.shiftKey || e.ctrlKey || e.metaKey)) {
13
- $(this).css({ 'pointer-events': 'none' });
14
- $(this).find('i').removeClass().addClass('fa fa-spinner');
15
- }
16
- });
7
+ // spinner buttons
8
+ $('.btn-spinner').on('click', function (e) {
9
+ if (!(e.shiftKey || e.ctrlKey || e.metaKey)) {
10
+ $(this).css({
11
+ 'pointer-events': 'none'
12
+ });
13
+ $(this).find('i').removeClass().addClass('fa fa-spinner');
14
+ }
15
+ });
17
16
 
18
- // dropdown Menu
19
- $('.dropdown-toggle').on('click', function () {
20
- $(this).parent().toggleClass('open');
21
- });
22
- $('.dropdown-item').on('click', function () {
23
- $(this).closest('.open').removeClass('open');
24
- });
25
- $('.dropdown-menu').on('mouseleave', function () {
26
- $(this).parent('.dropdown').removeClass('open');
27
- });
17
+ // dropdown Menu
18
+ $('.dropdown-toggle').on('click', function () {
19
+ $(this).parent().toggleClass('open');
20
+ });
21
+ $('.dropdown-item').on('click', function () {
22
+ $(this).closest('.open').removeClass('open');
23
+ });
24
+ $('.dropdown-menu').on('mouseleave', function () {
25
+ $(this).parent('.dropdown').removeClass('open');
26
+ });
28
27
 
29
- // remove empty nav titles when no children there
30
- $('.nav-title').filter(function () {
31
- return !$(this).next().hasClass('nav-item');
32
- }).hide();
28
+ // remove empty nav titles when no children there
29
+ $('.nav-title').filter(function () {
30
+ return !$(this).next().hasClass('nav-item');
31
+ }).hide();
33
32
  });
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@dejwcake/craftable",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "This is a frontend dependency for Craftable. Craftable is a Laravel-based open-source toolkit for building administration interfaces.",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {
7
7
  "test": "echo \"Error: no test specified\" && exit 1",
8
- "js": "babel src --presets babel-preset-es2015 --out-dir dist",
8
+ "js": "babel src --presets @babel/preset-env --out-dir dist",
9
9
  "build": "npm run js",
10
10
  "prepublish": "npm run build"
11
11
  },
@@ -46,15 +46,15 @@
46
46
  "vue2-dropzone": "^2.3.5"
47
47
  },
48
48
  "devDependencies": {
49
+ "@babel/preset-env": "^7.26.9",
50
+ "@babel/cli": "^7.26.4",
49
51
  "autoprefixer": "^9.3.1",
50
- "babel-cli": "^6.26.0",
51
- "babel-preset-es2015": "^6.24.1",
52
52
  "cpx": "^1.5.0",
53
+ "postcss-cli": "^8.3.1",
54
+ "resolve-url-loader": "^3.1.0",
53
55
  "sass": "^1.49.9",
54
56
  "sass-loader": "^8.0.2",
55
- "postcss-cli": "^8.3.1",
56
- "vue-loader": "^15.9.6",
57
- "resolve-url-loader": "^3.1.0"
57
+ "vue-loader": "^15.9.6"
58
58
  },
59
59
  "files": [
60
60
  "/dist",