Merge branch 'master' of https://github.com/thelia/thelia
This commit is contained in:
@@ -224,7 +224,7 @@
|
||||
<script src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
|
||||
|
||||
{debugbar_renderjs}
|
||||
{debugbar_renderresult}
|
||||
|
||||
|
||||
{block name="after-javascript-include"}{/block}
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 13 KiB |
BIN
templates/admin/default/assets/img/top-bar-logo-save.png
Normal file
BIN
templates/admin/default/assets/img/top-bar-logo-save.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.6 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 7.1 KiB |
148
templates/admin/default/assets/js/coupon.js
Normal file
148
templates/admin/default/assets/js/coupon.js
Normal file
@@ -0,0 +1,148 @@
|
||||
$(function($){
|
||||
|
||||
// Clean array from deleteValue (undefined) keys
|
||||
Array.prototype.clean = function(deleteValue) {
|
||||
for (var i = 0; i < this.length; i++) {
|
||||
if (this[i] == deleteValue) {
|
||||
this.splice(i, 1);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
// Remove 1 Rule then Save Rules AJAX
|
||||
couponManager.removeRuleAjax = function(id) {
|
||||
// Delete rule in temporary array
|
||||
delete couponManager.rulesToSave[id];
|
||||
couponManager.rulesToSave.clean(undefined);
|
||||
|
||||
// Save
|
||||
couponManager.saveRuleAjax();
|
||||
};
|
||||
|
||||
// Add 1 Rule / or update the temporary Rules array then Save Rules via AJAX
|
||||
couponManager.addRuleAjax = function(id) {
|
||||
console.log('addRuleAjax '+ id);
|
||||
// If create
|
||||
if(!id) {
|
||||
console.log('pushing');
|
||||
couponManager.rulesToSave.push(couponManager.ruleToSave);
|
||||
} else { // else update
|
||||
console.log('editing ' + id);
|
||||
couponManager.rulesToSave[id] = couponManager.ruleToSave;
|
||||
// reset edit mode to off
|
||||
couponManager.ruleIdToUpdate = false;
|
||||
}
|
||||
|
||||
// Save
|
||||
couponManager.saveRuleAjax();
|
||||
};
|
||||
|
||||
// Set rule inputs to allow editing
|
||||
couponManager.updateRuleAjax = function(id) {
|
||||
couponManager.ruleToUpdate = couponManager.rulesToSave[id];
|
||||
console.log('Set id to edit to ' + id);
|
||||
couponManager.ruleIdToUpdate = id;
|
||||
|
||||
// Deleting this rule, we will reset it
|
||||
delete couponManager.rulesToSave[id];
|
||||
|
||||
// Set the rule selector
|
||||
$("#category-rule option").filter(function() {
|
||||
return $(this).val() == couponManager.ruleToUpdate.serviceId;
|
||||
}).prop('selected', true);
|
||||
|
||||
// Force rule input refresh
|
||||
couponManager.loadRuleInputs(couponManager.ruleToUpdate.serviceId, function() {
|
||||
couponManager.fillInRuleInputs();
|
||||
});
|
||||
};
|
||||
|
||||
// Fill in rule inputs
|
||||
couponManager.fillInRuleInputs = function() {
|
||||
console.log('fillInRuleInputs with');
|
||||
console.log(couponManager.ruleToUpdate);
|
||||
var operatorId = null;
|
||||
var valueId = null;
|
||||
var idName = null;
|
||||
|
||||
for (idName in couponManager.ruleToUpdate.operators) {
|
||||
// Setting idName operator select
|
||||
operatorId = idName + '-operator';
|
||||
$('#' + operatorId).val(couponManager.ruleToUpdate.operators[idName]);
|
||||
|
||||
valueId = idName + '-value';
|
||||
// Setting idName value input
|
||||
$('#' + valueId).val(couponManager.ruleToUpdate.values[idName]);
|
||||
}
|
||||
couponManager.ruleToSave = couponManager.ruleToUpdate;
|
||||
|
||||
var id = couponManager.ruleIdToUpdate;
|
||||
console.log('id to edit = ' + id);
|
||||
if(id) {
|
||||
console.log('setint rulesToSave[' + id + ']');
|
||||
console.log(couponManager.ruleToSave);
|
||||
couponManager.rulesToSave[id] = couponManager.ruleToSave;
|
||||
}
|
||||
};
|
||||
|
||||
// Save rules on click
|
||||
couponManager.onClickSaveRule = function() {
|
||||
$('#constraint-save-btn').on('click', function () {
|
||||
couponManager.addRuleAjax(couponManager.ruleIdToUpdate);
|
||||
});
|
||||
};
|
||||
couponManager.onClickSaveRule();
|
||||
|
||||
// Remove rule on click
|
||||
couponManager.onClickDeleteRule = function() {
|
||||
$('.constraint-delete-btn').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
var $this = $(this);
|
||||
couponManager.removeRuleAjax($this.attr('data-int'));
|
||||
});
|
||||
};
|
||||
couponManager.onClickDeleteRule();
|
||||
|
||||
// Update rule on click
|
||||
couponManager.onClickUpdateRule = function() {
|
||||
$('.constraint-update-btn').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
var $this = $(this);
|
||||
couponManager.updateRuleAjax($this.attr('data-int'));
|
||||
|
||||
// Hide row being updated
|
||||
$this.parent().parent().remove();
|
||||
});
|
||||
};
|
||||
couponManager.onClickUpdateRule();
|
||||
|
||||
// Reload effect inputs when changing effect
|
||||
couponManager.onEffectChange = function() {
|
||||
$('#effect').on('change', function () {
|
||||
var optionSelected = $("option:selected", this);
|
||||
$('#effectToolTip').html(optionSelected.attr("data-description"));
|
||||
});
|
||||
};
|
||||
couponManager.onEffectChange();
|
||||
|
||||
// Reload rule inputs when changing effect
|
||||
couponManager.onRuleChange = function() {
|
||||
$('#category-rule').on('change', function () {
|
||||
couponManager.loadRuleInputs($(this).val(), function(ruleToSave) {});
|
||||
});
|
||||
};
|
||||
couponManager.onRuleChange();
|
||||
|
||||
// Fill in ready to be saved rule array
|
||||
// var onInputsChange = function()
|
||||
// In AJAX response
|
||||
|
||||
});
|
||||
|
||||
// Rule to save
|
||||
|
||||
var couponManager = {};
|
||||
couponManager.ruleToSave = {};
|
||||
couponManager.ruleIdToUpdate = false;
|
||||
@@ -40,7 +40,7 @@
|
||||
line-height: @topBarHeight;
|
||||
height: @topBarHeight;
|
||||
background: url("@{imgDir}/top-bar-logo.png") left -3px no-repeat;
|
||||
padding-left: 100px;
|
||||
padding-left: 170px;
|
||||
text-shadow: 0px 1px 1px black;
|
||||
color: #6d737b;
|
||||
}
|
||||
@@ -261,6 +261,6 @@
|
||||
|
||||
.loading{
|
||||
background: url("@{imgDir}/ajax-loader.gif") no-repeat;
|
||||
height: 24px;
|
||||
width: 24px;
|
||||
height: 30px;
|
||||
width: 30px;
|
||||
}
|
||||
@@ -16,7 +16,7 @@
|
||||
</div>
|
||||
|
||||
{form name="thelia.admin.coupon.creation"}
|
||||
{include file='coupon/form.html' formAction={url path={$formAction}}}
|
||||
{include file='coupon/form.html' formAction={url path={$formAction}} noRules=true}
|
||||
{/form}
|
||||
|
||||
</section> <!-- #wrapper -->
|
||||
|
||||
@@ -16,9 +16,10 @@
|
||||
</div>
|
||||
|
||||
{form name="thelia.admin.coupon.creation"}
|
||||
{include file='coupon/form.html' formAction={url path={$formAction}} form=$form}
|
||||
{include file='coupon/form.html' formAction={url path={$formAction}} form=$form noRules=false}
|
||||
{/form}
|
||||
|
||||
|
||||
</section> <!-- #wrapper -->
|
||||
{/block}
|
||||
|
||||
@@ -37,19 +38,19 @@
|
||||
<script src="{$asset_url}"></script>
|
||||
{/javascripts}
|
||||
|
||||
{javascripts file='assets/js/coupon.js'}
|
||||
<script src="{$asset_url}"></script>
|
||||
{/javascripts}
|
||||
|
||||
<script>
|
||||
$(function($){
|
||||
miniBrowser(0, '/test_to_remove/datas_coupon_edit.json');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Init Rules
|
||||
var initRule = function() {
|
||||
couponManager.initRules = function() {
|
||||
var rules = [];
|
||||
{foreach from=$rulesObject key=k item=rule}
|
||||
// Init rule
|
||||
var rule = {};
|
||||
rule['serviceId'] = '{$rule.serviceId nofilter}';
|
||||
rule['operators'] = {};
|
||||
@@ -59,24 +60,24 @@
|
||||
rule['operators']['{$input nofilter}'] = '{$operator nofilter}';
|
||||
rule['values']['{$input nofilter}'] = '{$rule.validators.setValues[$input] nofilter}';
|
||||
{/foreach}
|
||||
|
||||
// Add rule
|
||||
rules.push(rule);
|
||||
{/foreach}
|
||||
|
||||
return rules;
|
||||
}
|
||||
};
|
||||
|
||||
// Save Rules AJAX
|
||||
var saveRuleAjax = function() {
|
||||
couponManager.saveRuleAjax = function() {
|
||||
$('#constraint-add-operators-values').html('<div class="loading" ></div>');
|
||||
console.log('about to save');
|
||||
console.log(couponManager.rulesToSave);
|
||||
var $url = '{$urlAjaxUpdateRules}';
|
||||
console.log('save');
|
||||
console.log('{$urlAjaxUpdateRules}');
|
||||
console.log(rules);
|
||||
console.log(JSON.stringify(rules));
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: $url,
|
||||
{*data: {literal}{{/literal}rules:rules{literal}}{/literal},*}
|
||||
data: {literal}{{/literal}rules:JSON.stringify(rules){literal}}{/literal},
|
||||
data: {literal}{{/literal}rules:JSON.stringify(couponManager.rulesToSave){literal}}{/literal},
|
||||
statusCode: {
|
||||
404: function() {
|
||||
$('#constraint-add-operators-values').html(
|
||||
@@ -87,75 +88,34 @@
|
||||
}).done(function(data) {
|
||||
$('#constraint-list').html(data);
|
||||
$('#constraint-add-operators-values').html('');
|
||||
couponManager.onClickUpdateRule();
|
||||
couponManager.onClickDeleteRule();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// Remove 1 Rule then Save Rules AJAX
|
||||
var removeRuleAjax = function($id) {
|
||||
rules.slice($id, 1);
|
||||
saveRuleAjax();
|
||||
}
|
||||
|
||||
// Add 1 Rule then Save Rules AJAX
|
||||
var addRuleAjax = function() {
|
||||
rules.push(ruleToSave);
|
||||
saveRuleAjax();
|
||||
}
|
||||
|
||||
|
||||
var rules = initRule();
|
||||
console.log(rules);
|
||||
|
||||
|
||||
// Save rules on click
|
||||
var onClickSaveRule = function() {
|
||||
$('#constraint-save-btn').on('click', function (e) {
|
||||
addRuleAjax();
|
||||
});
|
||||
}
|
||||
onClickSaveRule();
|
||||
|
||||
// Remove rule on click
|
||||
var onClickDeleteRule = function() {
|
||||
$('#constraint-delete-btn').on('click', function (e) {
|
||||
// removeRuleAjax();
|
||||
});
|
||||
}
|
||||
onClickDeleteRule();
|
||||
|
||||
// Reload effect inputs when changing effect
|
||||
var onEffectChange = function() {
|
||||
$('#effect').on('change', function (e) {
|
||||
var optionSelected = $("option:selected", this);
|
||||
$('#effectToolTip').html(optionSelected.attr("data-description"));
|
||||
});
|
||||
}
|
||||
onEffectChange();
|
||||
|
||||
// Reload rule inputs when changing effect
|
||||
var onRuleChange = function() {
|
||||
$('#category-rule').on('change', function (e) {
|
||||
$('#constraint-add-operators-values').html('<div class="loading" ></div>');
|
||||
var url = "{$urlAjaxGetRuleInput}";
|
||||
url = url.replace('ruleId', $(this).val())
|
||||
$.ajax({
|
||||
url: url,
|
||||
statusCode: {
|
||||
404: function() {
|
||||
$('#constraint-add-operators-values').html(
|
||||
'{intl l='Please select another rule'}'
|
||||
);
|
||||
}
|
||||
// Reload rule inputs
|
||||
couponManager.loadRuleInputs = function(ruleId, callBack) {
|
||||
$('#constraint-add-operators-values').html('<div class="loading" ></div>');
|
||||
var url = "{$urlAjaxGetRuleInput}";
|
||||
url = url.replace('ruleId', ruleId)
|
||||
$.ajax({
|
||||
url: url,
|
||||
statusCode: {
|
||||
404: function() {
|
||||
$('#constraint-add-operators-values').html(
|
||||
'{intl l='Please select another rule'}'
|
||||
);
|
||||
}
|
||||
}).done(function(data) {
|
||||
$('#constraint-add-operators-values').html(data);
|
||||
});
|
||||
}
|
||||
}).done(function(data) {
|
||||
$('#constraint-add-operators-values').html(data);
|
||||
|
||||
return callBack();
|
||||
});
|
||||
}
|
||||
onRuleChange();
|
||||
};
|
||||
|
||||
// Rules which will be saved
|
||||
couponManager.rulesToSave = couponManager.initRules();
|
||||
});
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
{/block}
|
||||
|
||||
@@ -161,134 +161,122 @@
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="row">
|
||||
<div class="col-md-12 general-block-decorator">
|
||||
<table class="table table-striped">
|
||||
<caption class="clearfix">
|
||||
{intl l='Rules'}
|
||||
</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{intl l='Conditions'}</th>
|
||||
<th>{intl l='Actions'}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="constraint-list">
|
||||
{include file='coupon/rules.html' rules=$rulesObject}
|
||||
{*{foreach from=$rulesObject item=rule name=rulesForeach}*}
|
||||
{*<tr>*}
|
||||
{*<td>*}
|
||||
{*{if !$smarty.foreach.rulesForeach.first}*}
|
||||
{*<span class="label label-info">{intl l='And'}</span>*}
|
||||
{*{/if}*}
|
||||
{*{$rule.tooltip nofilter}*}
|
||||
{*</td>*}
|
||||
|
||||
{*<td>*}
|
||||
{*<a href="#url" class="btn btn-default btn-primary btn-medium"><span class="glyphicon glyphicon-edit"></span> {intl l='Edit'}</a>*}
|
||||
{*<a href="#url" class="btn btn-default btn-danger btn-medium" data-toggle="confirm" data-target="#delete"><span class="glyphicon glyphicon-remove"></span> {intl l='Delete'}</a>*}
|
||||
{*</td>*}
|
||||
{*</tr>*}
|
||||
{*{/foreach}*}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<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">
|
||||
<span class="glyphicon glyphicon-plus-sign"></span>
|
||||
</a>
|
||||
|
||||
<div id="rule-add-organizer" class="form-group col-md-2">
|
||||
<label for="type">{intl l='Condition type :'}</label>
|
||||
<label class="radio">
|
||||
<input type="radio" name="type" id="type" value="1" checked> {intl l='And'}
|
||||
</label>
|
||||
<label class="radio">
|
||||
<input type="radio" name="type" value="2"> {intl l='Or'}
|
||||
</label>
|
||||
{if $noRules}
|
||||
{include file='includes/notifications.html' message={intl l='Please save your Coupon in oder to affect it some application fields'}}
|
||||
{else}
|
||||
<section class="row">
|
||||
<div class="col-md-12 general-block-decorator">
|
||||
<table class="table table-striped">
|
||||
<caption class="clearfix">
|
||||
{intl l='Rules'}
|
||||
</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{intl l='Conditions'}</th>
|
||||
<th>{intl l='Actions'}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="constraint-list">
|
||||
{include file='coupon/rules.html' rules=$rules}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div id="rule-add-type" class="form-group col-md-4">
|
||||
<label for="categoryRule">{intl l='Rule\'s category :'}</label>
|
||||
<select name="categoryRule" id="category-rule" class="form-control">
|
||||
{foreach from=$availableRules item=availableRule}
|
||||
<option value="{$availableRule.serviceId}" data-description="{$availableRule.toolTip}">{$availableRule.name}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
<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">
|
||||
<span class="glyphicon glyphicon-plus-sign"></span>
|
||||
</a>
|
||||
|
||||
<div id="rule-add-organizer" class="form-group col-md-2">
|
||||
<label for="type">{intl l='Condition type :'}</label>
|
||||
<label class="radio">
|
||||
<input type="radio" name="type" id="type" value="1" checked> {intl l='And'}
|
||||
</label>
|
||||
<label class="radio">
|
||||
<input type="radio" name="type" value="2"> {intl l='Or'}
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div id="rule-add-type" class="form-group col-md-4">
|
||||
<label for="categoryRule">{intl l='Rule\'s category :'}</label>
|
||||
<select name="categoryRule" id="category-rule" class="form-control">
|
||||
{foreach from=$availableRules item=availableRule}
|
||||
<option value="{$availableRule.serviceId}" data-description="{$availableRule.toolTip}">{$availableRule.name}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div id="constraint-add-operators-values" class="form-group col-md-6">
|
||||
{*<label for="operator">{intl l='Operator :'}</label>*}
|
||||
{*<div class="row">*}
|
||||
{*<div class="col-lg-6">*}
|
||||
{*<select name="operator" id="operator" class="form-control">*}
|
||||
{*<option value="1">is superior to</option>*}
|
||||
{*<option value="2">equals to</option>*}
|
||||
{*<option value="3">is inferior to</option>*}
|
||||
{*<option value="4">is inferior or equals to</option>*}
|
||||
{*<option value="5">is superior or equals to</option>*}
|
||||
{*</select>*}
|
||||
{*</div>*}
|
||||
{*<div class="input-group col-lg-6">*}
|
||||
{*<input type="text" name="value" class="form-control">*}
|
||||
{*<span class="input-group-addon">€</span>*}
|
||||
{*</div>*}
|
||||
{*</div>*}
|
||||
{**}
|
||||
|
||||
{*<label for="operator">Operator :</label>*}
|
||||
{*<div class="row">*}
|
||||
{*<div class="col-lg-6">*}
|
||||
{*<select name="operator" id="operator" class="form-control">*}
|
||||
{*<option value="1">is superior to</option>*}
|
||||
{*<option value="2">equals to</option>*}
|
||||
{*<option value="3">is inferior to</option>*}
|
||||
{*<option value="4">is inferior or equals to</option>*}
|
||||
{*<option value="5">is superior or equals to</option>*}
|
||||
{*</select>*}
|
||||
{*</div>*}
|
||||
{*<div class="input-group col-lg-6 date" data-date="12/02/2012" data-date-format="dd/mm/yyyy">*}
|
||||
{*<input type="text" name="value" class="form-control">*}
|
||||
{*<span class="input-group-addon"><span class="glyphicon glyphicon-th"></span></span>*}
|
||||
{*</div>*}
|
||||
{*</div>*}
|
||||
|
||||
{*<label for="operator">Operator :</label>*}
|
||||
{*<div class="row">*}
|
||||
{*<div class="col-lg-6">*}
|
||||
{*<select name="operator" id="operator" class="form-control">*}
|
||||
{*<option value="1">is superior to</option>*}
|
||||
{*<option value="2">equals to</option>*}
|
||||
{*<option value="3">is inferior to</option>*}
|
||||
{*<option value="4">is inferior or equals to</option>*}
|
||||
{*<option value="5">is superior or equals to</option>*}
|
||||
{*</select>*}
|
||||
{*</div>*}
|
||||
{*<div class="col-lg-6">*}
|
||||
{*<input type="text" name="value" class="form-control">*}
|
||||
{*</div>*}
|
||||
{*</div>*}
|
||||
{*<div class="row">*}
|
||||
{*<div class="col-lg-12">*}
|
||||
{*<table class="table table-bordered">*}
|
||||
{*<tr>*}
|
||||
{*<td id="minibrowser-breadcrumb"></td>*}
|
||||
{*</tr>*}
|
||||
{*<tr>*}
|
||||
{*<th><span class="icon-th-list"></span> Categories list</th>*}
|
||||
{*</tr>*}
|
||||
{*<tr>*}
|
||||
{*<td id="minibrowser-categories"></td>*}
|
||||
{*</tr>*}
|
||||
{*</table>*}
|
||||
{*</div>*}
|
||||
{*</div>*}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="constraint-add-operators-values" class="form-group col-md-6">
|
||||
{*<label for="operator">{intl l='Operator :'}</label>*}
|
||||
{*<div class="row">*}
|
||||
{*<div class="col-lg-6">*}
|
||||
{*<select name="operator" id="operator" class="form-control">*}
|
||||
{*<option value="1">is superior to</option>*}
|
||||
{*<option value="2">equals to</option>*}
|
||||
{*<option value="3">is inferior to</option>*}
|
||||
{*<option value="4">is inferior or equals to</option>*}
|
||||
{*<option value="5">is superior or equals to</option>*}
|
||||
{*</select>*}
|
||||
{*</div>*}
|
||||
{*<div class="input-group col-lg-6">*}
|
||||
{*<input type="text" name="value" class="form-control">*}
|
||||
{*<span class="input-group-addon">€</span>*}
|
||||
{*</div>*}
|
||||
{*</div>*}
|
||||
{**}
|
||||
|
||||
{*<label for="operator">Operator :</label>*}
|
||||
{*<div class="row">*}
|
||||
{*<div class="col-lg-6">*}
|
||||
{*<select name="operator" id="operator" class="form-control">*}
|
||||
{*<option value="1">is superior to</option>*}
|
||||
{*<option value="2">equals to</option>*}
|
||||
{*<option value="3">is inferior to</option>*}
|
||||
{*<option value="4">is inferior or equals to</option>*}
|
||||
{*<option value="5">is superior or equals to</option>*}
|
||||
{*</select>*}
|
||||
{*</div>*}
|
||||
{*<div class="input-group col-lg-6 date" data-date="12/02/2012" data-date-format="dd/mm/yyyy">*}
|
||||
{*<input type="text" name="value" class="form-control">*}
|
||||
{*<span class="input-group-addon"><span class="glyphicon glyphicon-th"></span></span>*}
|
||||
{*</div>*}
|
||||
{*</div>*}
|
||||
|
||||
{*<label for="operator">Operator :</label>*}
|
||||
{*<div class="row">*}
|
||||
{*<div class="col-lg-6">*}
|
||||
{*<select name="operator" id="operator" class="form-control">*}
|
||||
{*<option value="1">is superior to</option>*}
|
||||
{*<option value="2">equals to</option>*}
|
||||
{*<option value="3">is inferior to</option>*}
|
||||
{*<option value="4">is inferior or equals to</option>*}
|
||||
{*<option value="5">is superior or equals to</option>*}
|
||||
{*</select>*}
|
||||
{*</div>*}
|
||||
{*<div class="col-lg-6">*}
|
||||
{*<input type="text" name="value" class="form-control">*}
|
||||
{*</div>*}
|
||||
{*</div>*}
|
||||
{*<div class="row">*}
|
||||
{*<div class="col-lg-12">*}
|
||||
{*<table class="table table-bordered">*}
|
||||
{*<tr>*}
|
||||
{*<td id="minibrowser-breadcrumb"></td>*}
|
||||
{*</tr>*}
|
||||
{*<tr>*}
|
||||
{*<th><span class="icon-th-list"></span> Categories list</th>*}
|
||||
{*</tr>*}
|
||||
{*<tr>*}
|
||||
{*<td id="minibrowser-categories"></td>*}
|
||||
{*</tr>*}
|
||||
{*</table>*}
|
||||
{*</div>*}
|
||||
{*</div>*}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</section>
|
||||
{/if}
|
||||
</form>
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
{*{$inputs.inputs|var_dump}*}
|
||||
{foreach from=$inputs.inputs key=name item=input}
|
||||
<label for="operator">{$input.title}</label>
|
||||
<div class="row">
|
||||
@@ -71,32 +70,33 @@
|
||||
{*</div>*}
|
||||
|
||||
<script>
|
||||
var ruleToSave = {};
|
||||
ruleToSave['serviceId'] = '{$ruleId}';
|
||||
ruleToSave['operators'] = {};
|
||||
ruleToSave['values'] = {};
|
||||
{foreach from=$inputs.inputs key=name item=input}
|
||||
ruleToSave['operators']['{$name nofilter}'] = '{foreach from=$inputs.inputs[$name].availableOperators key=keyOperator item=valueOperator name=operators}{if $smarty.foreach.operators.first}{$keyOperator nofilter}{/if}{/foreach}';
|
||||
ruleToSave['values']['{$name nofilter}'] = '{if count($inputs.inputs[$name].availableValues) != 0}{foreach from=$inputs.inputs[$name].availableValues key=keyValue item=valueValue name=values}{if $smarty.foreach.values.first}{$keyValue nofilter}{/if}{/foreach}{else}to set{/if}';
|
||||
{/foreach}
|
||||
|
||||
// Init Rules to set
|
||||
couponManager.ruleToSave['serviceId'] = '{$ruleId}';
|
||||
couponManager.ruleToSave['operators'] = {literal}{}{/literal};
|
||||
couponManager.ruleToSave['values'] = {literal}{}{/literal};
|
||||
{foreach from=$inputs.inputs key=name item=input}
|
||||
couponManager.ruleToSave['operators']['{$name nofilter}'] = '{foreach from=$inputs.inputs[$name].availableOperators key=keyOperator item=valueOperator name=operators}{if $smarty.foreach.operators.first}{$keyOperator nofilter}{/if}{/foreach}';
|
||||
couponManager.ruleToSave['values']['{$name nofilter}'] = '{if count($inputs.inputs[$name].availableValues) != 0}{foreach from=$inputs.inputs[$name].availableValues key=keyValue item=valueValue name=values}{if $smarty.foreach.values.first}{$keyValue nofilter}{/if}{/foreach}{else}to set{/if}';
|
||||
{/foreach}
|
||||
|
||||
|
||||
// Update ruleToSave Array ready to be saved
|
||||
var onInputsChange = function() {literal}{{/literal}
|
||||
{foreach from=$inputs.inputs key=name item=input}
|
||||
$('#{$name}-operator').change(function (e) {
|
||||
var $this = $(this);
|
||||
ruleToSave['operators']['{$name nofilter}'] = $this.val();
|
||||
console.log('#{$name}-operator changed ' + $this.val());
|
||||
console.log(ruleToSave);
|
||||
});
|
||||
$('#{$name}-value').change(function (e) {
|
||||
var $this = $(this);
|
||||
ruleToSave['values']['{$name nofilter}'] = $this.val();
|
||||
console.log('#{$name}-value changed ' + $this.val());
|
||||
console.log(ruleToSave);
|
||||
});
|
||||
{/foreach}
|
||||
// Fill in ready to be saved rule array
|
||||
couponManager.onInputsChange = function() {literal}{{/literal}
|
||||
{foreach from=$inputs.inputs key=name item=input}
|
||||
// Operator selector
|
||||
$('#{$name}-operator').change(function (e) {
|
||||
console.log('changin operator');
|
||||
var $this = $(this);
|
||||
couponManager.ruleToSave['operators']['{$name nofilter}'] = $this.val();
|
||||
});
|
||||
// Value input
|
||||
$('#{$name}-value').change(function (e) {
|
||||
console.log('changin value');
|
||||
var $this = $(this);
|
||||
couponManager.ruleToSave['values']['{$name nofilter}'] = $this.val();
|
||||
});
|
||||
{/foreach}
|
||||
{literal}}{/literal}
|
||||
onInputsChange();
|
||||
couponManager.onInputsChange();
|
||||
</script>
|
||||
@@ -1,4 +1,4 @@
|
||||
{foreach from=$rules item=rule name=rulesForeach}
|
||||
{foreach from=$rules item=rule key=i name=rulesForeach}
|
||||
<tr>
|
||||
<td>
|
||||
{if !$smarty.foreach.rulesForeach.first}
|
||||
@@ -7,10 +7,10 @@
|
||||
{$rule nofilter}
|
||||
</td>
|
||||
<td>
|
||||
<a class="btn btn-default btn-primary btn-medium" href="{$urlEdit}">
|
||||
<a data-int="{$i}" class="btn btn-default btn-primary btn-medium constraint-update-btn" href="{$urlEdit}">
|
||||
<span class="glyphicon glyphicon-edit"></span> {intl l='Edit'}
|
||||
</a>
|
||||
<a data-target="#delete" data-toggle="confirm" class="btn btn-default btn-danger btn-medium" href="{$urlDelete}">
|
||||
<a data-int="{$i}" data-target="#delete" data-toggle="confirm" class="btn btn-default btn-danger btn-medium constraint-delete-btn" href="{$urlDelete}">
|
||||
<span class="glyphicon glyphicon-remove"></span> {intl l='Delete'}
|
||||
</a>
|
||||
</td>
|
||||
|
||||
@@ -28,13 +28,13 @@
|
||||
|
||||
{form_field form=$form field='username'}
|
||||
<span {if $error}class="error"{/if}>
|
||||
<input type="text" class="input" placeholder="{intl l='User name'}" name="{$name}" value="{$value}" {$attr} />
|
||||
<input type="text" id="username" class="input" placeholder="{intl l='User name'}" name="{$name}" value="{$value}" {$attr} />
|
||||
</span>
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='password'}
|
||||
<span {if $error}class="error"{/if}>
|
||||
<input type="password" class="input" placeholder="{intl l='Password'}" name="{$name}" {$attr} />
|
||||
<input type="password" id="password" class="input" placeholder="{intl l='Password'}" name="{$name}" {$attr} />
|
||||
</span>
|
||||
{/form_field}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user