Merge branches 'catalog' and 'upload_management' of https://github.com/thelia/thelia into catalog

# By franck
# Via franck
* 'catalog' of https://github.com/thelia/thelia:
  Impemented combination creation

# By Manuel Raynaud (29) and others
# Via gmorel (6) and others
* 'upload_management' of https://github.com/thelia/thelia: (52 commits)
  Working : Upload image : Fix upload validation
  - Image format allowed - manual-reverse order on image loop
  Upload allow only for images
  Hide upload zone during upload
  Working : Upload image : Fix unit tests
  Working : Upload image : set product image form loaded via ajax, fix category, folder, content
  WIP : Upload image : set product image form loaded via ajax
  Setting tinymce
  Update uploader view Update image edit view
  Working : Upload management : on content
  Working : Upload management : on folder, category, product
  cache dataccessfunctions
  Working : Upload management : fix e.preventDefault in chrome and safari
  Working : Image management set on Category
  fire event on insert content in createmethod
  fix issue, default foler is set on content creation
  allow to create new content
  update default param of content model
  create content listener for crud management
  dispatch event in pre/post crud method for content model
  ...

Conflicts:
	templates/admin/default/product-edit.html
This commit is contained in:
gmorel
2013-09-23 17:10:03 +02:00
98 changed files with 8688 additions and 277 deletions

View File

@@ -85,7 +85,7 @@ $(function($){
couponManager.createOrUpdateRuleAjax();
}
}
return false;
});
};
couponManager.onClickSaveRule();
@@ -96,6 +96,7 @@ $(function($){
e.preventDefault();
var $this = $(this);
couponManager.removeRuleAjax($this.attr('data-int'));
return false;
});
};
couponManager.onClickDeleteRule();
@@ -109,6 +110,7 @@ $(function($){
// Hide row being updated
$this.parent().parent().remove();
return false;
});
};
couponManager.onClickUpdateRule();

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,99 @@
$(function($){
// Manage picture upload
$.imageUploadManager = {};
Dropzone.autoDiscover = false;
// Remove image on click
$.imageUploadManager.initImageDropZone = function() {
var imageDropzone = new Dropzone("#images-dropzone", {
dictDefaultMessage : $('.btn-browse').html(),
uploadMultiple: false,
maxFilesize: 8,
acceptedFiles: 'image/png, image/gif, image/jpeg'
});
var totalFiles = 0,
completedFiles = 0;
imageDropzone.on("addedfile", function(file){
totalFiles += 1;
if(totalFiles == 1){
$('.dz-message').hide();
}
});
imageDropzone.on("complete", function(file){
completedFiles += 1;
if (completedFiles === totalFiles){
$('.dz-message').slideDown();
}
});
imageDropzone.on("success", function(file) {
imageDropzone.removeFile(file);
$.imageUploadManager.updateImageListAjax();
$.imageUploadManager.onClickDeleteImage();
});
};
// Update picture list via AJAX call
$.imageUploadManager.updateImageListAjax = function() {
var $imageListArea = $(".image-manager .existing-image");
$imageListArea.html('<div class="loading" ></div>');
$.ajax({
type: "POST",
url: imageListUrl,
statusCode: {
404: function() {
$imageListArea.html(
imageListErrorMessage
);
}
}
}).done(function(data) {
$imageListArea.html(
data
);
});
};
// Remove image on click
$.imageUploadManager.onClickDeleteImage = function() {
$('.image-manager .image-delete-btn').on('click', function (e) {
e.preventDefault();
var $this = $(this);
var $parent = $this.parent();
$parent.find('a').remove();
$parent.append('<div class="loading" ></div>');
var $url = $this.attr("href");
var errorMessage = $this.attr("data-error-message");
$.ajax({
type: "POST",
url: $url,
statusCode: {
404: function() {
$(".image-manager .message").html(
errorMessage
);
}
}
}).done(function(data) {
$parent.parents('tr').remove();
$(".image-manager .message").html(
data
);
});
return false;
});
};
$.imageUploadManager.onClickDeleteImage();
});

View File

@@ -0,0 +1,160 @@
.dropzone{
cursor: pointer;
border: 4px dashed @gray-lighter;
padding: 70px;
margin: 20px 0;
&.dz-drag-hover{
border-color: @brand-primary;
}
.dz-message {
text-align: center;
span{
font-size: @font-size-large;
display: block;
color: @gray;
span{
display: block;
font-weight: bold;
margin: 10px 0;
font-size: @font-size-small;
}
button{
span{
display: inline-block;
font-size: @font-size-base;
margin: 0;
color: inherit;
}
}
}
}
.dz-error{
.alert();
.alert-danger();
margin: 10px 0;
}
.dz-preview,
.dropzone-previews .dz-preview {
background: rgba(255,255,255,0.8);
position: relative;
display: inline-block;
margin: 17px;
vertical-align: top;
border: 1px solid #acacac;
padding: 6px 6px 6px 6px;
}
.dz-preview.dz-file-preview [data-dz-thumbnail],
.dropzone-previews .dz-preview.dz-file-preview [data-dz-thumbnail] {
display: none;
}
.dz-preview .dz-details,
.dropzone-previews .dz-preview .dz-details {
width: 100px;
height: 100px;
position: relative;
background: #ebebeb;
padding: 5px;
margin-bottom: 22px;
}
.dz-preview .dz-details .dz-filename,
.dropzone-previews .dz-preview .dz-details .dz-filename {
overflow: hidden;
height: 100%;
}
.dz-preview .dz-details img,
.dropzone-previews .dz-preview .dz-details img {
position: absolute;
top: 0;
left: 0;
width: 100px;
height: 100px;
}
.dz-preview .dz-details .dz-size,
.dropzone-previews .dz-preview .dz-details .dz-size {
position: absolute;
bottom: -28px;
left: 3px;
height: 28px;
line-height: 28px;
}
.dz-preview.dz-error .dz-error-mark,
.dropzone-previews .dz-preview.dz-error .dz-error-mark {
display: block;
}
.dz-preview.dz-success .dz-success-mark,
.dropzone-previews .dz-preview.dz-success .dz-success-mark {
display: block;
}
.dz-preview:hover .dz-details img,
.dropzone-previews .dz-preview:hover .dz-details img {
display: none;
}
.dz-preview .dz-success-mark,
.dropzone-previews .dz-preview .dz-success-mark,
.dz-preview .dz-error-mark,
.dropzone-previews .dz-preview .dz-error-mark {
display: none;
position: absolute;
width: 40px;
height: 40px;
font-size: 30px;
text-align: center;
right: -10px;
top: -10px;
}
.dz-preview .dz-success-mark,
.dropzone-previews .dz-preview .dz-success-mark {
color: #8cc657;
}
.dz-preview .dz-error-mark,
.dropzone-previews .dz-preview .dz-error-mark {
color: #ee162d;
}
.dz-preview .dz-progress,
.dropzone-previews .dz-preview .dz-progress {
position: absolute;
top: 100px;
left: 6px;
right: 6px;
height: 6px;
background: #d7d7d7;
display: none;
}
.dz-preview .dz-progress .dz-upload,
.dropzone-previews .dz-preview .dz-progress .dz-upload {
position: absolute;
top: 0;
bottom: 0;
left: 0;
width: 0%;
background-color: #8cc657;
}
.dz-preview.dz-processing .dz-progress,
.dropzone-previews .dz-preview.dz-processing .dz-progress {
display: block;
}
.dz-preview .dz-error-message,
.dropzone-previews .dz-preview .dz-error-message {
display: none;
position: absolute;
top: -5px;
left: -20px;
background: rgba(245,245,245,0.8);
padding: 8px 10px;
color: #800;
min-width: 140px;
max-width: 500px;
z-index: 500;
}
.dz-preview:hover.dz-error .dz-error-message,
.dropzone-previews .dz-preview:hover.dz-error .dz-error-message {
display: block;
}
}

View File

@@ -14,6 +14,7 @@
@import "bootstrap-switch.less";
@import "bootstrap-select.less";
@import "jqplot.less";
@import "dropzone.less";
// -- Base styling ------------------------------------------------------------

View File

@@ -256,7 +256,8 @@
</div>
<div class="tab-pane fade {if $current_tab == 'images'}active in{/if}" id="images">
</div>
{include file='includes/image-upload-form.html' imageType='category' parentId=$category_id}
</div>
<div class="tab-pane fade {if $current_tab == 'documents'}active in{/if}" id="documents">
</div>
@@ -296,6 +297,14 @@
{/block}
{block name="javascript-initialization"}
{javascripts file='assets/js/dropzone.js'}
<script src="{$asset_url}"></script>
{/javascripts}
{javascripts file='assets/js/image-upload.js'}
<script src="{$asset_url}"></script>
{/javascripts}
<script src="{url file='/tinymce/tinymce.min.js'}"></script>
<script>
@@ -315,11 +324,9 @@
filemanager_title:"{intl l='Files manager'}" ,
external_plugins: { "filemanager" : "{url file='/tinymce/plugins/filemanager/plugin.min.js'}"}
});
</script>
<script>
$(function() {
$.imageUploadManager.initImageDropZone();
$('.use_default_rewriten_url').click(function(ev) {
alert("Not functionnal");

View File

@@ -0,0 +1,352 @@
{extends file="admin-layout.tpl"}
{block name="check-permissions"}admin.content.view{/block}
{block name="page-title"}{intl l='Edit content'}{/block}
{block name="main-content"}
<div class="folder edit-folder">
<div id="wrapper" class="container">
{* include file="includes/folder-breadcrumb.html" editing_category="true" *}
<div class="row">
{loop name="content_edit" type="content" visible="*" id="{$content_id}" backend_context="1" lang="$edit_language_id"}
<div class="col-md-12 general-block-decorator">
<div class="row">
<div class="col-md-7 title">
{intl l='Edit content %title' title=$TITLE}
</div>
<div class="col-md-5 actions">
{if $HAS_PREVIOUS != 0}
<a href="{url path="/admin/content/update/$PREVIOUS"}" class="btn btn-default" title="{intl l='Edit previous content'}"><span class="glyphicon glyphicon-arrow-left"></span></a>
{else}
<a href="#" disabled="disabled" class="btn btn-default"><span class="glyphicon glyphicon-arrow-left"></span></a>
{/if}
<a href="{$URL}" target="_blank" class="btn btn-default" title="{intl l='Preview folder page'}"><span class="glyphicon glyphicon-eye-open"></span></a>
{if $HAS_NEXT != 0}
<a href="{url path="/admin/content/update/$NEXT"}" class="btn btn-default" title="{intl l='Edit next content'}"><span class="glyphicon glyphicon-arrow-right"></span></a>
{else}
<a href="#" disabled="disabled" class="btn btn-default"><span class="glyphicon glyphicon-arrow-right"></span></a>
{/if}
</div>
</div>
<div class="row">
<div class="col-md-12">
<ul class="nav nav-tabs" id="tabbed-menu">
<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="#images" data-toggle="tab">{intl l="Images"}</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>
</ul>
<div class="tab-content">
<div class="tab-pane fade active in" id="general">
<div class="form-container">
{form name="thelia.admin.content.modification"}
<form method="POST" action="{url path='/admin/content/save'}" {form_enctype form=$form} class="clearfix">
{include file="includes/inner-form-toolbar.html" close_url="{url path='/admin/folders' parent=0}"}
{* Be sure to get the folder ID, even if the form could not be validated *}
<input type="hidden" name="content_id" value="{$content_id}" />
<input type="hidden" name="current_tab" value="general" />
{form_hidden_fields form=$form}
{form_field form=$form field='success_url'}
<input type="hidden" name="{$name}" value="{url path="/admin/content/update{$ID}"}" />
{/form_field}
{form_field form=$form field='locale'}
<input type="hidden" name="{$name}" value="{$edit_language_locale}" />
{/form_field}
{if $form_error}<div class="alert alert-danger">{$form_error_message}</div>{/if}
{include file="includes/standard-description-form-fields.html"}
{form_field form=$form field='url'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">
{intl l="{$label}"} :
</label>
<input type="text" id="{$label_attr.for}" required="required" name="{$name}" value="{$value}" title="{intl l='Rewritten URL'}" placeholder="{intl l='Rewriten URL'}" class="form-control">
</div>
{/form_field}
<div class="row">
<div class="col-md-6">
{form_field form=$form field='default_folder'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">
{intl l="{$label}"} :
</label>
<select id="{$label_attr.for}" required="required" name="{$name}" class="form-control">
<option value="0">{intl l="Top level"}</option>
{$myparent=$DEFAULT_FOLDER}
{loop name="fold-parent" type="folder-tree" visible="*" folder="0"}
<option value="{$ID}" style="padding-left: {3 + $LEVEL * 20}px" {if $myparent == $ID}selected="selected"{/if} {if $folder_id == $ID}disabled="disabled"{/if}>{$TITLE}</option>
{/loop }
</select>
</div>
{/form_field}
</div>
<div class="col-md-6">
{form_field form=$form field='visible'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l='Visibility'}</label>
<div class="checkbox">
<label>
<input type="checkbox" id="{$label_attr.for}" name="{$name}" value="1" {if $value != 0}checked="checked"{/if}>
{$label}
</label>
</div>
</div>
{/form_field}
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="control-group">
<lablel>&nbsp;</lablel>
<div class="controls">
<p>{intl l='Colder created on %date_create. Last modification: %date_change' date_create="{format_date date=$CREATE_DATE}" date_change="{format_date date=$UPDATE_DATE}"}</p>
</div>
</div>
</div>
</div>
</form>
{/form}
</div>
</div>
<div class="tab-pane fade" id="details">
<div class="form-container">
<div class="form-group">
<form action="{url path='/admin/folders/related-content/add'}" id="related_content_form">
{include
file="includes/inner-form-toolbar.html"
hide_submit_buttons=true
close_url="{url path='/admin/folders' folder_id=$folder_id}"
}
<input type="hidden" name="folder_id" value="{$folder_id}" />
<input type="hidden" name="current_tab" value="details" />
{ifloop rel="folders"}
<div class="row">
<div class="col-md-6">
<div class="form-group">
<select name="folder_id" id="folder_id" class="form-control">
<option value="">Select a folder...</option>
{loop name="folders" type="folder" backend_context="1" lang="$edit_language_id"}
<option value="{$ID}">{$TITLE}</option>
{/loop}
</select>
</div>
<span class="help-block">{intl l='Select a folder to get its content'}</span>
</div>
<div class="col-md-6">
<div id="content_selector" class="hide">
<div class="input-group">
<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>
</div>
{/ifloop}
{elseloop rel="folders"}
<div class="alert alert-info">{intl l="No folders found"}</div>
{/elseloop}
</form>
</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 class="tab-pane fade" id="images">
{include file='includes/image-upload-form.html' imageType='content' parentId=$content_id}
</div>
<div class="tab-pane fade" id="documents">
</div>
<div class="tab-pane fade" id="modules">
</div>
</div>
</div>
</div>
</div>
{/loop}
</div>
</div>
</div>
{* Delete related content confirmation dialog *}
{capture "delete_content_dialog"}
<!-- <input type="hidden" name="category_id" value="{$category_id}" /> -->
<input type="hidden" name="content_id" id="content_delete_id" value="" />
<input type="hidden" name="folder_id" id="folder_delete_id" value="" />
<input type="hidden" name="current_tab" value="details" />
{/capture}
{include
file = "includes/generic-confirm-dialog.html"
dialog_id = "delete_content_dialog"
dialog_title = {intl l="Remove related content"}
dialog_message = {intl l="Do you really want to remove this related content ?"}
form_action = {url path='/admin/folders/related-content/delete'}
form_content = {$smarty.capture.delete_content_dialog nofilter}
}
{/block}
{block name="javascript-initialization"}
{javascripts file='assets/js/dropzone.js'}
<script src="{$asset_url}"></script>
{/javascripts}
{javascripts file='assets/js/image-upload.js'}
<script src="{$asset_url}"></script>
{/javascripts}
<script>
$(function() {
$.imageUploadManager.initImageDropZone();
$('.use_default_rewriten_url').click(function(ev) {
alert("Not functionnal");
ev.preventDefault();
});
// Show proper tab, if defined
{if ! empty($current_tab)}
$('#tabbed-menu a[href="#{$current_tab}"]').tab('show')
{/if}
// Set proper content ID in delete content from
$('a.delete-content').click(function(ev) {
$('#content_delete_id').val($(this).data('id'));
$('#folder_delete_id').val($('#folder_id').val());
});
// Load content on folder selection
$('#folder_id').change(function(event) {
$.ajax({
url : '{url path="/admin/folder/$folder_id/available-related-content/"}' + $(this).val() + '.xml',
type : 'get',
dataType : 'json',
success : function(json) {
$('#content_id :not(:first-child)').remove();
var have_content = false;
$.each(json, function(idx, value) {
$('#content_id').append($('<option>').text(value.title).attr('value', value.id));
have_content = true; // Lame...
});
if (have_content)
$('#content_selector').removeClass('hide');
else
$('#content_selector').addClass('hide');
}
});
});
// Initialize folder (id={$folder_id}) select value
{if $folder_id != 0}
$('#folder_id').val("{$folder_id}").change();
{/if}
});
</script>
{/block}

View File

@@ -21,7 +21,7 @@
<div class="col-md-5 actions">
{if $HAS_PREVIOUS != 0}
<a href="{url path='/admin/folders/update' folder_id=$PREVIOUS}" class="btn btn-default" title="{intl l='Edit previous folder'}"><span class="glyphicon glyphicon-arrow-left"></span></a>
<a href="{url path="/admin/folders/update/$PREVIOUS"}" class="btn btn-default" title="{intl l='Edit previous folder'}"><span class="glyphicon glyphicon-arrow-left"></span></a>
{else}
<a href="#" disabled="disabled" class="btn btn-default"><span class="glyphicon glyphicon-arrow-left"></span></a>
{/if}
@@ -29,7 +29,7 @@
<a href="{$URL}" target="_blank" class="btn btn-default" title="{intl l='Preview folder page'}"><span class="glyphicon glyphicon-eye-open"></span></a>
{if $HAS_NEXT != 0}
<a href="{url path='/admin/folders/update' folder_id=$NEXT}" class="btn btn-default" title="{intl l='Edit next folder'}"><span class="glyphicon glyphicon-arrow-right"></span></a>
<a href="{url path="/admin/folders/update/$NEXT"}" class="btn btn-default" title="{intl l='Edit next folder'}"><span class="glyphicon glyphicon-arrow-right"></span></a>
{else}
<a href="#" disabled="disabled" class="btn btn-default"><span class="glyphicon glyphicon-arrow-right"></span></a>
{/if}
@@ -67,7 +67,7 @@
{form_hidden_fields form=$form}
{form_field form=$form field='success_url'}
<input type="hidden" name="{$name}" value="{url path='/admin/folder' folder_id={$folder_id}}" />
<input type="hidden" name="{$name}" value="{url path="/admin/folders/update{$ID}"}" />
{/form_field}
{form_field form=$form field='locale'}
@@ -101,9 +101,9 @@
<option value="0">{intl l="Top level"}</option>
{$myparent=$PARENT}
{loop name="fold-parent" type="folder-tree" visible="*" folder="0"}
{* loop name="fold-parent" type="folder-tree" visible="*" folder="0"}
<option value="{$ID}" style="padding-left: {3 + $LEVEL * 20}px" {if $myparent == $ID}selected="selected"{/if} {if $folder_id == $ID}disabled="disabled"{/if}>{$TITLE}</option>
{/loop}
{/loop *}
</select>
</div>
@@ -209,7 +209,7 @@
</thead>
<tbody>
{loop name="assigned_contents" type="associated_content" folder="$folder_id" backend_context="1" lang="$edit_language_id"}
{*loop name="assigned_contents" type="associated_content" folder="$folder_id" backend_context="1" lang="$edit_language_id"}
<tr>
<td>{$ID}</td>
@@ -239,13 +239,14 @@
</div>
</td>
</tr>
{/elseloop}
{/elseloop*}
</tbody>
</table>
</div>
</div>
<div class="tab-pane fade" id="images">
{include file='includes/image-upload-form.html' imageType='folder' parentId=$folder_id}
</div>
<div class="tab-pane fade" id="documents">
@@ -286,59 +287,65 @@
{/block}
{block name="javascript-initialization"}
<script>
{javascripts file='assets/js/dropzone.js'}
<script src="{$asset_url}"></script>
{/javascripts}
{javascripts file='assets/js/image-upload.js'}
<script src="{$asset_url}"></script>
{/javascripts}
<script>
$(function() {
$.imageUploadManager.initImageDropZone();
$(function() {
$('.use_default_rewriten_url').click(function(ev) {
alert("Not functionnal");
$('.use_default_rewriten_url').click(function(ev) {
alert("Not functionnal");
ev.preventDefault();
});
ev.preventDefault();
});
// Show proper tab, if defined
{if ! empty($current_tab)}
$('#tabbed-menu a[href="#{$current_tab}"]').tab('show')
{/if}
// Show proper tab, if defined
{if ! empty($current_tab)}
$('#tabbed-menu a[href="#{$current_tab}"]').tab('show')
{/if}
// Set proper content ID in delete content from
$('a.delete-content').click(function(ev) {
$('#content_delete_id').val($(this).data('id'));
$('#folder_delete_id').val($('#folder_id').val());
});
// Set proper content ID in delete content from
$('a.delete-content').click(function(ev) {
$('#content_delete_id').val($(this).data('id'));
$('#folder_delete_id').val($('#folder_id').val());
});
// Load content on folder selection
$('#folder_id').change(function(event) {
$.ajax({
url : '{url path="/admin/folder/$folder_id/available-related-content/"}' + $(this).val() + '.xml',
type : 'get',
dataType : 'json',
success : function(json) {
$('#content_id :not(:first-child)').remove();
// Load content on folder selection
$('#folder_id').change(function(event) {
$.ajax({
url : '{url path="/admin/folder/$folder_id/available-related-content/"}' + $(this).val() + '.xml',
type : 'get',
dataType : 'json',
success : function(json) {
$('#content_id :not(:first-child)').remove();
var have_content = false;
var have_content = false;
$.each(json, function(idx, value) {
$('#content_id').append($('<option>').text(value.title).attr('value', value.id));
$.each(json, function(idx, value) {
$('#content_id').append($('<option>').text(value.title).attr('value', value.id));
have_content = true; // Lame...
});
have_content = true; // Lame...
});
if (have_content)
$('#content_selector').removeClass('hide');
else
$('#content_selector').addClass('hide');
if (have_content)
$('#content_selector').removeClass('hide');
else
$('#content_selector').addClass('hide');
}
});
});
// Initialize folder (id={$folder_id}) select value
{if $folder_id != 0}
$('#folder_id').val("{$folder_id}").change();
{/if}
}
});
});
// Initialize folder (id={$folder_id}) select value
{if $folder_id != 0}
$('#folder_id').val("{$folder_id}").change();
{/if}
});
</script>
</script>
{/block}

View File

@@ -0,0 +1,149 @@
{extends file="admin-layout.tpl"}
{block name="page-title"}{intl l='Edit an image'}{/block}
{block name="check-permissions"}admin.image.edit{/block}
{block name="main-content"}
<div class="customers edit-image">
<div id="wrapper" class="container">
{loop type="image" name="image_edit" source="{$imageType}" id="{$imageId}" width="580" backend_context="1" lang="$edit_language_id"}
<ul class="breadcrumb">
<li><a href="{url path='/admin/home'}">{intl l="Home"}</a></li>
<li><a href="{url path="{$redirectUrl}"}">{intl l="Image"}</a></li>
<li>{intl l='Editing image "%name"' name="{$TITLE}"}</li>
</ul>
<div class="row">
<div class="col-md-12 general-block-decorator">
<div class="row">
<div class="col-md-12 title title-without-tabs">
{intl l="Edit image $TITLE"}
</div>
<div class="form-container">
<div class="col-md-12">
{form name="thelia.admin.category.image.modification"}
<form method="POST" action="{url path="/admin/image/type/{$imageType}/{$ID}/update"}" enctype="multipart/form-data" class="clearfix">
<div class="row inner-toolbar clearfix">
<div class="col-md-6 inner-actions pull-right">
<button type="submit" name="save_mode" value="stay" class="btn btn-default btn-primary" title="{intl l='Save'}">{intl l='Save'} <span class="glyphicon glyphicon-ok"></span></button>
<a href="{url path="{$redirectUrl}"}" class="btn btn-default btn-info">{intl l='Close'} <span class="glyphicon glyphicon-remove"></span></a>
</div>
</div>
{form_hidden_fields form=$form}
{form_field form=$form field='success_url'}
<input type="hidden" name="{$name}" value="{url path="/admin/image/type/{$imageType}/{$ID}/update"}" />
{/form_field}
{if $form_error}<div class="alert alert-danger">{$form_error_message}</div>{/if}
<p class="title title-without-tabs">{intl l="Image informations"}</p>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label class="control-label">{intl l="Preview"} : </label>
<p><img src="{$IMAGE_URL}" alt="{$TITLE}" class="img-thumbnail"></p>
</div>
</div>
<div class="col-md-6">
{form_field form=$form field='file'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<input type="file" id="{$label_attr.for}" name="{$name}" class="form-control" value="" title="{intl l="{$label}"}" placeholder="{intl l='File'}">
</div>
{/form_field}
{form_field form=$form field='title'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$TITLE}" title="{intl l="{$label}"}" placeholder="{intl l='Title'}">
</div>
{/form_field}
{form_field form=$form field='chapo'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<textarea id="{$label_attr.for}" name="{$name}" class="form-control" title="{intl l="{$label}"}" placeholder="{intl l='Chapo'}">{$CHAPO}</textarea>
</div>
{/form_field}
{form_field form=$form field='postscriptum'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<textarea id="{$label_attr.for}" name="{$name}" class="form-control" title="{intl l="{$label}"}" placeholder="{intl l='Post Scriptum'}">{$POSTSCRIPTUM}</textarea>
</div>
{/form_field}
</div>
</div>
<div class="row">
<div class="col-md-12">
{form_field form=$form field='description'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<textarea id="{$label_attr.for}" name="{$name}" class="form-control wysiwyg" title="{intl l="{$label}"}" placeholder="{intl l='Description'}">{$DESCRIPTION}</textarea>
</div>
{/form_field}
</div>
</div>
</form>
{/form}
</div>
</div>
</div>
</div>
</div>
{/loop}
{elseloop rel="image_edit"}
<div class="row">
<div class="col-md-12">
<div class="alert alert-error">
{intl l="Sorry, image ID=$imageId was not found."}
</div>
</div>
</div>
{/elseloop}
</div>
</div>
{/block}
{block name="javascript-initialization"}
{javascripts file='assets/js/main.js'}
<script src="{$asset_url}"></script>
{/javascripts}
<script src="{url file='/tinymce/tinymce.min.js'}"></script>
<script>
tinymce.init({
selector: ".wysiwyg",
theme: "modern",
menubar : false,
language: "",
plugins: [
"advlist autolink link image lists charmap print preview hr anchor pagebreak",
"searchreplace wordcount visualblocks visualchars insertdatetime media nonbreaking",
"table contextmenu directionality emoticons paste textcolor filemanager"
],
toolbar1: "undo redo | bold italic underline | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | styleselect | filemanager | link unlink anchor | image media | forecolor backcolor | print preview code ",
image_advtab: true ,
external_filemanager_path:"{url file='/tinymce/plugins/filemanager/'}'",
filemanager_title:"{intl l='Files manager'}" ,
external_plugins: { "filemanager" : "{url file='/tinymce/plugins/filemanager/plugin.min.js'}"}
});
</script>
{/block}

View File

@@ -12,6 +12,8 @@ A generic modal creation dialog template. Parameters
form_action = The form action URL. Form is submitted when OK button is clicked
form_enctype = The form encoding
form_error_message = The form error message (optional)
ok_button_id (optionnal) = the id of the OK button
*}
<div class="modal fade" id="{$dialog_id}" tabindex="-1" role="dialog" aria-hidden="true">
@@ -33,7 +35,7 @@ A generic modal creation dialog template. Parameters
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" aria-hidden="true"><span class="glyphicon glyphicon-remove"></span> {$dialog_cancel_label|default:{intl l='Cancel'}}</button>
<button type="submit" class="btn btn-default btn-primary"><span class="glyphicon glyphicon-check"></span> {$dialog_ok_label|default:{intl l='OK'}}</button>
<button {if ! empty($ok_button_id)}id="{$ok_button_id}"{/if} type="submit" class="btn btn-default btn-primary"><span class="glyphicon glyphicon-check"></span> {$dialog_ok_label|default:{intl l='OK'}}</button>
</div>
</form>

View File

@@ -0,0 +1,33 @@
{*
A generic image upload form
Parameters:
imageType = Image type (category, product, folder, content, module)
parentId = Image parent id, ex: category id
*}
<div class="image-manager" >
<form action="{url path="/admin/image/type/$imageType/$parentId/save-ajax"}" class="dropzone" id="images-dropzone" enctype="multipart/form-data">
<div class="fallback">
<input name="file" type="file" multiple />
</div>
<div class="btn-browse hide">
{intl l="Drop files to upload"}
<span>Or</span>
<button type="button" class="btn btn-info btn-upload"><span class="glyphicon glyphicon-upload"></span> {intl l="Browse files"}</button>
</div>
</form>
<div class="existing-image">
{include file='includes/image-upload-list-ajax.html'}
</div>
</div>
<script>
var imageDropZoneUrl = "{url path="/admin/image/type/$imageType/$parentId/save-ajax"}";
var imageListUrl = "{url path="/admin/image/type/$imageType/$parentId/list-ajax"}";
var imageListErrorMessage = "{intl l='Can\'t load images, please refresh this page.'}";
</script>

View File

@@ -0,0 +1,31 @@
{*
A generic image upload form
Parameters:
imageType = Image type (category, product, folder, content, module)
parentId = Image parent id, ex: category id
*}
{ifloop rel="image"}
<table class="table table-striped table-condensed table-left-aligned">
{loop type="image" name="image" source="{$imageType}" order="manual-reverse" source_id="{$parentId}" width="200" height="100" resize_mode="borders"}
<tr>
<td>
<img src="{$IMAGE_URL}" alt="{$TITLE}" class="img-thumbnail">
</td>
<td>
<div class="btn-group">
<a class="image-update-btn btn btn-default btn-xs" href="{url path="/admin/image/type/$imageType/$ID/update"}" data-error-message="{intl l='Please retry'}">
<span class="glyphicon glyphicon-edit"></span>
</a>
<a class="image-delete-btn btn btn-default btn-xs" href="{url path="/admin/image/type/$imageType/delete/$ID"}" data-error-message="{intl l='Please retry'}">
<span class="glyphicon glyphicon-trash"></span>
</a>
</div>
<td>
</tr>
{/loop}
</table>
{/ifloop}

View File

@@ -37,6 +37,10 @@
{/form_field}
{/loop}
<p class="title title-without-tabs">{intl l='Default pricing'}</p>
<p>{intl l="The default pricing is used with product that do not have any combinations. It is also used for product with combinations which share the same pricing information"}</p>
<div class="row">
{* -- Pricing ------------------------------------------------------- *}
@@ -173,81 +177,193 @@
{* -- Attribute combinations -------------------------------------------- *}
<div class="row">
<div class="col-md-12">
{module_include location='product_before_combinations'}
<p class="title title-without-tabs">{intl l='Attribute Combinations'}</p>
<div class="row">
<div class="col-md-12">
<div class="well well-sm">
{module_include location='product_before_combinations'}
<table class="table table-striped table-condensed" id="category_list">
<caption>
{intl l='Attribute Combinations'}
{ifloop rel="product-attributes"}
<form method="POST" action="{url path='/admin/products/combinations/save'}" {form_enctype form=$form} class="clearfix">
<div class="well well-sm">
<p class="title title-without-tabs">{intl l='Create a new combination'}</p>
{module_include location='product_combinations_list_caption'}
<div class="form-group">
<label class="control-label">{intl l="Attribute"} : </label>
<select required="required" name="attribute_id" id="attribute_id" class="form-control">
<option value="">{intl l='Select an attribute...'}</option>
{loop name="product-attributes" type="attribute" product=$product_id backend_context="1" lang=$edit_language_id}
<option value="{$ID}">{$TITLE}</option>
{/loop}
</select>
<span class="help-block">{intl l='Select an attribute and click (+) to view available values'}</span>
</div>
{loop type="auth" name="can_create" roles="ADMIN" permissions="admin.products.update"}
<a class="btn btn-default btn-primary action-btn" title="{intl l='Add a new combination'}" href="#combination_creation_dialog" data-toggle="modal">
<span class="glyphicon glyphicon-plus-sign"></span>
</a>
{/loop}
</caption>
<thead>
<tr>
<th>{intl l='Attributes'}</th>
<th class="text-center">{intl l='Quantity'}</th>
<th class="text-center">{intl l='Price<br />w/o taxes (%currency)' currency=$currency_symbol}</th>
<th class="text-center">{intl l='Price<br />w/ taxes (%currency)' currency=$currency_symbol}</th>
<th class="text-center">{intl l='Weight (Kg)'}</th>
<th class="text-center">{intl l='Is new'}</th>
<th class="text-center">{intl l='On sale'}</th>
<th class="text-center">{intl l='Sale price<br />w/o taxes (%currency)' currency=$currency_symbol}</th>
<th class="text-center">{intl l='Sale price<br />w/ taxes (%currency)' currency=$currency_symbol}</th>
<th class="actions">{intl l='Actions'}</th>
</tr>
</thead>
<tbody>
{loop name="product.sales.elements" type="product_sale_elements" product=$product_id currency=$edit_currency_id}
<tr>
<td>
{loop name="product.sales.elements.combinations" type="attribute_combination" product_sale_elements=$ID}
{$ATTRIBUTE_TITLE}&nbsp;
{/loop}
</td>
<td><input class="form-control text-right" type="text" name="quantity[{$ID}]" value="{format_number number=$QUANTITY}" /></td>
<td><input class="form-control text-right" type="text" name="price_wo_taxes[{$ID}]" value="{format_number number=$PRICE_TAX}" /></td>
<td><input class="form-control text-right" type="text" name="price_w_taxes[{$ID}]" value="{format_number number=$TAXED_PRICE}" /></td>
<td><input class="form-control text-right" type="text" name="weight[{$ID}]" value="{format_number number=$WEIGHT}" /></td>
<td>
<div class="make-switch switch-small" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
<input class="change-default" type="radio" name="on_sale[{$ID}]" value="{$ID}" {if $IS_PROMO}checked="checked"{/if}/>
</div>
</td>
<td>
<div class="make-switch switch-small" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
<input class="change-default" type="radio" name="is_new[{$ID}]" value="{$ID}" {if $IS_NEW}checked="checked"{/if}/>
</div>
</td>
<td><input class="form-control text-right" type="text" name="sale_price_wo_taxes[{$ID}]" value="{format_number number=$PROMO_PRICE_TAX}" /></td>
<td><input class="form-control text-right" type="text" name="sale_price_w_taxes[{$ID}]" value="{format_number number=$TAXED_PROMO_PRICE}" /></td>
<td class="actions">
<a class="btn btn-default btn-xs combination-delete" title="{intl l='Delete this combination'}" href="#combination_delete_dialog" data-id="{$ID}" data-toggle="modal"><i class="glyphicon glyphicon-trash"></i></a>
</td>
</tr>
{/loop}
</tbody>
</table>
</div>
</div>
</div>
{module_include location='product_after_combinations'}
</div>
{* -- Adding a new combination ------------------------------------------------- *}
{* Capture the dialog body, to pass it to the generic dialog *}
{capture "combination_creation_dialog"}
<input type="hidden" name="product_id" value="{$product_id}" />
<input type="hidden" name="current_tab" value="details" />
<div class="form-group">
<label class="control-label">{intl l="Attribute"} : </label>
<select name="attribute_id" id="attribute_id" class="form-control">
<option value="">{intl l='Select an attribute...'}</option>
{loop name="product-attributes" type="attribute" product=$product_id backend_context="1" lang=$edit_language_id}
<option value="{$ID}">{$TITLE}</option>
{/loop}
</select>
<span class="help-block">{intl l='Select an attribute and click (+) to view available values'}</span>
</div>
<div id="attribute_value_selector" class="hide">
<div class="input-group">
{* <label class="control-label">{intl l="Attribute values"} : </label> *}
<div id="attribute_value_selector" class="hide">
<div class="input-group">
{* <label class="control-label">{intl l="Attribute values"} : </label> *}
<select required="required" name="attribute_value_id" id="attribute_value_id" class="form-control">
<option value="">{intl l='Select an attribute value...'}</option>
</select>
<select rname="attribute_value_id" id="attribute_value_id" class="form-control">
<option value="">{intl l='Select an attribute value...'}</option>
</select>
<span class="input-group-btn" id="add_attr_value_button">
<button class="btn btn-default btn-primary action-btn add-value-to-combination" type="button"><span class="glyphicon glyphicon-plus-sign"></span></button>
</span>
</div>
<span class="input-group-btn" id="add_attr_value_button">
<button class="btn btn-default btn-primary action-btn add-value-to-combination" type="button"><span class="glyphicon glyphicon-plus-sign"></span></button>
</span>
</div>
<span class="help-block">{intl l='Select a value click (+) to add it to the combination'}</span>
</div>
<span class="help-block">{intl l='Select a value click (+) to add it to the combination'}</span>
</div>
<div id="attribute_value_selector_empty" class="hide">
<div class="alert alert-info">
{intl l="No available value for this attribute"}
</div>
</div>
<div id="attribute_value_selector_empty" class="hide">
<div class="alert alert-info">
{intl l="No available value for this attribute"}
</div>
</div>
<div class="form-group">
<div class="alert alert-danger hide" id="combination_attributes_error"></div>
<div class="form-group">
<div class="alert alert-danger hide" id="combination_attributes_error"></div>
<select multiple="multiple" size="5" name="combination_attributes" id="combination_attributes" class="form-control">
</select>
<select required="required" multiple="multiple" size="5" name="combination_attributes[]" id="combination_attributes" class="form-control">
</select>
<div class="help-block">
{intl l='To remove a value from the combination, select it and click "remove"'}
<div class="help-block">
{intl l='To remove a value from the combination, select it and click "remove"'}
<div class="pull-right">
<button class="btn btn-info btn-xs remove-value-from-combination" type="button">
{intl l="Remove selected value"} <span class="glyphicon glyphicon-minus-sign"></span>
</button>
</div>
</div>
</div>
<div class="pull-right">
<button class="btn btn-info btn-xs remove-value-from-combination" type="button">
{intl l="Remove selected values"} <span class="glyphicon glyphicon-minus-sign"></span>
</button>
</div>
</div>
</div>
</div>
</form>
{/ifloop}
{form_field form=$form field='isnew'}
<div class="form-group {if $error}has-error{/if}">
<div class="checkbox">
<label>
<input type="checkbox" id="use_default_princing" name="use_default_princing" value="1">
{intl l="Use default princing for this combination (you can change this later)"}
</label>
</div>
</div>
{/form_field}
{elseloop rel="product-attributes"}
<div class="alert alert-info">
{intl l="No attributes are attached to this product."}
</div>
{/elseloop}
{/capture}
{module_include location='product_after_combinations'}
{include
file = "includes/generic-create-dialog.html"
</div> {* com *}
</div> {* row *}
</div>
dialog_id = "combination_creation_dialog"
dialog_title = {intl l="Create a new combination"}
dialog_body = {$smarty.capture.combination_creation_dialog nofilter}
dialog_ok_label = {intl l="Create this combination"}
form_action = {url path='/admin/product/combination/add'}
form_enctype = ''
form_error_message = ''
ok_button_id = "combination_creation_dialog_ok"
}
{* -- Delete combination confirmation dialog ----------------------------------- *}
{capture "combination_delete_dialog"}
<input type="hidden" name="product_id" value="{$product_id}" />
<input type="hidden" name="current_tab" value="details" />
<input type="hidden" name="combination_id" id="combination_delete_id" value="" />
{module_include location='category_delete_form'}
{/capture}
{include
file = "includes/generic-confirm-dialog.html"
dialog_id = "combination_delete_dialog"
dialog_title = {intl l="Delete a combunation"}
dialog_message = {intl l="Do you really want to delete this combination ?"}
form_action = {url path='/admin/product/combination/delete'}
form_content = {$smarty.capture.combination_delete_dialog nofilter}
}

View File

@@ -62,7 +62,14 @@
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"
data-href="{url path="/admin/image/type/product/{$product_id}/form-ajax"}"
data-callback="$.imageUploadManager.initImageDropZone">
{intl l="Images"}
</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>
</ul>
@@ -109,9 +116,15 @@
{block name="javascript-initialization"}
{javascripts file='assets/js/bootstrap-editable/bootstrap-editable.js'}
<script src="{$asset_url}"></script>
{/javascripts}
{javascripts file='assets/js/dropzone.js'}
<script src="{$asset_url}"></script>
{/javascripts}
{javascripts file='assets/js/image-upload.js'}
<script src="{$asset_url}"></script>
{/javascripts}
{javascripts file='assets/js/bootstrap-editable/bootstrap-editable.js'}
<script src="{$asset_url}"></script>
{/javascripts}
<script src="{url file='/tinymce/tinymce.min.js'}"></script>
<script>
@@ -138,8 +151,10 @@ $(function() {
// Atomatic ajax tab load, if data-href is defined.
$('.nav-tabs a[data-href]').on('shown.bs.tab', function(ev) {
var zis = $(this);
$(zis.attr('href')).load(zis.data('href'));
var $this = $(this);
$($this.attr('href')).load($this.data('href'), function(ev) {
eval($this.data('callback') + '();');
});
});
// Load active tab
@@ -229,6 +244,17 @@ $(function() {
event.preventDefault();
});
// Set proper category ID in combination delete from
$('a.combination-delete').click(function(ev) {
$('#combination_delete_id').val($(this).data('id'));
});
// In create combination dialog, select all element of conbination list
$('#combination_creation_dialog_ok').click(function() {
$('#combination_attributes option').prop('selected', 'selected');
});
});
</script>