Lots of changes and additions to the project. Still early, and not usable.

This commit is contained in:
Brian McGonagill 2022-08-15 18:07:39 -05:00
parent 8636f8cf9b
commit 266dbd0856
41 changed files with 836 additions and 67 deletions

View file

@ -0,0 +1,5 @@
<template name="locMgmt">
{{> locMgmtForm}}
<hr>
{{> locMgmtTbl}}
</template>

View file

@ -0,0 +1,15 @@
Template.locMgmt.onCreated(function() {
});
Template.locMgmt.onRendered(function() {
});
Template.locMgmt.helpers({
});
Template.locMgmt.events({
});

View file

@ -0,0 +1,16 @@
<template name="locMgmtForm">
<div class="row">
<div class="col s12 m6 l6 input-field">
<input type="text" class="locNameInp" id="locNameInp" style="{{#if $eq locNameErr true}}border: 2px solid red;{{/if}}" />
<label for="locNameInp">Name*</label>
</div>
</div>
<div class="row">
<div class="col s6 m6 l6">
<a class="waves-effect waves-light btn cancelLocMgmt orange">Cancel</a>
</div>
<div class="col s6 m6 l6">
<a class="waves-effect waves-light btn saveLocMgmt green right">Add</a>
</div>
</div>
</template>

View file

@ -0,0 +1,39 @@
import { Locations } from '../../../imports/api/location.js';
Template.locMgmtForm.onCreated(function() {
this.subscribe("myLocations");
});
Template.locMgmtForm.onRendered(function() {
Session.set("locNameMiss", false);
});
Template.locMgmtForm.helpers({
locNameErr: function() {
return Session.get("locNameMiss");
},
});
Template.locMgmtForm.events({
'click .saveLocMgmt' (event) {
event.preventDefault();
let locName = $("#locNameInp").val();
if (locName == null || locName == "") {
Session.set("locNameMiss", true);
return;
} else {
Meteor.call('add.location', locName, function(err, result) {
if (err) {
// console.log(" ERROR: Can't add category: " + err);
} else {
// console.log(" SUCCESS adding category.");
$("#locNameInp").val("");
}
});
}
},
'click .cancelLocMgmt' (event) {
event.preventDefault();
$("#locNameInp").val("");
}
});

View file

@ -0,0 +1,21 @@
<template name="locMgmtTbl">
<table class="highlight striped responsive-table">
<thead>
<tr>
<th>Name</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{{#each locs}}
<tr>
<td>{{locationName}}</td>
<td>
<i class="material-icons clickable deleteCategory">delete</i>
<i class="material-icons clickable editCategory">edit</i>
</td>
</tr>
{{/each}}
</tbody>
</table>
</template>

View file

@ -0,0 +1,19 @@
import { Locations } from '../../../imports/api/location.js';
Template.locMgmtTbl.onCreated(function() {
this.subscribe("myLocations");
});
Template.locMgmtTbl.onRendered(function() {
});
Template.locMgmtTbl.helpers({
locs: function() {
return Locations.find({});
}
});
Template.locMgmtTbl.events([
]);