From a77182a9e89900dc7cc4f78e256e6826de866e9f Mon Sep 17 00:00:00 2001 From: aynsix Date: Wed, 15 Dec 2021 17:34:50 +0300 Subject: [PATCH 1/9] color unset facets --- Phraseanet-production-client/config/config.js | 2 +- .../dist/authenticate.js | 2 +- .../dist/authenticate.min.js | 2 +- Phraseanet-production-client/dist/commons.js | 2 +- .../dist/commons.min.js | 2 +- Phraseanet-production-client/dist/production.js | 17 +++++++++++++++++ .../dist/production.min.js | 17 +++++++++++++++++ .../src/components/ui/workzone/facets/index.js | 17 +++++++++++++++++ .../Phrasea/Twig/PhraseanetExtension.php | 2 +- 9 files changed, 57 insertions(+), 6 deletions(-) diff --git a/Phraseanet-production-client/config/config.js b/Phraseanet-production-client/config/config.js index 0a78e9ee8a..c4ff05c3f6 100644 --- a/Phraseanet-production-client/config/config.js +++ b/Phraseanet-production-client/config/config.js @@ -13,5 +13,5 @@ module.exports = { setupDir: _root + 'tests/setup/node.js', karmaConf: _root + 'config/karma.conf.js', // change this version when you change JS file for lazy loading - assetFileVersion: 35 + assetFileVersion: 36 }; diff --git a/Phraseanet-production-client/dist/authenticate.js b/Phraseanet-production-client/dist/authenticate.js index b51f90a9ce..e7785e416b 100644 --- a/Phraseanet-production-client/dist/authenticate.js +++ b/Phraseanet-production-client/dist/authenticate.js @@ -96,7 +96,7 @@ return /******/ (function(modules) { // webpackBootstrap /******/ if (__webpack_require__.nc) { /******/ script.setAttribute("nonce", __webpack_require__.nc); /******/ } -/******/ script.src = __webpack_require__.p + "lazy-" + ({}[chunkId]||chunkId) + ".js?v=35"; +/******/ script.src = __webpack_require__.p + "lazy-" + ({}[chunkId]||chunkId) + ".js?v=36"; /******/ var timeout = setTimeout(onScriptComplete, 120000); /******/ script.onerror = script.onload = onScriptComplete; /******/ function onScriptComplete() { diff --git a/Phraseanet-production-client/dist/authenticate.min.js b/Phraseanet-production-client/dist/authenticate.min.js index 40dd17fa7c..ab73713102 100644 --- a/Phraseanet-production-client/dist/authenticate.min.js +++ b/Phraseanet-production-client/dist/authenticate.min.js @@ -96,7 +96,7 @@ return /******/ (function(modules) { // webpackBootstrap /******/ if (__webpack_require__.nc) { /******/ script.setAttribute("nonce", __webpack_require__.nc); /******/ } -/******/ script.src = __webpack_require__.p + "lazy-" + ({}[chunkId]||chunkId) + ".min.js?v=35"; +/******/ script.src = __webpack_require__.p + "lazy-" + ({}[chunkId]||chunkId) + ".min.js?v=36"; /******/ var timeout = setTimeout(onScriptComplete, 120000); /******/ script.onerror = script.onload = onScriptComplete; /******/ function onScriptComplete() { diff --git a/Phraseanet-production-client/dist/commons.js b/Phraseanet-production-client/dist/commons.js index c78a9d28a2..e3306b43ad 100644 --- a/Phraseanet-production-client/dist/commons.js +++ b/Phraseanet-production-client/dist/commons.js @@ -91,7 +91,7 @@ /******/ if (__webpack_require__.nc) { /******/ script.setAttribute("nonce", __webpack_require__.nc); /******/ } -/******/ script.src = __webpack_require__.p + "lazy-" + ({}[chunkId]||chunkId) + ".js?v=35"; +/******/ script.src = __webpack_require__.p + "lazy-" + ({}[chunkId]||chunkId) + ".js?v=36"; /******/ var timeout = setTimeout(onScriptComplete, 120000); /******/ script.onerror = script.onload = onScriptComplete; /******/ function onScriptComplete() { diff --git a/Phraseanet-production-client/dist/commons.min.js b/Phraseanet-production-client/dist/commons.min.js index 00e37f2a02..d67df8904b 100644 --- a/Phraseanet-production-client/dist/commons.min.js +++ b/Phraseanet-production-client/dist/commons.min.js @@ -91,7 +91,7 @@ /******/ if (__webpack_require__.nc) { /******/ script.setAttribute("nonce", __webpack_require__.nc); /******/ } -/******/ script.src = __webpack_require__.p + "lazy-" + ({}[chunkId]||chunkId) + ".min.js?v=35"; +/******/ script.src = __webpack_require__.p + "lazy-" + ({}[chunkId]||chunkId) + ".min.js?v=36"; /******/ var timeout = setTimeout(onScriptComplete, 120000); /******/ script.onerror = script.onload = onScriptComplete; /******/ function onScriptComplete() { diff --git a/Phraseanet-production-client/dist/production.js b/Phraseanet-production-client/dist/production.js index 2efa3444b6..0a5283249e 100644 --- a/Phraseanet-production-client/dist/production.js +++ b/Phraseanet-production-client/dist/production.js @@ -3916,6 +3916,8 @@ var workzoneFacets = function workzoneFacets(services) { treeSource = _parseColors(treeSource); + treeSource = _colorUnsetText(treeSource); + return _getFacetsTree().reload(treeSource).done(function () { _.each((0, _jquery2.default)('#proposals').find('.fancytree-expanded'), function (element, i) { (0, _jquery2.default)(element).find('.fancytree-title, .fancytree-expander').css('line-height', '50px'); @@ -3975,6 +3977,21 @@ var workzoneFacets = function workzoneFacets(services) { } } + function _colorUnsetText(source) { + _.forEach(source, function (facet) { + if (!_.isUndefined(facet.children) && facet.children.length > 0) { + _.forEach(facet.children, function (child) { + if (child.raw_value.toString() === '_unset_') { + var title = child.title; + child.title = '' + title.toString() + ''; + } + }); + } + }); + + return source; + } + // from stackoverflow // http://stackoverflow.com/questions/979256/sorting-an-array-of-javascript-objects/979325#979325 function _sortFacets(field, reverse, primer) { diff --git a/Phraseanet-production-client/dist/production.min.js b/Phraseanet-production-client/dist/production.min.js index 2efa3444b6..0a5283249e 100644 --- a/Phraseanet-production-client/dist/production.min.js +++ b/Phraseanet-production-client/dist/production.min.js @@ -3916,6 +3916,8 @@ var workzoneFacets = function workzoneFacets(services) { treeSource = _parseColors(treeSource); + treeSource = _colorUnsetText(treeSource); + return _getFacetsTree().reload(treeSource).done(function () { _.each((0, _jquery2.default)('#proposals').find('.fancytree-expanded'), function (element, i) { (0, _jquery2.default)(element).find('.fancytree-title, .fancytree-expander').css('line-height', '50px'); @@ -3975,6 +3977,21 @@ var workzoneFacets = function workzoneFacets(services) { } } + function _colorUnsetText(source) { + _.forEach(source, function (facet) { + if (!_.isUndefined(facet.children) && facet.children.length > 0) { + _.forEach(facet.children, function (child) { + if (child.raw_value.toString() === '_unset_') { + var title = child.title; + child.title = '' + title.toString() + ''; + } + }); + } + }); + + return source; + } + // from stackoverflow // http://stackoverflow.com/questions/979256/sorting-an-array-of-javascript-objects/979325#979325 function _sortFacets(field, reverse, primer) { diff --git a/Phraseanet-production-client/src/components/ui/workzone/facets/index.js b/Phraseanet-production-client/src/components/ui/workzone/facets/index.js index e1bbb353dd..39504ecc75 100644 --- a/Phraseanet-production-client/src/components/ui/workzone/facets/index.js +++ b/Phraseanet-production-client/src/components/ui/workzone/facets/index.js @@ -156,6 +156,8 @@ const workzoneFacets = services => { treeSource = _parseColors(treeSource); + treeSource = _colorUnsetText(treeSource); + return _getFacetsTree().reload(treeSource) .done(function () { _.each($('#proposals').find('.fancytree-expanded'), function (element, i) { @@ -215,6 +217,21 @@ const workzoneFacets = services => { } } + function _colorUnsetText(source) { + _.forEach(source, function (facet) { + if (!_.isUndefined(facet.children) && (facet.children.length > 0)) { + _.forEach(facet.children, function (child) { + if (child.raw_value.toString() === '_unset_') { + var title = child.title; + child.title = '' + title.toString() +''; + } + }); + } + }); + + return source; + } + // from stackoverflow // http://stackoverflow.com/questions/979256/sorting-an-array-of-javascript-objects/979325#979325 diff --git a/lib/Alchemy/Phrasea/Twig/PhraseanetExtension.php b/lib/Alchemy/Phrasea/Twig/PhraseanetExtension.php index dcc9a63486..18a2ea66e0 100644 --- a/lib/Alchemy/Phrasea/Twig/PhraseanetExtension.php +++ b/lib/Alchemy/Phrasea/Twig/PhraseanetExtension.php @@ -59,7 +59,7 @@ class PhraseanetExtension extends \Twig_Extension { return [ // change this version when you change JS file to force the navigation to reload js file - 'assetFileVersion' => 35 + 'assetFileVersion' => 36 ]; } From 86743577cda65b29ce5ed2fa7f6f85c4634a6225 Mon Sep 17 00:00:00 2001 From: aynsix Date: Thu, 16 Dec 2021 10:51:46 +0300 Subject: [PATCH 2/9] taken account hide facets with one result --- Phraseanet-production-client/dist/production.js | 2 +- Phraseanet-production-client/dist/production.min.js | 2 +- Phraseanet-production-client/src/components/search/index.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Phraseanet-production-client/dist/production.js b/Phraseanet-production-client/dist/production.js index 0a5283249e..f8358414e9 100644 --- a/Phraseanet-production-client/dist/production.js +++ b/Phraseanet-production-client/dist/production.js @@ -68148,7 +68148,7 @@ var search = function search(services) { var updateFacetData = function updateFacetData() { appEvents.emit('facets.doLoadFacets', { facets: facets, - filterFacet: (0, _jquery2.default)('#look_box_settings input[name=filter_facet]').prop('checked'), + filterFacet: (0, _jquery2.default)('.look_box_settings input[name=filter_facet]').prop('checked'), facetOrder: (0, _jquery2.default)('.look_box_settings select[name=orderFacet]').val(), facetValueOrder: (0, _jquery2.default)('.look_box_settings select[name=facetValuesOrder]').val(), hiddenFacetsList: savedHiddenFacetsList diff --git a/Phraseanet-production-client/dist/production.min.js b/Phraseanet-production-client/dist/production.min.js index 0a5283249e..f8358414e9 100644 --- a/Phraseanet-production-client/dist/production.min.js +++ b/Phraseanet-production-client/dist/production.min.js @@ -68148,7 +68148,7 @@ var search = function search(services) { var updateFacetData = function updateFacetData() { appEvents.emit('facets.doLoadFacets', { facets: facets, - filterFacet: (0, _jquery2.default)('#look_box_settings input[name=filter_facet]').prop('checked'), + filterFacet: (0, _jquery2.default)('.look_box_settings input[name=filter_facet]').prop('checked'), facetOrder: (0, _jquery2.default)('.look_box_settings select[name=orderFacet]').val(), facetValueOrder: (0, _jquery2.default)('.look_box_settings select[name=facetValuesOrder]').val(), hiddenFacetsList: savedHiddenFacetsList diff --git a/Phraseanet-production-client/src/components/search/index.js b/Phraseanet-production-client/src/components/search/index.js index e9b235966b..bb85e0d63d 100644 --- a/Phraseanet-production-client/src/components/search/index.js +++ b/Phraseanet-production-client/src/components/search/index.js @@ -431,7 +431,7 @@ const search = services => { const updateFacetData = () => { appEvents.emit('facets.doLoadFacets', { facets: facets, - filterFacet: $('#look_box_settings input[name=filter_facet]').prop('checked'), + filterFacet: $('.look_box_settings input[name=filter_facet]').prop('checked'), facetOrder: $('.look_box_settings select[name=orderFacet]').val(), facetValueOrder: $('.look_box_settings select[name=facetValuesOrder]').val(), hiddenFacetsList: savedHiddenFacetsList From 61921db099fcd0543f6e2666e670eb2f4723ce83 Mon Sep 17 00:00:00 2001 From: aynsix Date: Thu, 16 Dec 2021 17:38:04 +0300 Subject: [PATCH 3/9] remove a facet filter --- templates/web/prod/index.html.twig | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/templates/web/prod/index.html.twig b/templates/web/prod/index.html.twig index afcc4b0872..9ff35a1669 100644 --- a/templates/web/prod/index.html.twig +++ b/templates/web/prod/index.html.twig @@ -268,11 +268,12 @@ {% set _empty_facetFilter = app['settings'].getUserSetting(app.getAuthenticatedUser(), 'show_unset_field_facet') %}
{{ 'index::advance_search: facet' | trans }}
- -
+ {# TODO : make behaviour as in 4.0 #} +{# #} +{#
#}