From ca09122c7fd05d49a18e42bfafd9c31284243c50 Mon Sep 17 00:00:00 2001 From: Mark Schouten Date: Thu, 10 Jul 2014 16:17:32 +0200 Subject: [PATCH] Refresh user when switching between users and zones field --- index.php | 113 +++++++++++++++++++++++++++++------------------------- 1 file changed, 61 insertions(+), 52 deletions(-) diff --git a/index.php b/index.php index 5fe9e66..4f74b4e 100644 --- a/index.php +++ b/index.php @@ -149,56 +149,6 @@ function escapeHtml(string) { $(document).ready(function () { - - $('#Users').hide(); - $('#useradmin').click(function () { - $('#Users').show(); - $('#MasterZones').hide(); - $('#SlaveZones').hide(); - }); - $('#zoneadmin').click(function () { - $('#Users').hide(); - $('#MasterZones').show(); - $('#SlaveZones').show(); - $('#MasterZones').jtable('load'); - $('#SlaveZones').jtable('load'); - }); - $('#Users').jtable({ - title: 'Users', - paging: true, - pageSize: 20, - sorting: false, - actions: { - listAction: 'users.php?action=list', - createAction: 'users.php?action=create', - deleteAction: 'users.php?action=delete', - updateAction: 'users.php?action=update' - }, - messages: { - addNewRecord: 'Add new user' - }, - fields: { - id: { - key: true, - type: 'hidden' - }, - emailaddress: { - title: 'User' - }, - password: { - title: 'Password', - type: 'password', - list: false - }, - isadmin: { - title: 'Admin', - type: 'checkbox', - values: {'0': 'No', '1': 'Yes'} - } - } - }); - $('#Users').jtable('load'); - $('#SlaveZones').jtable({ title: 'Slave Zones', paging: true, @@ -225,7 +175,10 @@ $(document).ready(function () { owner: { title: 'Owner', - options: {'admin': 'admin'}, + options: function(data) { + data.clearCache(); + return 'users.php?action=listoptions'; + }, defaultValue: 'admin' }, @@ -345,7 +298,10 @@ $(document).ready(function () { owner: { title: 'Owner', - options: {'admin': 'admin'}, + options: function(data) { + data.clearCache(); + return 'users.php?action=listoptions'; + }, defaultValue: 'admin' }, @@ -494,6 +450,59 @@ $(document).ready(function () { }); $('#MasterZones').jtable('load'); $('#SlaveZones').jtable('load'); + + $('#Users').hide(); + $('#useradmin').click(function () { + $('#Users').jtable('reload'); + $('#Users').show(); + $('#MasterZones').hide(); + $('#SlaveZones').hide(); + }); + $('#zoneadmin').click(function () { + $('#Users').hide(); + $('#MasterZones').jtable('reload'); + $('#MasterZones').show(); + $('#SlaveZones').jtable('reload'); + $('#SlaveZones').show(); + $('#MasterZones').jtable('load'); + $('#SlaveZones').jtable('load'); + }); + $('#Users').jtable({ + title: 'Users', + paging: true, + pageSize: 20, + sorting: false, + actions: { + listAction: 'users.php?action=list', + createAction: 'users.php?action=create', + deleteAction: 'users.php?action=delete', + updateAction: 'users.php?action=update' + }, + messages: { + addNewRecord: 'Add new user' + }, + fields: { + id: { + key: true, + type: 'hidden' + }, + emailaddress: { + title: 'User' + }, + password: { + title: 'Password', + type: 'password', + list: false + }, + isadmin: { + title: 'Admin', + type: 'checkbox', + values: {'0': 'No', '1': 'Yes'} + } + } + }); + $('#Users').jtable('load'); + });