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:
@@ -4,12 +4,18 @@
|
||||
const fixAssetAssignments = () => {
|
||||
Meteor.call('assets.fixAssetAssignments');
|
||||
}
|
||||
const fixAssetCondition = () => {
|
||||
Meteor.call('assets.fixAssetCondition');
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="container">
|
||||
<Button variant="raised" touch on:click={fixAssetAssignments}>
|
||||
<Label style="color: white">Fix Assignments</Label>
|
||||
</Button>
|
||||
<Button variant="raised" touch on:click={fixAssetCondition}>
|
||||
<Label style="color: white">Fix Missing Asset Condition</Label>
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
|
||||
@@ -63,11 +63,14 @@
|
||||
}
|
||||
let assetId = "";
|
||||
let serial = "";
|
||||
let conditions = ['New', 'Like New', 'Good', 'Okay', 'Damaged'];
|
||||
let condition = "New";
|
||||
let conditionDetails = "";
|
||||
const addAsset = () => {
|
||||
if(selectedAssetType && selectedAssetType._id && assetId) {
|
||||
let result = Meteor.call("assets.add", selectedAssetType._id, assetId, serial, (err, res) => {
|
||||
let result = Meteor.call("assets.add", selectedAssetType._id, assetId, serial, condition, conditionDetails, (err, res) => {
|
||||
if (err) {
|
||||
if (err.error === 'duplicateAssetId')
|
||||
if (err.error === 'Duplicate Asset Id')
|
||||
alert("The asset ID `" + assetId + "` has already been used.");
|
||||
else
|
||||
alert(err);
|
||||
@@ -138,6 +141,15 @@
|
||||
<TextField type="text" style="width: 100%" bind:value={serial} label="Serial">
|
||||
</TextField>
|
||||
</div>
|
||||
<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%" bind:value={conditionDetails} label="Condition Details">
|
||||
</TextField>
|
||||
</div>
|
||||
<div style="text-align: right; margin-top: 2rem">
|
||||
<Button on:click={addAsset} variant="raised">Add</Button>
|
||||
</div>
|
||||
|
||||
@@ -64,11 +64,14 @@
|
||||
],
|
||||
};
|
||||
const deleteAsset = asset => {
|
||||
if(asset && asset._id) Meteor.call("assets.remove", asset._id);
|
||||
if(asset && asset._id) {
|
||||
if(confirm("Delete Asset? This is permanent.")) Meteor.call("assets.remove", asset._id);
|
||||
}
|
||||
};
|
||||
// Create a holder for the site being edited. This allows us to clear the editor when the user finishes, and allows the table or parent view to setup the editor.
|
||||
let editedAsset = writable(null);
|
||||
let dirtyAsset = null;
|
||||
let conditions = ['New', 'Like New', 'Good', 'Okay', 'Damaged'];
|
||||
// Copy the edited site when ever it changes, set some defaults for a new site object (to make the view happy).
|
||||
editedAsset.subscribe(site => {
|
||||
if(site) {
|
||||
@@ -126,6 +129,15 @@
|
||||
<TextField type="text" style="width: 100%" bind:value={dirtyAsset.serial} label="Serial">
|
||||
</TextField>
|
||||
</div>
|
||||
<Select bind:value={dirtyAsset.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%" bind:value={dirtyAsset.conditionDetails} label="Condition Details">
|
||||
</TextField>
|
||||
</div>
|
||||
|
||||
<div style="grid-column: 1/span 1; white-space: nowrap; text-align: right; margin-top: 0.5rem">
|
||||
<button type="button" style="grid-column: 2/span 1;" class="button accept-button material-icons material-symbols-outlined" on:click={applyAssetChanges}>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -9,8 +9,9 @@
|
||||
import {Assets} from "/imports/api/assets";
|
||||
import {Students} from "/imports/api/students";
|
||||
import {AssetTypes} from "/imports/api/asset-types";
|
||||
import Button, { Label } from '@smui/button';
|
||||
import Dialog, { Title, Content, Actions } from '@smui/dialog';
|
||||
import Select, { Option } from '@smui/select';
|
||||
import Button, { Label } from '@smui/button';
|
||||
import Dialog, { Title, Content, Actions } from '@smui/dialog';
|
||||
|
||||
onMount(async () => {
|
||||
Meteor.subscribe('assets');
|
||||
@@ -51,19 +52,83 @@
|
||||
foundAssignee = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
let conditions = ['New', 'Like New', 'Good', 'Okay', 'Damaged'];
|
||||
let condition = "New";
|
||||
let comment = "";
|
||||
let conditionDetails = "";
|
||||
|
||||
const formatDate = (date) => {
|
||||
return date.toLocaleDateString('en-us', {weekday: 'long', year: 'numeric', month: 'short', day: 'numeric'});
|
||||
}
|
||||
const unassign = () => {
|
||||
if(confirm("Unassign Asset?")) {
|
||||
Meteor.call("assets.unassign", foundAsset.assetId);
|
||||
}
|
||||
// if(confirm("Unassign Asset?")) {
|
||||
// Meteor.call("assets.unassign", foundAsset.assetId);
|
||||
// }
|
||||
condition = foundAsset.condition;
|
||||
conditionDetails = foundAsset.conditionDetails;
|
||||
|
||||
openDialog();
|
||||
}
|
||||
|
||||
let isDialogOpen = false;
|
||||
|
||||
const openDialog = () => {
|
||||
// assetTypeDialogSelectedIndex = -1;
|
||||
isDialogOpen = true;
|
||||
}
|
||||
const dialogClosed = (e) => {
|
||||
switch (e.detail.action) {
|
||||
case 'unassign':
|
||||
if(foundAsset && foundAsset.assetId) {
|
||||
Meteor.call("assets.unassign", foundAsset.assetId, comment, condition, conditionDetails, (err, result) => {
|
||||
if(err) {
|
||||
console.error(err);
|
||||
//TODO: Display an error!
|
||||
}
|
||||
else {
|
||||
// TODO: Set focus to the asset ID field.
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
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 Asset</h1>
|
||||
|
||||
<Paper>
|
||||
<LayoutGrid>
|
||||
@@ -75,6 +140,10 @@
|
||||
|
||||
{#if foundAsset}
|
||||
<div>Asset ID: {foundAsset.assetId}</div>
|
||||
<div>Condition: {foundAsset.condition}</div>
|
||||
{#if foundAsset.conditionDetails}
|
||||
<div>Condition Details: {foundAsset.conditionDetails}</div>
|
||||
{/if}
|
||||
{#if foundAssetType}
|
||||
<div>{foundAssetType.name}</div>
|
||||
{/if}
|
||||
|
||||
@@ -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