Die Einträge werden aufgelistet und angezeigt.

This commit is contained in:
2021-04-09 21:19:19 +02:00
parent 9d5af9a0fb
commit bc83fc8dd1
+44 -4
View File
@@ -7,6 +7,48 @@
import checkIcon from '@iconify-icons/oi/check'; import checkIcon from '@iconify-icons/oi/check';
import xIcon from '@iconify-icons/oi/x'; import xIcon from '@iconify-icons/oi/x';
let activeRecord = null; let activeRecord = null;
params = {
title: 'Einträge',
records: [],
isLoading: true
}
const Records = {
'browse': () => {
// noinspection JSUnresolvedVariable
fetch(env.API_URL + '/working-hours')
.then(res => {
if (!res.ok) {
throw new Error('Fail!');
}
return res.json();
})
.then(data => {
params.records = data;
params.isLoading = false;
})
.catch(err => {
params.isLoading = false;
console.log(err);
});
},
'read': date => {
// noinspection JSUnresolvedVariable
fetch(env.API_URL + '/working-hours/' + date)
.then(res => {
if (!res.ok) {
throw new Error('Fail!');
}
return res.json();
})
.then(data => {
activeRecord = data;
})
.catch(err => {
console.log(err);
});
}
};
Records.browse();
</script> </script>
<svelte:head> <svelte:head>
@@ -33,7 +75,7 @@
<td>{record.workingDay}</td> <td>{record.workingDay}</td>
<td>{record.workingTime}</td> <td>{record.workingTime}</td>
<td> <td>
<button>Bearbeiten <IconifyIcon icon={wrenchIcon} /></button> <button on:click={() => Records.read(record.workingDay)}>Bearbeiten <IconifyIcon icon={wrenchIcon} /></button>
<button>Löschen <IconifyIcon icon={trashIcon} color="red" /></button> <button>Löschen <IconifyIcon icon={trashIcon} color="red" /></button>
</td> </td>
</tr> </tr>
@@ -53,18 +95,16 @@
<fieldset name="record-data"> <fieldset name="record-data">
<div> <div>
<label for="workingDay">Arbeitstag</label> <label for="workingDay">Arbeitstag</label>
<!--suppress JSUnresolvedVariable -->
<input bind:value={activeRecord.workingDay} placeholder="Arbeitstag" type="date" id="workingDay"> <input bind:value={activeRecord.workingDay} placeholder="Arbeitstag" type="date" id="workingDay">
</div> </div>
<div> <div>
<label for="workingTime">Arbeitszeit</label> <label for="workingTime">Arbeitszeit</label>
<!--suppress JSUnresolvedVariable -->
<input bind:value={activeRecord.workingTime} placeholder="Arbeitszeit" type="time" id="workingTime"> <input bind:value={activeRecord.workingTime} placeholder="Arbeitszeit" type="time" id="workingTime">
</div> </div>
</fieldset> </fieldset>
<fieldset name="buttons"> <fieldset name="buttons">
<button>Übernehmen <IconifyIcon icon={checkIcon} color="green" /></button> <button>Übernehmen <IconifyIcon icon={checkIcon} color="green" /></button>
<button>Abbrechen <IconifyIcon icon={xIcon} /></button> <button on:click={() => Records.read(null)}>Abbrechen <IconifyIcon icon={xIcon} /></button>
</fieldset> </fieldset>
</form> </form>
</article> </article>