diff --git a/client/AdminMgmt/SysConfig/systemAdmin.html b/client/AdminMgmt/SysConfig/systemAdmin.html
index 9d8040f..17bd519 100644
--- a/client/AdminMgmt/SysConfig/systemAdmin.html
+++ b/client/AdminMgmt/SysConfig/systemAdmin.html
@@ -41,6 +41,9 @@
+
+
+
diff --git a/client/Locations/locationInfo.html b/client/Locations/locationInfo.html
new file mode 100644
index 0000000..7f5863f
--- /dev/null
+++ b/client/Locations/locationInfo.html
@@ -0,0 +1,14 @@
+
+ {{#each parentLocations}}
+
+ {{locationName}}
+
+ {{#each childLocation}}
+
+ {{locationName}}
+
+ {{/each}}
+
+
+ {{/each}}
+
\ No newline at end of file
diff --git a/client/Locations/locationInfo.js b/client/Locations/locationInfo.js
new file mode 100644
index 0000000..64aec76
--- /dev/null
+++ b/client/Locations/locationInfo.js
@@ -0,0 +1,33 @@
+import { Roles } from 'meteor/roles';
+import { FlowRouter } from 'meteor/ostrio:flow-router-extra';
+import { Locations } from '../../imports/api/locations.js';
+import { LocationTypes } from '../../imports/api/locationTypes.js';
+import _classCheckPrivateStaticFieldDescriptor from '@babel/runtime/helpers/classCheckPrivateStaticFieldDescriptor';
+
+Template.locationInfo.onCreated(function () {
+ this.subscribe("LocationTypes");
+ this.subscribe("Locations");
+});
+
+Template.locationInfo.onRendered(function () {
+
+});
+
+Template.locationInfo.helpers({
+ parentLocations: function () {
+ return Locations.find({ isChild: false });
+ },
+ childLocation: function () {
+ let parId = Session.get("parentId");
+ console.log("Child Loc: " + parId);
+ return Locations.find({ parentId: parId });
+ },
+});
+
+Template.locationInfo.events({
+ 'click .topLevel'(e) {
+ let parentId = e.currentTarget.id;
+ console.log("Parent ID: " + parentId);
+ Session.set("parentId", parentId);
+ },
+});
\ No newline at end of file
diff --git a/client/Locations/locations.html b/client/Locations/locations.html
index c4b7f15..c9a3cef 100644
--- a/client/Locations/locations.html
+++ b/client/Locations/locations.html
@@ -1,4 +1,55 @@
Locations
-
+ You can build out your storage structure heere. Setting a location as a 'child' will prompt you to select the 'parent' location.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{#if $eq isChild true}}
+
+
+
+
+ {{/if}}
+
+
+
+ {{> locationInfo}}
+ {{> snackbar}}
\ No newline at end of file
diff --git a/client/Locations/locations.js b/client/Locations/locations.js
index 4a2d111..35b1f0e 100644
--- a/client/Locations/locations.js
+++ b/client/Locations/locations.js
@@ -1,19 +1,92 @@
import { Roles } from 'meteor/roles';
import { FlowRouter } from 'meteor/ostrio:flow-router-extra';
-// import { Locations } from '../../imports/api/locations.js';
-
-Template.locations.onCreated(function() {
+import { Locations } from '../../imports/api/locations.js';
+import { LocationTypes } from '../../imports/api/locationTypes.js';
+Template.locations.onCreated(function () {
+ this.subscribe("LocationTypes");
+ this.subscribe("Locations");
});
-Template.locations.onRendered(function() {
-
+Template.locations.onRendered(function () {
+ Session.set("isChild", false);
});
Template.locations.helpers({
-
+ isChild: function () {
+ return Session.get("isChild");
+ },
+ locations: function () {
+ return Locations.find({});
+ },
+ locTypes: function () {
+ return LocationTypes.find({});
+ }
});
Template.locations.events({
+ 'change #locationIsChild'(event) {
+ console.log("Clicked.");
+ let isChild = $("#locationIsChild").prop('checked');
+ if (isChild) {
+ Session.set("isChild", true);
+ } else {
+ Session.set("isChild", false);
+ }
+ },
+ 'click #saveLocation'(event) {
+ let locName = $("#locationName").val();
+ let locDesc = $("#locationDesc").val();
+ let locType = $("#locationType").val();
+ let isChild = $("#locationIsChild").prop("checked");
+ let parentLocation = $("#parentLocation").val();
+ let parentInfo = [];
+ let parentName = "";
+ let parentId = "";
+
+ let locTypeParts = locType.split(' | ');
+ let locTypeName = locTypeParts[0];
+ let locTypeId = locTypeParts[1];
+
+ if (isChild == true) {
+ // split the parent location name details
+ if (parentLocation == "" || parentLocation == null) {
+ showSnackbar("Parent Location is Required!", "red");
+ return;
+ } else {
+ parentInfo = parentLocation.split(' | ');
+ parentName = parentInfo[0];
+ parentId = parentInfo[1];
+ }
+ }
+
+ if (locName == null || locName == "") {
+ showSnackbar("Location Name is Required!", "red");
+ return;
+ } else if (locType == "" || locType == null) {
+ showSnackbar("Location Type is Required!", "red");
+ return;
+ } else {
+ let addLocation = async () => {
+ try {
+ const result = await Meteor.callAsync('add.location', locName, locDesc, locTypeName, locTypeId, isChild, parentName, parentId);
+ if (!result) {
+ showSnackbar("Could not add location!", "red");
+ return;
+ } else {
+ showSnackbar("Location Successfuly Added!", "green");
+ $("#locationName").val("");
+ $("#locationDesc").val("");
+ $("#locationType").val("");
+ $("#isChild").prop('checked', false);
+ $("#parentLocation").val("");
+ }
+ } catch (error) {
+ console.log(error);
+ }
+ }
+ addLocation();
+ }
+ }
});
\ No newline at end of file
diff --git a/imports/api/locationTypes.js b/imports/api/locationTypes.js
index d02fef6..852bc4c 100644
--- a/imports/api/locationTypes.js
+++ b/imports/api/locationTypes.js
@@ -20,11 +20,11 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to add location types. Make sure you are logged in with valid user credentials.');
}
- return await LocationTypes.insertAsync({
- locationTypeName: typeName,
- locationTypeDesc: typeDesc,
- dateAdded: new Date(),
- addedBy: this.userId,
- });
+ return await LocationTypes.insertAsync({
+ locationTypeName: typeName,
+ locationTypeDesc: typeDesc,
+ dateAdded: new Date(),
+ addedBy: this.userId,
+ });
}
});
\ No newline at end of file
diff --git a/imports/api/locations.js b/imports/api/locations.js
index d7d3233..d6093d1 100644
--- a/imports/api/locations.js
+++ b/imports/api/locations.js
@@ -12,5 +12,29 @@ Locations.allow({
});
Meteor.methods({
+ async 'add.location' (locName, locDesc, locTypeName, locTypeId, isChild, parentName, parentId) {
+ check(locName, String);
+ check(locDesc, String);
+ check(locTypeName, String);
+ check(locTypeId, String);
+ check(isChild, Boolean);
+ check(parentName, String);
+ check(parentId, String);
+ if (!this.userId) {
+ throw new Meteor.Error('You are not allowed to add locations. Make sure you are logged in with valid user credentials.');
+ }
+
+ return await Locations.insertAsync({
+ locationName: locName,
+ locationDesc: locDesc,
+ locationTypeName: locTypeName,
+ locationTypeId: locTypeId,
+ isChild: isChild,
+ parentName: parentName,
+ parentId: parentId,
+ addedOn: new Date(),
+ addedBy: this.userId,
+ });
+ },
});
\ No newline at end of file