group smartblock search criteria fields to accurately reflect query

This commit is contained in:
r 2019-02-04 14:18:02 -06:00
parent 71315cf925
commit 3f43c9abb5
5 changed files with 62 additions and 24 deletions

View file

@ -44,7 +44,7 @@
<a style='margin-right:3px' class='btn btn-small btn-danger' id='criteria_remove_<?php echo $i ?>'> <a style='margin-right:3px' class='btn btn-small btn-danger' id='criteria_remove_<?php echo $i ?>'>
<i class='icon-white icon-remove spl-no-r-margin'></i> <i class='icon-white icon-remove spl-no-r-margin'></i>
</a> </a>
<span class='db-logic-label<?php echo ' db-logic-label-' . $logicLabel; ?>' <?php if ($nextDisabled) echo 'style="display:none"';?>> <span class='db-logic-label' <?php if ($nextDisabled) echo 'style="display:none"';?>>
<?php echo $logicLabel;?> <?php echo $logicLabel;?>
</span> </span>

View file

@ -217,9 +217,10 @@ tr.lib-selected > td > div.library_actions_btn:hover {
.search-criteria .criteria-element > div { .search-criteria .criteria-element > div {
margin-bottom: 5px; margin-bottom: 5px;
display: flex; display: flex;
flex-wrap: wrap;
position: relative; position: relative;
} }
.search-criteria .criteria-element > div.search-row-and { margin-bottom: 36px; } .search-criteria .criteria-element > div.search-row-and { margin-bottom: 42px; }
.search-criteria .criteria-element > div input[type="text"], .search-criteria .criteria-element > div input[type="text"],
.search-criteria .criteria-element > div select { .search-criteria .criteria-element > div select {
-webkit-box-sizing: border-box; -webkit-box-sizing: border-box;

View file

@ -634,7 +634,7 @@ li.spl_empty {
} }
#criteria_add { #criteria_add {
margin-bottom: 5px; margin: -10px 0 5px;
} }
.smart-block-form dt, .smart-block-form dd { .smart-block-form dt, .smart-block-form dd {

View file

@ -706,26 +706,39 @@ table.library-get-file-md.table-small{
.modifier_add_link { .modifier_add_link {
font-size: 12px; font-size: 12px;
display: block; display: block;
margin: 0 0 10px 33%; margin: 0 0 10px 29%;
text-decoration: underline; text-decoration: underline;
cursor: pointer; cursor: pointer;
position: absolute; position: absolute;
top: 30px; top: calc(100% + 5px);
} }
.db-logic-label { .db-logic-label {
font-size:14px; font-size:12px;
position: absolute; position: absolute;
top: 36px; top: calc(100% + 5px);
margin: 7px;
} }
.db-logic-label-and { .search-row-and .db-logic-label {
top: 42px; display: table;
white-space: nowrap;
width: 100%;
text-align: center;
margin: 1.5em 0 0;
}
.search-row-and .db-logic-label:before, .search-row-and .db-logic-label:after {
border-top: 1px solid hsl(0, 0%, 29%);
content: '';
display: table-cell;
position: relative;
top: 0.5em;
width: 45%;
} }
.sp-invisible{ .sp-invisible{
visibility: hidden; visibility: hidden;
} }
.sp_input_select{ .sp_input_select, .sp_input_text {
flex: 0 0 33%; flex: 0 0 29%;
} }
.sp_input_text_limit{ .sp_input_text_limit{
@ -737,18 +750,13 @@ table.library-get-file-md.table-small{
margin-right: 0px !important; margin-right: 0px !important;
} }
input.input_text.sp_input_text{
width: 139px !important;
}
input.input_text.sp_extra_input_text{
width: 139px !important;
}
.sp_text_font{ .sp_text_font{
font-size: 13px; font-size: 12px;
font-family: Helvetica, Arial, sans-serif; font-family: Helvetica, Arial, sans-serif;
color: #FFFFFF; color: #FFFFFF;
line-height: 26px;
display: inline-block;
margin-right: 4px;
} }
.sp_text_font_bold{ .sp_text_font_bold{

View file

@ -24,7 +24,7 @@ function setSmartBlockEvents() {
} else { } else {
div.find('.db-logic-label').text('and').show(); div.find('.db-logic-label').text('and').css('display', 'table');
div.removeClass('search-row-or').addClass('search-row-and'); div.removeClass('search-row-or').addClass('search-row-and');
div = div.next().show(); div = div.next().show();
@ -41,6 +41,7 @@ function setSmartBlockEvents() {
appendModAddButton(); appendModAddButton();
removeButtonCheck(); removeButtonCheck();
// disableAndHideDateTimeDropdown(newRowVal); // disableAndHideDateTimeDropdown(newRowVal);
groupCriteriaRows();
} }
}); });
@ -48,7 +49,7 @@ function setSmartBlockEvents() {
/********** ADD MODIFIER ROW **********/ /********** ADD MODIFIER ROW **********/
form.find('a[id^="modifier_add"]').live('click', function(){ form.find('a[id^="modifier_add"]').live('click', function(){
var criteria_value = $(this).siblings('select[name^="sp_criteria_field"]').val(); var criteria_value = $(this).siblings('select[name^="sp_criteria_field"]').val();
//make new modifier row //make new modifier row
var newRow = $(this).parent().clone(), var newRow = $(this).parent().clone(),
@ -83,13 +84,14 @@ function setSmartBlockEvents() {
$(this).parent().after(newRow); $(this).parent().after(newRow);
// remove extra spacing from previous row
newRow.prev().removeClass('search-row-and').addClass('search-row-or'); newRow.prev().removeClass('search-row-and').addClass('search-row-or');
newRow.prev().find(".db-logic-label").removeClass('db-logic-label-and').addClass('db-logic-label-or');
reindexElements(); reindexElements();
appendAddButton(); appendAddButton();
appendModAddButton(); appendModAddButton();
removeButtonCheck(); removeButtonCheck();
groupCriteriaRows();
}); });
/********** REMOVE ROW **********/ /********** REMOVE ROW **********/
@ -277,6 +279,9 @@ function setSmartBlockEvents() {
// remove the 'x' button if only one row is enabled // remove the 'x' button if only one row is enabled
removeButtonCheck(); removeButtonCheck();
groupCriteriaRows();
}); });
/********** SAVE ACTION **********/ /********** SAVE ACTION **********/
@ -313,7 +318,7 @@ function setSmartBlockEvents() {
/********** CRITERIA CHANGE **********/ /********** CRITERIA CHANGE **********/
form.find('select[id^="sp_criteria"]:not([id^="sp_criteria_modifier"])').live("change", function(){ form.find('select[id^="sp_criteria"]:not([id^="sp_criteria_modifier"]):not([id^="sp_criteria_datetime"]):not([id^="sp_criteria_extra_datetime"])').live("change", function(){
var index = getRowIndex($(this).parent()); var index = getRowIndex($(this).parent());
//need to change the criteria value for any modifier rows //need to change the criteria value for any modifier rows
var critVal = $(this).val(); var critVal = $(this).val();
@ -813,6 +818,30 @@ function enableLoadingIcon() {
function disableLoadingIcon() { function disableLoadingIcon() {
$(".side_playlist.active-tab").unblock() $(".side_playlist.active-tab").unblock()
} }
function groupCriteriaRows() {
// check whether rows should be "grouped" and shown with an "or" "logic label", or separated by an "and" "logic label"
var visibleRows = $("#sp_criteria-element > div:visible"),
prevRowGroup = "0";
visibleRows.each(function (index){
if (index > 0) {
var fieldId = $(this).find('select[id^="sp_criteria_field"]').attr("id");
var currRowGroup = fieldId[fieldId.length - 3];
if (currRowGroup === prevRowGroup) {
$(this).prev().addClass("search-row-or").removeClass("search-row-and")
} else {
$(this).prev().addClass("search-row-and").removeClass("search-row-or")
}
prevRowGroup = currRowGroup;
}
});
// ensure spacing below last visible row
$("#sp_criteria-element > div:visible:last").addClass("search-row-and").removeClass("search-row-or");
}
// We need to know if the criteria value will be a string // We need to know if the criteria value will be a string
// or numeric value in order to populate the modifier // or numeric value in order to populate the modifier
// select list // select list