Removed old asset assignment collection (delete from the db if you have it). Added proper history associated with assigning and unassigning. Need to still add events attached to a CB which then transition to the history when the CB is checked in.
This commit is contained in:
@@ -14,10 +14,12 @@
|
||||
import List, {Item, Graphic, Meta, Text, PrimaryText, SecondaryText} from '@smui/list';
|
||||
import Paper from '@smui/paper';
|
||||
import LayoutGrid, {Cell} from '@smui/layout-grid';
|
||||
import {Assets} from "/imports/api/assets";
|
||||
|
||||
let grades = ['All'];
|
||||
onMount(async () => {
|
||||
Meteor.subscribe('sites');
|
||||
Meteor.subscribe('assets');
|
||||
Meteor.call('students.getPossibleGrades', (err, result) => {
|
||||
if(err) console.log(err);
|
||||
else {
|
||||
@@ -55,23 +57,75 @@
|
||||
}
|
||||
}
|
||||
|
||||
let conditions = ['New', 'Like New', 'Good', 'Okay', 'Damaged'];
|
||||
let condition = "New";
|
||||
let conditionDetails = "";
|
||||
|
||||
const createAssignment = () => {
|
||||
if(assetId && assetId.length && selectedAssignee) {
|
||||
Meteor.call("assets.assign", assetId, selectedCategory === 'Student' ? "Student" : "Staff", selectedAssignee._id, (err, result) => {
|
||||
if(err) {
|
||||
console.error(err);
|
||||
//TODO: Display an error!
|
||||
let asset = Assets.findOne({assetId});
|
||||
|
||||
if(asset) {
|
||||
condition = asset.condition;
|
||||
conditionDetails = asset.conditionDetails;
|
||||
}
|
||||
|
||||
openCreateDialog();
|
||||
}
|
||||
|
||||
let openDialog = false;
|
||||
|
||||
const openCreateDialog = () => {
|
||||
// assetTypeDialogSelectedIndex = -1;
|
||||
openDialog = true;
|
||||
}
|
||||
const dialogClosed = (e) => {
|
||||
switch (e.detail.action) {
|
||||
case 'create':
|
||||
if(assetId && assetId.length && selectedAssignee) {
|
||||
Meteor.call("assets.assign", assetId, selectedCategory === 'Student' ? "Student" : "Staff", selectedAssignee._id, condition, conditionDetails, (err, result) => {
|
||||
if(err) {
|
||||
console.error(err);
|
||||
//TODO: Display an error!
|
||||
}
|
||||
else {
|
||||
// TODO: Set focus to the asset ID field.
|
||||
assetId = "";
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
// TODO: Set focus to the asset ID field.
|
||||
assetId = "";
|
||||
}
|
||||
});
|
||||
break;
|
||||
default:
|
||||
case 'cancel':
|
||||
break;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="container">
|
||||
<Dialog bind:open={openDialog} surface$style="width: 850px; max-width: calc(100vw - 32px);"
|
||||
on:SMUIDialog:closed={dialogClosed}>
|
||||
<Title id="large-scroll-title">Report Asset Condition</Title>
|
||||
<Content id="large-scroll-content">
|
||||
<Select bind:value={condition} label="Condition">
|
||||
{#each conditions as next}
|
||||
<Option value={next}>{next}</Option>
|
||||
{/each}
|
||||
</Select>
|
||||
<div style="grid-column: 1/span 1">
|
||||
<TextField textarea style="width: 100%; height: 20rem; margin-top: 1rem" helperLine$style="width: 100%" bind:value={conditionDetails} label="Condition Details">
|
||||
</TextField>
|
||||
</div>
|
||||
</Content>
|
||||
<Actions>
|
||||
<Button action="create" default>
|
||||
<Label>Ok</Label>
|
||||
</Button>
|
||||
<Button action="cancel">
|
||||
<Label>Cancel</Label>
|
||||
</Button>
|
||||
</Actions>
|
||||
</Dialog>
|
||||
|
||||
<h1 style="display: block">Assign Assets</h1>
|
||||
|
||||
<Paper>
|
||||
|
||||
Reference in New Issue
Block a user