mirror of
https://gitlab.com/bmcgonag/get_my.git
synced 2026-03-27 00:08:49 +00:00
Many chcanges, but version 0.1.0 is ready to be cut.
This commit is contained in:
parent
42643a37f5
commit
6e37ae8c74
46 changed files with 1038 additions and 273 deletions
34
client/ListItems/listItemsForm.html
Normal file
34
client/ListItems/listItemsForm.html
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<template name="listItemsForm">
|
||||
<div class="row">
|
||||
<div class="col s6">
|
||||
<h4>{{selListName}}</h4>
|
||||
</div>
|
||||
<div class="col s6">
|
||||
<p>
|
||||
<label>
|
||||
<input type="checkbox" id="showReceivedItems" />
|
||||
<span>Show Recv'd</span>
|
||||
</label>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col s9 m10 l10">
|
||||
<input list="listItemsData" name="listItems" id="listItems">
|
||||
|
||||
<datalist id="listItemsData">
|
||||
{{#each itemProdName}}
|
||||
<option value="{{prodName}}">{{prodName}}</option>
|
||||
{{/each}}
|
||||
</datalist>
|
||||
</div>
|
||||
<div class="col s3 m2 l2">
|
||||
{{#if $eq editMode false}}
|
||||
<a class="waves-effect waves-light btn saveListItem green right">Add</a>
|
||||
{{else}}
|
||||
<a class="waves-effect waves-light btn renameListItem blue right">Rename</a>
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
68
client/ListItems/listItemsForm.js
Normal file
68
client/ListItems/listItemsForm.js
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
import { ListItems } from '../../imports/api/listItems.js'
|
||||
import { Lists } from '../../imports/api/lists.js';
|
||||
import { Products } from '../../imports/api/products.js';
|
||||
|
||||
Template.listItemsForm.onCreated(function() {
|
||||
this.subscribe("myListItems", Session.get("listId"));
|
||||
this.subscribe("myLists");
|
||||
this.subscribe("myProducts");
|
||||
});
|
||||
|
||||
Template.listItemsForm.onRendered(function() {
|
||||
Meteor.setTimeout(function() {
|
||||
$('select').formSelect();
|
||||
}, 100);
|
||||
$('select').formSelect();
|
||||
Session.set("listItemEditMode", false);
|
||||
Session.set("itemReqErr", false);
|
||||
Session.set("showReceivedItems", false);
|
||||
});
|
||||
|
||||
Template.listItemsForm.helpers({
|
||||
selListName: function() {
|
||||
let selListId = Session.get("listId");
|
||||
console.log("List ID in Helper is: " + selListId);
|
||||
let listInfo = Lists.findOne({ _id: selListId });
|
||||
return listInfo.listName;
|
||||
},
|
||||
itemProdName: function() {
|
||||
return Products.find({});
|
||||
},
|
||||
editMode: function() {
|
||||
return Session.get("listItemEditMode");
|
||||
}
|
||||
});
|
||||
|
||||
Template.listItemsForm.events({
|
||||
'click .saveListItem' (event) {
|
||||
event.preventDefault();
|
||||
let item = $("#listItems").val();
|
||||
let listId = Session.get("listId");
|
||||
if (item == null || item == "") {
|
||||
Session.set("itemReqErr", true);
|
||||
} else {
|
||||
Meteor.call("add.listItem", item, listId, function(err, result) {
|
||||
if (err) {
|
||||
console.log(" ERROR adding item to list: " + err);
|
||||
} else {
|
||||
console.log(" SUCCESS adding item to list.");
|
||||
$("#listItems").val("");
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
'keypress #listItemInput' (event) {
|
||||
event.preventDefault();
|
||||
|
||||
},
|
||||
'click .editListItem' (event) {
|
||||
event.preventDefault();
|
||||
},
|
||||
'click #showReceivedItems' (event) {
|
||||
if ($("#showReceivedItems").prop('checked') == true) {
|
||||
Session.set("showReceivedItems", true);
|
||||
} else {
|
||||
Session.set("showReceivedItems", false);
|
||||
}
|
||||
}
|
||||
});
|
||||
5
client/ListItems/listItemsMain.html
Normal file
5
client/ListItems/listItemsMain.html
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<template name="listItemsMain">
|
||||
{{> listItemsForm}}
|
||||
<hr>
|
||||
{{> listItemsTbl}}
|
||||
</template>
|
||||
15
client/ListItems/listItemsMain.js
Normal file
15
client/ListItems/listItemsMain.js
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
Template.listItemsMain.onCreated(function() {
|
||||
|
||||
});
|
||||
|
||||
Template.listItemsMain.onRendered(function() {
|
||||
|
||||
});
|
||||
|
||||
Template.listItemsMain.helpers({
|
||||
|
||||
});
|
||||
|
||||
Template.listItemsMain.events({
|
||||
|
||||
});
|
||||
21
client/ListItems/listItemsTbl.html
Normal file
21
client/ListItems/listItemsTbl.html
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<template name="listItemsTbl">
|
||||
<div class="row">
|
||||
<div class="col s12">
|
||||
<ul class="collection">
|
||||
{{#each thisListItems}}
|
||||
<li class="collection-item">
|
||||
<span>
|
||||
{{#if $eq itemOrdered true}}
|
||||
<strike>{{itemName}}</strike>
|
||||
{{else}}
|
||||
{{itemName}}
|
||||
{{/if}}
|
||||
</span>
|
||||
<i class="material-icons clickable deleteListItem right">delete</i>
|
||||
<i class="material-icons clickable markListItemReceived right">check</i>
|
||||
</li>
|
||||
{{/each}}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
67
client/ListItems/listItemsTbl.js
Normal file
67
client/ListItems/listItemsTbl.js
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
import { ListItems } from '../../imports/api/listItems.js';
|
||||
|
||||
Template.listItemsTbl.onCreated(function() {
|
||||
this.autorun( () => {
|
||||
this.subscribe("myListItems", Session.get("listId"));
|
||||
});
|
||||
});
|
||||
|
||||
Template.listItemsTbl.onRendered(function() {
|
||||
Session.set("showReceivedItems", false);
|
||||
});
|
||||
|
||||
Template.listItemsTbl.helpers({
|
||||
'thisListItems': function() {
|
||||
let showRecvd = Session.get("showReceivedItems");
|
||||
console.log("Show Received is: " + showRecvd);
|
||||
if (showRecvd == false) {
|
||||
return ListItems.find({ itemReceived: false });
|
||||
} else {
|
||||
return ListItems.find({});
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
Template.listItemsTbl.events({
|
||||
'click li' (event) {
|
||||
event.preventDefault();
|
||||
let itemInfo = ListItems.findOne({ _id: this._id });
|
||||
if (itemInfo.itemOrdered == true) {
|
||||
Meteor.call('setNotOrdered.listItem', this._id, function(err, result) {
|
||||
if (err) {
|
||||
console.log(" ERROR setting this item as NOT ordered: " + err);
|
||||
} else {
|
||||
console.log(" SUCCESS setting this item as NOT ordered.");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Meteor.call('setOrdered.listItem', this._id, function(err, result) {
|
||||
if (err) {
|
||||
console.log(" ERROR marking item ordered: " + err);
|
||||
} else {
|
||||
console.log(" SUCCESS marking this item ordered.");
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
'click .markListItemReceived' (event) {
|
||||
event.preventDefault();
|
||||
Meteor.call('setReceived.listItem', this._id, function(err, result) {
|
||||
if (err) {
|
||||
console.log(" ERROR setting item as received: " + err);
|
||||
} else {
|
||||
console.log(" SUCCESS setting item received.");
|
||||
}
|
||||
});
|
||||
},
|
||||
'click .deleteListItem' (event) {
|
||||
event.preventDefault();
|
||||
Meteor.call('delete.listItem', this._id, function(err, result) {
|
||||
if (err) {
|
||||
console.log(" ERROR deleting the list item: " + err);
|
||||
} else {
|
||||
console.log(" SUCCESS deleting the list item.");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue