Skip to content

Commit 258fdcc

Browse files
committed
Fixed layouts not refreshing correctly
1 parent 079ba30 commit 258fdcc

File tree

5 files changed

+52
-68
lines changed

5 files changed

+52
-68
lines changed

resources/js/calendar-layouts.js

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,30 @@ export default () => ({
3737
"static_data.settings.layout": layout.name.toLowerCase(),
3838
});
3939

40-
do_update_all(window.hash)
41-
.then(() => {
42-
window.onbeforeunload = function() { }
43-
window.location.reload(false);
44-
})
45-
.catch((error) => {
46-
this.$store.calendar.update({
47-
"static_data.settings.layout": previous_layout
40+
if(window.location.href.endsWith("/edit")) {
41+
do_update_all(window.hash)
42+
.then(() => {
43+
window.onbeforeunload = function () {
44+
}
45+
window.location.reload(false);
46+
})
47+
.catch((error) => {
48+
this.$store.calendar.update({
49+
"static_data.settings.layout": previous_layout
50+
});
51+
this.$store.calendar.static_data.settings.layout = previous_layout;
52+
this.$dispatch("app-busy-end");
53+
this.$dispatch('notify', {
54+
content: error.response.data.message,
55+
type: "error"
56+
});
4857
});
49-
this.$store.calendar.static_data.settings.layout = previous_layout;
50-
this.$dispatch("app-busy-end");
51-
this.$dispatch('notify', {
52-
content: error.response.data.message,
53-
type: "error"
54-
});
55-
});
58+
}else{
59+
window.location = window.location.href.split("/create")[0] + "/create?resume=1";
60+
// window.onbeforeunload = function () {
61+
// }
62+
// window.location.reload(false);
63+
}
5664
}
5765

5866
})

resources/js/calendar/calendar_create_page.js

Lines changed: 25 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -157,54 +157,22 @@ export default (calendar_structure) => ({
157157
bind_calendar_events();
158158

159159
document.addEventListener("DOMContentLoaded", () => {
160-
161-
const queryString = window.location.search;
162-
if (should_resume(queryString)) {
163-
this.autoload();
160+
if (this.should_resume(window.location.search)) {
161+
this.autoload(false);
164162
} else {
165163
this.queryAutoload();
166164
}
167165

168-
window.dispatchEvent(new CustomEvent("rebuild-calendar"));
169-
170-
});
171-
172-
function should_resume(queryString) {
173-
const urlParams = new URLSearchParams(queryString);
174-
return urlParams.has("resume");
175-
}
176-
177-
window.dispatchEvent(new CustomEvent("events-changed"));
178-
179-
this.$nextTick(async () => {
180-
181-
let autoload = await this.queryAutoload();
182-
if(autoload) return;
183-
184-
this.$dispatch('calendar-loaded', {
185-
hash: window.hash,
186-
calendar_name: window.calendar_name,
187-
calendar_id: window.calendar_id,
188-
static_data: window.static_data,
189-
dynamic_data: window.dynamic_data,
190-
is_linked: window.is_linked,
191-
has_parent: window.has_parent,
192-
parent_hash: window.parent_hash,
193-
parent_offset: window.parent_offset,
194-
events: window.events,
195-
event_categories: window.event_categories,
196-
last_static_change: window.last_static_change,
197-
last_dynamic_change: window.last_dynamic_change,
198-
advancement: window.advancement
199-
});
200-
201166
this.evaluate_current_step();
202-
203167
});
204168

205169
window.dispatchEvent(new CustomEvent("events-changed"));
206170
},
207171

172+
should_resume(queryString) {
173+
const urlParams = new URLSearchParams(queryString);
174+
return urlParams.has("resume");
175+
},
208176

209177
autosave() {
210178
let saved_data = JSON.stringify({
@@ -262,14 +230,25 @@ export default (calendar_structure) => ({
262230

263231
this.evaluate_current_step();
264232

265-
this.$dispatch(
266-
'calendar-loaded', {
267-
calendar_name: data.calendar_name,
268-
static_data: data.static_data,
269-
dynamic_data: data.dynamic_data,
270-
events: data.events
271-
}
272-
)
233+
this.$dispatch('calendar-loaded', {
234+
hash: window.hash,
235+
calendar_name: window.calendar_name,
236+
calendar_id: window.calendar_id,
237+
static_data: window.static_data,
238+
dynamic_data: window.dynamic_data,
239+
is_linked: window.is_linked,
240+
has_parent: window.has_parent,
241+
parent_hash: window.parent_hash,
242+
parent_offset: window.parent_offset,
243+
events: window.events,
244+
event_categories: window.event_categories,
245+
last_static_change: window.last_static_change,
246+
last_dynamic_change: window.last_dynamic_change,
247+
advancement: window.advancement
248+
});
249+
250+
window.dispatchEvent(new CustomEvent("rebuild-calendar"));
251+
window.dispatchEvent(new CustomEvent("events-changed"));
273252

274253
if (popup) {
275254
swal.fire({

resources/js/calendar/create_button.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,6 @@ export default () => ({
8484
clearTimeout(this.timeout);
8585
}
8686

87-
let updateMethod;
88-
let updateParams = [];
89-
9087
this.save_status = "saving";
9188

9289
create_calendar()

resources/views/components/collapsible.blade.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@
1313
x-data="{
1414
open: {{ $open ? 'true' : 'false' }},
1515
show: true,
16-
step: @js($step),
16+
step: Number(@js($step)),
1717
toggle() {
1818
this.open = !this.open;
1919
2020
// TODO: Use this within any components (clock?) that need it
2121
$dispatch('{{ Str::slug($contains) }}-toggled', this.open);
2222
},
2323
evaluate_calendar_step($event) {
24-
this.show = $event.detail.done || (this.step !== null && $event.detail.step >= this.step);
25-
if(this.step !== null && $event.detail.step === this.step){
24+
this.show = $event.detail.done || (this.step && $event.detail.step >= this.step);
25+
if(this.step && $event.detail.step === this.step){
2626
this.open = true;
2727
}
2828
}

resources/views/components/weekdays-collapsible.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
</div>
7474
@endif
7575

76-
<div class="flex flex-col" x-show='overflow_weekdays'>
76+
<div class="flex flex-col" x-show='overflow_weekdays && weekdays.length'>
7777
<x-separator class="mt-[1rem]"></x-separator>
7878

7979
<strong>Start the first year on:</strong>

0 commit comments

Comments
 (0)