-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(admin-ui): Allow groups admin from CustomerDetailComponent
Relates to #330
- Loading branch information
1 parent
9635677
commit 8dca9a3
Showing
9 changed files
with
161 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...r/src/components/select-customer-group-dialog/select-customer-group-dialog.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<ng-template vdrDialogTitle> | ||
{{ 'customer.add-customer-to-group' }} | ||
</ng-template> | ||
|
||
<ng-select | ||
[items]="groups$ | async" | ||
appendTo="body" | ||
[addTag]="false" | ||
[multiple]="true" | ||
bindValue="id" | ||
[(ngModel)]="selectedGroupIds" | ||
[clearable]="true" | ||
[searchable]="false" | ||
> | ||
<ng-template ng-label-tmp let-item="item" let-clear="clear"> | ||
<span aria-hidden="true" class="ng-value-icon left" (click)="clear(item)"> × </span> | ||
<vdr-chip [colorFrom]="item.id">{{ item.name }}</vdr-chip> | ||
</ng-template> | ||
<ng-template ng-option-tmp let-item="item"> | ||
<vdr-chip [colorFrom]="item.id">{{ item.name }}</vdr-chip> | ||
</ng-template> | ||
</ng-select> | ||
|
||
|
||
<ng-template vdrDialogButtons> | ||
<button type="button" class="btn" (click)="cancel()">{{ 'common.cancel' | translate }}</button> | ||
<button type="submit" (click)="add()" [disabled]="!selectedGroupIds.length" class="btn btn-primary"> | ||
{{ 'customer.add-customer-to-groups-with-count' | translate: {count: selectedGroupIds.length} }} | ||
</button> | ||
</ng-template> |
Empty file.
33 changes: 33 additions & 0 deletions
33
...mer/src/components/select-customer-group-dialog/select-customer-group-dialog.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core'; | ||
import { ActivatedRoute } from '@angular/router'; | ||
import { DataService, Dialog, GetCustomerGroups, GetCustomerList } from '@vendure/admin-ui/core'; | ||
import { BehaviorSubject, Observable } from 'rxjs'; | ||
import { map, switchMap } from 'rxjs/operators'; | ||
|
||
@Component({ | ||
selector: 'vdr-select-customer-group-dialog', | ||
templateUrl: './select-customer-group-dialog.component.html', | ||
styleUrls: ['./select-customer-group-dialog.component.scss'], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class SelectCustomerGroupDialogComponent implements Dialog<string[]>, OnInit { | ||
resolveWith: (result?: string[]) => void; | ||
groups$: Observable<GetCustomerGroups.Items[]>; | ||
selectedGroupIds: string[] = []; | ||
|
||
constructor(private dataService: DataService) {} | ||
|
||
ngOnInit() { | ||
this.groups$ = this.dataService.customer | ||
.getCustomerGroupList() | ||
.mapStream((res) => res.customerGroups.items); | ||
} | ||
|
||
cancel() { | ||
this.resolveWith(); | ||
} | ||
|
||
add() { | ||
this.resolveWith(this.selectedGroupIds); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters