Complete settings update including success dialog
This commit is contained in:
@@ -3,10 +3,17 @@
|
||||
$main = RippingCluster_Main::instance();
|
||||
$config = $main->config();
|
||||
|
||||
$messages = array();
|
||||
|
||||
// Iterate over the settings and store each one back to the backend
|
||||
foreach($_POST as $key => $value) {
|
||||
// Convert - to . (to work around the PHP register global backwards compatibility that renames input variables)
|
||||
$key = str_replace("-", ".", $key);
|
||||
|
||||
if ($config->exists($key)) {
|
||||
$config->set($key, $value);
|
||||
} else {
|
||||
$messages[] = "Unknown config key '{$key}', value not updated.";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,19 +15,19 @@
|
||||
<td>
|
||||
{switch $type}
|
||||
{case Sihnon_Config::TYPE_BOOL}
|
||||
<input type="checkbox" id="setting_{$id}" name="{$name}" value="1" {if $value}checked="checked" {/if} class="setting" />
|
||||
<input type="checkbox" id="setting_{$id}" name="{$id}" value="1" {if $value}checked="checked" {/if} class="setting" />
|
||||
{/case}
|
||||
{case Sihnon_Config::TYPE_INT}
|
||||
<input type="text" id="setting_{$id}" name="{$name}" value="{$value}" class="setting settings_field_numeric" />
|
||||
<input type="text" id="setting_{$id}" name="{$id}" value="{$value}" class="setting settings_field_numeric" />
|
||||
{/case}
|
||||
{case Sihnon_Config::TYPE_STRING}
|
||||
<input type="text" id="setting_{$id}" name="{$name}" value="{$value}" class="setting settings_field_string" />
|
||||
<input type="text" id="setting_{$id}" name="{$id}" value="{$value}" class="setting settings_field_string" />
|
||||
{/case}
|
||||
{case Sihnon_Config::TYPE_STRING_LIST}
|
||||
<div id="container_{$id}">
|
||||
{foreach from=$value item=line name=settings}
|
||||
<div id="settings_{$id}_line{$smarty.foreach.settings.iteration}">
|
||||
<input type="text" name="{$name}[]" value="{$line}" class="setting settings_field_string" />
|
||||
<input type="text" name="{$id}[]" value="{$line}" class="setting settings_field_string" />
|
||||
<input type="button" value="-" class="settings_field_remove" onclick="rc.settings.remove_field('{$id}', '{$smarty.foreach.settings.iteration}')" />
|
||||
</div>
|
||||
{/foreach}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
{
|
||||
{if $messages}
|
||||
messages: [
|
||||
{foreach from=$messages item=message}
|
||||
'{$message|json_encode}',
|
||||
"messages": [
|
||||
{foreach from=$messages item=message name=messages}
|
||||
{$message|json_encode}{if ! $smarty.foreach.messages.last},{/if}
|
||||
{/foreach}
|
||||
],
|
||||
]{if $page_content},{/if}
|
||||
{/if}
|
||||
|
||||
{$page_content}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
"page_replacements": {
|
||||
|
||||
"dialogheadertitle": {
|
||||
"content": "Update Settings"
|
||||
},
|
||||
|
||||
"dialogcontent": {
|
||||
{include file="fragments/update-settings-dialog.tpl" assign=dialog_content}
|
||||
"content": {$dialog_content|json_encode}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
"dialog": {
|
||||
"show": true,
|
||||
"buttons": {
|
||||
"type": "ok",
|
||||
"actions": {
|
||||
"ok": "close-dialog"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
7
webui/source/templates/fragments/messages.tpl
Normal file
7
webui/source/templates/fragments/messages.tpl
Normal file
@@ -0,0 +1,7 @@
|
||||
{if $messages}
|
||||
<ul>
|
||||
{foreach from=$messages item=message}
|
||||
<li>{$message|escape}</li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
{/if}
|
||||
10
webui/source/templates/fragments/update-settings-dialog.tpl
Normal file
10
webui/source/templates/fragments/update-settings-dialog.tpl
Normal file
@@ -0,0 +1,10 @@
|
||||
<p>
|
||||
Settings have been saved.
|
||||
</p>
|
||||
|
||||
{if $messages}
|
||||
<p>
|
||||
Some messages were generated during this operation:
|
||||
{include file="fragments/messages.tpl"}
|
||||
</p>
|
||||
{/if}
|
||||
@@ -64,6 +64,11 @@
|
||||
</div>
|
||||
<div id="dialogcontent"></div>
|
||||
<div id="dialogfooter">
|
||||
<div id="dialogfooterok" class="dialogfooterbuttonset">
|
||||
<fieldset>
|
||||
<input type="button" class="dialogbutton" id="dialogfooterok" value="Ok" />
|
||||
</fieldset>
|
||||
</div>
|
||||
<div id="dialogfooteryesno" class="dialogfooterbuttonset">
|
||||
<fieldset>
|
||||
<input type="button" class="dialogbutton" id="dialogfooteryes" value="Yes" />
|
||||
|
||||
Reference in New Issue
Block a user