Merge branch 'feature-settings' into develop
This commit is contained in:
@@ -112,7 +112,33 @@ var rc = {
|
||||
$(".dialogfooterbuttonset").hide();
|
||||
// Strip all event handlers
|
||||
$(".dialogfooterbuttonset input[type='button']").unbind('click');
|
||||
}
|
||||
},
|
||||
|
||||
error: function(title, content, messages) {
|
||||
var formatted_content = $('<div>').append($('<p>').text('content'));
|
||||
if (messages) {
|
||||
var formatted_messages = $('<ul>');
|
||||
for (var message in messages) {
|
||||
formatted_messages.append($('<li>').text(message));
|
||||
}
|
||||
|
||||
formatted_content.append($('<p>').text('These messages were reported:').append(formatted_messages));
|
||||
}
|
||||
|
||||
rc.dialog.prepare({
|
||||
dialog: {
|
||||
show: true,
|
||||
title: title,
|
||||
content: formatted_content,
|
||||
buttons: {
|
||||
type: 'ok',
|
||||
actions: {
|
||||
ok: 'close-dialog'
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
@@ -159,9 +185,21 @@ var rc = {
|
||||
$("#settings tbody").append(params.content);
|
||||
},
|
||||
|
||||
'rename_setting': function(params) {
|
||||
rc.ajax.post(base_url + 'ajax/admin/rename-setting/name/' + params.name + '/new-name/' + $('#'+params.new_name_field).val() + '/confirm/');
|
||||
},
|
||||
|
||||
'rename_setting_confirm': function(params) {
|
||||
$('#setting_'+params.old_id+'_row').replaceWith($(params.content));
|
||||
},
|
||||
|
||||
'remove_setting': function(params) {
|
||||
$('#setting_' + params.id + '_row').remove();
|
||||
rc.ajax.post(base_url + 'ajax/admin/remove-setting/name/' + params.name + '/');
|
||||
rc.trigger('remove_setting_row', params);
|
||||
},
|
||||
|
||||
'remove_setting_row': function(params) {
|
||||
$('#setting_' + params.id + '_row').remove();
|
||||
}
|
||||
|
||||
},
|
||||
@@ -207,6 +245,10 @@ var rc = {
|
||||
rc.ajax.get(base_url + "ajax/admin/new-setting/");
|
||||
},
|
||||
|
||||
rename_setting: function(id, name) {
|
||||
rc.ajax.get(base_url + "ajax/admin/rename-setting/name/" + name + "/");
|
||||
},
|
||||
|
||||
remove_setting: function(id, name) {
|
||||
rc.dialog.prepare({
|
||||
dialog: {
|
||||
|
||||
@@ -4,6 +4,7 @@ $main = RippingCluster_Main::instance();
|
||||
$config = $main->config();
|
||||
|
||||
$settings = $config->enumerateAll();
|
||||
asort($settings);
|
||||
$this->smarty->assign('settings', $settings);
|
||||
$this->smarty->assign('config', $config);
|
||||
|
||||
|
||||
39
webui/source/pages/ajax/admin/rename-setting.php
Normal file
39
webui/source/pages/ajax/admin/rename-setting.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
$main = RippingCluster_Main::instance();
|
||||
$req = $main->request();
|
||||
$config = $main->config();
|
||||
|
||||
$messages = array();
|
||||
$result = false;
|
||||
|
||||
$confirm = $req->exists('confirm');
|
||||
$this->smarty->assign('confirm', $confirm);
|
||||
|
||||
if ($confirm) {
|
||||
try {
|
||||
$name = $req->get('name', 'RippingCluster_Exception_InvalidParameters');
|
||||
$new_name = $req->get('new-name', 'RippingCluster_Exception_InvalidParameters');
|
||||
|
||||
$result = $config->rename($name, $new_name);
|
||||
$this->smarty->assign('success', $result);
|
||||
|
||||
$this->smarty->assign('old_name', $name);
|
||||
$this->smarty->assign('old_id', str_replace('.', '-', $name));
|
||||
$this->smarty->assign('name', $new_name);
|
||||
$this->smarty->assign('id', str_replace('.', '-', $new_name));
|
||||
$this->smarty->assign('type', $config->type($new_name));
|
||||
$this->smarty->assign('value', $config->get($new_name));
|
||||
|
||||
} catch(RippingCluster_Exception $e) {
|
||||
$messages[] = get_class($e) . ':' . $e->getMessage();
|
||||
$this->smarty->assign('messages', $messages);
|
||||
$this->smarty->assign('success', false);
|
||||
}
|
||||
} else {
|
||||
$name = $req->get('name', 'RippingCluster_Exception_InvalidParameters');
|
||||
$this->smarty->assign('name', $name);
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
44
webui/source/templates/ajax/admin/rename-setting.tpl
Normal file
44
webui/source/templates/ajax/admin/rename-setting.tpl
Normal file
@@ -0,0 +1,44 @@
|
||||
{if $confirm}
|
||||
{if $success}
|
||||
"actions": {
|
||||
"rename_setting_confirm": {
|
||||
"old_name": {$old_name|json_encode},
|
||||
"old_id": {$old_id|json_encode},
|
||||
"name": {$name|json_encode},
|
||||
{include file="fragments/admin-setting-row.tpl" assign="content"}
|
||||
"content": {$content|json_encode}
|
||||
}
|
||||
},
|
||||
{/if}
|
||||
|
||||
"success": {$success|json_encode}
|
||||
{else}
|
||||
"page_replacements": {
|
||||
"dialogheadertitle": {
|
||||
"content": "Rename Setting"
|
||||
},
|
||||
|
||||
"dialogcontent": {
|
||||
{include file="fragments/rename-setting-dialog.tpl" assign="content"}
|
||||
"content": {$content|json_encode}
|
||||
}
|
||||
},
|
||||
|
||||
"dialog": {
|
||||
"show": true,
|
||||
"buttons": {
|
||||
"type": "okcancel",
|
||||
"actions": {
|
||||
"ok": [
|
||||
"rename_setting",
|
||||
"close-dialog"
|
||||
],
|
||||
"cancel": "close-dialog"
|
||||
},
|
||||
"params": {
|
||||
"name": {$name|json_encode},
|
||||
"new_name_field": "settings_rename_name"
|
||||
}
|
||||
}
|
||||
}
|
||||
{/if}
|
||||
@@ -2,6 +2,7 @@
|
||||
<td>
|
||||
<p>
|
||||
{$name}<br />
|
||||
<input type="button" id="setting_{$id}_rename" value="Rename" onclick="rc.settings.rename_setting('{$id}', '{$name}');" />
|
||||
<input type="button" id="setting_{$id}_remove" value="Remove" onclick="rc.settings.remove_setting('{$id}', '{$name}');" />
|
||||
</p>
|
||||
</td>
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
<div>
|
||||
<p>
|
||||
Enter a new name for setting '{$name|escape}' below.
|
||||
</p>
|
||||
<input type="text" id="settings_rename_name" value="" />
|
||||
</div>
|
||||
Reference in New Issue
Block a user