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 74fd96cf25 - Show all commits
+38 -2
View File
@@ -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);
1
@@ -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>