Skip to content

Commit

Permalink
fix(admin-ui): Give all data table columns immutable ids
Browse files Browse the repository at this point in the history
Previously the ID was based on the heading, which changed when updating the current
display language.
  • Loading branch information
michaelbromley committed Sep 6, 2023
1 parent 26f88b7 commit 73a78db
Show file tree
Hide file tree
Showing 32 changed files with 196 additions and 253 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,30 @@
[searchTermControl]="filterTermControl"
[searchTermPlaceholder]="'catalog.filter-by-name' | translate"
/>
<vdr-dt2-column [heading]="'common.id' | translate" [hiddenByDefault]="true">
<vdr-dt2-column [heading]="'common.id' | translate" id="id" [hiddenByDefault]="true">
<ng-template let-variant="item">
{{ variant.id }}
</ng-template>
</vdr-dt2-column>
<vdr-dt2-column [heading]="'common.created-at' | translate" [hiddenByDefault]="true">
<vdr-dt2-column [heading]="'common.created-at' | translate" id="created-at" [hiddenByDefault]="true">
<ng-template let-variant="item">
{{ variant.createdAt | localeDate : 'short' }}
</ng-template>
</vdr-dt2-column>
<vdr-dt2-column [heading]="'common.updated-at' | translate" [hiddenByDefault]="true">
<vdr-dt2-column [heading]="'common.updated-at' | translate" id="updated-at" [hiddenByDefault]="true">
<ng-template let-variant="item">
{{ variant.updatedAt | localeDate : 'short' }}
</ng-template>
</vdr-dt2-column>
<vdr-dt2-column [heading]="'common.name' | translate" [optional]="false">
<vdr-dt2-column [heading]="'common.name' | translate" id="name" [optional]="false">
<ng-template let-variant="item">
<a class="button-ghost" [routerLink]="['/catalog/inventory', variant.productId]"
><span>{{ variant.name }}</span
><clr-icon shape="arrow right"
/></a>
</ng-template>
</vdr-dt2-column>
<vdr-dt2-column [heading]="'catalog.sku' | translate" [optional]="false">
<vdr-dt2-column [heading]="'catalog.sku' | translate" id="sku" [optional]="false">
<ng-template let-variant="item">
{{ variant.sku }}
</ng-template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@
[searchTermControl]="searchTermControl"
[searchTermPlaceholder]="'common.search-by-name' | translate"
></vdr-dt2-search>
<vdr-dt2-column [heading]="'common.id' | translate" [hiddenByDefault]="true">
<vdr-dt2-column [heading]="'common.id' | translate" id="id" [hiddenByDefault]="true">
<ng-template let-collection="item">
{{ collection.id }}
</ng-template>
</vdr-dt2-column>
<vdr-dt2-column
[heading]="'common.created-at' | translate"
[heading]="'common.created-at' | translate" id="created-at"
[hiddenByDefault]="true"
[sort]="sorts.get('createdAt')"
>
Expand All @@ -60,7 +60,7 @@
</ng-template>
</vdr-dt2-column>
<vdr-dt2-column
[heading]="'common.updated-at' | translate"
[heading]="'common.updated-at' | translate" id="updated-at"
[hiddenByDefault]="true"
[sort]="sorts.get('updatedAt')"
>
Expand All @@ -69,7 +69,7 @@
</ng-template>
</vdr-dt2-column>
<vdr-dt2-column
[heading]="'common.position' | translate"
[heading]="'common.position' | translate" id="position"
[hiddenByDefault]="true"
[sort]="sorts.get('position')"
>
Expand All @@ -78,7 +78,7 @@
</ng-template>
</vdr-dt2-column>
<vdr-dt2-column
[heading]="'common.name' | translate"
[heading]="'common.name' | translate" id="name"
[optional]="false"
[sort]="sorts.get('name')"
>
Expand All @@ -104,7 +104,7 @@
</a>
</ng-template>
</vdr-dt2-column>
<vdr-dt2-column [heading]="'common.breadcrumb' | translate">
<vdr-dt2-column [heading]="'common.breadcrumb' | translate" id="breadcrumb">
<ng-template let-collection="item">
<div class="breadcrumb">
<ng-container *ngIf="collection | collectionBreadcrumb as breadcrumbs">
Expand All @@ -118,12 +118,12 @@
</div>
</ng-template>
</vdr-dt2-column>
<vdr-dt2-column [heading]="'common.slug' | translate" [sort]="sorts.get('slug')">
<vdr-dt2-column [heading]="'common.slug' | translate" id="slug" [sort]="sorts.get('slug')">
<ng-template let-collection="item">
{{ collection.slug }}
</ng-template>
</vdr-dt2-column>
<vdr-dt2-column [heading]="'common.visibility' | translate">
<vdr-dt2-column [heading]="'common.visibility' | translate" id="visibility">
<ng-template let-collection="item">
<vdr-chip *ngIf="collection.isPrivate" colorType="warning">{{
'common.private' | translate
Expand All @@ -133,7 +133,7 @@
}}</vdr-chip>
</ng-template>
</vdr-dt2-column>
<vdr-dt2-column [heading]="'common.view-contents' | translate" [optional]="false">
<vdr-dt2-column [heading]="'common.view-contents' | translate" id="view-contents" [optional]="false">
<ng-template let-collection="item">
<a
class="button-small bg-weight-150"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@
[searchTermControl]="searchTermControl"
[searchTermPlaceholder]="'catalog.filter-by-name' | translate"
></vdr-dt2-search>
<vdr-dt2-column [heading]="'common.id' | translate" [hiddenByDefault]="true" [sort]="sorts.get('id')">
<vdr-dt2-column [heading]="'common.id' | translate" id="id" [hiddenByDefault]="true" [sort]="sorts.get('id')">
<ng-template let-facet="item">
{{ facet.id }}
</ng-template>
</vdr-dt2-column>
<vdr-dt2-column
[heading]="'common.created-at' | translate"
[heading]="'common.created-at' | translate" id="created-at"
[hiddenByDefault]="true"
[sort]="sorts.get('createdAt')"
>
Expand All @@ -55,28 +55,28 @@
</ng-template>
</vdr-dt2-column>
<vdr-dt2-column
[heading]="'common.updated-at' | translate"
[heading]="'common.updated-at' | translate" id="updated-at"
[hiddenByDefault]="true"
[sort]="sorts.get('updatedAt')"
>
<ng-template let-facet="item">
{{ facet.updatedAt | localeDate : 'short' }}
</ng-template>
</vdr-dt2-column>
<vdr-dt2-column [heading]="'common.name' | translate" [optional]="false" [sort]="sorts.get('name')">
<vdr-dt2-column [heading]="'common.name' | translate" id="name" [optional]="false" [sort]="sorts.get('name')">
<ng-template let-facet="item">
<a class="button-ghost" [routerLink]="['./', facet.id]"
><span>{{ facet.name }}</span>
<clr-icon shape="arrow right"></clr-icon>
</a>
</ng-template>
</vdr-dt2-column>
<vdr-dt2-column [heading]="'common.code' | translate">
<vdr-dt2-column [heading]="'common.code' | translate" id="code">
<ng-template let-facet="item">
{{ facet.code }}
</ng-template>
</vdr-dt2-column>
<vdr-dt2-column [heading]="'common.visibility' | translate">
<vdr-dt2-column [heading]="'common.visibility' | translate" id="visibility">
<ng-template let-facet="item">
<vdr-chip *ngIf="facet.isPrivate" colorType="warning">{{
'common.private' | translate
Expand All @@ -86,7 +86,7 @@
}}</vdr-chip>
</ng-template>
</vdr-dt2-column>
<vdr-dt2-column [heading]="'catalog.values' | translate">
<vdr-dt2-column [heading]="'catalog.values' | translate" id="values">
<ng-template let-facet="item">
<div class="facet-values-list">
<vdr-facet-value-chip
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
[searchTermControl]="searchTermControl"
[searchTermPlaceholder]="'common.search-by-name' | translate"
></vdr-dt2-search>
<vdr-dt2-column [heading]="'common.id' | translate" [hiddenByDefault]="true">
<vdr-dt2-column [heading]="'common.id' | translate" id="id" [hiddenByDefault]="true">
<ng-template let-collection="item">
{{ collection.id }}
</ng-template>
</vdr-dt2-column>
<vdr-dt2-column [heading]="'common.name' | translate" [optional]="false">
<vdr-dt2-column [heading]="'common.name' | translate" id="name" [optional]="false">
<ng-template let-collection="item" let-depth="depth">
<div [ngClass]="'indent-' + depth"></div>
<clr-icon
Expand All @@ -46,7 +46,7 @@
</button>
</ng-template>
</vdr-dt2-column>
<vdr-dt2-column [heading]="'common.breadcrumb' | translate">
<vdr-dt2-column [heading]="'common.breadcrumb' | translate" id="breadcrumb">
<ng-template let-collection="item">
<div class="breadcrumb">
<ng-container *ngIf="collection | collectionBreadcrumb as breadcrumbs">
Expand All @@ -60,7 +60,7 @@
</div>
</ng-template>
</vdr-dt2-column>
<vdr-dt2-column [heading]="'common.slug' | translate">
<vdr-dt2-column [heading]="'common.slug' | translate" id="slug">
<ng-template let-collection="item">
{{ collection.slug }}
</ng-template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,70 +47,17 @@
[hostComponent]="this"
[selectionManager]="selectionManager"
></vdr-bulk-action-menu>
<!--<ng-template #vdrDt2CustomSearch>
<div class="search-form">
<vdr-product-search-input
#productSearchInputComponent
[facetValueResults]="facetValues$ | async"
(searchTermChange)="setSearchTerm($event)"
(facetValueChange)="setFacetValueIds($event)"
></vdr-product-search-input>
<vdr-dropdown class="search-settings-menu mr3">
<button
type="button"
class="icon-button search-index-button"
[title]="
(pendingSearchIndexUpdates
? 'catalog.pending-search-index-updates'
: 'catalog.search-index-controls'
) | translate
"
vdrDropdownTrigger
>
<clr-icon shape="cog"></clr-icon>
<vdr-status-badge *ngIf="pendingSearchIndexUpdates" type="warning"></vdr-status-badge>
</button>
<vdr-dropdown-menu vdrPosition="bottom-right">
<h4 class="dropdown-header">{{ 'catalog.search-index-controls' | translate }}</h4>
<ng-container *ngIf="pendingSearchIndexUpdates">
<button
type="button"
class="run-updates-button"
vdrDropdownItem
(click)="runPendingSearchIndexUpdates()"
[disabled]="!(['UpdateCatalog', 'UpdateProduct'] | hasPermission)"
>
<vdr-status-badge type="warning"></vdr-status-badge>
{{
'catalog.run-pending-search-index-updates'
| translate : { count: pendingSearchIndexUpdates }
}}
</button>
<div class="dropdown-divider"></div>
</ng-container>
<button
type="button"
vdrDropdownItem
(click)="rebuildSearchIndex()"
[disabled]="!(['UpdateCatalog', 'UpdateProduct'] | hasPermission)"
>
{{ 'catalog.rebuild-search-index' | translate }}
</button>
</vdr-dropdown-menu>
</vdr-dropdown>
</div>
</ng-template>-->
<vdr-dt2-search
[searchTermControl]="searchTermControl"
[searchTermPlaceholder]="'catalog.filter-by-name' | translate"
/>
<vdr-dt2-column [heading]="'common.id' | translate" [hiddenByDefault]="true" [sort]="sorts.get('id')">
<vdr-dt2-column [heading]="'common.id' | translate" id="id" [hiddenByDefault]="true" [sort]="sorts.get('id')">
<ng-template let-product="item">
{{ product.id }}
</ng-template>
</vdr-dt2-column>
<vdr-dt2-column
[heading]="'common.created-at' | translate"
[heading]="'common.created-at' | translate" id="created-at"
[hiddenByDefault]="true"
[sort]="sorts.get('createdAt')"
>
Expand All @@ -119,15 +66,15 @@ <h4 class="dropdown-header">{{ 'catalog.search-index-controls' | translate }}</h
</ng-template>
</vdr-dt2-column>
<vdr-dt2-column
[heading]="'common.updated-at' | translate"
[heading]="'common.updated-at' | translate" id="updated-at"
[hiddenByDefault]="true"
[sort]="sorts.get('updatedAt')"
>
<ng-template let-product="item">
{{ product.updatedAt | localeDate : 'short' }}
</ng-template>
</vdr-dt2-column>
<vdr-dt2-column [heading]="'common.image' | translate">
<vdr-dt2-column [heading]="'common.image' | translate" id="image">
<ng-template let-product="item">
<div class="image-placeholder">
<img
Expand All @@ -142,20 +89,20 @@ <h4 class="dropdown-header">{{ 'catalog.search-index-controls' | translate }}</h
</div>
</ng-template>
</vdr-dt2-column>
<vdr-dt2-column [heading]="'catalog.name' | translate" [optional]="false" [sort]="sorts.get('name')">
<vdr-dt2-column [heading]="'catalog.name' | translate" id="name" [optional]="false" [sort]="sorts.get('name')">
<ng-template let-product="item">
<a class="button-ghost" [routerLink]="['./', product.id]"
><span>{{ product.name }}</span
><clr-icon shape="arrow right"
/></a>
</ng-template>
</vdr-dt2-column>
<vdr-dt2-column [heading]="'common.slug' | translate" [sort]="sorts.get('slug')">
<vdr-dt2-column [heading]="'common.slug' | translate" id="slug" [sort]="sorts.get('slug')">
<ng-template let-product="item">
{{ product.slug }}
</ng-template>
</vdr-dt2-column>
<vdr-dt2-column [heading]="'common.enabled' | translate">
<vdr-dt2-column [heading]="'common.enabled' | translate" id="enabled">
<ng-template let-product="item">
<vdr-chip *ngIf="product.enabled" colorType="success">{{
'common.enabled' | translate
Expand All @@ -165,7 +112,7 @@ <h4 class="dropdown-header">{{ 'catalog.search-index-controls' | translate }}</h
}}</vdr-chip>
</ng-template>
</vdr-dt2-column>
<vdr-dt2-column [heading]="'catalog.number-of-variants' | translate">
<vdr-dt2-column [heading]="'catalog.number-of-variants' | translate" id="number-of-variants">
<ng-template let-product="item">
{{ 'catalog.variant-count' | translate : { count: product.variantList?.totalItems } }}
</ng-template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,22 +83,22 @@
(pageChange)="paginationSettings[optionGroup.value.id].currentPage = $event"
[totalItems]="options.length"
>
<vdr-dt2-column [heading]="'common.id' | translate" [hiddenByDefault]="true">
<vdr-dt2-column [heading]="'common.id' | translate" id="id" [hiddenByDefault]="true">
<ng-template let-optionControl="item">
{{ optionControl.value.id }}
</ng-template>
</vdr-dt2-column>
<vdr-dt2-column [heading]="'common.created-at' | translate" [hiddenByDefault]="true">
<vdr-dt2-column [heading]="'common.created-at' | translate" id="created-at" [hiddenByDefault]="true">
<ng-template let-optionControl="item">
{{ optionControl.value.createdAt | localeDate : 'short' }}
</ng-template>
</vdr-dt2-column>
<vdr-dt2-column [heading]="'common.updated-at' | translate" [hiddenByDefault]="true">
<vdr-dt2-column [heading]="'common.updated-at' | translate" id="updated-at" [hiddenByDefault]="true">
<ng-template let-optionControl="item">
{{ optionControl.value.updatedAt | localeDate : 'short' }}
</ng-template>
</vdr-dt2-column>
<vdr-dt2-column [heading]="'common.name' | translate" [optional]="false">
<vdr-dt2-column [heading]="'common.name' | translate" id="name" [optional]="false">
<ng-template let-optionControl="item">
<input
type="text"
Expand All @@ -107,13 +107,13 @@
/>
</ng-template>
</vdr-dt2-column>
<vdr-dt2-column [heading]="'common.code' | translate" [optional]="false">
<vdr-dt2-column [heading]="'common.code' | translate" id="code" [optional]="false">
<ng-template let-optionControl="item">
<input type="text" [formControl]="optionControl.get('code')" />
</ng-template>
</vdr-dt2-column>
<vdr-dt2-column
[heading]="'common.custom-fields' | translate"
[heading]="'common.custom-fields' | translate" id="custom-fields"
[hiddenByDefault]="optionCustomFields.length === 0"
>
<ng-template let-optionControl="item">
Expand Down
Loading

0 comments on commit 73a78db

Please sign in to comment.