// update positions module tab

This commit is contained in:
sLorenzini
2013-07-12 17:48:07 +02:00
parent c12ce3dd29
commit 4919d6d81a
2 changed files with 151 additions and 93 deletions
@@ -30,103 +30,160 @@
<script type="text/javascript" src="../js/admin-dnd.js"></script>
{include file="toolbar.tpl" toolbar_btn=$toolbar_btn toolbar_scroll=$toolbar_scroll title=$title}
<div class="leadin">{block name="leadin"}{/block}</div>
<div>{block name="leadin"}{/block}</div>
<div class="filter-module">
<form>
{l s='Show'} :
<select id="show_modules" onChange="autoUrl('show_modules', '{$url_show_modules}')">
<option value="all">{l s='All modules'}&nbsp;</option>
<option>---------------</option>
{foreach $modules as $module}
<option value="{$module->id|intval}" {if $display_key == $module->id}selected="selected"{/if}>{$module->displayName}</option>
{/foreach}
</select>
<br /><br />
<input type="checkbox" id="hook_position" onclick="autoUrlNoList('hook_position', '{$url_show_invisible}')" {if $hook_position}checked="checked"{/if} />&nbsp;
<label class="t" for="hook_position">{l s='Display non-positionable hooks'}</label>
</form>
<div class="well">
<form class="form-inline">
<label>{l s='Show'} :</label>
<span>
<select id="show_modules" onChange="autoUrl('show_modules', '{$url_show_modules}')" class="filter fixed-width-XL">
<option value="all">{l s='All modules'}&nbsp;</option>
<option>---------------</option>
{foreach $modules as $module}
<option value="{$module->id|intval}" {if $display_key == $module->id}selected="selected"{/if}>{$module->displayName}</option>
{/foreach}
</select>
</span>
<p class="checkbox">
<label class="control-label" for="hook_position">
<input type="checkbox" id="hook_position" onclick="autoUrlNoList('hook_position', '{$url_show_invisible}')" {if $hook_position}checked="checked"{/if} />
{l s='Display non-positionable hooks'}
</label>
</p>
</form>
</div>
<br/>
<div>
<div id="modulePosition">
<div class="blocLiveEdit"><h2>{l s='LiveEdit'}</h2>
{if $live_edit}
<p>{l s='You have to select a shop to use LiveEdit'}</p>
{else}
<p>{l s='Click here to be redirected to the Front Office of your shop where you can move and delete modules directly.'}</p>
<a href="{$url_live_edit}" target="_blank" class="button">{l s='Run LiveEdit'}</a>
{/if}
</div>
<form method="post" action="{$url_submit}">
<div id="unhook_button_position_top">
<input class="button floatr" type="submit" name="unhookform" value="{l s='Unhook the selection'}"/></div>
<div class="row">
<div id="modulePosition">
<div class="col-lg-9">
<form method="post" action="{$url_submit}">
<span class="pull-right">
<button type="submit" class="btn btn-default" name="unhookform" onclick="modules_management('install')">
<i class="icon-minus-sign-alt"></i>
{l s='Unhook the selection'}
</button>
</span>
{if !$can_move}
<span class="alert">
{l s='If you want to order/move the following data, please select a shop from the shop list.'}
</span>
{/if}
{if !$can_move}
<br /><div><b>{l s='If you want to order/move the following data, please select a shop from the shop list.'}</b></div>
{/if}
{foreach $hooks as $hook}
<a name="{$hook['name']}"/>
<table cellpadding="0" cellspacing="0" class="table widthfull space {if $hook['module_count'] >= 2} tableDnD{/if}" id="{$hook['id_hook']}">
<colgroup>
<col width="10">
<col width="30">
<col width="40">
<col width="">
<col width="50">
</colgroup>
<tr class="nodrag nodrop"><th colspan="5"> {if $hook['module_count'] && $can_move}
<input type="checkbox" id="Ghook{$hook['id_hook']}" style="margin-right: 2px;" onclick="hookCheckboxes({$hook['id_hook']}, 0, this)"/>
{/if}{$hook['title']} - <span style="color: red">{$hook['module_count']}</span> {if $hook['module_count'] > 1}{l s='Modules'}{else}{l s='Module'}{/if}
{if !empty($hook['description'])}
&nbsp;<span style="font-size:0.8em; font-weight: normal">[{$hook['description']}]</span>
{/if}
<span style="color:grey;">({l s='Technical name: '}{$hook['name']})</span></th></tr>
{if $hook['module_count']}
{foreach $hook['modules'] as $position => $module}
{if isset($module['instance'])}
<tr id="{$hook['id_hook']}_{$module['instance']->id}" {cycle values='class="alt_row",'} style="height: 42px;">
<td align=center ><input type="checkbox" id="mod{$hook['id_hook']}_{$module['instance']->id}" class="hook{$hook['id_hook']}" onclick="hookCheckboxes({$hook['id_hook']}, 1, this)" name="unhooks[]" value="{$hook['id_hook']}_{$module['instance']->id}"/></td>
{if !$display_key}
<td align=center class="positions">{$module@iteration}</td>
<td {if $can_move && $hook['module_count'] >= 2} align=center class="dragHandle"{/if} id="td_{$hook['id_hook']}_{$module['instance']->id}">
{if $can_move}
<a {if {$module@iteration} == 1} style="display: none;"{/if} href="{$current}&id_module={$module['instance']->id}&id_hook={$hook['id_hook']}&direction=0&token={$token}&changePosition#{$hook['name']}">
<img src="../img/admin/up.gif" alt="{l s='Up'}" title="{l s='Up'}" />
</a><br />
<a {if {$module@iteration} == count($hook['modules'])} style="display: none;"{/if} href="{$current}&id_module={$module['instance']->id}&id_hook={$hook['id_hook']}&direction=1&token={$token}&changePosition#{$hook['name']}">
<img src="../img/admin/down.gif" alt="{l s='Down'}" title="{l s='Down'}" />
</a>
{/if}
</td>
<td><div class="lab_modules_positions" for="mod{$hook['id_hook']}_{$module['instance']->id}">
{foreach $hooks as $hook}
<div class="row-light clearfix">
<a name="{$hook['name']}"></a>
<table cellpadding="0" cellspacing="0" class="table table-striped table-hover {if $hook['module_count'] >= 2} tableDnD{/if}" id="{$hook['id_hook']}">
<colgroup>
<col width="10">
<col width="30">
<col width="40">
<col width="">
<col width="50">
</colgroup>
<tr class="nodrag nodrop">
<th colspan="5">
{if $hook['module_count'] && $can_move}
<input type="checkbox" id="Ghook{$hook['id_hook']}" style="margin-right: 2px;" onclick="hookCheckboxes({$hook['id_hook']}, 0, this)"/>
{/if}
<span>{$hook['title']} - </span>
<span class="badge">{$hook['module_count']} {if $hook['module_count'] > 1}{l s='Modules'}{else}{l s='Module'}{/if} </span>
{if !empty($hook['description'])}
<p class="text-muted">
[{$hook['description']}]
</p>
{/if}
<p>({l s='Technical name: '}{$hook['name']})</p>
</th>
</tr>
{if $hook['module_count']}
{foreach $hook['modules'] as $position => $module}
{if isset($module['instance'])}
<tr id="{$hook['id_hook']}_{$module['instance']->id}" {cycle values='class="alt_row",'}>
<td align="center">
<input type="checkbox" id="mod{$hook['id_hook']}_{$module['instance']->id}" class="hook{$hook['id_hook']}" onclick="hookCheckboxes({$hook['id_hook']}, 1, this)" name="unhooks[]" value="{$hook['id_hook']}_{$module['instance']->id}"/>
</td>
{if !$display_key}
<td align="center" class="positions">{$module@iteration}</td>
<td {if $can_move && $hook['module_count'] >= 2} align=center class="dragHandle"{/if} id="td_{$hook['id_hook']}_{$module['instance']->id}">
{if $can_move}
<a {if {$module@iteration} == 1} style="display: none;"{/if} href="{$current}&id_module={$module['instance']->id}&id_hook={$hook['id_hook']}&direction=0&token={$token}&changePosition#{$hook['name']}">
<img src="../img/admin/up.gif" alt="{l s='Up'}" title="{l s='Up'}" />
</a><br />
<a {if {$module@iteration} == count($hook['modules'])} style="display: none;"{/if} href="{$current}&id_module={$module['instance']->id}&id_hook={$hook['id_hook']}&direction=1&token={$token}&changePosition#{$hook['name']}">
<img src="../img/admin/down.gif" alt="{l s='Down'}" title="{l s='Down'}" />
</a>
{/if}
</td>
<td>
<div class="lab_modules_positions" for="mod{$hook['id_hook']}_{$module['instance']->id}">
{else}
<td colspan="3">
<div class="lab_modules_positions" for="mod{$hook['id_hook']}_{$module['instance']->id}">
{/if}
<h3>
<img src="../modules/{$module['instance']->name}/logo.png" alt="{$module['instance']->name|stripslashes}" />
{$module['instance']->displayName|stripslashes}
</h3>
<dl class="dl-horizontal">
<dt>{l s='Version:'}</dt>
<dd>
{if $module['instance']->version}v{if $module['instance']->version|intval == $module['instance']->version}{sprintf('%.1f', $module['instance']->version)}{else}{$module['instance']->version|floatval}{/if}{/if}
</dd>
<dt>{l s='Description:'}</dt>
<dd>
{$module['instance']->description}
</dd>
</dl>
</div>
</td>
<td>
<div class="btn-group btn-group-action">
<button class="btn btn-default btn-small dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>&nbsp;
</button>
<ul class="dropdown-menu">
<li>
<a href="{$current}&id_module={$module['instance']->id}&id_hook={$hook['id_hook']}&editGraft{if $display_key}&show_modules={$display_key}{/if}&token={$token}">
<i class="icon-edit"></i>
{l s='Edit'}
</a>
</li>
<li>
<a href="{$current}&id_module={$module['instance']->id}&id_hook={$hook['id_hook']}&deleteGraft{if $display_key}&show_modules={$display_key}{/if}&token={$token}">
<i class="icon-remove"></i>
{l s='Delete'}
</a>
</li>
</ul>
</div>
</td>
</tr>
{/if}
{/foreach}
{else}
<tr>
<td colspan="5">
<p class="text-warning">{l s='No module was found for this hook.'}</p>
</td>
</tr>
{/if}
</table>
</div>
{/foreach}
<div id="unhook_button_position_bottom"><input class="button floatr" type="submit" name="unhookform" value="{l s='Unhook the selection'}"/></div>
</form>
</div>
<div class="col-lg-3">
<h2>{l s='LiveEdit'}</h2>
{if $live_edit}
<p>{l s='You have to select a shop to use LiveEdit'}</p>
{else}
<td colspan="3"><div class="lab_modules_positions" for="mod{$hook['id_hook']}_{$module['instance']->id}">
{/if}
<img src="../modules/{$module['instance']->name}/logo.png" alt="{$module['instance']->name|stripslashes}" /> <h3>{$module['instance']->displayName|stripslashes}</h3>
<span>{if $module['instance']->version}v{if $module['instance']->version|intval == $module['instance']->version}{sprintf('%.1f', $module['instance']->version)}{else}{$module['instance']->version|floatval}{/if}{/if}</span><p>{$module['instance']->description}</p>
</div></td>
<td>
<a href="{$current}&id_module={$module['instance']->id}&id_hook={$hook['id_hook']}&editGraft{if $display_key}&show_modules={$display_key}{/if}&token={$token}">
<img src="../img/admin/edit.gif" border="0" alt="{l s='Edit'}" title="{l s='Edit'}" />
<p>{l s='Click here to be redirected to the Front Office of your shop where you can move and delete modules directly.'}</p>
<a class="btn btn-default btn-small pull-right" href="{$url_live_edit}" target="_blank">
<i class="icon-edit"></i>
{l s='Run LiveEdit'}
</a>
<a href="{$current}&id_module={$module['instance']->id}&id_hook={$hook['id_hook']}&deleteGraft{if $display_key}&show_modules={$display_key}{/if}&token={$token}">
<img src="../img/admin/delete.gif" border="0" alt="{l s='Delete'}" title="{l s='Delete'}" />
</a>
</td>
</tr>
{/if}
{/foreach}
{else}
<tr><td colspan="5">{l s='No module was found for this hook.'}</td></tr>
{/if}
</table>
{/foreach}
<div id="unhook_button_position_bottom"><input class="button floatr" type="submit" name="unhookform" value="{l s='Unhook the selection'}"/></div>
</div>
</div>
</form>
</div>
</div>
</div>
@@ -30,6 +30,7 @@ class AdminModulesPositionsControllerCore extends AdminController
public function postProcess()
{
$this->bootstrap = true;
// Getting key value for display
if (Tools::getValue('show_modules') && strval(Tools::getValue('show_modules')) != 'all')
$this->display_key = (int)Tools::getValue('show_modules');