Updated assignments by person to allow unassigning and assigning.

This commit is contained in:
2022-08-20 22:51:54 -07:00
parent 2b9825159b
commit 8d4b72c581
13 changed files with 808 additions and 638 deletions

View File

@@ -0,0 +1,45 @@
<script>
import {Assets} from "/imports/api/assets";
import {AssetTypes} from "/imports/api/asset-types";
import {onMount} from "svelte";
import {Meteor} from "meteor/meteor";
import Button, { Label } from '@smui/button';
import { createEventDispatcher } from 'svelte';
import {useTracker} from 'meteor/rdb:svelte-meteor-data';
const dispatch = createEventDispatcher();
export let person;
onMount(async () => {
//Meteor.subscribe('assetsAssignedTo', person._id);
Meteor.subscribe('assets');
Meteor.subscribe('assetTypes');
});
let assignedAssets;
//$: assignedAssets = useTracker(() => Assets.find({assigneeId: person._id}).fetch());
$m: assignedAssets = Assets.find({assigneeId: person._id}).fetch();
$m: {
//assignedAssets = Assets.find({}).fetch();
for (next of assignedAssets) {
next.type = AssetTypes.findOne({_id: next.assetTypeId})
}
}
let unassign = (asset) => {
dispatch('unassign', asset);
}
</script>
{#each assignedAssets as asset}
<div class="asset">
Type: {asset.type.name}<br/>
AssetId: {asset.assetId}<br/>
Serial: {asset.serial}<br/>
Assignee ID: {asset.assigneeId}<br/>
<Button variant="raised" color="secondary" touch on:click={() => {unassign(asset)}}>
<Label style="color: white">Unassign</Label>
</Button>
</div>
{/each}