WIP : Refactor contraint/rule becomes conditions (more generic)

This commit is contained in:
gmorel
2013-09-25 14:51:42 +02:00
parent cb389f126c
commit d6172f23cf
75 changed files with 582 additions and 2787 deletions

View File

@@ -90,12 +90,15 @@ $(function($){
// Save rules on click
$.couponManager.onClickSaveRule = function() {
$('#constraint-save-btn').on('click', function () {
if($('#category-rule').val() == 'thelia.constraint.rule.available_for_everyone') {
// @todo translate + modal
var r= confirm("Do you really want to set this coupon available to everyone ?");
console.log('constraint-save-btn');
if($('#category-rule').val() == 'thelia.condition.match_for_everyone') {
// // @todo translate + modal
var r = confirm("Do you really want to set this coupon available to everyone ?");
if (r == true) {
$.couponManager.createOrUpdateRuleAjax();
}
} else {
$.couponManager.createOrUpdateRuleAjax();
}
});

View File

@@ -54,23 +54,36 @@
// -- Confirm Box --
if($('[data-toggle="confirm"]').length){
$('[data-toggle="confirm"]').click(function(e){
$('[data-toggle="confirm"]').click(function(e){
var $link = $(this);
var modal = $(this).data('target');
var $this = $(this);
var $modal = $($this.data('target'));
$(modal).modal('show');
$modal.modal('show');
$(modal).on('shown', function () {
$('[data-confirm]').attr('href', $link.attr('href'));
$modal.on('shown', function () {
if($this.data('script')){
$('[data-confirm]').click(function(){
eval($this.data('script'));
$modal.modal('hide');
return false;
});
}
else{
$('[data-confirm]').attr('href', $this.attr('href'));
}
});
if($(modal).is(':hidden')){
if($modal.is(':hidden')){
e.preventDefault();
}
});
}
}
// -- Mini browser --
miniBrowser = function (root, url){

View File

@@ -24,8 +24,6 @@
</section> <!-- #wrapper -->
{/block}
{include file='includes/confirmation-modal.html'}
{block name="javascript-initialization"}
{javascripts file='assets/bootstrap-datepicker/js/bootstrap-datepicker.js'}
<script src="{$asset_url}"></script>
@@ -89,7 +87,7 @@
$('#constraint-add-operators-values').html('');
// Set the rule selector
$("#category-rule option").filter(function() {
return $(this).val() == 'thelia.constraint.rule.available_for_everyone';
return $(this).val() == 'thelia.condition.match_for_everyone';
}).prop('selected', true);
$.couponManager.onClickUpdateRule();

View File

@@ -190,7 +190,7 @@
<section class="row">
<div class="col-md-12 general-block-decorator clearfix">
<a id="constraint-save-btn" title="{intl l='Save this rule'}" class="btn btn-default btn-primary pull-right">
<a id="constraint-save-btn" title="{intl l='Save this rule'}" class="btn btn-default btn-primary pull-right" data-toggle="confirm" data-script="">
<span class="glyphicon glyphicon-plus-sign"></span> {intl l='Save this rule'}
</a>