Added the ability to create and edit students and staff. Still cannot delete.

This commit is contained in:
2022-08-21 11:13:19 -07:00
parent 8d4b72c581
commit 23838990d4
4 changed files with 66 additions and 14 deletions

View File

@@ -104,15 +104,17 @@
}
let dirtyStaff;
// Copy the edited value when ever it changes, set some defaults for a new value object (to make the view happy).
editedStaff.subscribe(v => {dirtyStaff = Object.assign({email: "", firstName: "", lastName: ""}, v)});
editedStaff.subscribe(v => {dirtyStaff = Object.assign({id: "", email: "", firstName: "", lastName: "", siteId: selectedSiteId}, v)});
const deleteStaff = staff => {
//TODO:
//TODO: We must first ensure we have no assets assigned to the staff member.
};
const applyStaffChanges = () => {
if(dirtyStaff._id)
Meteor.call("staff.update", dirtyStaff);
else
Meteor.call("staff.add", dirtyStaff);
if(dirtyStaff._id) {
Meteor.call("staff.update", dirtyStaff._id, dirtyStaff.id, dirtyStaff.firstName, dirtyStaff.lastName, dirtyStaff.email, dirtyStaff.siteId);
}
else {
Meteor.call("staff.add", dirtyStaff.id, dirtyStaff.firstName, dirtyStaff.lastName, dirtyStaff.email, dirtyStaff.siteId);
}
editedStaff.set(null);
dirtyStaff = null;
}
@@ -145,6 +147,10 @@
<GridTable bind:rows={staff} columns="{staffColumns}" actions="{staffActions}" rowKey="{(v) => {return v._id}}" bind:edited="{editedStaff}" on:selection={onStaffSelection}>
{#if dirtyStaff}
<div class="editorContainer">
<div style="grid-column: 1/span 1">
<TextField type="number" style="width: 100%" bind:value={dirtyStaff.id} label="ID">
</TextField>
</div>
<div style="grid-column: 1/span 1">
<TextField type="text" style="width: 100%" bind:value={dirtyStaff.email} label="Email">
</TextField>
@@ -157,6 +163,13 @@
<TextField type="text" style="width: 100%" bind:value={dirtyStaff.lastName} label="Last Name">
</TextField>
</div>
<div style="grid-column: 1/span 1">
<Select bind:value={dirtyStaff.siteId} label="Site">
{#each $sites as site}
<Option value={site._id}>{site.name}</Option>
{/each}
</Select>
</div>
<button type="button" style="grid-column: 2/span 1;" class="button accept-button material-icons material-symbols-outlined" on:click={applyStaffChanges}>
check