js-rest-aktionen #6

Merged
TorstenHettstedt merged 9 commits from js-rest-aktionen into master 2021-04-12 14:11:32 +02:00
Showing only changes of commit 0a5e40d7cb - Show all commits
+33 -15
View File
@@ -24,7 +24,7 @@
return res.json();
})
.then(data => {
activeRecord = null;
Controller.cancelActiveRecord();
params.records = data;
params.isLoading = false;
})
@@ -45,7 +45,7 @@
.then(data => {
activeRecord = data;
if (date === null) {
Records.browse();
Controller.listRecords();
}
})
.catch(err => {
@@ -73,8 +73,7 @@
}
})
.then(() => {
newRecord = false;
Records.browse();
Controller.listRecords();
})
.catch(err => {
console.log(err);
@@ -101,14 +100,39 @@
}
})
.then(() => {
Records.browse();
Controller.listRecords();
})
.catch(err => {
console.log(err);
});
}
};
const Controller = {
'listRecords': () => {
Controller.cancelActiveRecord();
Records.browse();
},
'newRecord': () => {
activeRecord = {workingTime: '00:00:00'};
newRecord = true;
},
'saveRecord': () => {
if (newRecord === true) {
Records.add(activeRecord);
} else {
Records.update(activeRecord.workingDay, activeRecord);
}
},
'selectActiveRecord': record => Records.read(record.workingDay),
'cancelActiveRecord': () => {
activeRecord = null;
newRecord = false;
}
};
const initSite = () => {
Controller.listRecords()
};
initSite()
</script>
<svelte:head>
@@ -127,7 +151,7 @@
<!--suppress HtmlUnknownTarget -->
<form action="/working-hours">
<fieldset>
<button on:click={() => {activeRecord = {workingTime: '00:00:00'}; newRecord = true}}>Neuer Eintrag
<button on:click={Controller.newRecord}>Neuer Eintrag
<IconifyIcon icon={documentIcon}/>
</button>
</fieldset>
@@ -146,7 +170,7 @@
<td>{record.workingDay}</td>
<td>{record.workingTime}</td>
<td>
<button on:click={() => Records.read(record.workingDay)}>Bearbeiten
<button on:click={() => Controller.selectActiveRecord(record)}>Bearbeiten
<IconifyIcon icon={wrenchIcon}/>
</button>
</td>
TorstenHettstedt marked this conversation as resolved
Review

Es sollten auch die Sekunden eintragbar sein und der Defaultwert sollte '00:00:00' sein.

Es sollten auch die Sekunden eintragbar sein und der Defaultwert sollte '00:00:00' sein.
@@ -178,16 +202,10 @@
</div>
</fieldset>
<fieldset name="buttons">
{#if newRecord === true}
<button on:click={() => Records.add(activeRecord)}>Übernehmen
<button on:click={Controller.saveRecord}>Übernehmen
<IconifyIcon icon={checkIcon} color="green"/>
</button>
{:else}
<button on:click={() => Records.update(activeRecord.workingDay, activeRecord)}>Übernehmen
<IconifyIcon icon={checkIcon} color="green"/>
</button>
{/if}
<button on:click={() => Records.read(null)}>Abbrechen
<button on:click={Controller.cancelActiveRecord}>Abbrechen
<IconifyIcon icon={xIcon}/>
</button>
</fieldset>