Skip to content

Commit

Permalink
feat(admin-ui): Product & variant lists can be filtered by name & sku
Browse files Browse the repository at this point in the history
Closes #2519
  • Loading branch information
michaelbromley committed Dec 19, 2023
1 parent c4bd484 commit 74293cb
Show file tree
Hide file tree
Showing 23 changed files with 85 additions and 67 deletions.
50 changes: 25 additions & 25 deletions packages/admin-ui/i18n-coverage.json
Original file line number Diff line number Diff line change
@@ -1,94 +1,94 @@
{
"generatedOn": "2023-12-18T15:00:22.906Z",
"lastCommit": "4f42cf168eaee02eb73d6e70a6355265a88c4a05",
"generatedOn": "2023-12-19T10:42:11.831Z",
"lastCommit": "c4bd4847c06633538301a20d0efd946d7fd08f30",
"translationStatus": {
"ar": {
"tokenCount": 761,
"tokenCount": 760,
"translatedCount": 760,
"percentage": 100
},
"cs": {
"tokenCount": 761,
"translatedCount": 570,
"tokenCount": 760,
"translatedCount": 571,
"percentage": 75
},
"de": {
"tokenCount": 761,
"tokenCount": 760,
"translatedCount": 760,
"percentage": 100
},
"en": {
"tokenCount": 761,
"tokenCount": 760,
"translatedCount": 760,
"percentage": 100
},
"es": {
"tokenCount": 761,
"tokenCount": 760,
"translatedCount": 760,
"percentage": 100
},
"fa": {
"tokenCount": 761,
"tokenCount": 760,
"translatedCount": 760,
"percentage": 100
},
"fr": {
"tokenCount": 761,
"tokenCount": 760,
"translatedCount": 757,
"percentage": 99
"percentage": 100
},
"he": {
"tokenCount": 761,
"tokenCount": 760,
"translatedCount": 760,
"percentage": 100
},
"hr": {
"tokenCount": 761,
"tokenCount": 760,
"translatedCount": 759,
"percentage": 100
},
"it": {
"tokenCount": 761,
"tokenCount": 760,
"translatedCount": 760,
"percentage": 100
},
"ne": {
"tokenCount": 761,
"tokenCount": 760,
"translatedCount": 749,
"percentage": 98
"percentage": 99
},
"pl": {
"tokenCount": 761,
"tokenCount": 760,
"translatedCount": 399,
"percentage": 52
"percentage": 53
},
"pt_BR": {
"tokenCount": 761,
"tokenCount": 760,
"translatedCount": 759,
"percentage": 100
},
"pt_PT": {
"tokenCount": 761,
"translatedCount": 608,
"tokenCount": 760,
"translatedCount": 607,
"percentage": 80
},
"ru": {
"tokenCount": 761,
"tokenCount": 760,
"translatedCount": 760,
"percentage": 100
},
"uk": {
"tokenCount": 761,
"tokenCount": 760,
"translatedCount": 595,
"percentage": 78
},
"zh_Hans": {
"tokenCount": 761,
"tokenCount": 760,
"translatedCount": 540,
"percentage": 71
},
"zh_Hant": {
"tokenCount": 761,
"tokenCount": 760,
"translatedCount": 386,
"percentage": 51
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
></vdr-bulk-action-menu>
<vdr-dt2-search
[searchTermControl]="searchTermControl"
[searchTermPlaceholder]="'catalog.filter-by-name' | translate"
[searchTermPlaceholder]="'settings.search-by-product-name-or-sku' | translate"
/>
<vdr-dt2-column [heading]="'common.id' | translate" id="id" [hiddenByDefault]="true" [sort]="sorts.get('id')">
<ng-template let-product="item">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
FacetValueFormInputComponent,
JobQueueService,
JobState,
LogicalOperator,
ModalService,
NotificationService,
ProductListQueryDocument,
Expand Down Expand Up @@ -97,19 +98,31 @@ export class ProductListComponent
this.configure({
document: ProductListQueryDocument,
getItems: data => data.products,
setVariables: (skip, take) => ({
options: {
skip,
take,
filter: {
setVariables: (skip, take) => {
const searchTerm = this.searchTermControl.value;
let filterInput = this.filters.createFilterInput();
if (searchTerm) {
filterInput = {
name: {
contains: this.searchTermControl.value,
contains: searchTerm,
},
...this.filters.createFilterInput(),
sku: {
contains: searchTerm,
},
};
}
return {
options: {
skip,
take,
filter: {
...(filterInput ?? {}),
},
filterOperator: searchTerm ? LogicalOperator.OR : LogicalOperator.AND,
sort: this.sorts.createSortInput(),
},
sort: this.sorts.createSortInput(),
},
}),
};
},
refreshListOnChanges: [this.sorts.valueChanges, this.filters.valueChanges],
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
/>
<vdr-dt2-search
[searchTermControl]="searchTermControl"
[searchTermPlaceholder]="'catalog.filter-by-sku' | translate"
[searchTermPlaceholder]="'settings.search-by-product-name-or-sku' | translate"
/>
<vdr-dt2-column [heading]="'common.id' | translate" id="id" [hiddenByDefault]="true" [sort]="sorts.get('id')">
<ng-template let-variant="item">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { Component, Input, OnInit } from '@angular/core';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import {
DataTableLocationId,
LogicalOperator,
ProductVariantFilterParameter,
ProductVariantListQueryDocument,
TypedBaseListComponent,
} from '@vendure/admin-ui/core';
Expand Down Expand Up @@ -75,20 +77,41 @@ export class ProductVariantListComponent
this.configure({
document: ProductVariantListQueryDocument,
getItems: data => data.productVariants,
setVariables: (skip, take) => ({
options: {
skip,
take,
filter: {
sku: {
contains: this.searchTermControl.value,
setVariables: (skip, take) => {
const searchTerm = this.searchTermControl.value;
const filterParam: ProductVariantFilterParameter = { _and: [] };
const filterInput = this.filters.createFilterInput();
if (Object.keys(filterInput).length) {
filterParam._and?.push(filterInput);
}
if (searchTerm) {
filterParam._and?.push({
_or: [
{
name: { contains: searchTerm },
},
{
sku: { contains: searchTerm },
},
],
});
}
if (this.productId) {
filterParam._and?.push({
productId: {
eq: this.productId,
},
...this.filters.createFilterInput(),
...(this.productId ? { productId: { eq: this.productId } } : {}),
});
}
return {
options: {
skip,
take,
filter: filterParam,
sort: this.sorts.createSortInput(),
},
sort: this.sorts.createSortInput(),
},
}),
};
},
refreshListOnChanges: [this.sorts.valueChanges, this.filters.valueChanges],
});
}
Expand Down
1 change: 0 additions & 1 deletion packages/admin-ui/src/lib/static/i18n-messages/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@
"facet-values": "قيم الفئة",
"facets": "فئات",
"filter-by-name": "تصفية بالاسم",
"filter-by-sku": "تصفية بواسطة SKU",
"filter-inheritance": "طبيعة الإنتقاء",
"filters": "الإنتقاء",
"inherit-filters-from-parent": "إنتقاء موروث من الأصل",
Expand Down
1 change: 0 additions & 1 deletion packages/admin-ui/src/lib/static/i18n-messages/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@
"facet-values": "Hodnoty atributů",
"facets": "",
"filter-by-name": "Filtrovat dle jména",
"filter-by-sku": "",
"filter-inheritance": "",
"filters": "Filtry",
"inherit-filters-from-parent": "",
Expand Down
1 change: 0 additions & 1 deletion packages/admin-ui/src/lib/static/i18n-messages/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@
"facet-values": "Facettenwerte",
"facets": "Facetten",
"filter-by-name": "Nach Name filtern",
"filter-by-sku": "Nach Artikelnummer filtern",
"filter-inheritance": "Filter Vererbung",
"filters": "Filter",
"inherit-filters-from-parent": "Erbe Filter vom Elternteil",
Expand Down
1 change: 0 additions & 1 deletion packages/admin-ui/src/lib/static/i18n-messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@
"facet-values": "Facet values",
"facets": "Facets",
"filter-by-name": "Filter by name",
"filter-by-sku": "Filter by SKU",
"filter-inheritance": "Filter inheritance",
"filters": "Filters",
"inherit-filters-from-parent": "Inherit filters from parent",
Expand Down
1 change: 0 additions & 1 deletion packages/admin-ui/src/lib/static/i18n-messages/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@
"facet-values": "Valores de faceta",
"facets": "Facets",
"filter-by-name": "Filtrar por nombre",
"filter-by-sku": "Filtrar por código de referencia",
"filter-inheritance": "Herencia de filtros",
"filters": "Filtros",
"inherit-filters-from-parent": "Heredar filtros del nivel superior",
Expand Down
1 change: 0 additions & 1 deletion packages/admin-ui/src/lib/static/i18n-messages/fa.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@
"facet-values": "مقادیر ویژگی ها",
"facets": "ویژگی ها",
"filter-by-name": "فیلتر براساس نام",
"filter-by-sku": "فیلتر براساس شناسه انحصاری محصول",
"filter-inheritance": "فیلتر براساس وراثت",
"filters": "فیلترها",
"inherit-filters-from-parent": "به ارث بردن فیلترها از والد",
Expand Down
1 change: 0 additions & 1 deletion packages/admin-ui/src/lib/static/i18n-messages/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@
"facet-values": "Valeurs de composant",
"facets": "Composants",
"filter-by-name": "Filtrer par nom",
"filter-by-sku": "Filtrer par UGS",
"filter-inheritance": "Héritage des filtres",
"filters": "Filtres",
"inherit-filters-from-parent": "Hériter les filtres du parent",
Expand Down
1 change: 0 additions & 1 deletion packages/admin-ui/src/lib/static/i18n-messages/he.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@
"facet-values": "ערכי גבעול",
"facets": "גבעולים",
"filter-by-name": "סנן לפי שם",
"filter-by-sku": "סנן לפי SKU",
"filter-inheritance": "ירושת מסננים",
"filters": "מסננים",
"inherit-filters-from-parent": "רש את המסננים מההורה",
Expand Down
1 change: 0 additions & 1 deletion packages/admin-ui/src/lib/static/i18n-messages/hr.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@
"facet-values": "Vrijednosti aspekta",
"facets": "Aspekti",
"filter-by-name": "Filtriraj po imenu",
"filter-by-sku": "Filtriraj po SKU",
"filter-inheritance": "Nasljeđivanje filtera",
"filters": "Filteri",
"inherit-filters-from-parent": "Naslijedi filtere od roditelja",
Expand Down
1 change: 0 additions & 1 deletion packages/admin-ui/src/lib/static/i18n-messages/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@
"facet-values": "Valori attributo",
"facets": "Attributi",
"filter-by-name": "Filtra per nome",
"filter-by-sku": "Filtra per codice SKU",
"filter-inheritance": "Ereditarietà filtri",
"filters": "Filtri",
"inherit-filters-from-parent": "Eredita filtri dal padre",
Expand Down
1 change: 0 additions & 1 deletion packages/admin-ui/src/lib/static/i18n-messages/ne.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@
"facet-values": "मूल्यहरू",
"facets": "मूल्यहरू",
"filter-by-name": "नामद्वारा फिल्टर गर्नुहोस्",
"filter-by-sku": "एसक्यूका अनुसार फिल्टर गर्नुहोस्",
"filter-inheritance": "फिल्टर उत्तराधिकार",
"filters": "फिल्टरहरू",
"inherit-filters-from-parent": "उत्तराधिकारीबाट फिल्टरहरू समावेश गर्नुहोस्",
Expand Down
1 change: 0 additions & 1 deletion packages/admin-ui/src/lib/static/i18n-messages/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@
"facet-values": "Wartości faseta",
"facets": "",
"filter-by-name": "Filtruj po nazwie",
"filter-by-sku": "Filtruj według SKU",
"filter-inheritance": "",
"filters": "Filtry",
"inherit-filters-from-parent": "",
Expand Down
1 change: 0 additions & 1 deletion packages/admin-ui/src/lib/static/i18n-messages/pt_BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@
"facet-values": "Valor da Etiqueta",
"facets": "Etiquetas",
"filter-by-name": "Filtrar por nome",
"filter-by-sku": "Filtrar por SKU",
"filter-inheritance": "Filtrar herança",
"filters": "Filtros",
"inherit-filters-from-parent": "Herdar filtros do pai",
Expand Down
1 change: 0 additions & 1 deletion packages/admin-ui/src/lib/static/i18n-messages/pt_PT.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@
"facet-values": "Valor da Etiqueta",
"facets": "",
"filter-by-name": "Filtrar por nome",
"filter-by-sku": "Filtrar por SKU",
"filter-inheritance": "",
"filters": "Filtros",
"inherit-filters-from-parent": "",
Expand Down
1 change: 0 additions & 1 deletion packages/admin-ui/src/lib/static/i18n-messages/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@
"facet-values": "Значения тега",
"facets": "Теги",
"filter-by-name": "Фильтр по имени",
"filter-by-sku": "Фильтровать по SKU",
"filter-inheritance": "Наследование фильтра",
"filters": "Фильтры",
"inherit-filters-from-parent": "Наследовать фильтры от родительского",
Expand Down
1 change: 0 additions & 1 deletion packages/admin-ui/src/lib/static/i18n-messages/uk.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@
"facet-values": "Значення тегу",
"facets": "",
"filter-by-name": "Фільтр по імені",
"filter-by-sku": "Фільтрувати за SKU",
"filter-inheritance": "",
"filters": "Фільтри",
"inherit-filters-from-parent": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@
"facet-values": "特征值列表",
"facets": "",
"filter-by-name": "按名字过滤",
"filter-by-sku": "按SKU筛选",
"filter-inheritance": "",
"filters": "过滤条件",
"inherit-filters-from-parent": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@
"facet-values": "特徵值列表",
"facets": "",
"filter-by-name": "按名字篩選",
"filter-by-sku": "依照SKU篩選",
"filter-inheritance": "",
"filters": "篩選條件",
"inherit-filters-from-parent": "",
Expand Down

0 comments on commit 74293cb

Please sign in to comment.