Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
"CdxButton",
"CdxCheckbox",
"CdxField",
"CdxSelect",
"CdxTabs",
"CdxTextInput"
]
Expand Down
4 changes: 2 additions & 2 deletions i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"wikibase-faceted-search-instance-type-all": "Alle",
"wikibase-faceted-search-filters": "Filter",
"wikibase-faceted-search-settings": "Einstellungen",
"wikibase-faceted-search-and": "Und",
"wikibase-faceted-search-or": "Oder",
"wikibase-faceted-search-facet-all-selected-values": "Und",
"wikibase-faceted-search-facet-any-selected-values": "Oder",
"wikibase-faceted-search-facet-apply": "Anwenden",
"wikibase-faceted-search-facet-show-more": "Mehr anzeigen",
"wikibase-faceted-search-facet-show-less": "Weniger anzeigen",
Expand Down
6 changes: 4 additions & 2 deletions i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@
"wikibase-faceted-search-filters": "Filters",
"wikibase-faceted-search-settings": "Configure",

"wikibase-faceted-search-and": "And",
"wikibase-faceted-search-or": "Or",
"wikibase-faceted-search-facet-all-selected-values": "All selected values",
"wikibase-faceted-search-facet-any-selected-values": "Any selected value",
"wikibase-faceted-search-facet-any-value": "Any value",
"wikibase-faceted-search-facet-no-value": "No value",

"wikibase-faceted-search-facet-apply": "Apply",

Expand Down
4 changes: 2 additions & 2 deletions i18n/et.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
},
"wikibase-faceted-search-instance-type-all": "Kõik",
"wikibase-faceted-search-filters": "Filtrid",
"wikibase-faceted-search-and": "Ja",
"wikibase-faceted-search-or": "Või",
"wikibase-faceted-search-facet-all-selected-values": "Ja",
"wikibase-faceted-search-facet-any-selected-values": "Või",
"wikibase-faceted-search-facet-show-more": "Näita veel",
"wikibase-faceted-search-facet-range-min": "Minimaalne",
"wikibase-faceted-search-facet-range-max": "Maksimaalne"
Expand Down
4 changes: 2 additions & 2 deletions i18n/fa.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"wikibase-faceted-search-instance-type-all": "همه",
"wikibase-faceted-search-filters": "پالایه‌ها",
"wikibase-faceted-search-settings": "پیکربندی",
"wikibase-faceted-search-and": "و",
"wikibase-faceted-search-or": "یا",
"wikibase-faceted-search-facet-all-selected-values": "و",
"wikibase-faceted-search-facet-any-selected-values": "یا",
"wikibase-faceted-search-facet-apply": "اعمال",
"wikibase-faceted-search-facet-show-more": "نمایش بیشتر",
"wikibase-faceted-search-facet-show-less": "نمایش کمتر",
Expand Down
4 changes: 2 additions & 2 deletions i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"wikibase-faceted-search-instance-type-all": "Tous",
"wikibase-faceted-search-filters": "Filtres",
"wikibase-faceted-search-settings": "Configurer",
"wikibase-faceted-search-and": "Et",
"wikibase-faceted-search-or": "Ou",
"wikibase-faceted-search-facet-all-selected-values": "Et",
"wikibase-faceted-search-facet-any-selected-values": "Ou",
"wikibase-faceted-search-facet-apply": "Appliquer",
"wikibase-faceted-search-facet-show-more": "Afficher plus",
"wikibase-faceted-search-facet-show-less": "Afficher moins",
Expand Down
4 changes: 2 additions & 2 deletions i18n/he.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"wikibase-faceted-search-instance-type-all": "הכול",
"wikibase-faceted-search-filters": "מסננים",
"wikibase-faceted-search-settings": "הגדרות",
"wikibase-faceted-search-and": "וגם",
"wikibase-faceted-search-or": "או",
"wikibase-faceted-search-facet-all-selected-values": "וגם",
"wikibase-faceted-search-facet-any-selected-values": "או",
"wikibase-faceted-search-facet-apply": "החלה",
"wikibase-faceted-search-facet-show-more": "להציג עוד",
"wikibase-faceted-search-facet-show-less": "להציג פחות",
Expand Down
4 changes: 2 additions & 2 deletions i18n/hi.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"wikibase-faceted-search-instance-type-all": "सभी",
"wikibase-faceted-search-filters": "फिल्टर",
"wikibase-faceted-search-settings": "सेटिंग्स",
"wikibase-faceted-search-and": "और",
"wikibase-faceted-search-or": "या",
"wikibase-faceted-search-facet-all-selected-values": "और",
"wikibase-faceted-search-facet-any-selected-values": "या",
"wikibase-faceted-search-facet-apply": "लागू करें",
"wikibase-faceted-search-facet-show-more": "और दिखायें",
"wikibase-faceted-search-facet-show-less": "कम दिखाएँ",
Expand Down
4 changes: 2 additions & 2 deletions i18n/ia.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"wikibase-faceted-search-instance-type-all": "Totes",
"wikibase-faceted-search-filters": "Filtros",
"wikibase-faceted-search-settings": "Configurar",
"wikibase-faceted-search-and": "E",
"wikibase-faceted-search-or": "O",
"wikibase-faceted-search-facet-all-selected-values": "E",
"wikibase-faceted-search-facet-any-selected-values": "O",
"wikibase-faceted-search-facet-apply": "Applicar",
"wikibase-faceted-search-facet-show-more": "Monstrar plus",
"wikibase-faceted-search-facet-show-less": "Monstrar minus",
Expand Down
4 changes: 2 additions & 2 deletions i18n/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"wikibase-faceted-search-instance-type-all": "모두",
"wikibase-faceted-search-filters": "필터",
"wikibase-faceted-search-settings": "구성",
"wikibase-faceted-search-and": "그리고",
"wikibase-faceted-search-or": "또는",
"wikibase-faceted-search-facet-all-selected-values": "그리고",
"wikibase-faceted-search-facet-any-selected-values": "또는",
"wikibase-faceted-search-facet-apply": "적용",
"wikibase-faceted-search-facet-show-more": "더 보기",
"wikibase-faceted-search-facet-show-less": "덜 보기",
Expand Down
4 changes: 2 additions & 2 deletions i18n/lb.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"wikibase-faceted-search-config-invalid": "Är Ännerunge goufen net gespäichert. Si enthalen déi follgend {{PLURAL:$1|Feeler}}:",
"wikibase-faceted-search-filters": "Filteren",
"wikibase-faceted-search-settings": "Astellen",
"wikibase-faceted-search-and": "An",
"wikibase-faceted-search-or": "Oder",
"wikibase-faceted-search-facet-all-selected-values": "An",
"wikibase-faceted-search-facet-any-selected-values": "Oder",
"wikibase-faceted-search-facet-apply": "Uwenden",
"wikibase-faceted-search-facet-show-more": "Méi weisen",
"wikibase-faceted-search-facet-show-less": "Manner weisen",
Expand Down
4 changes: 2 additions & 2 deletions i18n/mk.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"wikibase-faceted-search-instance-type-all": "Сè",
"wikibase-faceted-search-filters": "Филтри",
"wikibase-faceted-search-settings": "Нагоди",
"wikibase-faceted-search-and": "И",
"wikibase-faceted-search-or": "Или",
"wikibase-faceted-search-facet-all-selected-values": "И",
"wikibase-faceted-search-facet-any-selected-values": "Или",
"wikibase-faceted-search-facet-apply": "Примени",
"wikibase-faceted-search-facet-show-more": "Прикажи повеќе",
"wikibase-faceted-search-facet-show-less": "Прикажи помалку",
Expand Down
4 changes: 2 additions & 2 deletions i18n/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"wikibase-faceted-search-instance-type-all": "Alle",
"wikibase-faceted-search-filters": "Filters",
"wikibase-faceted-search-settings": "Instellingen",
"wikibase-faceted-search-and": "En",
"wikibase-faceted-search-or": "Of",
"wikibase-faceted-search-facet-all-selected-values": "En",
"wikibase-faceted-search-facet-any-selected-values": "Of",
"wikibase-faceted-search-facet-apply": "Toepassen",
"wikibase-faceted-search-facet-show-more": "Meer weergeven",
"wikibase-faceted-search-facet-show-less": "Minder weergeven",
Expand Down
4 changes: 2 additions & 2 deletions i18n/pa.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"wikibase-faceted-search-instance-type-all": "ਸਾਰੇ",
"wikibase-faceted-search-filters": "ਛਾਨਣੀਆਂ",
"wikibase-faceted-search-settings": "ਤਰਜੀਹਾਂ",
"wikibase-faceted-search-and": "ਅਤੇ",
"wikibase-faceted-search-or": "ਜਾਂ",
"wikibase-faceted-search-facet-all-selected-values": "ਅਤੇ",
"wikibase-faceted-search-facet-any-selected-values": "ਜਾਂ",
"wikibase-faceted-search-facet-apply": "ਲਾਗੂ ਕਰੋ",
"wikibase-faceted-search-facet-show-more": "ਹੋਰ ਵਿਖਾਓ",
"wikibase-faceted-search-facet-show-less": "ਘੱਟ ਵਿਖਾਓ",
Expand Down
6 changes: 4 additions & 2 deletions i18n/qqq.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
"wikibase-faceted-search-instance-type-all": "Label used for the tab for all instance types",
"wikibase-faceted-search-filters": "Label used for the Filters button to toggle the facets. Translate as a noun.",
"wikibase-faceted-search-settings": "Label used for the Settings button to visit the configuration page",
"wikibase-faceted-search-and": "Label used for the And toggle button in the And/Or toggle",
"wikibase-faceted-search-or": "Label used for the Or toggle button in the And/Or toggle",
"wikibase-faceted-search-facet-all-selected-values": "Label used for the All selected values option in the facet mode select dropdown",
"wikibase-faceted-search-facet-any-selected-values": "Label used for the Any selected value option in the facet mode select dropdown",
"wikibase-faceted-search-facet-any-value": "Label used for the Any value option in the facet mode select dropdown",
"wikibase-faceted-search-facet-no-value": "Label used for the No value option in the facet mode select dropdown",
"wikibase-faceted-search-facet-apply": "Label used for the Apply button in the facet",
"wikibase-faceted-search-facet-show-more": "Label used for the Show more button in the facet",
"wikibase-faceted-search-facet-show-less": "Label used for the Show less button in the facet",
Expand Down
4 changes: 2 additions & 2 deletions i18n/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"wikibase-faceted-search-instance-type-all": "Все",
"wikibase-faceted-search-filters": "Фильтры",
"wikibase-faceted-search-settings": "Настроить",
"wikibase-faceted-search-and": "И",
"wikibase-faceted-search-or": "Или",
"wikibase-faceted-search-facet-all-selected-values": "И",
"wikibase-faceted-search-facet-any-selected-values": "Или",
"wikibase-faceted-search-facet-apply": "Применить",
"wikibase-faceted-search-facet-show-more": "Показать больше",
"wikibase-faceted-search-facet-show-less": "Показать меньше",
Expand Down
2 changes: 1 addition & 1 deletion i18n/sc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"wikibase-faceted-search-instance-type-all": "Totu",
"wikibase-faceted-search-filters": "Filtrus",
"wikibase-faceted-search-settings": "Cunfiguratzionis",
"wikibase-faceted-search-and": "E",
"wikibase-faceted-search-facet-all-selected-values": "E",
"wikibase-faceted-search-facet-apply": "Àplica",
"wikibase-faceted-search-facet-show-more": "Mostra de prus",
"wikibase-faceted-search-facet-show-less": "Mostra mancu"
Expand Down
4 changes: 2 additions & 2 deletions i18n/sr-ec.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"wikibase-faceted-search-instance-type-all": "Све",
"wikibase-faceted-search-filters": "Филтери",
"wikibase-faceted-search-settings": "Конфигуриши",
"wikibase-faceted-search-and": "И",
"wikibase-faceted-search-or": "Или",
"wikibase-faceted-search-facet-all-selected-values": "И",
"wikibase-faceted-search-facet-any-selected-values": "Или",
"wikibase-faceted-search-facet-apply": "Примени",
"wikibase-faceted-search-facet-show-more": "Прикажи више",
"wikibase-faceted-search-facet-show-less": "Прикажи мање",
Expand Down
64 changes: 46 additions & 18 deletions resources/ext.wikibase.facetedsearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
// TODO: Clean up the facet type detection logic after MVP or when we have more facet types
if ( target.classList.contains( 'wikibase-faceted-search__facet-item-checkbox' ) ) {
onListFacetInput( facet, propertyId );
} else if ( target.classList.contains( 'wikibase-faceted-search__facet-toggle-button' ) ) {
onListFacetInput( facet, propertyId, target.value );
} else if ( target.classList.contains( 'wikibase-faceted-search__facet-mode' ) ) {
onModeSelectInput( facet, propertyId, target.value, target.dataset.defaultValue );
} else if ( target.classList.contains( 'wikibase-faceted-search__facet-item-input' ) ) {
onRangeFacetInput( facet, propertyId );
}
Expand All @@ -81,24 +81,40 @@
*
* @param {HTMLDivElement} facet
* @param {string} propertyId
* @param {?string} mode
*/
function onListFacetInput( facet, propertyId, mode ) {
function onListFacetInput( facet, propertyId ) {
const selectedValues = getListFacetSelectedValues( facet );
const newQueries = getListFacetQuerySegments( selectedValues, propertyId, getListFacetQueryMode( facet ) );

Check warning on line 87 in resources/ext.wikibase.facetedsearch.js

View workflow job for this annotation

GitHub Actions / NPM: Lint

This line has a length of 111. Maximum allowed is 100

Check warning on line 87 in resources/ext.wikibase.facetedsearch.js

View workflow job for this annotation

GitHub Actions / NPM: Lint

This line has a length of 111. Maximum allowed is 100
submitSearchForm( buildQueryString( specialSearchInput.value, newQueries, propertyId ) );
}

/**
* Handles the input event for the mode select.
*
* @param {HTMLDivElement} facet
* @param {string} propertyId
* @param {string} mode
* @param {string} defaultMode
*/
function onModeSelectInput( facet, propertyId, mode, defaultMode ) {
if ( mode === defaultMode ) {
return;
}

const selectedValues = getListFacetSelectedValues( facet );
mode = mode || getListFacetQueryMode( facet );
const newQueries = getListFacetQuerySegments( selectedValues, propertyId, mode );
submitSearchForm( buildQueryString( specialSearchInput.value, newQueries, propertyId ) );
}

/**
* Determines the query mode for a list facet based on the selected toggle button.
* Determines the query mode for a list facet based on the selected mode.
*
* @param {HTMLDivElement} facet
* @return {string}
*/
function getListFacetQueryMode( facet ) {
const selectedButton = facet.querySelector( '.wikibase-faceted-search__facet-toggle > .cdx-button--action-progressive' );
return selectedButton ? selectedButton.value : 'AND';
const selectElement = facet.querySelector( '.wikibase-faceted-search__facet-mode' );
return selectElement ? selectElement.value : 'AND';
}

/**
Expand Down Expand Up @@ -193,16 +209,28 @@
*/
function getListFacetQuerySegments( selectedValues, propertyId, mode ) {
const segments = [];
if ( mode === 'AND' ) {
if ( selectedValues.length === 0 ) {
segments.push( `haswbfacet:${ propertyId }=` );
switch ( mode ) {
case 'AND':
if ( selectedValues.length === 0 ) {
segments.push( `haswbfacet:${ propertyId }=` );
}
selectedValues.forEach( ( value ) => {
segments.push( `haswbfacet:${ propertyId }=${ value }` );
} );
break;
case 'OR': {
const suffix = selectedValues.length <= 1 ? '|' : '';
segments.push( `haswbfacet:${ propertyId }=${ selectedValues.join( '|' ) }${ suffix }` );
break;
}
selectedValues.forEach( ( value ) => {
segments.push( `haswbfacet:${ propertyId }=${ value }` );
} );
} else {
const suffix = selectedValues.length <= 1 ? '|' : '';
segments.push( `haswbfacet:${ propertyId }=${ selectedValues.join( '|' ) }${ suffix }` );
case 'ANY':
segments.push( `haswbfacet:${ propertyId }` );
break;
case 'NONE':
segments.push( `-haswbfacet:${ propertyId }` );
break;
default:
segments.push( `haswbfacet:${ propertyId }=|` );
}

return segments;
Expand Down Expand Up @@ -255,7 +283,7 @@
function getFilteredQueries( query, propertyId ) {
const propertyIdPattern = propertyId || 'P\\d+';
return query.split( /\s+/ ).filter(
( item ) => !( new RegExp( `^(haswbfacet|\\-haswbfacet):${ propertyIdPattern }(=|>=|<=)` ) ).test( item )
( item ) => !( new RegExp( `^(haswbfacet|\\-haswbfacet):${ propertyIdPattern }(=|>=|<=)?\\b` ) ).test( item )
);
}

Expand Down
22 changes: 3 additions & 19 deletions resources/ext.wikibase.facetedsearch.less
Original file line number Diff line number Diff line change
Expand Up @@ -98,26 +98,10 @@
}
}

&__facet-toggle {
&__facet-mode.cdx-select {
min-width: auto;
width: 100%;
margin-bottom: @spacing-100;
display: grid;
grid-template-columns: 1fr 1fr;
border-radius: @border-radius-base;
overflow: hidden;

&-button {
width: 100%;

&:not( :first-child ) {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
}

&:not( :last-child ) {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}
}
}

// List facet
Expand Down
2 changes: 1 addition & 1 deletion src/Persistence/ElasticValueCounter.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function countValues( PropertyConstraints $constraints ): ValueCounts {
}

private function getFilteredQuery( PropertyConstraints $constraints ): AbstractQuery {
if ( $constraints->getOrSelectedValues() !== [] ) {
if ( $constraints->hasNoValue() || $constraints->getOrSelectedValues() !== [] ) {
return $this->queryFilter->removeFacet( $this->currentQuery, $constraints->propertyId );
}
return $this->currentQuery;
Expand Down
Loading