Calendar v2 - Combined Calendar Feature
This commit is contained in:
+48
-1
@@ -179,7 +179,6 @@
|
||||
currency_symbol: $('#currency_symbol').val(),
|
||||
currency_name: $('#currency_name').val(),
|
||||
currency_permanence: $('#currency_permanence').val(),
|
||||
timezone: $('#timezone').val(),
|
||||
week_starts_on: parseInt($('#week_starts_on').val(), 10)
|
||||
};
|
||||
postJson('/family_settings_save.php', payload)
|
||||
@@ -194,6 +193,53 @@
|
||||
});
|
||||
}
|
||||
|
||||
function collectBillDaysFromDom() {
|
||||
var out = [];
|
||||
$('#billDaysRows .bill-day-row').each(function () {
|
||||
var $row = $(this);
|
||||
var day = parseInt($row.find('.bill-day-dom').val(), 10);
|
||||
var title = ($row.find('.bill-day-title').val() || '').trim();
|
||||
if (title !== '' && day >= 1 && day <= 31) {
|
||||
out.push({ dayOfMonth: day, title: title });
|
||||
}
|
||||
});
|
||||
return out;
|
||||
}
|
||||
|
||||
function bindCalendarSettingsForm() {
|
||||
var $form = $('#calendarSettingsForm');
|
||||
if (!$form.length) {
|
||||
return;
|
||||
}
|
||||
$('#btnAddBillDayRow').on('click', function () {
|
||||
var $first = $('#billDaysRows .bill-day-row').first();
|
||||
if (!$first.length) {
|
||||
return;
|
||||
}
|
||||
var $clone = $first.clone();
|
||||
$clone.find('.bill-day-dom').val('1');
|
||||
$clone.find('.bill-day-title').val('');
|
||||
$('#billDaysRows').append($clone);
|
||||
});
|
||||
$form.on('submit', function (e) {
|
||||
e.preventDefault();
|
||||
var payload = {
|
||||
timezone: $('#family_timezone').val(),
|
||||
calendar_two_way_google: $('#calendar_two_way_google').is(':checked'),
|
||||
calendar_bill_days: collectBillDaysFromDom()
|
||||
};
|
||||
postJson('/family_settings_save.php', payload)
|
||||
.then(function () {
|
||||
showAlert($('#calendarSettingsFeedback'), 'success', 'Saved.');
|
||||
$('#calendarSettingsFeedback').removeClass('d-none');
|
||||
})
|
||||
.catch(function (err) {
|
||||
showAlert($('#calendarSettingsFeedback'), 'danger', err.message || 'Could not save');
|
||||
$('#calendarSettingsFeedback').removeClass('d-none');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function choreListPayloadFromForm() {
|
||||
var type = $('#chore_list_type').val() || 'checkbox';
|
||||
var raw = $('#chore_list_items').val() || '';
|
||||
@@ -785,6 +831,7 @@
|
||||
bindFirstHeadForm();
|
||||
bindAddPersonForm();
|
||||
bindFamilySettingsForm();
|
||||
bindCalendarSettingsForm();
|
||||
bindPeopleTable();
|
||||
bindChoresPage();
|
||||
bindCurrencyPage();
|
||||
|
||||
Reference in New Issue
Block a user