From cab3a513235a7dd5320168e7b33b9338571cad01 Mon Sep 17 00:00:00 2001 From: Ben Roberts Date: Sat, 27 Aug 2011 20:25:48 +0100 Subject: [PATCH] Add initial support for adding settings. Adds "Add Setting" button to table, and shows a popup with form elements for adding a new setting. Does not yet add setting to the db. --- webui/scripts/main.js | 30 +++++++++++++++---- webui/source/templates/admin/add-setting.tpl | 21 +++++++++++++ webui/source/templates/admin/settings.tpl | 1 + .../templates/ajax/admin/add-setting.tpl | 26 ++++++++++++++++ webui/source/templates/index.tpl | 6 ++++ 5 files changed, 79 insertions(+), 5 deletions(-) create mode 100644 webui/source/templates/admin/add-setting.tpl create mode 100644 webui/source/templates/ajax/admin/add-setting.tpl diff --git a/webui/scripts/main.js b/webui/scripts/main.js index 6bb6edc..e149041 100644 --- a/webui/scripts/main.js +++ b/webui/scripts/main.js @@ -63,6 +63,15 @@ var rc = { ); $("#dialogfooterok").show(); break; + case 'okcancel': + $("#dialogfooterokcancel_ok").click(function() { + rc.trigger(d.dialog.buttons.actions.ok, d.dialog.buttons.params); + }); + $("#dialogfooterokcancel_cancel").click(function() { + rc.trigger(d.dialog.buttons.actions.cancel, d.dialog.buttons.params); + }); + $("#dialogfooterokcancel").show(); + break; case 'yesno': $("#dialogfooteryes").click( function() { @@ -124,6 +133,11 @@ var rc = { 'delete-source-confirm': function(params) { rc.sources.remove_confirmed(params['plugin'], params['id']); + }, + + 'add-setting': function(params) { + // TODO + console.log('todo'); } }, @@ -148,11 +162,17 @@ var rc = { settings: { init: function() { - $("#settings_save").click( - function() { - rc.settings.save(); - } - ); + $("#settings_save").click(function() { + rc.settings.save(); + }); + + $("#settings_add").click(function() { + rc.settings.add(); + }); + }, + + add: function() { + rc.ajax.get(base_url + "ajax/admin/add-setting/"); }, add_stringlist_field: function(id) { diff --git a/webui/source/templates/admin/add-setting.tpl b/webui/source/templates/admin/add-setting.tpl new file mode 100644 index 0000000..ebc88a5 --- /dev/null +++ b/webui/source/templates/admin/add-setting.tpl @@ -0,0 +1,21 @@ + + + + + + + + + + + +
NameType
+ + + +
diff --git a/webui/source/templates/admin/settings.tpl b/webui/source/templates/admin/settings.tpl index 874a6d3..8ce9e2a 100644 --- a/webui/source/templates/admin/settings.tpl +++ b/webui/source/templates/admin/settings.tpl @@ -22,6 +22,7 @@ + diff --git a/webui/source/templates/ajax/admin/add-setting.tpl b/webui/source/templates/ajax/admin/add-setting.tpl new file mode 100644 index 0000000..90b3524 --- /dev/null +++ b/webui/source/templates/ajax/admin/add-setting.tpl @@ -0,0 +1,26 @@ +"page_replacements": { + + "dialogheadertitle": { + "content": "Add Setting" + }, + + "dialogcontent": { + {include file="admin/add-setting.tpl" assign=add_setting_content} + "content": {$add_setting_content|json_encode} + } + +}, + +"dialog": { + "show": true, + "buttons": { + "type": "okcancel", + "actions": { + "ok": [ + "add-setting", + "close-dialog" + ], + "cancel": "close-dialog" + } + } +} \ No newline at end of file diff --git a/webui/source/templates/index.tpl b/webui/source/templates/index.tpl index 412f558..5c8d460 100644 --- a/webui/source/templates/index.tpl +++ b/webui/source/templates/index.tpl @@ -69,6 +69,12 @@ +
+
+ + +
+