From 4eb40af5b7ddd4c841767a15d9208b467f27339a Mon Sep 17 00:00:00 2001 From: Richard Underwood Date: Wed, 4 Jan 2017 14:22:50 +0000 Subject: [PATCH] Moved things around in index.php so that the selection for records doesn't stop the permissions list from working. --- index.php | 403 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 207 insertions(+), 196 deletions(-) diff --git a/index.php b/index.php index e92e763..1df3400 100644 --- a/index.php +++ b/index.php @@ -513,199 +513,6 @@ $(document).ready(function () { ], }, sorting: false, - selecting: true, - selectOnRowClick: true, - selectionChanged: function (data) { - var $selectedRows = $('#MasterZones').jtable('selectedRows'); - $selectedRows.each(function () { - var zone = $(this).data('record'); - $('#MasterZones').jtable('openChildTable', - $(this).closest('tr'), { - title: 'Records in ' + zone.name, - messages: { - addNewRecord: 'Add to ' + zone.name, - noDataAvailable: 'No records for ' + zone.name - }, - toolbar: { - items: [ - { - text: 'Search zone', - click: function() { - $("#searchzone").dialog({ - modal: true, - title: "Search zone for ...", - width: 'auto', - buttons: { - Search: function() { - $( this ).dialog( 'close' ); - opentable.find('.jtable-title-text').text(opentableTitle + " (filtered)"); - opentable.jtable('load', { - label: $('#searchzone-label').val(), - type: $('#searchzone-type').val(), - content: $('#searchzone-content').val() - }); - }, - Reset: function() { - $('#searchzone-label').val(''); - $('#searchzone-type').val(''); - $('#searchzone-content').val(''); - $( this ).dialog( 'close' ); - opentable.find('.jtable-title-text').text(opentableTitle); - opentable.jtable('load'); - return false; - } - } - }); - } - } - ], - }, - paging: true, - sorting: true, - pageSize: 20, - openChildAsAccordion: true, - actions: { - listAction: 'zones.php?action=listrecords&zoneid=' + zone.id, - createAction: 'zones.php?action=createrecord&zoneid=' + zone.id, - deleteAction: 'zones.php?action=deleterecord&zoneid=' + zone.id, - updateAction: 'zones.php?action=editrecord&zoneid=' + zone.id - }, - fields: { - domid: { - create: true, - type: 'hidden', - defaultValue: zone.id - }, - id: { - key: true, - type: 'hidden', - create: false, - edit: false, - list: false - }, - domain: { - create: true, - type: 'hidden', - defaultValue: zone.name - }, - name: { - title: 'Label', - width: '7%', - sorting: true, - create: true, - display: displayContent('name', zone.name), - inputClass: 'name', - listClass: 'name' - }, - type: { - title: 'Type', - width: '2%', - options: function() { - zonename = new String(zone.name); - if (zonename.match(/(\.in-addr|\.ip6)\.arpa/)) { - return { - 'PTR': 'PTR', - 'NS': 'NS', - 'MX': 'MX', - 'TXT': 'TXT', - 'SOA': 'SOA', - 'A': 'A', - 'AAAA': 'AAAA', - 'CERT': 'CERT', - 'CNAME': 'CNAME', - 'LOC': 'LOC', - 'NAPTR': 'NAPTR', - 'SPF': 'SPF', - 'SRV': 'SRV', - 'SSHFP': 'SSHFP', - 'TLSA': 'TLSA', - 'DNAME': 'DNAME', - 'DS': 'DS' - }; - } - return { - 'A': 'A', - 'AAAA': 'AAAA', - 'CERT': 'CERT', - 'CNAME': 'CNAME', - 'DNAME': 'DNAME', - 'DS': 'DS', - 'LOC': 'LOC', - 'MX': 'MX', - 'NAPTR': 'NAPTR', - 'NS': 'NS', - 'PTR': 'PTR', - 'SOA': 'SOA', - 'SPF': 'SPF', - 'SRV': 'SRV', - 'SSHFP': 'SSHFP', - 'TLSA': 'TLSA', - 'TXT': 'TXT', - }; - }, - display: displayContent('type'), - create: true, - inputClass: 'type', - listClass: 'type' - }, - content: { - title: 'Content', - width: '30%', - create: true, - sorting: true, - display: displayContent('content'), - inputClass: 'content', - listClass: 'content' - }, - ttl: { - title: 'TTL', - width: '2%', - create: true, - sorting: false, - display: displayContent('ttl'), - defaultValue: '', - inputClass: 'ttl', - listClass: 'ttl' - }, - setptr: { - title: 'Set PTR Record', - width: '2%', - list: false, - create: true, - defaultValue: 'false', - inputClass: 'setptr', - listClass: 'setptr', - options: function() { - return { - '0': 'No', - '1': 'Yes', - }; - }, - }, - disabled: { - title: 'Disabled', - width: '2%', - create: true, - sorting: false, - display: displayContent('disabled'), - defaultValue: '', - inputClass: 'disabled', - listClass: 'disabled', - options: function() { - return { - '0': 'No', - '1': 'Yes', - }; - }, - }, - } - }, function (data) { - opentable=data.childTable; - opentableTitle=opentable.find('.jtable-title-text').text(); - data.childTable.jtable('load'); - }); - }); - }, openChildAsAccordion: true, actions: { listAction: 'zones.php?action=list', @@ -800,6 +607,207 @@ $(document).ready(function () { inputClass: 'serial', listClass: 'serial' }, + records: { + title: 'Records', + width: '10%', + paging: true, + pageSize: 20, + create: false, + edit: false, + display: function(data) { + var $img = $(''); + $img.click(function () { + var zone = data.record; + $('#MasterZones').jtable('openChildTable', + $(this).closest('tr'), { + title: 'Records in ' + zone.name, + messages: { + addNewRecord: 'Add to ' + zone.name, + noDataAvailable: 'No records for ' + zone.name + }, + toolbar: { + items: [ + { + text: 'Search zone', + click: function() { + $("#searchzone").dialog({ + modal: true, + title: "Search zone for ...", + width: 'auto', + buttons: { + Search: function() { + $( this ).dialog( 'close' ); + opentable.find('.jtable-title-text').text(opentableTitle + " (filtered)"); + opentable.jtable('load', { + label: $('#searchzone-label').val(), + type: $('#searchzone-type').val(), + content: $('#searchzone-content').val() + }); + }, + Reset: function() { + $('#searchzone-label').val(''); + $('#searchzone-type').val(''); + $('#searchzone-content').val(''); + $( this ).dialog( 'close' ); + opentable.find('.jtable-title-text').text(opentableTitle); + opentable.jtable('load'); + return false; + } + } + }); + } + } + ], + }, + paging: true, + sorting: true, + pageSize: 20, + openChildAsAccordion: true, + actions: { + listAction: 'zones.php?action=listrecords&zoneid=' + zone.id, + createAction: 'zones.php?action=createrecord&zoneid=' + zone.id, + deleteAction: 'zones.php?action=deleterecord&zoneid=' + zone.id, + updateAction: 'zones.php?action=editrecord&zoneid=' + zone.id + }, + fields: { + domid: { + create: true, + type: 'hidden', + defaultValue: zone.id + }, + id: { + key: true, + type: 'hidden', + create: false, + edit: false, + list: false + }, + domain: { + create: true, + type: 'hidden', + defaultValue: zone.name + }, + name: { + title: 'Label', + width: '7%', + sorting: true, + create: true, + display: displayContent('name', zone.name), + inputClass: 'name', + listClass: 'name' + }, + type: { + title: 'Type', + width: '2%', + options: function() { + zonename = new String(zone.name); + if (zonename.match(/(\.in-addr|\.ip6)\.arpa/)) { + return { + 'PTR': 'PTR', + 'NS': 'NS', + 'MX': 'MX', + 'TXT': 'TXT', + 'SOA': 'SOA', + 'A': 'A', + 'AAAA': 'AAAA', + 'CERT': 'CERT', + 'CNAME': 'CNAME', + 'LOC': 'LOC', + 'NAPTR': 'NAPTR', + 'SPF': 'SPF', + 'SRV': 'SRV', + 'SSHFP': 'SSHFP', + 'TLSA': 'TLSA', + 'DNAME': 'DNAME', + 'DS': 'DS' + }; + } + return { + 'A': 'A', + 'AAAA': 'AAAA', + 'CERT': 'CERT', + 'CNAME': 'CNAME', + 'DNAME': 'DNAME', + 'DS': 'DS', + 'LOC': 'LOC', + 'MX': 'MX', + 'NAPTR': 'NAPTR', + 'NS': 'NS', + 'PTR': 'PTR', + 'SOA': 'SOA', + 'SPF': 'SPF', + 'SRV': 'SRV', + 'SSHFP': 'SSHFP', + 'TLSA': 'TLSA', + 'TXT': 'TXT', + }; + }, + display: displayContent('type'), + create: true, + inputClass: 'type', + listClass: 'type' + }, + content: { + title: 'Content', + width: '30%', + create: true, + sorting: true, + display: displayContent('content'), + inputClass: 'content', + listClass: 'content' + }, + ttl: { + title: 'TTL', + width: '2%', + create: true, + sorting: false, + display: displayContent('ttl'), + defaultValue: '', + inputClass: 'ttl', + listClass: 'ttl' + }, + setptr: { + title: 'Set PTR Record', + width: '2%', + list: false, + create: true, + defaultValue: 'false', + inputClass: 'setptr', + listClass: 'setptr', + options: function() { + return { + '0': 'No', + '1': 'Yes', + }; + }, + }, + disabled: { + title: 'Disabled', + width: '2%', + create: true, + sorting: false, + display: displayContent('disabled'), + defaultValue: '', + inputClass: 'disabled', + listClass: 'disabled', + options: function() { + return { + '0': 'No', + '1': 'Yes', + }; + }, + }, + } + }, function (data) { + opentable=data.childTable; + opentableTitle=opentable.find('.jtable-title-text').text(); + data.childTable.jtable('load'); + }); + + }); + return $img; + } + }, permissions: { title: 'Permissions', width: '10%', @@ -815,6 +823,7 @@ $(document).ready(function () { actions: { listAction: 'permissions.php?action=list&zoneid=' + data.record.id, createAction: 'permissions.php?action=add&zoneid=' + data.record.id, + updateAction: 'permissions.php?action=update&zoneid=' + data.record.id, deleteAction: 'permissions.php?action=remove&zoneid=' + data.record.id }, fields: { @@ -835,7 +844,9 @@ $(document).ready(function () { value: { title: 'Name', inputClass: "usergrouplist", - display: displayContent('value') + display: displayContent('value'), + create: true, + edit: false }, permissions: { title: 'Permissions', @@ -853,12 +864,12 @@ $(document).ready(function () { }, formCreated: function(event, dat) { $( ".usergrouplist" ).autocomplete({ - source: "users.php?action=autocomplete&zoneid=" + data.record.id + "&type=" + $( ".permissionstype" ).val() + source: "permissions.php?action=autocomplete&type=" + $( ".permissionstype" ).val() }); $( ".permissionstype" ).change(function() { $( ".usergrouplist" ).val(""); $( ".usergrouplist" ).autocomplete({ - source: "users.php?action=autocomplete&type=" + $( ".permissionstype" ).val() + source: "permissions.php?action=autocomplete&type=" + $( ".permissionstype" ).val() }); }); }