Ein Eintrag kann verändert werden.
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
return res.json();
|
||||
})
|
||||
.then(data => {
|
||||
activeRecord = null;
|
||||
params.records = data;
|
||||
params.isLoading = false;
|
||||
})
|
||||
@@ -41,6 +42,37 @@
|
||||
})
|
||||
.then(data => {
|
||||
activeRecord = data;
|
||||
if (date === null) {
|
||||
Records.browse();
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
});
|
||||
},
|
||||
'update': (date, record) => {
|
||||
console.log(record);
|
||||
// noinspection JSUnresolvedVariable
|
||||
fetch(env.API_URL + '/working-hours/' + date, {
|
||||
method: 'PUT',
|
||||
mode: 'no-cors',
|
||||
cache: 'no-cache',
|
||||
credentials: 'same-origin',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
redirect: 'follow',
|
||||
referrerPolicy: 'no-referrer',
|
||||
body: JSON.stringify(record)
|
||||
})
|
||||
.then(res => {
|
||||
if (!res.ok) {
|
||||
throw new Error('Fail!');
|
||||
}
|
||||
})
|
||||
.then(() => {
|
||||
activeRecord = null;
|
||||
Records.browse();
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
@@ -103,8 +135,12 @@
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset name="buttons">
|
||||
<button>Übernehmen <IconifyIcon icon={checkIcon} color="green" /></button>
|
||||
<button on:click={() => Records.read(null)}>Abbrechen <IconifyIcon icon={xIcon} /></button>
|
||||
<button on:click={() => Records.update(activeRecord.workingDay, activeRecord)}>Übernehmen
|
||||
<IconifyIcon icon={checkIcon} color="green"/>
|
||||
</button>
|
||||
<button on:click={() => Records.read(null)}>Abbrechen
|
||||
<IconifyIcon icon={xIcon}/>
|
||||
</button>
|
||||
</fieldset>
|
||||
</form>
|
||||
</article>
|
||||
|
||||
Reference in New Issue
Block a user