--- Admin.html ----
remove hide link on groups form. fix widths of columns for "User Count" and delete button. --- admin.js ---- removed unused params from methods. removed auto adding a blank group item to form on startup (assign null/hide form on load). fix issues with page flickering in certain conditions (on group delete). #64
This commit is contained in:
parent
8d51f3545f
commit
d97343409c
@ -40,7 +40,7 @@
|
||||
<div id="GroupAdminPage" class="container">
|
||||
<div class="row">
|
||||
<h2 class="col-md-4">Groups</h2>
|
||||
<button class="col-md-1 btn btn-default pull-right" style="margin-top: 20px;" data-bind="click: $root.clearGroupForm">
|
||||
<button class="col-md-1 btn btn-default pull-right" style="margin-top: 20px;" data-bind="click: $root.newGroupForm">
|
||||
<span class="glyphicon glyphicon-plus"></span>
|
||||
</button>
|
||||
</div>
|
||||
@ -51,8 +51,8 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>User Count</th>
|
||||
<th></th>
|
||||
<th class="col-md-3">User Count</th>
|
||||
<th class="col-md-1"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody data-bind="foreach: Groups">
|
||||
@ -71,10 +71,9 @@
|
||||
<input for="Name" type="text" class="form-control" id="groupNameEdit" placeholder="Group Name" data-bind="value: Name"/>
|
||||
</div>
|
||||
<button pageDestination="Users" class="btn btn-secondary" type="button"
|
||||
data-bind="click: $root.clearGroupForm">Cancel</button>
|
||||
data-bind="click: $root.hideGroupForm">Cancel</button>
|
||||
|
||||
<button type="submit" class="btn btn-primary">Submit</button>
|
||||
<button class="btn btn-link pull-right" data-bind="click: $root.hideGroupForm" type="button">Hide</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
function AdminVM() {
|
||||
var self = this;
|
||||
self.groupsList = ko.observable(null);
|
||||
self.groupEditItem = ko.observable({Id:-1,Name:""});
|
||||
self.groupEditItem = ko.observable(null);
|
||||
self.helpers = new Helpers();
|
||||
self.uiPages = {
|
||||
overview: "overview",
|
||||
@ -13,18 +13,21 @@
|
||||
getGroups: "/api/groups",
|
||||
editGroup: "/api/groups/edit"
|
||||
};
|
||||
self.clearGroupForm = function (data, event) {
|
||||
self.goToMenuOption(self.uiPages.group);
|
||||
self.groupEditItem({ Id: -1, Name: "" });
|
||||
};
|
||||
self.hideGroupForm = function (data, event) {
|
||||
self.clearGroupForm = function () {
|
||||
self.helpers.goToMenuOption(self.uiPages.group);
|
||||
self.groupEditItem(null);
|
||||
};
|
||||
self.hideGroupForm = function () {
|
||||
self.groupEditItem(null);
|
||||
};
|
||||
self.newGroupForm = function () {
|
||||
self.groupEditItem({ Id: -1, Name: "" });
|
||||
self.helpers.goToMenuOption(self.uiPages.group);
|
||||
};
|
||||
self.groupFormHidden = ko.computed(function () {
|
||||
return self.groupEditItem() == null;
|
||||
}, self);
|
||||
self.editGroupClick = function (data, event) {
|
||||
self.editGroupClick = function (data) {
|
||||
self.helpers.goToMenuOption(self.uiPages.group);
|
||||
self.groupEditItem(data);
|
||||
};
|
||||
@ -32,12 +35,9 @@
|
||||
var url = self.helpers.createRequestUrl(self.apiEndpoints.getGroups, null, false);
|
||||
$.getJSON(url, function (res) {
|
||||
self.groupsList(res);
|
||||
//console.log(res);
|
||||
}).fail(function (resp, status, error) {
|
||||
console.log("error - getGroups");
|
||||
//var errObj = self.processRequestFailure(resp, status, error);
|
||||
//self.assignErrorObject(errObj.errorCode, errObj.errorMessage, "getGroups");
|
||||
//self.goToMenuOption(self.uiPages.home());
|
||||
var errorObj = self.helpers.processRequestFailure(resp, status, error);
|
||||
});
|
||||
};
|
||||
self.deleteGroup = function (groupId) {
|
||||
@ -48,11 +48,10 @@
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: 'DELETE',
|
||||
success: function (result) {
|
||||
success: function () {
|
||||
console.log("deleted " + groupId);
|
||||
self.hideGroupForm();
|
||||
self.helpers.goToMenuOption(self.uiPages.home());
|
||||
self.clearGroupForm();
|
||||
// Do something with the result
|
||||
}
|
||||
});
|
||||
console.log("delete: " + groupId);
|
||||
@ -67,11 +66,12 @@
|
||||
})
|
||||
.fail(function (resp, status, error) {
|
||||
self.helpers.goToMenuOption(self.uiPages.home());
|
||||
var errorObj = self.helpers.processRequestFailure(resp, status, error);
|
||||
});
|
||||
};
|
||||
Sammy(function () {
|
||||
this.disable_push_state = true;
|
||||
this.get("#overview", function () {
|
||||
self.clearGroupForm();
|
||||
self.getGroups();
|
||||
});
|
||||
this.post("#editgroup", function () {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user