Skip to content

Commit

Permalink
Merge branch 'master' into minor
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbromley committed Sep 14, 2021
2 parents 81d9836 + 459a794 commit abfd986
Show file tree
Hide file tree
Showing 37 changed files with 591 additions and 463 deletions.
4 changes: 2 additions & 2 deletions docs/data/build.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": "1.1.3",
"commit": "812b2cbbd"
"version": "1.2.0",
"commit": "765479402"
}
2 changes: 2 additions & 0 deletions packages/admin-ui-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
"lint": "tslint --fix --project ./",
"compile": "tsc -p ./tsconfig.build.json"
},
"homepage": "https://www.vendure.io/",
"funding": "https://github.com/sponsors/michaelbromley",
"publishConfig": {
"access": "public"
},
Expand Down
4 changes: 3 additions & 1 deletion packages/admin-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
"extract-translations": "node scripts/extract-translations.js",
"ngcc": "ngcc --properties es2015 browser module main --first-only --create-ivy-entry-points"
},
"homepage": "https://www.vendure.io/",
"funding": "https://github.com/sponsors/michaelbromley",
"publishConfig": {
"access": "public",
"directory": "package"
Expand All @@ -34,7 +36,7 @@
"@clr/core": "^4.0.15",
"@clr/icons": "^12.0.2",
"@clr/ui": "^12.0.2",
"@ng-select/ng-select": "^6.1.0",
"@ng-select/ng-select": "^7.2.0",
"@ngx-translate/core": "^13.0.0",
"@ngx-translate/http-loader": "^6.0.0",
"@vendure/common": "^1.2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,30 +60,32 @@
<div class="clr-row">
<div class="clr-col">
<section class="form-block" formGroupName="product">
<ng-container *vdrIfMultichannel>
<vdr-form-item
[label]="'common.channels' | translate"
*vdrIfDefaultChannelActive
>
<div class="flex channel-assignment">
<ng-container *ngFor="let channel of productChannels$ | async">
<vdr-chip
*ngIf="!isDefaultChannel(channel.code)"
icon="times-circle"
(iconClick)="removeFromChannel(channel.id)"
>
<vdr-channel-badge
[channelCode]="channel.code"
></vdr-channel-badge>
{{ channel.code | channelCodeToLabel }}
</vdr-chip>
</ng-container>
<button class="btn btn-sm" (click)="assignToChannel()">
<clr-icon shape="layers"></clr-icon>
{{ 'catalog.assign-to-channel' | translate }}
</button>
</div>
</vdr-form-item>
<ng-container *ngIf="!(isNew$ | async)">
<ng-container *vdrIfMultichannel>
<vdr-form-item
[label]="'common.channels' | translate"
*vdrIfDefaultChannelActive
>
<div class="flex channel-assignment">
<ng-container *ngFor="let channel of productChannels$ | async">
<vdr-chip
*ngIf="!isDefaultChannel(channel.code)"
icon="times-circle"
(iconClick)="removeFromChannel(channel.id)"
>
<vdr-channel-badge
[channelCode]="channel.code"
></vdr-channel-badge>
{{ channel.code | channelCodeToLabel }}
</vdr-chip>
</ng-container>
<button class="btn btn-sm" (click)="assignToChannel()">
<clr-icon shape="layers"></clr-icon>
{{ 'catalog.assign-to-channel' | translate }}
</button>
</div>
</vdr-form-item>
</ng-container>
</ng-container>
<vdr-form-field [label]="'catalog.product-name' | translate" for="name">
<input
Expand All @@ -109,7 +111,7 @@
/>
<label>{{
'catalog.auto-update-product-variant-name' | translate
}}</label>
}}</label>
</clr-checkbox-wrapper>
</div>
<vdr-form-field
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { AfterViewInit, Component, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import {
Expand Down Expand Up @@ -36,10 +36,12 @@ import { ProductSearchInputComponent } from '../product-search-input/product-sea
})
export class ProductListComponent
extends BaseListComponent<SearchProducts.Query, SearchProducts.Items, SearchProducts.Variables>
implements OnInit {
implements OnInit, AfterViewInit
{
searchTerm = '';
facetValueIds: string[] = [];
groupByProduct = true;
selectedFacetValueIds$: Observable<string[]>;
facetValues$: Observable<SearchProducts.FacetValues[]>;
availableLanguages$: Observable<LanguageCode[]>;
contentLanguage$: Observable<LanguageCode>;
Expand All @@ -55,6 +57,25 @@ export class ProductListComponent
route: ActivatedRoute,
) {
super(router, route);
this.route.queryParamMap
.pipe(
map(qpm => qpm.get('q')),
takeUntil(this.destroy$),
)
.subscribe(term => {
this.searchTerm = term || '';
if (this.productSearchInput) {
this.productSearchInput.setSearchTerm(term);
}
});
this.selectedFacetValueIds$ = this.route.queryParamMap.pipe(map(qpm => qpm.getAll('fvids')));

this.selectedFacetValueIds$.pipe(takeUntil(this.destroy$)).subscribe(ids => {
this.facetValueIds = ids;
if (this.productSearchInput) {
this.productSearchInput.setFacetValues(ids);
}
});
super.setQueryFn(
(...args: any[]) =>
this.dataService.product.searchProducts(this.searchTerm, ...args).refetchOnChannelChange(),
Expand All @@ -75,33 +96,27 @@ export class ProductListComponent

ngOnInit() {
super.ngOnInit();
this.facetValues$ = this.result$.pipe(map(data => data.search.facetValues));
// this.facetValues$ = of([]);
this.route.queryParamMap
.pipe(
map(qpm => qpm.get('q')),
takeUntil(this.destroy$),
)
.subscribe(term => {
this.productSearchInput.setSearchTerm(term);
});

const fvids$ = this.route.queryParamMap.pipe(map(qpm => qpm.getAll('fvids')));

fvids$.pipe(takeUntil(this.destroy$)).subscribe(ids => {
this.productSearchInput.setFacetValues(ids);
});
this.facetValues$ = this.result$.pipe(map(data => data.search.facetValues));

this.facetValues$.pipe(take(1), delay(100), withLatestFrom(fvids$)).subscribe(([__, ids]) => {
this.productSearchInput.setFacetValues(ids);
});
this.facetValues$
.pipe(take(1), delay(100), withLatestFrom(this.selectedFacetValueIds$))
.subscribe(([__, ids]) => {
this.productSearchInput.setFacetValues(ids);
});
this.availableLanguages$ = this.serverConfigService.getAvailableLanguages();
this.contentLanguage$ = this.dataService.client
.uiState()
.mapStream(({ uiState }) => uiState.contentLanguage)
.pipe(tap(() => this.refresh()));
}

ngAfterViewInit() {
if (this.productSearchInput && this.searchTerm) {
setTimeout(() => this.productSearchInput.setSearchTerm(this.searchTerm));
}
}

setSearchTerm(term: string) {
this.searchTerm = term;
this.setQueryParam({ q: term || null, page: 1 });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class ProductSearchInputComponent {
});

ids.map(id => {
return items.find(item => this.isFacetValueItem(item) && item.facetValue.id === id);
return items?.find(item => this.isFacetValueItem(item) && item.facetValue.id === id);
})
.filter(notNullOrUndefined)
.forEach(item => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@
display: flex;
color: var(--color-grey-400);
}

::ng-deep .clr-control-container {
width: 100%;
}
}

.channel-assignment {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class AssetSearchInputComponent {
});

tags.map(tag => {
return items.find(item => this.isTag(item) && item.id === tag.id);
return items?.find(item => this.isTag(item) && item.id === tag.id);
})
.filter(notNullOrUndefined)
.forEach(item => {
Expand Down Expand Up @@ -77,9 +77,7 @@ export class AssetSearchInputComponent {
}
}

const searchTermItem = searchTermItems[searchTermItems.length - 1] as
| { label: string }
| undefined;
const searchTermItem = searchTermItems[searchTermItems.length - 1] as { label: string } | undefined;

const searchTerm = searchTermItem ? searchTermItem.label : '';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
:host {
display: block;
width: 100%;
.toggle-switch {
margin-top: 0;
margin-bottom: 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
@import 'variables';

:host {
flex: 1;
}

.list-container {
border: 1px solid var(--color-component-border-200);
border-radius: 3px;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
input {
width: 100%;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
textarea {
resize: both;
height: 6rem;
width: 100%;
}
}
Loading

0 comments on commit abfd986

Please sign in to comment.