CC-4536: Smart block criteria use AND logic, but additional modifiers use OR logic, without labels to show the difference
-added labels
This commit is contained in:
parent
5b14c4fe88
commit
cc208da2fb
|
@ -30,8 +30,22 @@
|
|||
|
||||
<dd id='sp_criteria-element' class='criteria-element'>
|
||||
<?php for ($i = 0; $i < $this->criteriasLength; $i++) {?>
|
||||
<?php for ($j = 0; $j < $this->modRowMap[$i]; $j++) {?>
|
||||
<div <?php if (($i > 0) && ($this->element->getElement("sp_criteria_field_".$i."_".$j)->getAttrib('disabled') == 'disabled')) {
|
||||
<?php for ($j = 0; $j < $this->modRowMap[$i]; $j++) {
|
||||
if ($this->modRowMap[$i] > 1 && $j != $this->modRowMap[$i]-1) $logicLabel = 'or';
|
||||
else $logicLabel = 'and';
|
||||
$disabled = $this->element->getElement("sp_criteria_field_".$i."_".$j)->getAttrib('disabled') == 'disabled'?true:false;
|
||||
// determine if the next row is disabled and only display the logic label if it isn't
|
||||
if ($j == $this->modRowMap[$i]-1 && $i < 25) {
|
||||
$n = $i+1;
|
||||
$nextIndex = $n."_0";
|
||||
} elseif ($j+1 < $this->modRowMap[$i]-1) {
|
||||
$n = $j+1;
|
||||
$nextIndex = $i."_".$n;
|
||||
|
||||
}
|
||||
$nextDisabled = $this->element->getElement("sp_criteria_field_".$nextIndex)->getAttrib('disabled') == 'disabled'?true:false;
|
||||
?>
|
||||
<div <?php if (($i > 0) && $disabled) {
|
||||
echo 'style=display:none';
|
||||
} ?>>
|
||||
<?php echo $this->element->getElement("sp_criteria_field_".$i."_".$j) ?>
|
||||
|
@ -45,6 +59,9 @@
|
|||
<a style='margin-right:3px' class='btn btn-small btn-danger' id='criteria_remove_<?php echo $i ?>'>
|
||||
<i class='icon-white icon-remove'></i>
|
||||
</a>
|
||||
<span class='db-logic-label' <?php if ($nextDisabled) echo "style='display:none'"?>>
|
||||
<?php echo $logicLabel;?>
|
||||
</span>
|
||||
<?php if($this->element->getElement("sp_criteria_field_".$i."_".$j)->hasErrors()) : ?>
|
||||
<?php foreach($this->element->getElement("sp_criteria_field_".$i."_".$j)->getMessages() as $error): ?>
|
||||
<span class='errors sp-errors'>
|
||||
|
|
|
@ -514,6 +514,9 @@ table.library-get-file-md.table-small{
|
|||
|
||||
|
||||
/***** SMART BLOCK SPECIFIC STYLES BEGIN *****/
|
||||
.db-logic-label{
|
||||
font-size:11px;
|
||||
}
|
||||
.sp-invisible{
|
||||
visibility: hidden;
|
||||
}
|
||||
|
|
|
@ -8,14 +8,17 @@ function setSmartBlockEvents() {
|
|||
/********** ADD CRITERIA ROW **********/
|
||||
form.find('#criteria_add').live('click', function(){
|
||||
|
||||
var div = $('dd[id="sp_criteria-element"]').children('div:visible:last').next();
|
||||
|
||||
div.show();
|
||||
var div = $('dd[id="sp_criteria-element"]').children('div:visible:last');
|
||||
|
||||
div.find('.db-logic-label').text('and').show();
|
||||
div = div.next().show();
|
||||
|
||||
div.children().removeAttr('disabled');
|
||||
div = div.next();
|
||||
if (div.length === 0) {
|
||||
$(this).hide();
|
||||
}
|
||||
|
||||
appendAddButton();
|
||||
appendModAddButton();
|
||||
removeButtonCheck();
|
||||
|
@ -24,7 +27,7 @@ function setSmartBlockEvents() {
|
|||
/********** ADD MODIFIER ROW **********/
|
||||
form.find('a[id^="modifier_add"]').live('click', function(){
|
||||
var criteria_value = $(this).siblings('select[name^="sp_criteria_field"]').val();
|
||||
|
||||
|
||||
//make new modifier row
|
||||
var newRow = $(this).parent().clone(),
|
||||
newRowCrit = newRow.find('select[name^="sp_criteria_field"]'),
|
||||
|
@ -285,6 +288,11 @@ function reindexElements() {
|
|||
var divs = $('#smart-block-form').find('div select[name^="sp_criteria_field"]').parent(),
|
||||
index = 0,
|
||||
modIndex = 0;
|
||||
/* Hide all logic labels
|
||||
* We will re-add them as each row gets indexed
|
||||
*/
|
||||
$('.db-logic-label').text('').hide();
|
||||
|
||||
$.each(divs, function(i, div){
|
||||
if (i > 0 && index < 26) {
|
||||
|
||||
|
@ -292,8 +300,14 @@ function reindexElements() {
|
|||
* a modifier row
|
||||
*/
|
||||
if ($(div).find('select[name^="sp_criteria_field"]').hasClass('sp-invisible')) {
|
||||
if ($(div).is(':visible')) {
|
||||
$(div).prev().find('.db-logic-label').text('or').show();
|
||||
}
|
||||
modIndex++;
|
||||
} else {
|
||||
if ($(div).is(':visible')) {
|
||||
$(div).prev().find('.db-logic-label').text('and').show();
|
||||
}
|
||||
index++;
|
||||
modIndex = 0;
|
||||
}
|
||||
|
@ -337,8 +351,8 @@ function setupUI() {
|
|||
*/
|
||||
var plContents = $('#spl_sortable').children();
|
||||
var shuffleButton = $('button[id="shuffle_button"]');
|
||||
|
||||
if (plContents.text() !== 'Empty playlist') {
|
||||
|
||||
if (!plContents.hasClass('spl_empty')) {
|
||||
if (shuffleButton.hasClass('ui-state-disabled')) {
|
||||
shuffleButton.removeClass('ui-state-disabled');
|
||||
shuffleButton.removeAttr('disabled');
|
||||
|
|
Loading…
Reference in New Issue