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:
@@ -311,7 +311,7 @@
|
|||||||
|
|
||||||
.panel-body{
|
.panel-body{
|
||||||
|
|
||||||
.draggable{
|
.draggable, .drag{
|
||||||
margin: 5px 0;
|
margin: 5px 0;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
border: 1px dashed @gray-light;
|
border: 1px dashed @gray-light;
|
||||||
|
|||||||
@@ -50,7 +50,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
|
|
||||||
<div class="panel panel-default place">
|
<div id="panel" class="panel panel-default place">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<h3 class="panel-title">Create a tax rule</h3>
|
<h3 class="panel-title">Create a tax rule</h3>
|
||||||
</div>
|
</div>
|
||||||
@@ -72,12 +72,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</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>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
|
|
||||||
<div class="panel panel-default take">
|
<div id="panel-list" class="panel panel-default take">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<h3 class="panel-title">List of taxes</h3>
|
<h3 class="panel-title">List of taxes</h3>
|
||||||
</div>
|
</div>
|
||||||
@@ -104,11 +104,11 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{* Delete confirmation dialog *}
|
{* Confirmation dialog *}
|
||||||
|
|
||||||
{capture "delete_dialog"}
|
{capture "confirmation_dialog"}
|
||||||
|
|
||||||
<form action="" method="">
|
<form action="" method="post">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<select name="" id="" data-toggle="selectpicker" multiple>
|
<select name="" id="" data-toggle="selectpicker" multiple>
|
||||||
<option value="1">France</option>
|
<option value="1">France</option>
|
||||||
@@ -120,18 +120,20 @@
|
|||||||
|
|
||||||
{/capture}
|
{/capture}
|
||||||
|
|
||||||
{include
|
{include
|
||||||
file = "includes/generic-confirm-dialog.html"
|
file = "includes/generic-create-dialog.html"
|
||||||
|
|
||||||
dialog_id = "delete_dialog"
|
dialog_id = "confirmation_dialog"
|
||||||
dialog_title = {intl l="Delete attribute"}
|
dialog_title = {intl l="Create a new tax rule"}
|
||||||
dialog_message = {intl l="Do you really want to delete this attribute ? It will be removed from all product templates."}
|
dialog_body = {$smarty.capture.confirmation_dialog nofilter}
|
||||||
|
|
||||||
form_action = {url path='/admin/configuration/attributes/delete'}
|
dialog_ok_label = {intl l="Create this tax rule"}
|
||||||
form_content = {$smarty.capture.delete_dialog nofilter}
|
|
||||||
|
form_action = {url path='/admin/categories/create'}
|
||||||
|
|
||||||
|
form_error_message = $form_error_message
|
||||||
}
|
}
|
||||||
|
|
||||||
</div>
|
|
||||||
{/block}
|
{/block}
|
||||||
|
|
||||||
{block name="javascript-initialization"}
|
{block name="javascript-initialization"}
|
||||||
@@ -145,105 +147,112 @@
|
|||||||
{/javascripts}
|
{/javascripts}
|
||||||
|
|
||||||
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
|
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
|
||||||
|
{literal}
|
||||||
<script>
|
<script>
|
||||||
$(function() {
|
$(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(){
|
$('#apply-taxes-rules').click(function(){
|
||||||
var taxesRules = [],
|
var taxesRules = [],
|
||||||
index;
|
index;
|
||||||
|
|
||||||
$('.place .panel-body .drop-group').each(function(i){
|
$('.drop-group', $group).each(function(i){
|
||||||
|
|
||||||
var $this = $(this);
|
var $this = $(this);
|
||||||
|
|
||||||
index = i;
|
index = i;
|
||||||
taxesRules[index] = [];
|
taxesRules[index] = [];
|
||||||
|
|
||||||
$('.draggable', $this).each(function(j){
|
$('.drag', $this).each(function(j){
|
||||||
taxesRules[index][j] = [];
|
taxesRules[index][j] = [];
|
||||||
taxesRules[index][j] = $(this).text();
|
taxesRules[index][j] = $(this).text();
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log(taxesRules);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.place .panel-body').sortable({
|
// Default options for draggable
|
||||||
axis: "y",
|
var dragOptions = {
|
||||||
revert: true,
|
cursor: 'move',
|
||||||
containment: "parent",
|
|
||||||
items : "> div"
|
|
||||||
});
|
|
||||||
|
|
||||||
$(".draggable").draggable({
|
|
||||||
cursor: "move",
|
|
||||||
revert: true,
|
|
||||||
containment: "document",
|
containment: "document",
|
||||||
opacity: 0.5,
|
opacity: 0.5,
|
||||||
start: function(event, ui){
|
revert: "invalid", // when not dropped, the item will revert back to its initial position
|
||||||
// Initilisation du droppable pour nouveaux groupes
|
zIndex: 10
|
||||||
initDrop();
|
};
|
||||||
},
|
|
||||||
stop: function(event, ui) {
|
|
||||||
|
|
||||||
var $zone = $('.panel-body').find('.droppable');
|
// Default options for sortabble
|
||||||
var zoneLength = $zone.length;
|
var sortOptions = {
|
||||||
|
cursor: 'move',
|
||||||
if(zoneLength > 1){
|
items: 'div',
|
||||||
$zone.each(function(){
|
update: function( event, ui ){
|
||||||
var $this = $(this);
|
// Check if we have an empty group
|
||||||
var draggableLength = $('.draggable', $this).length;
|
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
|
||||||
// Si une zone est vide on la supprime
|
$(this).slideUp(function(){ $(this).remove(); });
|
||||||
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>
|
</script>
|
||||||
|
{/literal}
|
||||||
|
|
||||||
{/block}
|
{/block}
|
||||||
Reference in New Issue
Block a user