@dejwcake/craftable 0.1.10 → 2.0.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.
- package/README.md +117 -3
- package/dist/buildMatchPatternFn-BV4I8r8j.js +63 -0
- package/dist/buildMatchPatternFn-T5KjFTBQ.cjs +1 -0
- package/dist/craftable.css +2 -0
- package/dist/cs-B5QMxFrl.js +682 -0
- package/dist/cs-MAoetkhe.cjs +1 -0
- package/dist/de-BlQ2ZKmc.js +526 -0
- package/dist/de-BoVLAn6U.cjs +1 -0
- package/dist/en-US-BLvEnhs4.js +443 -0
- package/dist/en-US-Dz8vkDZ_.cjs +1 -0
- package/dist/en-US-X9gX759i.cjs +1 -0
- package/dist/es-DBHDeXHI.cjs +1 -0
- package/dist/es-YEqfkBY2.js +437 -0
- package/dist/fr-B7MHC2AN.js +407 -0
- package/dist/fr-DLs3QoNB.cjs +1 -0
- package/dist/hu-BKZPI9jH.cjs +1 -0
- package/dist/hu-reoJgNxD.js +425 -0
- package/dist/index.cjs +1 -0
- package/dist/index.mjs +3866 -0
- package/dist/isSameWeek-CC6GX_zp.js +40 -0
- package/dist/isSameWeek-Mctj6Tdj.cjs +1 -0
- package/dist/pl-B5A0Rjp7.js +628 -0
- package/dist/pl-BMyrOO-Q.cjs +1 -0
- package/dist/sk-B7JF2MoV.cjs +1 -0
- package/dist/sk-Btro3W4S.js +602 -0
- package/package.json +68 -40
- package/scripts/publish-components.js +118 -0
- package/scss/_images.scss +1 -1
- package/scss/_variables.scss +13 -6
- package/scss/app.scss +4 -4
- package/scss/overrides/_alerts.scss +0 -2
- package/scss/overrides/_badges.scss +1 -17
- package/scss/overrides/_buttons.scss +64 -7
- package/scss/overrides/_cards.scss +4 -51
- package/scss/overrides/_checkboxes.scss +54 -59
- package/scss/overrides/_forms.scss +270 -176
- package/scss/overrides/_index.scss +18 -18
- package/scss/overrides/_keyframes.scss +6 -4
- package/scss/overrides/_layout.scss +24 -30
- package/scss/overrides/_media-wysiwyg.scss +9 -111
- package/scss/overrides/_modal.scss +0 -18
- package/scss/overrides/_multiselect.scss +63 -7
- package/scss/overrides/_nav.scss +55 -33
- package/scss/overrides/_notifications.scss +6 -1
- package/scss/overrides/_pagination.scss +3 -3
- package/scss/overrides/_sidebar.scss +84 -0
- package/scss/overrides/_tables.scss +52 -37
- package/scss/overrides/_text.scss +1 -3
- package/scss/overrides/_wysiwyg.scss +151 -48
- package/scss/styles/_auth.scss +32 -37
- package/scss/styles/_custom.scss +44 -1
- package/scss/styles/_index.scss +4 -4
- package/scss/styles/_legacy.scss +5 -81
- package/scss/styles/_others.scss +232 -337
- package/scss/vendor/_index.scss +5 -4
- package/src/auth/ActivationError.vue +23 -0
- package/src/auth/ActivationForm.vue +69 -0
- package/src/auth/ForgotPasswordForm.vue +74 -0
- package/src/auth/LoginForm.vue +107 -0
- package/src/auth/ResetPasswordForm.vue +122 -0
- package/src/components/ConfirmModal.vue +65 -0
- package/src/components/UserDetailTooltip.vue +88 -0
- package/src/components/form/CkeditorEditor.vue +205 -0
- package/src/components/form/FormCheckbox.vue +29 -0
- package/src/components/form/FormDatePicker.vue +52 -0
- package/src/components/form/FormEmail.vue +17 -0
- package/src/components/form/FormInput.vue +31 -0
- package/src/components/form/FormLocalizedInput.vue +47 -0
- package/src/components/form/FormLocalizedWysiwyg.vue +55 -0
- package/src/components/form/FormLocalizedWysiwygSimple.vue +55 -0
- package/src/components/form/FormMultiSelect.vue +36 -0
- package/src/components/form/FormPasswordConfirm.vue +49 -0
- package/src/components/form/FormSelect.vue +35 -0
- package/src/components/form/FormSubmit.vue +13 -0
- package/src/components/form/FormTextarea.vue +31 -0
- package/src/components/form/FormWysiwyg.vue +31 -0
- package/src/components/form/FormWysiwygSimple.vue +31 -0
- package/src/components/form/LocalizationBar.vue +90 -0
- package/src/components/form/MediaUpload.vue +317 -0
- package/src/components/form/TiptapEditor.vue +238 -0
- package/src/components/listing/BulkCheckboxHeader.vue +18 -0
- package/src/components/listing/BulkCheckboxRow.vue +21 -0
- package/src/components/listing/BulkOperationsBar.vue +41 -0
- package/src/components/listing/DeleteButton.vue +46 -0
- package/src/components/listing/EditButton.vue +17 -0
- package/src/components/listing/EmptyState.vue +25 -0
- package/src/components/listing/ListingHeader.vue +24 -0
- package/src/components/listing/Pagination.vue +158 -0
- package/src/components/listing/PerPage.vue +15 -0
- package/src/components/listing/PublishedAtColumn.vue +226 -0
- package/src/components/listing/Search.vue +81 -0
- package/src/components/listing/Sortable.vue +28 -0
- package/src/components/listing/ToggleSwitch.vue +47 -0
- package/src/composables/useAdmin.js +39 -0
- package/src/composables/useBaseAuth.js +81 -0
- package/src/composables/useBaseForm.js +265 -0
- package/src/composables/useBaseListing.js +316 -0
- package/src/composables/useResponsiveColumns.js +62 -0
- package/src/index.js +62 -0
- package/src/translation/TranslationListing.vue +230 -0
- package/src/translation/modals/TranslationEditModal.vue +86 -0
- package/src/translation/modals/TranslationExportModal.vue +74 -0
- package/src/translation/modals/TranslationImportModal.vue +255 -0
- package/src/ui/index.js +99 -0
- package/src/utils/ckeditorHelpers.js +36 -0
- package/src/utils/dateFnsLocale.js +24 -0
- package/src/utils/dateFormatters.js +30 -0
- package/src/utils/mediaProps.js +14 -0
- package/src/utils/notify.js +22 -0
- package/dist/admin/Admin.js +0 -42
- package/dist/auth/Form.js +0 -15
- package/dist/base-components/Form/BaseForm.js +0 -395
- package/dist/base-components/Form/BaseUpload.js +0 -188
- package/dist/base-components/Form/bootstrap.js +0 -21
- package/dist/base-components/Listing/BaseListing.js +0 -454
- package/dist/base-components/Listing/components/Pagination.js +0 -105
- package/dist/base-components/Listing/components/Sortable.js +0 -48
- package/dist/base-components/Listing/components/UserDetailTooltip.js +0 -55
- package/dist/index.js +0 -70
- package/dist/overrides/trumbowyg.edit-embed-template.js +0 -72
- package/dist/overrides/trumbowyg.reupload.js +0 -146
- package/dist/overrides/trumbowyg.template.js +0 -67
- package/dist/translation/Form.js +0 -15
- package/dist/translation/Listing.js +0 -283
- package/dist/ui/index.js +0 -33
- package/scss/overrides/_switches.scss +0 -25
package/src/ui/index.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
export function initUI() {
|
|
2
|
+
if (document.readyState === 'loading') {
|
|
3
|
+
document.addEventListener('DOMContentLoaded', initUIHandlers);
|
|
4
|
+
} else {
|
|
5
|
+
initUIHandlers();
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function initUIHandlers() {
|
|
10
|
+
const sidebar = document.getElementById('sidebar');
|
|
11
|
+
let backdrop = null;
|
|
12
|
+
|
|
13
|
+
// Spinner buttons
|
|
14
|
+
document.querySelectorAll('.btn-spinner').forEach((btn) => {
|
|
15
|
+
btn.addEventListener('click', (e) => {
|
|
16
|
+
if (!(e.shiftKey || e.ctrlKey || e.metaKey)) {
|
|
17
|
+
btn.style.pointerEvents = 'none';
|
|
18
|
+
const icon = btn.querySelector('i');
|
|
19
|
+
if (icon) {
|
|
20
|
+
icon.className = 'fa-solid fa-spinner fa-spin';
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// Remove empty nav titles when no children there
|
|
27
|
+
document.querySelectorAll('.nav-title').forEach((title) => {
|
|
28
|
+
const next = title.nextElementSibling;
|
|
29
|
+
if (!next || !next.classList.contains('nav-item')) {
|
|
30
|
+
title.style.display = 'none';
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// Sidebar: mobile show/hide toggle
|
|
35
|
+
function closeSidebar() {
|
|
36
|
+
if (!sidebar) return;
|
|
37
|
+
sidebar.classList.add('hide');
|
|
38
|
+
if (backdrop) {
|
|
39
|
+
backdrop.remove();
|
|
40
|
+
backdrop = null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
document.querySelectorAll('[data-coreui-toggle="sidebar"]').forEach((btn) => {
|
|
45
|
+
btn.addEventListener('click', () => {
|
|
46
|
+
if (!sidebar) return;
|
|
47
|
+
const isHidden = sidebar.classList.contains('hide');
|
|
48
|
+
if (isHidden) {
|
|
49
|
+
sidebar.classList.remove('hide');
|
|
50
|
+
// Create backdrop for mobile
|
|
51
|
+
backdrop = document.createElement('div');
|
|
52
|
+
backdrop.className = 'sidebar-backdrop fade show';
|
|
53
|
+
backdrop.addEventListener('click', closeSidebar);
|
|
54
|
+
document.body.appendChild(backdrop);
|
|
55
|
+
} else {
|
|
56
|
+
closeSidebar();
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// Sidebar: desktop unfoldable (narrow) toggle
|
|
62
|
+
document.querySelectorAll('[data-coreui-toggle="unfoldable"]').forEach((btn) => {
|
|
63
|
+
btn.addEventListener('click', () => {
|
|
64
|
+
if (!sidebar) return;
|
|
65
|
+
sidebar.classList.toggle('sidebar-narrow-unfoldable');
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// Dropdowns
|
|
70
|
+
document.querySelectorAll('[data-coreui-toggle="dropdown"]').forEach((toggle) => {
|
|
71
|
+
toggle.addEventListener('click', (e) => {
|
|
72
|
+
e.preventDefault();
|
|
73
|
+
const dropdown = toggle.closest('.dropdown');
|
|
74
|
+
if (!dropdown) return;
|
|
75
|
+
const menu = dropdown.querySelector('.dropdown-menu');
|
|
76
|
+
if (!menu) return;
|
|
77
|
+
const isOpen = menu.classList.contains('show');
|
|
78
|
+
|
|
79
|
+
// Close all other open dropdowns
|
|
80
|
+
document.querySelectorAll('.dropdown-menu.show').forEach((m) => m.classList.remove('show'));
|
|
81
|
+
|
|
82
|
+
if (!isOpen) {
|
|
83
|
+
menu.classList.add('show');
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// Close dropdowns when clicking outside
|
|
89
|
+
document.addEventListener('click', (e) => {
|
|
90
|
+
if (!e.target.closest('.dropdown')) {
|
|
91
|
+
document.querySelectorAll('.dropdown-menu.show').forEach((m) => m.classList.remove('show'));
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
// On mobile, sidebar starts hidden
|
|
96
|
+
if (sidebar && window.innerWidth < 992) {
|
|
97
|
+
sidebar.classList.add('hide');
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export function propagateImageWidths(html) {
|
|
2
|
+
if (!html) return html;
|
|
3
|
+
const parser = new DOMParser();
|
|
4
|
+
const doc = parser.parseFromString(html, 'text/html');
|
|
5
|
+
let changed = false;
|
|
6
|
+
doc.querySelectorAll('figure').forEach((figure) => {
|
|
7
|
+
const width = figure.style.width;
|
|
8
|
+
if (!width) return;
|
|
9
|
+
const img = figure.querySelector('img');
|
|
10
|
+
if (img) {
|
|
11
|
+
img.style.width = width;
|
|
12
|
+
img.style.height = 'auto';
|
|
13
|
+
changed = true;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
return changed ? doc.body.innerHTML : html;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function deepMerge(target, source) {
|
|
20
|
+
const result = { ...target };
|
|
21
|
+
for (const key of Object.keys(source)) {
|
|
22
|
+
if (
|
|
23
|
+
source[key] &&
|
|
24
|
+
typeof source[key] === 'object' &&
|
|
25
|
+
!Array.isArray(source[key]) &&
|
|
26
|
+
target[key] &&
|
|
27
|
+
typeof target[key] === 'object' &&
|
|
28
|
+
!Array.isArray(target[key])
|
|
29
|
+
) {
|
|
30
|
+
result[key] = deepMerge(target[key], source[key]);
|
|
31
|
+
} else {
|
|
32
|
+
result[key] = source[key];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { enUS } from 'date-fns/locale/en-US';
|
|
2
|
+
|
|
3
|
+
let resolvedLocale = enUS;
|
|
4
|
+
|
|
5
|
+
export function getDateFnsLocale() {
|
|
6
|
+
return resolvedLocale;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export async function initDateFnsLocale() {
|
|
10
|
+
const lang = document.documentElement.lang || 'en';
|
|
11
|
+
const map = {
|
|
12
|
+
sk: () => import('date-fns/locale/sk'),
|
|
13
|
+
cs: () => import('date-fns/locale/cs'),
|
|
14
|
+
en: () => import('date-fns/locale/en-US'),
|
|
15
|
+
de: () => import('date-fns/locale/de'),
|
|
16
|
+
fr: () => import('date-fns/locale/fr'),
|
|
17
|
+
es: () => import('date-fns/locale/es'),
|
|
18
|
+
pl: () => import('date-fns/locale/pl'),
|
|
19
|
+
hu: () => import('date-fns/locale/hu'),
|
|
20
|
+
};
|
|
21
|
+
const loader = map[lang] || map['en'];
|
|
22
|
+
const mod = await loader();
|
|
23
|
+
resolvedLocale = mod.default || mod[Object.keys(mod)[0]];
|
|
24
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
|
+
import customParseFormat from 'dayjs/plugin/customParseFormat.js';
|
|
3
|
+
import utc from 'dayjs/plugin/utc.js';
|
|
4
|
+
import timezone from 'dayjs/plugin/timezone.js';
|
|
5
|
+
|
|
6
|
+
dayjs.extend(customParseFormat);
|
|
7
|
+
dayjs.extend(utc);
|
|
8
|
+
dayjs.extend(timezone);
|
|
9
|
+
|
|
10
|
+
export function formatDate(date, format = 'DD.MM.YYYY') {
|
|
11
|
+
const d = dayjs(date);
|
|
12
|
+
return d.isValid() ? d.format(format) : '';
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function formatDatetime(datetime, format = 'DD.MM.YYYY HH:mm') {
|
|
16
|
+
const d = dayjs(datetime);
|
|
17
|
+
return d.isValid() ? d.format(format) : '';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function formatTime(time, format = 'HH:mm') {
|
|
21
|
+
// '2000-01-01' is here just because dayjs needs a date
|
|
22
|
+
const d = dayjs('2000-01-01 ' + time);
|
|
23
|
+
return d.isValid() ? d.format(format) : '';
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function nowInTimezone(tz = 'UTC', format = 'YYYY-MM-DD HH:mm:ss') {
|
|
27
|
+
return dayjs().tz(tz).format(format);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { dayjs };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const mediaCollectionDefaults = {
|
|
2
|
+
url: '',
|
|
3
|
+
collection: '',
|
|
4
|
+
maxNumberOfFiles: 1,
|
|
5
|
+
maxFileSizeInMb: 2,
|
|
6
|
+
acceptedFileTypes: undefined,
|
|
7
|
+
thumbnailWidth: 200,
|
|
8
|
+
uploadedMedia: [],
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const mediaCollectionProp = {
|
|
12
|
+
type: Object,
|
|
13
|
+
default: () => ({ ...mediaCollectionDefaults }),
|
|
14
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { notify } from '@kyvg/vue3-notification';
|
|
2
|
+
|
|
3
|
+
const DEFAULT_SUCCESS_TITLE = 'Success!';
|
|
4
|
+
const DEFAULT_SUCCESS_MESSAGE = 'Operation succeeded.';
|
|
5
|
+
const DEFAULT_ERROR_TITLE = 'Error!';
|
|
6
|
+
const DEFAULT_ERROR_MESSAGE = 'An error has occurred.';
|
|
7
|
+
|
|
8
|
+
export function notifySuccess(message) {
|
|
9
|
+
notify({
|
|
10
|
+
type: 'success',
|
|
11
|
+
title: DEFAULT_SUCCESS_TITLE,
|
|
12
|
+
text: message || DEFAULT_SUCCESS_MESSAGE,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function notifyError(message) {
|
|
17
|
+
notify({
|
|
18
|
+
type: 'error',
|
|
19
|
+
title: DEFAULT_ERROR_TITLE,
|
|
20
|
+
text: message || DEFAULT_ERROR_MESSAGE,
|
|
21
|
+
});
|
|
22
|
+
}
|
package/dist/admin/Admin.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var Admin = {
|
|
7
|
-
el: '#app',
|
|
8
|
-
data: function data() {
|
|
9
|
-
return {
|
|
10
|
-
loading: false
|
|
11
|
-
};
|
|
12
|
-
},
|
|
13
|
-
mounted: function mounted() {
|
|
14
|
-
var _this = this;
|
|
15
|
-
|
|
16
|
-
// Add a loader request interceptor
|
|
17
|
-
axios.interceptors.request.use(function (config) {
|
|
18
|
-
_this.setLoading(true);
|
|
19
|
-
return config;
|
|
20
|
-
}, function (error) {
|
|
21
|
-
_this.setLoading(false);
|
|
22
|
-
return Promise.reject(error);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
// Add a loader response interceptor
|
|
26
|
-
axios.interceptors.response.use(function (response) {
|
|
27
|
-
_this.setLoading(false);
|
|
28
|
-
return response;
|
|
29
|
-
}, function (error) {
|
|
30
|
-
_this.setLoading(false);
|
|
31
|
-
return Promise.reject(error);
|
|
32
|
-
});
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
methods: {
|
|
36
|
-
setLoading: function setLoading(value) {
|
|
37
|
-
this.loading = !!value;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
exports.default = Admin;
|
package/dist/auth/Form.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var _vue = require('vue');
|
|
4
|
-
|
|
5
|
-
var _vue2 = _interopRequireDefault(_vue);
|
|
6
|
-
|
|
7
|
-
var _BaseForm = require('../base-components/Form/BaseForm');
|
|
8
|
-
|
|
9
|
-
var _BaseForm2 = _interopRequireDefault(_BaseForm);
|
|
10
|
-
|
|
11
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
|
|
13
|
-
_vue2.default.component('auth-form', {
|
|
14
|
-
mixins: [_BaseForm2.default]
|
|
15
|
-
});
|
|
@@ -1,395 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
|
8
|
-
|
|
9
|
-
require('./bootstrap');
|
|
10
|
-
|
|
11
|
-
var _moment = require('moment');
|
|
12
|
-
|
|
13
|
-
var _moment2 = _interopRequireDefault(_moment);
|
|
14
|
-
|
|
15
|
-
var _vueTrumbowyg = require('vue-trumbowyg');
|
|
16
|
-
|
|
17
|
-
var _vueTrumbowyg2 = _interopRequireDefault(_vueTrumbowyg);
|
|
18
|
-
|
|
19
|
-
require('trumbowyg/dist/ui/trumbowyg.css');
|
|
20
|
-
|
|
21
|
-
require('trumbowyg/dist/plugins/colors/trumbowyg.colors');
|
|
22
|
-
|
|
23
|
-
require('trumbowyg/dist/plugins/colors/ui/trumbowyg.colors.css');
|
|
24
|
-
|
|
25
|
-
require('trumbowyg/dist/plugins/base64/trumbowyg.base64.min.js');
|
|
26
|
-
|
|
27
|
-
require('trumbowyg/dist/plugins/upload/trumbowyg.upload.js');
|
|
28
|
-
|
|
29
|
-
require('trumbowyg/dist/plugins/noembed/trumbowyg.noembed.js');
|
|
30
|
-
|
|
31
|
-
require('trumbowyg/dist/plugins/pasteembed/trumbowyg.pasteembed.js');
|
|
32
|
-
|
|
33
|
-
require('trumbowyg/dist/plugins/table/ui/trumbowyg.table.css');
|
|
34
|
-
|
|
35
|
-
require('trumbowyg/dist/plugins/table/trumbowyg.table.js');
|
|
36
|
-
|
|
37
|
-
require('../../overrides/trumbowyg.template');
|
|
38
|
-
|
|
39
|
-
require('../../overrides/trumbowyg.reupload');
|
|
40
|
-
|
|
41
|
-
require('../../overrides/trumbowyg.edit-embed-template');
|
|
42
|
-
|
|
43
|
-
var _UserDetailTooltip = require('../Listing/components/UserDetailTooltip');
|
|
44
|
-
|
|
45
|
-
var _UserDetailTooltip2 = _interopRequireDefault(_UserDetailTooltip);
|
|
46
|
-
|
|
47
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
48
|
-
|
|
49
|
-
Vue.component('wysiwyg', _vueTrumbowyg2.default);
|
|
50
|
-
|
|
51
|
-
var BaseForm = {
|
|
52
|
-
props: {
|
|
53
|
-
action: {
|
|
54
|
-
type: String,
|
|
55
|
-
required: true
|
|
56
|
-
},
|
|
57
|
-
locales: {
|
|
58
|
-
type: Array
|
|
59
|
-
},
|
|
60
|
-
defaultLocale: {
|
|
61
|
-
type: String,
|
|
62
|
-
default: function _default() {
|
|
63
|
-
return this.locales instanceof Array && this.locales.length > 0 ? this.locales[0] : '';
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
sendEmptyLocales: {
|
|
67
|
-
type: Boolean,
|
|
68
|
-
default: function _default() {
|
|
69
|
-
return true;
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
data: {
|
|
73
|
-
type: Object,
|
|
74
|
-
default: function _default() {
|
|
75
|
-
return {};
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
responsiveBreakpoint: {
|
|
79
|
-
type: Number,
|
|
80
|
-
default: 850
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
components: {
|
|
84
|
-
'user-detail-tooltip': _UserDetailTooltip2.default
|
|
85
|
-
},
|
|
86
|
-
|
|
87
|
-
created: function created() {
|
|
88
|
-
if (!!this.locales && this.locales.length > 0) {
|
|
89
|
-
var form = this.form;
|
|
90
|
-
// this.locales.map(function(l) {
|
|
91
|
-
// if (!_.has(form, l)) {
|
|
92
|
-
// _.set(form, l, {})
|
|
93
|
-
// }
|
|
94
|
-
// })
|
|
95
|
-
this.currentLocale = this.defaultLocale;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
//FIXME: now we can't add dynamic input in update type of form
|
|
99
|
-
if (!_.isEmpty(this.data)) {
|
|
100
|
-
this.form = this.data;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
window.addEventListener('resize', this.onResize);
|
|
104
|
-
},
|
|
105
|
-
|
|
106
|
-
data: function data() {
|
|
107
|
-
var that = this;
|
|
108
|
-
|
|
109
|
-
return {
|
|
110
|
-
form: {},
|
|
111
|
-
wysiwygMedia: [],
|
|
112
|
-
mediaCollections: [],
|
|
113
|
-
isFormLocalized: false,
|
|
114
|
-
currentLocale: '',
|
|
115
|
-
submiting: false,
|
|
116
|
-
onSmallScreen: window.innerWidth < this.responsiveBreakpoint,
|
|
117
|
-
datePickerConfig: {
|
|
118
|
-
dateFormat: 'Y-m-d H:i:S',
|
|
119
|
-
altInput: true,
|
|
120
|
-
altFormat: 'd.m.Y',
|
|
121
|
-
locale: null
|
|
122
|
-
},
|
|
123
|
-
timePickerConfig: {
|
|
124
|
-
enableTime: true,
|
|
125
|
-
noCalendar: true,
|
|
126
|
-
time_24hr: true,
|
|
127
|
-
enableSeconds: true,
|
|
128
|
-
dateFormat: 'H:i:S',
|
|
129
|
-
altInput: true,
|
|
130
|
-
altFormat: 'H:i:S',
|
|
131
|
-
locale: null
|
|
132
|
-
},
|
|
133
|
-
datetimePickerConfig: {
|
|
134
|
-
enableTime: true,
|
|
135
|
-
time_24hr: true,
|
|
136
|
-
enableSeconds: true,
|
|
137
|
-
dateFormat: 'Y-m-d H:i:S',
|
|
138
|
-
altInput: true,
|
|
139
|
-
altFormat: 'd.m.Y H:i:S',
|
|
140
|
-
locale: null
|
|
141
|
-
},
|
|
142
|
-
wysiwygConfig: {
|
|
143
|
-
placeholder: 'Type a text here',
|
|
144
|
-
modules: {
|
|
145
|
-
toolbar: {
|
|
146
|
-
container: [[{ header: [1, 2, 3, 4, 5, 6, false] }], ['bold', 'italic', 'underline', 'strike'], [{ list: 'ordered' }, { list: 'bullet' }], [{ color: [] }, { background: [] }], [{ align: [] }], ['link', 'image'], ['clean']]
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
},
|
|
150
|
-
mediaWysiwygConfig: {
|
|
151
|
-
autogrow: true,
|
|
152
|
-
imageWidthModalEdit: true,
|
|
153
|
-
btnsDef: {
|
|
154
|
-
image: {
|
|
155
|
-
dropdown: ['insertImage', 'upload', 'base64'],
|
|
156
|
-
ico: 'insertImage'
|
|
157
|
-
},
|
|
158
|
-
align: {
|
|
159
|
-
dropdown: ['justifyLeft', 'justifyCenter', 'justifyRight', 'justifyFull'],
|
|
160
|
-
ico: 'justifyLeft'
|
|
161
|
-
}
|
|
162
|
-
},
|
|
163
|
-
btns: [['formatting'], ['strong', 'em', 'del'], ['align'], ['unorderedList', 'orderedList', 'table'], ['foreColor', 'backColor'], ['link', 'noembed', 'image'], ['template'], ['fullscreen', 'viewHTML']],
|
|
164
|
-
plugins: {
|
|
165
|
-
upload: {
|
|
166
|
-
// https://alex-d.github.io/Trumbowyg/documentation/plugins/#plugin-upload
|
|
167
|
-
serverPath: '/admin/wysiwyg-media',
|
|
168
|
-
headers: {
|
|
169
|
-
'X-CSRF-TOKEN': document.head.querySelector('meta[name="csrf-token"]').getAttribute('content')
|
|
170
|
-
},
|
|
171
|
-
imageWidthModalEdit: true,
|
|
172
|
-
success: function success(data, trumbowyg, $modal, values) {
|
|
173
|
-
that.wysiwygMedia.push(data.mediaId);
|
|
174
|
-
|
|
175
|
-
function getDeep(object, propertyParts) {
|
|
176
|
-
var mainProperty = propertyParts.shift(),
|
|
177
|
-
otherProperties = propertyParts;
|
|
178
|
-
|
|
179
|
-
if (object !== null) {
|
|
180
|
-
if (otherProperties.length === 0) {
|
|
181
|
-
return object[mainProperty];
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
if ((typeof object === 'undefined' ? 'undefined' : _typeof(object)) === 'object') {
|
|
185
|
-
return getDeep(object[mainProperty], otherProperties);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
return object;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
if (!!getDeep(data, trumbowyg.o.plugins.upload.statusPropertyName.split('.'))) {
|
|
192
|
-
var url = getDeep(data, trumbowyg.o.plugins.upload.urlPropertyName.split('.'));
|
|
193
|
-
trumbowyg.execCmd('insertImage', url, false, true);
|
|
194
|
-
var $img = $('img[src="' + url + '"]:not([alt])', trumbowyg.$box);
|
|
195
|
-
$img.attr('alt', values.alt);
|
|
196
|
-
if (trumbowyg.o.imageWidthModalEdit && parseInt(values.width) > 0) {
|
|
197
|
-
$img.attr({
|
|
198
|
-
width: values.width
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
setTimeout(function () {
|
|
202
|
-
trumbowyg.closeModal();
|
|
203
|
-
}, 250);
|
|
204
|
-
trumbowyg.$c.trigger('tbwuploadsuccess', [trumbowyg, data, url]);
|
|
205
|
-
} else {
|
|
206
|
-
trumbowyg.addErrorOnModalField($('input[type=file]', $modal), trumbowyg.lang[data.message]);
|
|
207
|
-
trumbowyg.$c.trigger('tbwuploaderror', [trumbowyg, data]);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
},
|
|
211
|
-
reupload: {
|
|
212
|
-
success: function success(data, trumbowyg, $modal, values, $img) {
|
|
213
|
-
that.wysiwygMedia.push(data.mediaId);
|
|
214
|
-
|
|
215
|
-
$img.attr({
|
|
216
|
-
src: data.file
|
|
217
|
-
});
|
|
218
|
-
trumbowyg.execCmd('insertHTML');
|
|
219
|
-
setTimeout(function () {
|
|
220
|
-
trumbowyg.closeModal();
|
|
221
|
-
}, 250);
|
|
222
|
-
var url = getDeep(data, trumbowyg.o.plugins.upload.urlPropertyName.split('.'));
|
|
223
|
-
trumbowyg.$c.trigger('tbwuploadsuccess', [trumbowyg, data, url]);
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
};
|
|
229
|
-
},
|
|
230
|
-
|
|
231
|
-
computed: {
|
|
232
|
-
otherLocales: function otherLocales() {
|
|
233
|
-
var _this = this;
|
|
234
|
-
|
|
235
|
-
return this.locales.filter(function (x) {
|
|
236
|
-
return x != _this.defaultLocale;
|
|
237
|
-
});
|
|
238
|
-
},
|
|
239
|
-
showLocalizedValidationError: function showLocalizedValidationError() {
|
|
240
|
-
var _this2 = this;
|
|
241
|
-
|
|
242
|
-
// TODO ked sme neni na mobile, tak pozerat zo vsetkych
|
|
243
|
-
return this.otherLocales.some(function (lang) {
|
|
244
|
-
return _this2.errors.items.some(function (item) {
|
|
245
|
-
return item.field.endsWith('_' + lang) || item.field.startsWith(lang + '_');
|
|
246
|
-
});
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
|
-
},
|
|
250
|
-
filters: {
|
|
251
|
-
date: function date(date) {
|
|
252
|
-
var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'YYYY-MM-DD';
|
|
253
|
-
|
|
254
|
-
var date = (0, _moment2.default)(date);
|
|
255
|
-
return date.isValid() ? date.format(format) : "";
|
|
256
|
-
},
|
|
257
|
-
datetime: function datetime(_datetime) {
|
|
258
|
-
var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'YYYY-MM-DD HH:mm:ss';
|
|
259
|
-
|
|
260
|
-
var date = (0, _moment2.default)(_datetime);
|
|
261
|
-
return date.isValid() ? date.format(format) : "";
|
|
262
|
-
},
|
|
263
|
-
time: function time(_time) {
|
|
264
|
-
var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'HH:mm:ss';
|
|
265
|
-
|
|
266
|
-
// '2000-01-01' is here just because momentjs needs a date
|
|
267
|
-
var date = (0, _moment2.default)('2000-01-01 ' + _time);
|
|
268
|
-
return date.isValid() ? date.format(format) : "";
|
|
269
|
-
}
|
|
270
|
-
},
|
|
271
|
-
methods: {
|
|
272
|
-
getPostData: function getPostData() {
|
|
273
|
-
var _this3 = this;
|
|
274
|
-
|
|
275
|
-
if (this.mediaCollections) {
|
|
276
|
-
this.mediaCollections.forEach(function (collection, index, arr) {
|
|
277
|
-
if (_this3.form[collection]) {
|
|
278
|
-
console.warn("MediaUploader warning: Media input must have a unique name, '" + collection + "' is already defined in regular inputs.");
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
if (_this3.$refs[collection + '_uploader']) {
|
|
282
|
-
_this3.form[collection] = _this3.$refs[collection + '_uploader'].getFiles();
|
|
283
|
-
}
|
|
284
|
-
});
|
|
285
|
-
}
|
|
286
|
-
this.form['wysiwygMedia'] = this.wysiwygMedia;
|
|
287
|
-
|
|
288
|
-
return this.form;
|
|
289
|
-
},
|
|
290
|
-
onSubmit: function onSubmit() {
|
|
291
|
-
var _this4 = this;
|
|
292
|
-
|
|
293
|
-
return this.$validator.validateAll().then(function (result) {
|
|
294
|
-
if (!result) {
|
|
295
|
-
_this4.$notify({
|
|
296
|
-
type: 'error',
|
|
297
|
-
title: 'Error!',
|
|
298
|
-
text: 'The form contains invalid fields.'
|
|
299
|
-
});
|
|
300
|
-
return false;
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
var data = _this4.form;
|
|
304
|
-
if (!_this4.sendEmptyLocales) {
|
|
305
|
-
data = _.omit(_this4.form, _this4.locales.filter(function (locale) {
|
|
306
|
-
return _.isEmpty(_this4.form[locale]);
|
|
307
|
-
}));
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
_this4.submiting = true;
|
|
311
|
-
|
|
312
|
-
axios.post(_this4.action, _this4.getPostData()).then(function (response) {
|
|
313
|
-
return _this4.onSuccess(response.data);
|
|
314
|
-
}).catch(function (errors) {
|
|
315
|
-
return _this4.onFail(errors.response.data);
|
|
316
|
-
});
|
|
317
|
-
});
|
|
318
|
-
},
|
|
319
|
-
onSuccess: function onSuccess(data) {
|
|
320
|
-
this.submiting = false;
|
|
321
|
-
if (data.redirect) {
|
|
322
|
-
window.location.replace(data.redirect);
|
|
323
|
-
}
|
|
324
|
-
},
|
|
325
|
-
onFail: function onFail(data) {
|
|
326
|
-
this.submiting = false;
|
|
327
|
-
if (_typeof(data.errors) !== (typeof undefined === 'undefined' ? 'undefined' : _typeof(undefined))) {
|
|
328
|
-
var bag = this.$validator.errors;
|
|
329
|
-
bag.clear();
|
|
330
|
-
Object.keys(data.errors).map(function (key) {
|
|
331
|
-
var splitted = key.split('.', 2);
|
|
332
|
-
// we assume that first dot divides column and locale (TODO maybe refactor this and make it more general)
|
|
333
|
-
if (splitted.length > 1) {
|
|
334
|
-
bag.add({
|
|
335
|
-
field: splitted[0] + '_' + splitted[1],
|
|
336
|
-
msg: data.errors[key][0]
|
|
337
|
-
});
|
|
338
|
-
} else {
|
|
339
|
-
bag.add({
|
|
340
|
-
field: key,
|
|
341
|
-
msg: data.errors[key][0]
|
|
342
|
-
});
|
|
343
|
-
}
|
|
344
|
-
});
|
|
345
|
-
if (_typeof(data.message) === (typeof undefined === 'undefined' ? 'undefined' : _typeof(undefined))) {
|
|
346
|
-
this.$notify({
|
|
347
|
-
type: 'error',
|
|
348
|
-
title: 'Error!',
|
|
349
|
-
text: 'The form contains invalid fields.'
|
|
350
|
-
});
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
if (_typeof(data.message) !== (typeof undefined === 'undefined' ? 'undefined' : _typeof(undefined))) {
|
|
354
|
-
this.$notify({
|
|
355
|
-
type: 'error',
|
|
356
|
-
title: 'Error!',
|
|
357
|
-
text: data.message
|
|
358
|
-
});
|
|
359
|
-
}
|
|
360
|
-
},
|
|
361
|
-
getLocalizedFormDefaults: function getLocalizedFormDefaults() {
|
|
362
|
-
var object = {};
|
|
363
|
-
this.locales.forEach(function (currentValue, index, arr) {
|
|
364
|
-
object[currentValue] = null;
|
|
365
|
-
});
|
|
366
|
-
return object;
|
|
367
|
-
},
|
|
368
|
-
showLocalization: function showLocalization() {
|
|
369
|
-
this.isFormLocalized = true;
|
|
370
|
-
this.currentLocale = this.otherLocales[0];
|
|
371
|
-
$('.container-xl').addClass('width-auto');
|
|
372
|
-
},
|
|
373
|
-
hideLocalization: function hideLocalization() {
|
|
374
|
-
this.isFormLocalized = false;
|
|
375
|
-
$('.container-xl').removeClass('width-auto');
|
|
376
|
-
},
|
|
377
|
-
validate: function validate(event) {
|
|
378
|
-
this.$validator.errors.remove(event.target.name);
|
|
379
|
-
},
|
|
380
|
-
shouldShowLangGroup: function shouldShowLangGroup(locale) {
|
|
381
|
-
if (!this.onSmallScreen) {
|
|
382
|
-
if (this.defaultLocale == locale) return true;
|
|
383
|
-
|
|
384
|
-
return this.isFormLocalized && this.currentLocale == locale;
|
|
385
|
-
} else {
|
|
386
|
-
return this.currentLocale == locale;
|
|
387
|
-
}
|
|
388
|
-
},
|
|
389
|
-
onResize: function onResize() {
|
|
390
|
-
this.onSmallScreen = window.innerWidth < this.responsiveBreakpoint;
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
};
|
|
394
|
-
|
|
395
|
-
exports.default = BaseForm;
|