diff --git a/css/light-grey.css b/css/light-grey.css index 0e4c47ac1..b934f465d 100644 --- a/css/light-grey.css +++ b/css/light-grey.css @@ -745,6 +745,8 @@ input.dp-applied { /* Pictogram */ } .search_form_handler .sf_title .sft_picto { + display: none; + /* TODO: Remove this class and the correspondig DOM element if this option is kept. */ margin-right: 10px; } .search_form_handler .sf_title .sft_refresh, .search_form_handler .sf_title .sft_toggler { @@ -1033,10 +1035,22 @@ input.dp-applied { .search_form_handler .sf_criterion_area .sf_more_criterion .sfm_content .sfm_lists { margin: 0px -8px; padding: 0px 8px; - max-height: 460px; + max-height: 400px; overflow-x: hidden; overflow-y: auto; } +.search_form_handler .sf_criterion_area .sf_more_criterion .sfm_content .sfm_buttons { + display: none; +} +.search_form_handler .sf_criterion_area .sf_more_criterion .sfm_content .sfm_buttons button { + margin-top: 8px; + margin-right: 5px; + padding: 3px 6px; + font-size: 11px; +} +.search_form_handler .sf_criterion_area .sf_more_criterion .sfm_content .sfm_buttons button:last-of-type { + margin-right: 0px; +} .search_form_handler .sf_list:not(:first-of-type) .sfl_title { border-top: 1px solid #ddd; padding-top: 8px; diff --git a/css/light-grey.scss b/css/light-grey.scss index ced27d246..fccb46b2e 100644 --- a/css/light-grey.scss +++ b/css/light-grey.scss @@ -832,6 +832,7 @@ input.dp-applied { /* Pictogram */ .sft_picto{ + display: none; /* TODO: Remove this class and the correspondig DOM element if this option is kept. */ margin-right: 10px; } @@ -1200,10 +1201,24 @@ input.dp-applied { .sfm_lists{ margin: 0px -8px; padding: 0px 8px; - max-height: 460px; + max-height: 400px; overflow-x: hidden; overflow-y: auto; } + .sfm_buttons{ + display: none; + + button{ + margin-top: 8px; + margin-right: 5px; + padding: 3px 6px; + font-size: 11px; + + &:last-of-type{ + margin-right: 0px; + } + } + } } } } diff --git a/js/search/search_form_handler.js b/js/search/search_form_handler.js index fcbea37dc..b08479284 100644 --- a/js/search/search_form_handler.js +++ b/js/search/search_form_handler.js @@ -205,18 +205,6 @@ $(function() this._openMoreCriterion(); } }, - // - Show / hide "add criterions" buttons from more criterion menu - _updateMoreCriterionButtons: function() - { - if(this.elements.more_criterion.find('.sf_list .sfm_field input[type="checkbox"]:checked').length > 0) - { - - } - else - { - - } - }, // - Close all criterion _closeAllCriterion: function() { @@ -320,16 +308,18 @@ $(function() .appendTo(this.elements.more_criterion); // - Filter - var oFilterElem = $('
') + var oFilterElem = $('
') + .addClass('sf_filter') + .addClass('sfm_filter') .append('') .appendTo(oContentElem); - // - Lists + // - Lists container var oListsElem = $('
') .addClass('sfm_lists') .appendTo(oContentElem); - // - Add recent fields list + // - Recently used list var oRecentsElem = $('
') .addClass('sf_list') .addClass('sf_list_recents') @@ -344,7 +334,7 @@ $(function() .append('
  • ' + Dict.S('UI:Search:AddCriteria:List:RecentlyUsed:Placeholder') + '
  • ') .appendTo(oRecentsElem); - // - Add fields from zlist list + // - Search zlist list var oZlistElem = $('
    ') .addClass('sf_list') .addClass('sf_list_zlist') @@ -368,7 +358,7 @@ $(function() .appendTo(oZListItemsElem); } - // - Add fields remaining + // - Remaining fields list if(this.options.search.fields.others !== undefined) { var oOthersElem = $('
    ') @@ -396,10 +386,10 @@ $(function() } // - Buttons - var oButtons = $('
    ') + var oButtonsElem = $('
    ') .addClass('sfm_buttons') - .append('') - .append('') + .append('') + .append('') .appendTo(oContentElem); // Bind events @@ -443,12 +433,15 @@ $(function() } } }); + + // - More criteria toggling this.elements.more_criterion.find('.sfm_header').on('click', function(oEvent){ // Prevent anchor oEvent.preventDefault(); me._toggleMoreCriterion(); }); + // - Filter // Note: "keyup" event is use instead of "keydown", otherwise, the inpu value would not be set yet. oFilterElem.find('input').on('keyup focus', function(oEvent){ @@ -501,7 +494,8 @@ $(function() .val('') .trigger('focus'); }); - // - Add criteria + + // - Add one criteria this.elements.more_criterion.find('.sfm_field').on('click', function(oEvent){ // Prevent anchor oEvent.preventDefault(); @@ -517,11 +511,47 @@ $(function() // Add criteria but don't submit form as the user has not specified the value yet. me._addCriteria(oData); }); + + // - Add several criterion this.elements.more_criterion.find('.sfm_field input[type="checkbox"]').on('click', function(oEvent){ + // Prevent propagation to field and instant add of the criteria oEvent.stopPropagation(); - // TODO: Show add button - console.log($(this).val(), $(this).prop('checked')); + if(me.elements.more_criterion.find('.sfm_field input[type="checkbox"]:checked').length === 0) + { + oButtonsElem.hide(); + } + else + { + oButtonsElem.show(); + } + + // Put focus back to filter to improve UX. + oFilterElem.find('input').trigger('focus'); + }); + oButtonsElem.find('button').on('click', function(){ + // Add criterion on apply + if($(this).attr('name') === 'apply') + { + me.elements.more_criterion.find('.sfm_field input[type="checkbox"]:checked').each(function(iIdx, oElem){ + var oData = { + 'ref': $(oElem).closest('.sfm_field').attr('data-field-ref'), + 'init_opened': false, + }; + me._addCriteria(oData); + }); + } + + // Clear all + // - Checkboxes + me.elements.more_criterion.find('.sfm_field input[type="checkbox"]:checked').prop('checked', false); + // - Filter + oFilterElem.find('input') + .val('') + .trigger('focus'); + + // Hide buttons + oButtonsElem.hide(); }); }, // - Prepare results area @@ -557,6 +587,7 @@ $(function() // TODO: Translate sentence. oResultAreaElem.html('

    Add some criterion on the search box or click the search button to view the objects.

    '); oResultAreaElem.find('button').on('click', function(){ + // TODO: Bug: Open "Search for CI", change child classe in the dropdown, click the search button. It submit the search for the original child classe, not the current one; whereas a click on the upper right pictogram does. This might be due to the form reloading. me._onSubmitClick(); }); } diff --git a/sources/application/search/searchform.class.inc.php b/sources/application/search/searchform.class.inc.php index 7a69715fe..b27daf8b3 100644 --- a/sources/application/search/searchform.class.inc.php +++ b/sources/application/search/searchform.class.inc.php @@ -117,7 +117,7 @@ class SearchForm $sAction = (isset($aExtraParams['action'])) ? $aExtraParams['action'] : utils::GetAbsoluteUrlAppRoot().'pages/UI.php'; $sStyle = (isset($aExtraParams['open']) && ($aExtraParams['open'] == 'true')) ? 'opened' : ''; $sHtml .= "
    \n"; // Don't use $_SERVER['SCRIPT_NAME'] since the form may be called asynchronously (from ajax.php) - $sHtml .= "

    " . Dict::Format('UI:SearchFor_Class_Objects', $sClassesCombo) . "

    \n"; + $sHtml .= "

    " . Dict::Format('UI:SearchFor_Class_Objects', $sClassesCombo) . "

    \n"; $sHtml .= "
    \n"; $sHtml .= "
    \n
    \n"; $sHtml .= "
    \n";