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
|
|
@ -6,12 +6,16 @@ Template.catMgmtForm.onCreated(function() {
|
|||
|
||||
Template.catMgmtForm.onRendered(function() {
|
||||
Session.set("catNameMiss", false);
|
||||
Session.set("catEditMode", false);
|
||||
});
|
||||
|
||||
Template.catMgmtForm.helpers({
|
||||
catNameErr: function() {
|
||||
return Session.get("catNameMiss");
|
||||
},
|
||||
catEditMode: function() {
|
||||
return Session.get("catEditMode");
|
||||
}
|
||||
});
|
||||
|
||||
Template.catMgmtForm.events({
|
||||
|
|
@ -32,8 +36,60 @@ Template.catMgmtForm.events({
|
|||
});
|
||||
}
|
||||
},
|
||||
'click .editCatMgmt' (event) {
|
||||
event.preventDefault();
|
||||
let catName = $("#catNameInp").val();
|
||||
let catId = this._id;
|
||||
if (catName == null || catName == "") {
|
||||
Session.set("catNameMiss", true);
|
||||
return;
|
||||
} else {
|
||||
let catId = Session.get("categoryEditId");
|
||||
Meteor.call('edit.category', catId, catName, function(err, result) {
|
||||
if (err) {
|
||||
// console.log(" ERROR: Can't edit category: " + err);
|
||||
} else {
|
||||
// console.log(" SUCCESS editing category.");
|
||||
$("#catNameInp").val("");
|
||||
Session.set("catEditMode", false);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
'submit #catInputForm' (event) {
|
||||
event.preventDefault();
|
||||
let catName = $("#catNameInp").val();
|
||||
let editMode = Session.get("catEditMode");
|
||||
if (catName == null || catName == "") {
|
||||
Session.set("catNameMiss", true);
|
||||
return;
|
||||
} else {
|
||||
if (editMode == false) {
|
||||
Meteor.call('add.category', catName, function(err, result) {
|
||||
if (err) {
|
||||
// console.log(" ERROR: Can't add category: " + err);
|
||||
} else {
|
||||
// console.log(" SUCCESS adding category.");
|
||||
$("#catNameInp").val("");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
let catId = Session.get("categoryEditId");
|
||||
Meteor.call('edit.category', catId, catName, function(err, result) {
|
||||
if (err) {
|
||||
// console.log(" ERROR: Can't edit category: " + err);
|
||||
} else {
|
||||
// console.log(" SUCCESS editing category.");
|
||||
$("#catNameInp").val("");
|
||||
Session.set("catEditMode", false);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
'click .cancelCatMgmt' (event) {
|
||||
event.preventDefault();
|
||||
$("#catNameInp").val("");
|
||||
Session.set("catEditMode", false);
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue