Merge branch 'views-management' of https://github.com/thelia/thelia into views-management

Conflicts:
	templates/admin/default/tax-rule-edit.html
This commit is contained in:
mespeche
2013-09-30 10:14:11 +02:00
2 changed files with 105 additions and 96 deletions

View File

@@ -311,7 +311,7 @@
.panel-body{
.draggable{
.draggable, .drag{
margin: 5px 0;
padding: 10px;
border: 1px dashed @gray-light;

View File

@@ -21,10 +21,10 @@
<div class="title title-without-tabs">
{intl l="Edit tax rule $TITLE"}
</div>
</div>
<form action="" method="post">
<div class="form-group">
<label for="" class="label-control">{intl l="Choose a country"} :</label>
<div class="input-group">
@@ -39,23 +39,23 @@
</div>
</form>
<p><strong>{intl l="Countries that have the same tax rule"} :<strong></p>
<p class="lead">
<span class="label label-info">Italy</span>
<span class="label label-info">England</span>
<span class="label label-info">Japan</span>
</p>
<div class="row">
<div class="col-md-6">
<div class="panel panel-default place">
<div id="panel" class="panel panel-default place">
<div class="panel-heading">
<h3 class="panel-title">Create a tax rule</h3>
</div>
<div class="panel-body">
<div class="drop-group droppable add-to-group">
<p class="drop-message">
<span class="glyphicon glyphicon-plus"></span>
@@ -72,12 +72,12 @@
</div>
</div>
<a href="#delete_dialog" data-toggle="modal" id="apply-taxes-rules" class="btn btn-default btn-primary btn-block"><span class="glyphicon glyphicon-check"></span> {intl l="Apply"}</a>
<a href="#confirmation_dialog" data-toggle="modal" id="apply-taxes-rules" class="btn btn-default btn-primary btn-block"><span class="glyphicon glyphicon-check"></span> {intl l="Apply"}</a>
</div>
<div class="col-md-6">
<div class="panel panel-default take">
<div id="panel-list" class="panel panel-default take">
<div class="panel-heading">
<h3 class="panel-title">List of taxes</h3>
</div>
@@ -86,7 +86,7 @@
<div class="draggable">Dapibus ac facilisis in</div>
<div class="draggable">Morbi leo risus</div>
<div class="draggable">Porta ac consectetur ac</div>
<div class="draggable">Vestibulum at eros</div>
<div class="draggable">Vestibulum at eros</div>
</div>
<div class="panel-footer droppable remove-from-group">
<p class="drop-message">
@@ -95,7 +95,7 @@
</p>
</div>
</div>
</div>
</div>
@@ -104,11 +104,11 @@
</div>
{* Delete confirmation dialog *}
{* Confirmation dialog *}
{capture "delete_dialog"}
{capture "confirmation_dialog"}
<form action="" method="">
<form action="" method="post">
<div class="form-group">
<select name="" id="" data-toggle="selectpicker" multiple>
<option value="1">France</option>
@@ -120,22 +120,24 @@
{/capture}
{include
file = "includes/generic-confirm-dialog.html"
{include
file = "includes/generic-create-dialog.html"
dialog_id = "delete_dialog"
dialog_title = {intl l="Delete attribute"}
dialog_message = {intl l="Do you really want to delete this attribute ? It will be removed from all product templates."}
dialog_id = "confirmation_dialog"
dialog_title = {intl l="Create a new tax rule"}
dialog_body = {$smarty.capture.confirmation_dialog nofilter}
form_action = {url path='/admin/configuration/attributes/delete'}
form_content = {$smarty.capture.delete_dialog nofilter}
dialog_ok_label = {intl l="Create this tax rule"}
form_action = {url path='/admin/categories/create'}
form_error_message = $form_error_message
}
</div>
{/block}
{block name="javascript-initialization"}
{javascripts file='assets/js/bootstrap-select/bootstrap-select.js'}
<script src="{$asset_url}"></script>
{/javascripts}
@@ -145,105 +147,112 @@
{/javascripts}
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
{literal}
<script>
$(function() {
// Création du tableau des règles de taxe
// Cache jQuery Objects
var $group = $('#panel');
var $list = $('#panel-list');
// Build array of taxes rules
$('#apply-taxes-rules').click(function(){
var taxesRules = [],
index;
$('.place .panel-body .drop-group').each(function(i){
$('.drop-group', $group).each(function(i){
var $this = $(this);
index = i;
taxesRules[index] = [];
$('.draggable', $this).each(function(j){
$('.drag', $this).each(function(j){
taxesRules[index][j] = [];
taxesRules[index][j] = $(this).text();
});
});
});
$('.place .panel-body').sortable({
axis: "y",
revert: true,
containment: "parent",
items : "> div"
console.log(taxesRules);
});
$(".draggable").draggable({
cursor: "move",
revert: true,
// Default options for draggable
var dragOptions = {
cursor: 'move',
containment: "document",
opacity: 0.5,
start: function(event, ui){
// Initilisation du droppable pour nouveaux groupes
initDrop();
},
stop: function(event, ui) {
revert: "invalid", // when not dropped, the item will revert back to its initial position
zIndex: 10
};
var $zone = $('.panel-body').find('.droppable');
var zoneLength = $zone.length;
if(zoneLength > 1){
$zone.each(function(){
var $this = $(this);
var draggableLength = $('.draggable', $this).length;
// Default options for sortabble
var sortOptions = {
cursor: 'move',
items: 'div',
update: function( event, ui ){
// Check if we have an empty group
var $zone = $('.add-to-group', $group);
if($zone.size() > 1 && $(this).find('> div').size() == 0){ // Remove empty group only if we have more than 1 group
$(this).slideUp(function(){ $(this).remove(); });
}
}
};
// Si une zone est vide on la supprime
if(draggableLength == 0){
$this.slideUp(function(){
$this.remove();
});
}
// Default options for droppable
var dropOptions = {
accept: "#panel-list .draggable", // Controls which draggable elements are accepted
hoverClass: "over",
drop: function( event, ui ) {
var $drop = $(this);
});
}
if($(this).hasClass('create-group')){
// Check if we have already an empty group
var $empty_group = $group.find('.drop-group:not(:has(> div))');
if($empty_group.size() > 0){ // if yes (Use the first empty group)
$drop = $empty_group.filter(':first');
}else{ //if no (Create a new group)
$drop = $group.find('.drop-group:last-child').clone().appendTo($group.find('.panel-body'));
// Remove taxes
$drop.find('> div').remove();
// Make the new group droppable
$drop
.droppable(dropOptions)
.sortable(sortOptions);
}
}
$("<div></div>").addClass('drag').text( ui.draggable.text() ).appendTo( $drop );
ui.draggable.remove();
}
};
// Make the list of taxes draggable
$('.draggable', $list).draggable(dragOptions);
// let the drop-group be droppable & sortable, accepting the tax items
$('.droppable', $group)
.droppable(dropOptions)
.sortable(sortOptions);
var sortOptionsGroup = { };
$('.place .panel-body').sortable($.extend(sortOptions, sortOptionsGroup));
// let the gallery be droppable as well, accepting items from the trash
$('.remove-from-group', $list)
.droppable({
accept: "#panel .drag",
hoverClass: 'over',
drop: function( event, ui ) {
$("<div></div>").addClass('draggable').text( ui.draggable.text() ).draggable(dragOptions).appendTo( $list.find('.panel-body') );
ui.draggable.remove();
}
});
// Initialisation du droppable
initDrop();
// Fonction droppable
function initDrop() {
$(".droppable").droppable({
hoverClass: "over",
drop: function( event, ui ) {
var $this = $(this),
$elem = ui.draggable.detach();
// On ajout au groupe existant
if($this.hasClass('add-to-group')){
$this.find('.drop-message').after($elem);
}
// On crée un nouveau groupe
else if($this.hasClass('create-group')){
var $dropZone = $this.prev('.panel-body').find('.drop-group:last-child').clone();
$dropZone.find('.draggable').remove();
var $panelBody = $this.prev('.panel-body');
$panelBody.append($dropZone);
var $newZone = $panelBody.find('.drop-group:last-child');
$newZone.find('.drop-message').after($elem);
}
// On supprime d'un groupe
else if($this.hasClass('remove-from-group')){
var $panelBody = $this.prev('.panel-body');
$panelBody.append($elem);
}
}
});
}
});
</script>
{/literal}
{/block}