Allow smart blocks with no criteria

This commit is contained in:
Albert Santoni 2015-09-02 16:25:30 -04:00
parent f05157c376
commit 01b3ae1bf0
4 changed files with 55 additions and 35 deletions

View File

@ -370,6 +370,10 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
// add elelments that needs to be added
// set multioption for modifier according to criteria_field
$modRowMap = array();
if (!isset($data['criteria'])) {
return $data;
}
foreach ($data['criteria'] as $critKey=>$d) {
$count = 1;
foreach ($d as $modKey=>$modInfo) {

View File

@ -1517,27 +1517,27 @@ SQL;
$i++;
}
}
// check if file exists
$qry->add("file_exists", "true", Criteria::EQUAL);
$qry->add("hidden", "false", Criteria::EQUAL);
$sortTracks = 'random';
if (isset($storedCrit['sort'])) {
$sortTracks = $storedCrit['sort']['value'];
}
if ($sortTracks == 'newest') {
$qry->addDescendingOrderByColumn('utime');
}
else if ($sortTracks == 'oldest') {
$qry->addAscendingOrderByColumn('utime');
}
else if ($sortTracks == 'random') {
$qry->addAscendingOrderByColumn('random()');
} else {
Logging::warning("Unimplemented sortTracks type in ".__FILE__);
}
}
// check if file exists
$qry->add("file_exists", "true", Criteria::EQUAL);
$qry->add("hidden", "false", Criteria::EQUAL);
$sortTracks = 'random';
if (isset($storedCrit['sort'])) {
$sortTracks = $storedCrit['sort']['value'];
}
if ($sortTracks == 'newest') {
$qry->addDescendingOrderByColumn('utime');
}
else if ($sortTracks == 'oldest') {
$qry->addAscendingOrderByColumn('utime');
}
else if ($sortTracks == 'random') {
$qry->addAscendingOrderByColumn('random()');
} else {
Logging::warning("Unimplemented sortTracks type in ".__FILE__);
}
// construct limit restriction
$limits = array();

View File

@ -89,9 +89,9 @@
}
$nextDisabled = $this->element->getElement("sp_criteria_field_".$nextIndex)->getAttrib('disabled') == 'disabled'?true:false;
?>
<div <?php if (($i > 0) && $disabled) {
echo 'style=display:none';
} ?>>
<div <?php if (/*($i > 0) && */ $disabled) {
echo 'style=display:none';
} ?> >
<?php echo $this->element->getElement("sp_criteria_field_".$i."_".$j) ?>
<?php echo $this->element->getElement("sp_criteria_modifier_".$i."_".$j) ?>
<?php echo $this->element->getElement("sp_criteria_value_".$i."_".$j) ?>

View File

@ -11,18 +11,30 @@ function setSmartBlockEvents() {
var div = $('dd[id="sp_criteria-element"]').children('div:visible:last');
div.find('.db-logic-label').text('and').show();
div = div.next().show();
if (div.length == 0) {
div = $('dd[id="sp_criteria-element"]').children('div:first');
div.children().removeAttr('disabled');
div.show();
div.children().removeAttr('disabled');
div = div.next();
if (div.length === 0) {
$(this).hide();
appendAddButton();
appendModAddButton();
removeButtonCheck();
} else {
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();
}
appendAddButton();
appendModAddButton();
removeButtonCheck();
});
/********** ADD MODIFIER ROW **********/
@ -512,7 +524,9 @@ function callback(json, type) {
form.find('.success').show();
}
form.find('.smart-block-form').removeClass("closed");
removeButtonCheck();
form.find('.smart-block-form').removeClass("closed");
} else {
if (json.result == "0") {
$('.active-tab #sp-success-saved').text($.i18n._('Smart block saved')).show();
@ -524,6 +538,7 @@ function callback(json, type) {
}
else {
AIRTIME.playlist.playlistResponse(json);
removeButtonCheck();
}
form.find('.smart-block-form').removeClass("closed");
}
@ -551,6 +566,7 @@ function appendAddButton() {
}
function removeButtonCheck() {
/*
var rows = $('.active-tab dd[id="sp_criteria-element"]').children('div'),
enabled = rows.find('select[name^="sp_criteria_field"]:enabled'),
rmv_button = enabled.siblings('a[id^="criteria_remove"]');
@ -560,7 +576,7 @@ function removeButtonCheck() {
} else {
rmv_button.removeAttr('disabled');
rmv_button.show();
}
}*/
}
function enableLoadingIcon() {