//dashactivity configuration
This commit is contained in:
@@ -43,10 +43,10 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-3">
|
||||
<div class="col-lg-3" id="hookDashboardZoneOne">
|
||||
{$hookDashboardZoneOne}
|
||||
</div>
|
||||
<div class="col-lg-7">
|
||||
<div class="col-lg-7" id="hookDashboardZoneTwo">
|
||||
{$hookDashboardZoneTwo}
|
||||
</div>
|
||||
<div class="col-lg-2">
|
||||
|
||||
@@ -96,10 +96,8 @@ class AdminDashboardControllerCore extends AdminController
|
||||
{
|
||||
$return = array('has_errors' => false, 'rss' => array());
|
||||
if (!$this->isFresh('/config/xml/blog-'.$this->context->language->iso_code.'.xml', 604800))
|
||||
{
|
||||
if (!$this->refresh('/config/xml/blog-'.$this->context->language->iso_code.'.xml', 'https://api.prestashop.com/rss/blog/blog-'.$this->context->language->iso_code.'.xml'))
|
||||
$return['has_errors'] = true;
|
||||
}
|
||||
|
||||
if (!$return['has_errors'])
|
||||
{
|
||||
@@ -120,4 +118,27 @@ class AdminDashboardControllerCore extends AdminController
|
||||
|
||||
die(Tools::jsonEncode($return));
|
||||
}
|
||||
}
|
||||
|
||||
public function ajaxProcessSaveDashConfig()
|
||||
{
|
||||
$return = array('has_errors' => false);
|
||||
$module = Tools::getValue('module');
|
||||
$hook = Tools::getValue('hook');
|
||||
$configs = Tools::getValue('configs');
|
||||
|
||||
if (Validate::isModuleName($module) && $module_obj = Module::getInstanceByName($module))
|
||||
if (Validate::isLoadedObject($module_obj) && method_exists($module_obj, 'saveDashConfig'))
|
||||
$return['has_errors'] = $module_obj->saveDashConfig($configs);
|
||||
else if (is_array($configs) && count($configs))
|
||||
foreach ($configs as $name => $value)
|
||||
if (Validate::isConfigName($name))
|
||||
Configuration::updateValue($name, $value);
|
||||
|
||||
if (Validate::isHookName($hook) && method_exists($module_obj, $hook))
|
||||
$return['widget_html'] = $module_obj->$hook(array());
|
||||
|
||||
die(Tools::jsonEncode($return));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+40
-1
@@ -31,6 +31,8 @@ $(document).ready( function () {
|
||||
|
||||
refreshDashboard(false, false);
|
||||
getBlogRss();
|
||||
bindSubmitDashConfig();
|
||||
|
||||
});
|
||||
|
||||
function refreshDashboard(module_name, use_push)
|
||||
@@ -183,8 +185,9 @@ function data_list_small(widget_name, data)
|
||||
{
|
||||
for (var data_id in data)
|
||||
{
|
||||
$('#'+data_id).html('');
|
||||
for (var item in data[data_id])
|
||||
$('#'+data_id+' ').append('<li><span class="data_label">'+item+'</span><span class="data_value size_s">'+data[data_id][item]+'</span></li>');
|
||||
$('#'+data_id).append('<li><span class="data_label">'+item+'</span><span class="data_value size_s">'+data[data_id][item]+'</span></li>');
|
||||
$('#'+data_id+', #'+widget_name).closest('section').removeClass('loading');
|
||||
}
|
||||
}
|
||||
@@ -233,4 +236,40 @@ function toggleDashConfig(widget)
|
||||
}
|
||||
}
|
||||
|
||||
function bindSubmitDashConfig()
|
||||
{
|
||||
$('.submit_dash_config').on('click', function () {
|
||||
saveDashConfig($(this).closest('section.widget').attr('id'));
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
function saveDashConfig(widget_name)
|
||||
{
|
||||
configs = '';
|
||||
$('#'+widget_name+' form input, #'+widget_name+' form textarea , #'+widget_name+' form select').each( function () {
|
||||
if ($(this).attr('type') == 'radio' && !$(this).attr('checked'))
|
||||
return;
|
||||
configs += '&configs['+$(this).attr('name')+']='+$(this).val();
|
||||
});
|
||||
data = 'ajax=true&action=saveDashConfig&module='+widget_name+configs+'&hook='+$('#'+widget_name).closest('[id^=hook]').attr('id');
|
||||
|
||||
$.ajax({
|
||||
url : dashboard_ajax_url,
|
||||
data : data,
|
||||
dataType: 'json',
|
||||
success : function(jsonData){
|
||||
if (!jsonData.has_errors)
|
||||
{
|
||||
$('#'+widget_name).find('section').not('.dash_config').remove();
|
||||
$('#'+widget_name).append($(jsonData.widget_html).find('section').not('.dash_config'));
|
||||
refreshDashboard(widget_name);
|
||||
toggleDashConfig(widget_name);
|
||||
}
|
||||
},
|
||||
error : function(data){
|
||||
//@TODO display errors
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -261,7 +261,11 @@ class Dashactivity extends Module
|
||||
$fields_form = array(
|
||||
'form' => array(
|
||||
'id_form' => 'step_carrier_general',
|
||||
'input' => array()
|
||||
'input' => array(),
|
||||
'submit' => array(
|
||||
'title' => $this->l(' Save '),
|
||||
'class' => 'btn submit_dash_config'
|
||||
)
|
||||
),
|
||||
);
|
||||
|
||||
@@ -302,6 +306,7 @@ class Dashactivity extends Module
|
||||
$this->fields_form = array();
|
||||
$helper->id = (int)Tools::getValue('id_carrier');
|
||||
$helper->identifier = $this->identifier;
|
||||
$helper->submit_action = 'submitDashConfig';
|
||||
$helper->tpl_vars = array(
|
||||
'fields_value' => $this->getConfigFieldsValues(),
|
||||
'languages' => $this->context->controller->getLanguages(),
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
</a>
|
||||
</span>
|
||||
</div>
|
||||
<section id="dashactivity" class="dash_config hide">
|
||||
<section id="dashactivity_config" class="dash_config hide">
|
||||
<header><i class="icon-wrench"></i> {l s='Configuration'}</header>
|
||||
{$dashactivity_config_form}
|
||||
</section>
|
||||
|
||||
Reference in New Issue
Block a user