Skip to content

Commit

Permalink
feat(admin-ui): Enable filtering by custom Order states in list view
Browse files Browse the repository at this point in the history
Also improved highlighting of states
  • Loading branch information
chladog authored Oct 19, 2020
1 parent f7bffa9 commit 76d2d56
Show file tree
Hide file tree
Showing 7 changed files with 4,147 additions and 4,390 deletions.
9 changes: 9 additions & 0 deletions packages/admin-ui/src/lib/core/src/common/generated-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6207,6 +6207,13 @@ export type UpdatePaymentMethodMutation = { updatePaymentMethod: (
export type GlobalSettingsFragment = (
{ __typename?: 'GlobalSettings' }
& Pick<GlobalSettings, 'id' | 'availableLanguages' | 'trackInventory'>
& { serverConfig: (
{ __typename?: 'ServerConfig' }
& { orderProcess: Array<(
{ __typename?: 'OrderProcessState' }
& Pick<OrderProcessState, 'name'>
)> }
) }
);

export type GetGlobalSettingsQueryVariables = Exact<{ [key: string]: never; }>;
Expand Down Expand Up @@ -8015,6 +8022,8 @@ export namespace UpdatePaymentMethod {

export namespace GlobalSettings {
export type Fragment = GlobalSettingsFragment;
export type ServerConfig = (NonNullable<GlobalSettingsFragment['serverConfig']>);
export type OrderProcess = NonNullable<(NonNullable<(NonNullable<GlobalSettingsFragment['serverConfig']>)['orderProcess']>)[number]>;
}

export namespace GetGlobalSettings {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,11 @@ export const GLOBAL_SETTINGS_FRAGMENT = gql`
id
availableLanguages
trackInventory
serverConfig {
orderProcess {
name
}
}
}
`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,20 @@ export class OrderStateLabelComponent {

get chipColorType() {
switch (this.state) {
case 'AddingItems':
case 'ArrangingPayment':
return '';
case 'Delivered':
return 'success';
case 'Cancelled':
return 'error';
case 'PaymentAuthorized':
case 'PaymentSettled':
case 'PartiallyDelivered':
case 'PartiallyShipped':
case 'Shipped':
default:
return 'warning';
case 'Delivered':
return 'success';
case 'Cancelled':
return 'error';
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,9 @@
<div class="search-form">
<select clrSelect name="state" [formControl]="stateFilter">
<option value="all">{{ 'order.state-all-orders' | translate }}</option>
<option value="AddingItems">{{ 'order.state-adding-items' | translate }}</option>
<option value="ArrangingPayment">{{ 'order.state-arranging-payment' | translate }}</option>
<option value="PaymentAuthorized">{{ 'order.state-payment-authorized' | translate }}</option>
<option value="PaymentSettled">{{ 'order.state-payment-settled' | translate }}</option>
<option value="PartiallyDelivered">
{{ 'order.state-partially-delivered' | translate }}
<option *ngFor="let orderState of (orderStates$ | async)" [value]="orderState">
{{ orderState | orderStateI18nToken | translate }}
</option>
<option value="Delivered">{{ 'order.state-delivered' | translate }}</option>
<option value="Cancelled">{{ 'order.state-cancelled' | translate }}</option>
</select>
<input
type="text"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export class OrderListComponent extends BaseListComponent<GetOrderList.Query, Ge
implements OnInit {
searchTerm = new FormControl('');
stateFilter = new FormControl('all');
orderStates$ = this.dataService.settings.getGlobalSettings().mapSingle(data => data.globalSettings.serverConfig.orderProcess.map(item => item.name));

constructor(private dataService: DataService, router: Router, route: ActivatedRoute) {
super(router, route);
Expand Down
Loading

0 comments on commit 76d2d56

Please sign in to comment.