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:
@@ -11,6 +11,8 @@
|
||||
import LayoutGrid, {Cell} from '@smui/layout-grid';
|
||||
import {Assets} from "/imports/api/assets";
|
||||
import {AssetTypes} from "/imports/api/asset-types";
|
||||
import Button, { Label } from '@smui/button';
|
||||
import Dialog, { Title, Content, Actions } from '@smui/dialog';
|
||||
|
||||
onMount(async () => {
|
||||
Meteor.subscribe('students');
|
||||
@@ -53,10 +55,82 @@
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
let conditions = ['New', 'Like New', 'Good', 'Okay', 'Damaged'];
|
||||
let condition = "New";
|
||||
let conditionDetails = "";
|
||||
let comment = "";
|
||||
let unassignAsset;
|
||||
|
||||
const unassign = (asset) => {
|
||||
unassignAsset = asset;
|
||||
condition = asset.condition;
|
||||
conditionDetails = asset.conditionDetails;
|
||||
// if(confirm("Unassign Asset?")) {
|
||||
// Meteor.call("assets.unassign", asset.assetId);
|
||||
// }
|
||||
openDialog();
|
||||
}
|
||||
|
||||
let isDialogOpen = false;
|
||||
let dialogAsset;
|
||||
|
||||
const openDialog = () => {
|
||||
// assetTypeDialogSelectedIndex = -1;
|
||||
isDialogOpen = true;
|
||||
}
|
||||
const dialogClosed = (e) => {
|
||||
switch (e.detail.action) {
|
||||
case 'unassign':
|
||||
if(unassignAsset && unassignAsset.assetId) {
|
||||
Meteor.call("assets.unassign", unassignAsset.assetId, comment, condition, conditionDetails, (err, result) => {
|
||||
if(err) {
|
||||
console.error(err);
|
||||
//TODO: Display an error!
|
||||
}
|
||||
else {
|
||||
// TODO: Set focus to the asset ID field.
|
||||
unassignAsset = undefined;
|
||||
}
|
||||
});
|
||||
}
|
||||
break;
|
||||
default:
|
||||
case 'cancel':
|
||||
break;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="container">
|
||||
<h1 style="display: block">Asset Assignments</h1>
|
||||
<Dialog bind:open={isDialogOpen} 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 type="text" style="width: 100%; margin-top: 1rem" bind:value={comment} label="Comment"></TextField>
|
||||
</div>
|
||||
<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="unassign" default>
|
||||
<Label>Ok</Label>
|
||||
</Button>
|
||||
<Button action="cancel">
|
||||
<Label>Cancel</Label>
|
||||
</Button>
|
||||
</Actions>
|
||||
</Dialog>
|
||||
|
||||
<h1 style="display: block">Asset Assignments By Student/Staff</h1>
|
||||
|
||||
<Paper>
|
||||
<LayoutGrid>
|
||||
@@ -91,6 +165,9 @@
|
||||
Type: {asset.type.name}<br/>
|
||||
AssetId: {asset.assetId}<br/>
|
||||
Serial: {asset.serial}<br/>
|
||||
<Button variant="raised" touch on:click={() => {unassign(asset)}}>
|
||||
<Label style="color: white">Unassign</Label>
|
||||
</Button>
|
||||
{/each}
|
||||
</div>
|
||||
</li>
|
||||
@@ -107,6 +184,9 @@
|
||||
Type: {asset.type.name}<br/>
|
||||
AssetId: {asset.assetId}<br/>
|
||||
Serial: {asset.serial}<br/>
|
||||
<Button variant="raised" touch on:click={() => {unassign(asset)}}>
|
||||
<Label style="color: white">Unassign</Label>
|
||||
</Button>
|
||||
{/each}
|
||||
</div>
|
||||
</li>
|
||||
|
||||
Reference in New Issue
Block a user