display good content_folder on content_edit admin template

This commit is contained in:
Manuel Raynaud
2013-09-30 18:10:05 +02:00
parent e6e95b2516
commit cd5c89a33b
2 changed files with 101 additions and 88 deletions

View File

@@ -31,6 +31,7 @@ use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Model\ContentQuery;
use Thelia\Model\FolderQuery; use Thelia\Model\FolderQuery;
use Thelia\Type\TypeCollection; use Thelia\Type\TypeCollection;
use Thelia\Type; use Thelia\Type;
@@ -55,6 +56,7 @@ class Folder extends BaseI18nLoop
return new ArgumentCollection( return new ArgumentCollection(
Argument::createIntListTypeArgument('id'), Argument::createIntListTypeArgument('id'),
Argument::createIntTypeArgument('parent'), Argument::createIntTypeArgument('parent'),
Argument::createIntTypeArgument('content'),
Argument::createBooleanTypeArgument('current'), Argument::createBooleanTypeArgument('current'),
Argument::createBooleanTypeArgument('not_empty', 0), Argument::createBooleanTypeArgument('not_empty', 0),
Argument::createBooleanOrBothTypeArgument('visible', 1), Argument::createBooleanOrBothTypeArgument('visible', 1),
@@ -107,6 +109,16 @@ class Folder extends BaseI18nLoop
$search->filterById($exclude, Criteria::NOT_IN); $search->filterById($exclude, Criteria::NOT_IN);
} }
$content = $this->getContent();
if (null !== $content) {
$obj = ContentQuery::create()->findPk($content);
if($obj) {
$search->filterByContent($obj, Criteria::IN);
}
}
$visible = $this->getVisible(); $visible = $this->getVisible();
if ($visible != BooleanOrBothType::ANY) $search->filterByVisible($visible ? 1 : 0); if ($visible != BooleanOrBothType::ANY) $search->filterByVisible($visible ? 1 : 0);

View File

@@ -42,7 +42,7 @@
<ul class="nav nav-tabs" id="tabbed-menu"> <ul class="nav nav-tabs" id="tabbed-menu">
<li class="active"><a href="#general" data-toggle="tab">{intl l="General description"}</a></li> <li class="active"><a href="#general" data-toggle="tab">{intl l="General description"}</a></li>
<li><a href="#details" data-toggle="tab">{intl l="Details"}</a></li> <li><a href="#association" data-toggle="tab">{intl l="Associations"}</a></li>
<li><a href="#images" data-toggle="tab">{intl l="Images"}</a></li> <li><a href="#images" data-toggle="tab">{intl l="Images"}</a></li>
<li><a href="#documents" data-toggle="tab">{intl l="Documents"}</a></li> <li><a href="#documents" data-toggle="tab">{intl l="Documents"}</a></li>
<li><a href="#modules" data-toggle="tab">{intl l="Modules"}</a></li> <li><a href="#modules" data-toggle="tab">{intl l="Modules"}</a></li>
@@ -141,107 +141,108 @@
</div> </div>
</div> </div>
<div class="tab-pane fade" id="details"> <div class="tab-pane fade" id="association">
<div class="form-container"> <div class="form-container">
<div class="form-group"> <div class="row">
<form action="{url path='/admin/folders/related-content/add'}" id="related_content_form"> {* -- Begin folders management ----------------------------------- *}
<div class="col-md-6">
<div class="well well-sm">
<div class="form-group">
<form method="POST" action="{url path='/admin/products/category/add'}" id="related_content_form">
{include <p class="title title-without-tabs">{intl l='Additional categories'}</p>
file="includes/inner-form-toolbar.html" <p>{intl l='A content could be attached to more than one folder. Select here the additional fodlers for this content.'}
hide_submit_buttons=true {loop name="default_folder" type="folder" id=$DEFAULT_FOLDER}
close_url="{url path='/admin/folders' folder_id=$folder_id}" {intl l='You can change the default folder (%title) in the "General" tab.' title=$TITLE}
} {/loop}
<input type="hidden" name="folder_id" value="{$folder_id}" /> {$exclude_from_tree = "-1"}
<input type="hidden" name="current_tab" value="details" /> {loop name="additional_folders" type="folder" exclude=$DEFAULT_FOLDER content=$content_id backend_context="1" lang="$edit_language_id"}
{$exclude_from_tree = "$exclude_from_tree,$ID"}
{/loop}
<input type="hidden" name="content_id" value="{$content_id}" />
<input type="hidden" name="current_tab" value="association" />
{ifloop rel="folders"} {ifloop rel="folders"}
<div class="row"> <div class="input-group">
<div class="col-md-6"> <select name="additional_category_id" id="accessory_category_id" class="form-control">
<div class="form-group"> <option value="">{intl l='Select a folder...'}</option>
<select name="folder_id" id="folder_id" class="form-control"> {loop name="folders" type="folder-tree" folder="0" exclude=$exclude_from_tree backend_context="1" lang="$edit_language_id"}
<option value="">Select a folder...</option> <option value="{$ID}" style="padding-left: {3 + $LEVEL * 20}px" {if $DEFAULT_FOLDER==$ID}disabled="disabled"{/if}>
{loop name="folders" type="folder" backend_context="1" lang="$edit_language_id"} {$TITLE} {if $DEFAULT_FOLDER==$ID}{intl l=' (default)'}{/if}
<option value="{$ID}">{$TITLE}</option> </option>
{/loop} {/loop}
</select> </select>
<span class="input-group-btn" id="content_add_button">
<button class="btn btn-default btn-primary action-btn" type="submit"><span class="glyphicon glyphicon-plus-sign"></span></button>
</span>
</div> </div>
<span class="help-block">{intl l='Select a folder to get its content'}</span> <span class="help-block">{intl l='Select a folder and click (+) to add it to the additional folder list'}</span>
</div> {/ifloop}
<div class="col-md-6"> {elseloop rel="folders"}
<div id="content_selector" class="hide"> <div class="alert alert-info">{intl l="No Folders found"}</div>
<div class="input-group"> {/elseloop}
<select required="required" name="content_id" id="content_id" class="form-control">
<option value="">Select a folder content...</option>
</select>
<span class="input-group-btn" id="content_add_button">
<button class="btn btn-default btn-primary action-btn" type="submit"><span class="glyphicon glyphicon-plus-sign"></span></button>
</span>
</div>
<span class="help-block">{intl l='Select a content and click (+) to add it to this category'}</span>
</div>
</div>
</form>
</div> </div>
{/ifloop}
{elseloop rel="folders"} <div class="table-responsive">
<div class="alert alert-info">{intl l="No folders found"}</div> <table class="table table-striped table-condensed table-left-aligned">
{/elseloop} <thead>
<tr>
<th>{intl l='ID'}</th>
</form> <th>{intl l='Folder title'}</th>
{module_include location='product_folders_table_header'}
<th class="actions">{intl l="Actions"}</th>
</tr>
</thead>
<tbody>
{loop name="additional_folders" type="folder" content=$content_id exclude=$DEFAULT_FOLDER backend_context="1" lang="$edit_language_id"}
<tr>
<td>{$ID}</td>
<td>
{$TITLE}
</td>
{module_include location='product_folders_table_row'}
<td class="actions">
<div class="btn-group">
{loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.product.category.delete"}
<a class="btn btn-default btn-xs delete-category" title="{intl l='Remove the product from this category'}" href="#delete_category_dialog" data-id="{$ID}" data-toggle="modal">
<span class="glyphicon glyphicon-trash"></span>
</a>
{/loop}
</div>
</td>
</tr>
{/loop}
{elseloop rel="additional_folders"}
<tr>
<td colspan="3">
<div class="alert alert-info">
{intl l="This product doesn't belong to any additional folder."}
</div>
</td>
</tr>
{/elseloop}
</tbody>
</table>
</div>
</div>
</div>
{* -- End folders management ------------------------------------- *}
</div> </div>
<table class="table table-striped table-condensed table-left-aligned">
<thead>
<tr>
<th>{intl l='ID'}</th>
<th>{intl l='Attribute title'}</th>
{module_include location='folder_contents_table_header'}
<th class="actions">{intl l="Actions"}</th>
</tr>
</thead>
<tbody>
{*loop name="assigned_contents" type="associated_content" folder="$folder_id" backend_context="1" lang="$edit_language_id"}
<tr>
<td>{$ID}</td>
<td>
{$TITLE}
</td>
{module_include location='folder_contents_table_row'}
<td class="actions">
<div class="btn-group">
{loop type="auth" name="can_create" roles="ADMIN" permissions="admin.configuration.folder.content.delete"}
<a class="btn btn-default btn-xs delete-content" title="{intl l='Delete this content'}" href="#delete_content_dialog" data-id="{$ID}" data-toggle="modal">
<span class="glyphicon glyphicon-trash"></span>
</a>
{/loop}
</div>
</td>
</tr>
{/loop}
{elseloop rel="assigned_contents"}
<tr>
<td colspan="3">
<div class="alert alert-info">
{intl l="This folder contains no contents"}
</div>
</td>
</tr>
{/elseloop*}
</tbody>
</table>
</div> </div>
</div> </div>