working on message settings:
- created form - implemented storing of settings - implemented loading of settings next: pre-filling from with settings loaded from DB
This commit is contained in:
@@ -1,7 +1,162 @@
|
||||
<script>
|
||||
import { t } from '../../translations.svelte';
|
||||
import { api, patch } from '../../urls.svelte';
|
||||
import { error, yikes } from '../../warn.svelte';
|
||||
|
||||
let instant = false;
|
||||
let silent = false;
|
||||
let at8 = false;
|
||||
let at9 = false;
|
||||
let at10 = false;
|
||||
let at11 = false;
|
||||
let at12 = false;
|
||||
let at13 = false;
|
||||
let at14 = true;
|
||||
let at15 = false;
|
||||
let at16 = false;
|
||||
let at17 = false;
|
||||
let at18 = false;
|
||||
let at19 = false;
|
||||
let at20 = false;
|
||||
let at21 = false;
|
||||
let at22 = false;
|
||||
|
||||
function delivery(mode){
|
||||
if (mode){
|
||||
silent = false;
|
||||
} else {
|
||||
instant = false;
|
||||
}
|
||||
at8 = at9 = at10 = at11 = at12 = at13 = at14 = at15 = at16 = at17 = at18 = at19 = at20 = at21 = at22 = false;
|
||||
saveTimes();
|
||||
}
|
||||
|
||||
async function saveTimes(){
|
||||
let data = {
|
||||
instantly : instant,
|
||||
hours : []
|
||||
}
|
||||
if (at8) data.hours.push(8);
|
||||
if (at9) data.hours.push(9);
|
||||
if (at10) data.hours.push(10);
|
||||
if (at11) data.hours.push(11);
|
||||
if (at12) data.hours.push(12);
|
||||
if (at13) data.hours.push(13);
|
||||
if (at14) data.hours.push(14);
|
||||
if (at15) data.hours.push(15);
|
||||
if (at16) data.hours.push(16);
|
||||
if (at17) data.hours.push(17);
|
||||
if (at18) data.hours.push(18);
|
||||
if (at19) data.hours.push(19);
|
||||
if (at20) data.hours.push(20);
|
||||
if (at21) data.hours.push(21);
|
||||
if (at22) data.hours.push(22);
|
||||
let url = api('message/settings');
|
||||
let res = await patch(url,data);
|
||||
if (res.ok){
|
||||
yikes();
|
||||
} else {
|
||||
error(res);
|
||||
}
|
||||
}
|
||||
|
||||
function selectTime(ev){
|
||||
instant = false;
|
||||
silent = !(at8 || at9 || at10 || at11 || at12 || at13 || at14 || at15 || at16 || at17 || at18 || at19 || at20 || at21 || at22);
|
||||
saveTimes();
|
||||
}
|
||||
</script>
|
||||
|
||||
<fieldset>
|
||||
<legend>{t('message settingss')}</legend>
|
||||
<fieldset class="message settings">
|
||||
<legend>{t('message settings')}</legend>
|
||||
<p>{t('When shall messages be delivered?')}</p>
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td colspan="3">
|
||||
<label>
|
||||
<input type="checkbox" onchange={ev => delivery(true)} bind:checked={instant} />{t('instantly')}
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{t('collect messages and send them at')}
|
||||
</td>
|
||||
<td>
|
||||
⎧<br/>
|
||||
⎪<br/>
|
||||
⎪<br/>
|
||||
⎪<br/>
|
||||
⎪<br/>
|
||||
⎪<br/>
|
||||
⎪<br/>
|
||||
⎪<br/>
|
||||
⎨<br/>
|
||||
⎪<br/>
|
||||
⎪<br/>
|
||||
⎪<br/>
|
||||
⎪<br/>
|
||||
⎪<br/>
|
||||
⎪<br/>
|
||||
⎪<br/>
|
||||
⎩
|
||||
</td>
|
||||
<td>
|
||||
<label>
|
||||
<input type="checkbox" onchange={selectTime} bind:checked={at8} />{t('8 am')}
|
||||
</label>
|
||||
<label>
|
||||
<input type="checkbox" onchange={selectTime} bind:checked={at9} />{t('9:00 am')}
|
||||
</label>
|
||||
<label>
|
||||
<input type="checkbox" onchange={selectTime} bind:checked={at10} />{t('10:00 am')}
|
||||
</label>
|
||||
<label>
|
||||
<input type="checkbox" onchange={selectTime} bind:checked={at11} />{t('11:00 am')}
|
||||
</label>
|
||||
<label>
|
||||
<input type="checkbox" onchange={selectTime} bind:checked={at12} />{t('noon')}
|
||||
</label>
|
||||
<label>
|
||||
<input type="checkbox" onchange={selectTime} bind:checked={at13} />{t('1:00 pm')}
|
||||
</label>
|
||||
<label>
|
||||
<input type="checkbox" onchange={selectTime} bind:checked={at14} />{t('2:00 pm')}
|
||||
</label>
|
||||
<label>
|
||||
<input type="checkbox" onchange={selectTime} bind:checked={at15} />{t('3:00 pm')}
|
||||
</label>
|
||||
<label>
|
||||
<input type="checkbox" onchange={selectTime} bind:checked={at16} />{t('4:00 pm')}
|
||||
</label>
|
||||
<label>
|
||||
<input type="checkbox" onchange={selectTime} bind:checked={at17} />{t('5:00 pm')}
|
||||
</label>
|
||||
<label>
|
||||
<input type="checkbox" onchange={selectTime} bind:checked={at18} />{t('6:00 pm')}
|
||||
</label>
|
||||
<label>
|
||||
<input type="checkbox" onchange={selectTime} bind:checked={at19} />{t('7:00 pm')}
|
||||
</label>
|
||||
<label>
|
||||
<input type="checkbox" onchange={selectTime} bind:checked={at20} />{t('8:00 pm')}
|
||||
</label>
|
||||
<label>
|
||||
<input type="checkbox" onchange={selectTime} bind:checked={at21} />{t('9:00 pm')}
|
||||
</label>
|
||||
<label>
|
||||
<input type="checkbox" onchange={selectTime} bind:checked={at22} />{t('10:00 pm')}
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3">
|
||||
<label>
|
||||
<input type="checkbox" onchange={ev => delivery(false)} bind:checked={silent} />{t('i don`t want to receive email notifications!')}
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</fieldset>
|
||||
Reference in New Issue
Block a user