Merge branch 'feature-settings' into develop

This commit is contained in:
2011-08-28 16:19:52 +01:00
5 changed files with 69 additions and 2 deletions

View File

@@ -89,6 +89,14 @@ var rc = {
}
}
if (d.dialog.title) {
$('#dialogheadertitle').html(d.dialog.title);
}
if (d.dialog.content) {
$('#dialogcontent').html(d.dialog.content);
}
$("#dialog").show();
}
},
@@ -149,6 +157,11 @@ var rc = {
'add_setting_row': function(params) {
$("#settings tbody").append(params.content);
},
'remove_setting': function(params) {
$('#setting_' + params.id + '_row').remove();
rc.ajax.post(base_url + 'ajax/admin/remove-setting/name/' + params.name + '/');
}
},
@@ -194,6 +207,30 @@ var rc = {
rc.ajax.get(base_url + "ajax/admin/new-setting/");
},
remove_setting: function(id, name) {
rc.dialog.prepare({
dialog: {
show: true,
title: 'Remove setting',
content: "Do you really want to remove setting '" + name + "'",
buttons: {
type: 'okcancel',
actions: {
ok: [
'remove_setting',
'close-dialog'
],
cancel: 'close-dialog'
},
params: {
id: id,
name: name
}
}
}
});
},
add_stringlist_field: function(id) {
var container = $('#container_'+id);
var next = $('#settings_'+id+'_next');

View File

@@ -38,6 +38,7 @@ try {
$this->smarty->assign('success', $result);
$this->smarty->assign('name', $name);
$this->smarty->assign('id', str_replace('.', '-',$name));
$this->smarty->assign('type', $type);
$this->smarty->assign('value', '');

View File

@@ -0,0 +1,23 @@
<?php
$main = RippingCluster_Main::instance();
$req = $main->request();
$config = $main->config();
$messages = array();
$result = false;
try {
$name = $req->get('name', 'RippingCluster_Exception_InvalidParameters');
$result = $config->remove($name);
$this->smarty->assign('success', $result);
} catch(RippingCluster_Exception $e) {
$messages[] = get_class($e) . ':' . $e->getMessage();
$this->smarty->assign('messages', $messages);
$this->smarty->assign('success', false);
}
?>

View File

@@ -0,0 +1 @@
"success": {$success|json_encode}

View File

@@ -1,5 +1,10 @@
<tr>
<td>{$name}</td>
<tr id="setting_{$id}_row">
<td>
<p>
{$name}<br />
<input type="button" id="setting_{$id}_remove" value="Remove" onclick="rc.settings.remove_setting('{$id}', '{$name}');" />
</p>
</td>
<td>
{include file="fragments/admin-setting-value.tpl"}
</td>