js-rest-aktionen #6
@@ -24,7 +24,7 @@
|
|||||||
return res.json();
|
return res.json();
|
||||||
})
|
})
|
||||||
.then(data => {
|
.then(data => {
|
||||||
activeRecord = null;
|
Controller.cancelActiveRecord();
|
||||||
params.records = data;
|
params.records = data;
|
||||||
params.isLoading = false;
|
params.isLoading = false;
|
||||||
})
|
})
|
||||||
@@ -45,7 +45,7 @@
|
|||||||
.then(data => {
|
.then(data => {
|
||||||
activeRecord = data;
|
activeRecord = data;
|
||||||
if (date === null) {
|
if (date === null) {
|
||||||
Records.browse();
|
Controller.listRecords();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
@@ -73,8 +73,7 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
newRecord = false;
|
Controller.listRecords();
|
||||||
Records.browse();
|
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
@@ -101,14 +100,39 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
Records.browse();
|
Controller.listRecords();
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Records.browse();
|
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>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
@@ -127,7 +151,7 @@
|
|||||||
<!--suppress HtmlUnknownTarget -->
|
<!--suppress HtmlUnknownTarget -->
|
||||||
<form action="/working-hours">
|
<form action="/working-hours">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<button on:click={() => {activeRecord = {workingTime: '00:00:00'}; newRecord = true}}>Neuer Eintrag
|
<button on:click={Controller.newRecord}>Neuer Eintrag
|
||||||
<IconifyIcon icon={documentIcon}/>
|
<IconifyIcon icon={documentIcon}/>
|
||||||
</button>
|
</button>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
@@ -146,7 +170,7 @@
|
|||||||
<td>{record.workingDay}</td>
|
<td>{record.workingDay}</td>
|
||||||
<td>{record.workingTime}</td>
|
<td>{record.workingTime}</td>
|
||||||
<td>
|
<td>
|
||||||
<button on:click={() => Records.read(record.workingDay)}>Bearbeiten
|
<button on:click={() => Controller.selectActiveRecord(record)}>Bearbeiten
|
||||||
<IconifyIcon icon={wrenchIcon}/>
|
<IconifyIcon icon={wrenchIcon}/>
|
||||||
</button>
|
</button>
|
||||||
</td>
|
</td>
|
||||||
|
TorstenHettstedt marked this conversation as resolved
|
|||||||
@@ -178,16 +202,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset name="buttons">
|
<fieldset name="buttons">
|
||||||
{#if newRecord === true}
|
<button on:click={Controller.saveRecord}>Übernehmen
|
||||||
<button on:click={() => Records.add(activeRecord)}>Übernehmen
|
<IconifyIcon icon={checkIcon} color="green"/>
|
||||||
<IconifyIcon icon={checkIcon} color="green"/>
|
</button>
|
||||||
</button>
|
<button on:click={Controller.cancelActiveRecord}>Abbrechen
|
||||||
{:else}
|
|
||||||
<button on:click={() => Records.update(activeRecord.workingDay, activeRecord)}>Übernehmen
|
|
||||||
<IconifyIcon icon={checkIcon} color="green"/>
|
|
||||||
</button>
|
|
||||||
{/if}
|
|
||||||
<button on:click={() => Records.read(null)}>Abbrechen
|
|
||||||
<IconifyIcon icon={xIcon}/>
|
<IconifyIcon icon={xIcon}/>
|
||||||
</button>
|
</button>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|||||||
Reference in New Issue
Block a user
Es sollten auch die Sekunden eintragbar sein und der Defaultwert sollte '00:00:00' sein.