added editGroup endpoint.
added goToMenuOption function to enable navigation and posting (edit, create etc, on the homepage). created submitGroupEdit function to post the changed/new object to the server. #30
This commit is contained in:
parent
f27a124751
commit
3945789ee6
@ -8,11 +8,19 @@
|
||||
home: function () { return this.overview; }
|
||||
};
|
||||
self.apiEndpoints = {
|
||||
getGroups:"/api/groups"
|
||||
getGroups: "/api/groups",
|
||||
editGroup: "/api/groups/edit"
|
||||
};
|
||||
self.goToMenuOption = function (menu) { location.hash = menu; console.log("goToMenuOption: " + menu); };
|
||||
self.clearGroupForm = function(data, event) {
|
||||
self.groupEditItem({ Id: -1, Name: "" });
|
||||
};
|
||||
self.hideGroupForm = function(data, event) {
|
||||
self.groupEditItem(null);
|
||||
};
|
||||
self.groupFormHidden = ko.computed(function () {
|
||||
return self.groupEditItem() == null;
|
||||
}, self);
|
||||
self.editGroupClick = function(data, event) {
|
||||
self.groupEditItem(data);
|
||||
};
|
||||
@ -28,27 +36,24 @@
|
||||
//self.goToMenuOption(self.uiPages.home());
|
||||
});
|
||||
};
|
||||
self.submitGroupEdit = function(group) {
|
||||
var url = self.helpers.createRequestUrl(self.apiEndpoints.editGroup, null, false);
|
||||
$.post(url, group, function () {
|
||||
}, "json")
|
||||
.done(function () {
|
||||
self.groupEditItem(null);
|
||||
self.goToMenuOption(self.uiPages.home());
|
||||
})
|
||||
.fail(function (resp, status, error) {
|
||||
self.goToMenuOption(self.uiPages.home());
|
||||
});
|
||||
};
|
||||
Sammy(function () {
|
||||
this.get("#overview", function () {
|
||||
self.getGroups();
|
||||
});
|
||||
this.post("#editgroup", function () {
|
||||
|
||||
return false;
|
||||
});
|
||||
this.post("#edituser", function () {
|
||||
$.each(self.chosenUserDetails().AssociatedIdentifiers,
|
||||
function (k, v) {
|
||||
if (v.IsAssociatedToUser !== true) {
|
||||
self.chosenUserDetails().AssociatedIdentifiers.splice(k, 1);
|
||||
}
|
||||
});
|
||||
$.each(self.unassignedCardData().data, function (k, v) {
|
||||
if (v.IsAssociatedToUser === true) {
|
||||
self.chosenUserDetails().AssociatedIdentifiers.push(v);
|
||||
}
|
||||
});
|
||||
self.submitChangedUser(self.chosenUserDetails());
|
||||
self.submitGroupEdit(self.groupEditItem());
|
||||
return false;
|
||||
});
|
||||
//default route (home page)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user