comfy_middle_seat 4.0.0 → 4.0.1
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 +4 -4
- data/app/assets/javascripts/comfy/admin/cms/application.js +0 -1
- data/app/assets/javascripts/comfy/admin/cms/base.js +0 -2
- data/app/helpers/comfy/admin/cms_helper.rb +0 -4
- data/config/locales/ar.yml +0 -2
- data/config/locales/ca.yml +0 -2
- data/config/locales/cs.yml +0 -2
- data/config/locales/da.yml +0 -2
- data/config/locales/de.yml +0 -2
- data/config/locales/en.yml +0 -2
- data/config/locales/es.yml +0 -2
- data/config/locales/fi.yml +0 -2
- data/config/locales/fr.yml +0 -2
- data/config/locales/gr.yml +0 -2
- data/config/locales/hr.yml +0 -2
- data/config/locales/it.yml +0 -2
- data/config/locales/ja.yml +0 -2
- data/config/locales/nb.yml +0 -2
- data/config/locales/nl.yml +0 -2
- data/config/locales/pl.yml +0 -2
- data/config/locales/pt-BR.yml +0 -2
- data/config/locales/ru.yml +0 -2
- data/config/locales/sk.yml +0 -2
- data/config/locales/sv.yml +0 -2
- data/config/locales/tr.yml +0 -2
- data/config/locales/uk.yml +0 -2
- data/config/locales/zh-CN.yml +0 -2
- data/config/locales/zh-TW.yml +0 -2
- data/lib/comfy_middle_seat/version.rb +1 -1
- metadata +1 -2
- data/app/assets/javascripts/comfy/admin/cms/dirty_forms.js +0 -201
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c2b743bb8f3cdbae17801963c031a890072c7b4694336e155dd0d381a49ec2ff
|
|
4
|
+
data.tar.gz: c73a92f4aa40a06760914731d40cd0c9f7471b5abf20aa3710f522d300353f84
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: edd044c383fafb4c9c310df6c83e35f365fa5aeac4052f844f0fd8051a89b1b63564af6ad6ddc5a12637a866b700f34ce3342d077ca9e54dacf20b35a3ccec2a
|
|
7
|
+
data.tar.gz: 204fac7b1e4c2b3bfc3677529fede906334ffe97cdda1180a24c19a40c6b8175b0a13e6635b2d5d1ad78cb87e9fdd1c62c604f057f28193ca23065d6375b3374
|
|
@@ -32,13 +32,11 @@
|
|
|
32
32
|
CMS.fileUpload.init();
|
|
33
33
|
CMS.diff();
|
|
34
34
|
CMS.draftForms.init();
|
|
35
|
-
CMS.dirtyForms.init();
|
|
36
35
|
};
|
|
37
36
|
|
|
38
37
|
CMS.dispose = () => {
|
|
39
38
|
CMS.pageFragments.dispose();
|
|
40
39
|
CMS.draftForms.dispose();
|
|
41
|
-
CMS.dirtyForms.dispose();
|
|
42
40
|
CMS.codemirror.dispose();
|
|
43
41
|
CMS.wysiwyg.dispose();
|
|
44
42
|
CMS.files.dispose();
|
|
@@ -26,10 +26,6 @@ module Comfy
|
|
|
26
26
|
def cms_draft_form_data(*key_parts, record:)
|
|
27
27
|
namespace = session[:comfy_cms_draft_namespace] ||= SecureRandom.hex(16)
|
|
28
28
|
{
|
|
29
|
-
cms_unsaved_message: t(
|
|
30
|
-
'comfy.admin.cms.forms.unsaved_changes',
|
|
31
|
-
default: 'You have unsaved changes. Are you sure you want to leave this page?'
|
|
32
|
-
),
|
|
33
29
|
cms_draft_key: ['comfy-cms:draft:v1', namespace, *key_parts].join(':'),
|
|
34
30
|
cms_draft_title: t('comfy.admin.cms.drafts.title', default: 'Unsaved draft found'),
|
|
35
31
|
cms_draft_message: t(
|
data/config/locales/ar.yml
CHANGED
data/config/locales/ca.yml
CHANGED
data/config/locales/cs.yml
CHANGED
data/config/locales/da.yml
CHANGED
data/config/locales/de.yml
CHANGED
data/config/locales/en.yml
CHANGED
data/config/locales/es.yml
CHANGED
data/config/locales/fi.yml
CHANGED
data/config/locales/fr.yml
CHANGED
data/config/locales/gr.yml
CHANGED
data/config/locales/hr.yml
CHANGED
data/config/locales/it.yml
CHANGED
data/config/locales/ja.yml
CHANGED
data/config/locales/nb.yml
CHANGED
data/config/locales/nl.yml
CHANGED
data/config/locales/pl.yml
CHANGED
data/config/locales/pt-BR.yml
CHANGED
data/config/locales/ru.yml
CHANGED
data/config/locales/sk.yml
CHANGED
data/config/locales/sv.yml
CHANGED
data/config/locales/tr.yml
CHANGED
data/config/locales/uk.yml
CHANGED
data/config/locales/zh-CN.yml
CHANGED
data/config/locales/zh-TW.yml
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: comfy_middle_seat
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.0.
|
|
4
|
+
version: 4.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Oleg Khabarov
|
|
@@ -233,7 +233,6 @@ files:
|
|
|
233
233
|
- app/assets/javascripts/comfy/admin/cms/codemirror.js
|
|
234
234
|
- app/assets/javascripts/comfy/admin/cms/custom.js
|
|
235
235
|
- app/assets/javascripts/comfy/admin/cms/diff.js
|
|
236
|
-
- app/assets/javascripts/comfy/admin/cms/dirty_forms.js
|
|
237
236
|
- app/assets/javascripts/comfy/admin/cms/draft_forms.js
|
|
238
237
|
- app/assets/javascripts/comfy/admin/cms/file_link.js
|
|
239
238
|
- app/assets/javascripts/comfy/admin/cms/file_upload.js
|
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
(() => {
|
|
2
|
-
const defaultMessage =
|
|
3
|
-
"You have unsaved changes. Are you sure you want to leave this page?";
|
|
4
|
-
|
|
5
|
-
let forms = [];
|
|
6
|
-
let baselines = new WeakMap();
|
|
7
|
-
let submittingForms = new WeakSet();
|
|
8
|
-
let navigationAllowed = false;
|
|
9
|
-
|
|
10
|
-
const controlState = (control) => {
|
|
11
|
-
if (!control.name) return null;
|
|
12
|
-
|
|
13
|
-
const type = (control.type || "").toLowerCase();
|
|
14
|
-
if (["button", "image", "reset", "submit"].includes(type)) return null;
|
|
15
|
-
|
|
16
|
-
if (type === "checkbox" || type === "radio") {
|
|
17
|
-
return [control.name, type, control.value, control.checked];
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (type === "file") {
|
|
21
|
-
return [
|
|
22
|
-
control.name,
|
|
23
|
-
type,
|
|
24
|
-
Array.from(control.files).map((file) => [
|
|
25
|
-
file.name,
|
|
26
|
-
file.size,
|
|
27
|
-
file.lastModified,
|
|
28
|
-
]),
|
|
29
|
-
];
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (control instanceof HTMLSelectElement && control.multiple) {
|
|
33
|
-
return [
|
|
34
|
-
control.name,
|
|
35
|
-
type,
|
|
36
|
-
Array.from(control.selectedOptions).map((option) => option.value),
|
|
37
|
-
];
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return [control.name, type, control.value];
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const formState = (form) =>
|
|
44
|
-
JSON.stringify(Array.from(form.elements).map(controlState).filter(Boolean));
|
|
45
|
-
|
|
46
|
-
const syncEditors = () => {
|
|
47
|
-
if (CMS.codemirror && CMS.codemirror.sync) CMS.codemirror.sync();
|
|
48
|
-
if (CMS.wysiwyg && CMS.wysiwyg.sync) CMS.wysiwyg.sync();
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const dirtyForms = () => {
|
|
52
|
-
syncEditors();
|
|
53
|
-
return forms.filter(
|
|
54
|
-
(form) =>
|
|
55
|
-
form.isConnected &&
|
|
56
|
-
baselines.has(form) &&
|
|
57
|
-
baselines.get(form) !== formState(form)
|
|
58
|
-
);
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
const formsRequiringWarning = () =>
|
|
62
|
-
dirtyForms().filter((form) => !submittingForms.has(form));
|
|
63
|
-
|
|
64
|
-
const warningMessage = (dirtyForm) =>
|
|
65
|
-
dirtyForm.dataset.cmsUnsavedMessage || defaultMessage;
|
|
66
|
-
|
|
67
|
-
const beforeUnload = (event) => {
|
|
68
|
-
if (navigationAllowed || formsRequiringWarning().length === 0) return;
|
|
69
|
-
|
|
70
|
-
event.preventDefault();
|
|
71
|
-
event.returnValue = "";
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
const navigationTarget = (event) => {
|
|
75
|
-
if (
|
|
76
|
-
event.defaultPrevented ||
|
|
77
|
-
event.button !== 0 ||
|
|
78
|
-
event.metaKey ||
|
|
79
|
-
event.ctrlKey ||
|
|
80
|
-
event.shiftKey ||
|
|
81
|
-
event.altKey
|
|
82
|
-
) {
|
|
83
|
-
return null;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const link = event.target.closest("a[href]");
|
|
87
|
-
if (!link || link.hasAttribute("download")) return null;
|
|
88
|
-
|
|
89
|
-
const target = link.getAttribute("target");
|
|
90
|
-
if (target && !["_self", "_top", "_parent", window.name].includes(target)) {
|
|
91
|
-
return null;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const url = new URL(link.href, document.location.href);
|
|
95
|
-
if (
|
|
96
|
-
url.origin === document.location.origin &&
|
|
97
|
-
url.pathname === document.location.pathname &&
|
|
98
|
-
url.search === document.location.search &&
|
|
99
|
-
url.hash
|
|
100
|
-
) {
|
|
101
|
-
return null;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return link;
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
const allowCurrentNavigation = () => {
|
|
108
|
-
navigationAllowed = true;
|
|
109
|
-
window.setTimeout(() => {
|
|
110
|
-
navigationAllowed = false;
|
|
111
|
-
}, 0);
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
const confirmLinkNavigation = (event) => {
|
|
115
|
-
if (navigationAllowed || !navigationTarget(event)) return;
|
|
116
|
-
|
|
117
|
-
const dirtyForm = formsRequiringWarning()[0];
|
|
118
|
-
if (!dirtyForm) return;
|
|
119
|
-
|
|
120
|
-
if (!window.confirm(warningMessage(dirtyForm))) {
|
|
121
|
-
event.preventDefault();
|
|
122
|
-
event.stopImmediatePropagation();
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
allowCurrentNavigation();
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
const confirmTurbolinksNavigation = (event) => {
|
|
130
|
-
if (navigationAllowed) return;
|
|
131
|
-
|
|
132
|
-
const dirtyForm = formsRequiringWarning()[0];
|
|
133
|
-
if (!dirtyForm) return;
|
|
134
|
-
|
|
135
|
-
if (!window.confirm(warningMessage(dirtyForm))) {
|
|
136
|
-
event.preventDefault();
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
allowCurrentNavigation();
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
const markSubmitting = (event) => {
|
|
144
|
-
const form = event.target;
|
|
145
|
-
const submitterTarget = event.submitter && event.submitter.formTarget;
|
|
146
|
-
const target = submitterTarget || form.target;
|
|
147
|
-
|
|
148
|
-
if (
|
|
149
|
-
target &&
|
|
150
|
-
!["_self", "_top", "_parent", window.name].includes(target)
|
|
151
|
-
) {
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
submittingForms.add(form);
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
window.CMS.dirtyForms = {
|
|
159
|
-
init() {
|
|
160
|
-
forms = Array.from(
|
|
161
|
-
document.querySelectorAll("form[data-cms-unsaved-message]")
|
|
162
|
-
);
|
|
163
|
-
baselines = new WeakMap();
|
|
164
|
-
submittingForms = new WeakSet();
|
|
165
|
-
navigationAllowed = false;
|
|
166
|
-
|
|
167
|
-
for (const form of forms) {
|
|
168
|
-
const baseline =
|
|
169
|
-
form.dataset.cmsSaveFailed === "true" ? null : formState(form);
|
|
170
|
-
baselines.set(form, baseline);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
window.addEventListener("beforeunload", beforeUnload);
|
|
174
|
-
document.addEventListener("click", confirmLinkNavigation, true);
|
|
175
|
-
document.addEventListener("submit", markSubmitting, true);
|
|
176
|
-
document.addEventListener(
|
|
177
|
-
"turbolinks:before-visit",
|
|
178
|
-
confirmTurbolinksNavigation
|
|
179
|
-
);
|
|
180
|
-
},
|
|
181
|
-
|
|
182
|
-
dispose() {
|
|
183
|
-
window.removeEventListener("beforeunload", beforeUnload);
|
|
184
|
-
document.removeEventListener("click", confirmLinkNavigation, true);
|
|
185
|
-
document.removeEventListener("submit", markSubmitting, true);
|
|
186
|
-
document.removeEventListener(
|
|
187
|
-
"turbolinks:before-visit",
|
|
188
|
-
confirmTurbolinksNavigation
|
|
189
|
-
);
|
|
190
|
-
|
|
191
|
-
forms = [];
|
|
192
|
-
baselines = new WeakMap();
|
|
193
|
-
submittingForms = new WeakSet();
|
|
194
|
-
navigationAllowed = false;
|
|
195
|
-
},
|
|
196
|
-
|
|
197
|
-
isDirty() {
|
|
198
|
-
return dirtyForms().length > 0;
|
|
199
|
-
},
|
|
200
|
-
};
|
|
201
|
-
})();
|