-
-
Notifications
You must be signed in to change notification settings - Fork 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): Handle Fulfillments state from Order detail view
Relates to #426
- Loading branch information
1 parent
8232ddc
commit 7883a7a
Showing
28 changed files
with
350 additions
and
77 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,41 @@ | ||
{ | ||
"generatedOn": "2020-08-26T08:49:50.552Z", | ||
"lastCommit": "8881aee83b25f57edba537fbdcb85c77bf5f3c4e", | ||
"generatedOn": "2020-09-15T15:16:07.529Z", | ||
"lastCommit": "8232ddce0b03f8f1b30e8d02563d5fe2d5f5ebe8", | ||
"translationStatus": { | ||
"de": { | ||
"tokenCount": 662, | ||
"translatedCount": 610, | ||
"percentage": 92 | ||
"tokenCount": 670, | ||
"translatedCount": 609, | ||
"percentage": 91 | ||
}, | ||
"en": { | ||
"tokenCount": 662, | ||
"translatedCount": 662, | ||
"tokenCount": 670, | ||
"translatedCount": 669, | ||
"percentage": 100 | ||
}, | ||
"es": { | ||
"tokenCount": 662, | ||
"translatedCount": 467, | ||
"percentage": 71 | ||
"tokenCount": 670, | ||
"translatedCount": 466, | ||
"percentage": 70 | ||
}, | ||
"pl": { | ||
"tokenCount": 662, | ||
"translatedCount": 566, | ||
"percentage": 85 | ||
"tokenCount": 669, | ||
"translatedCount": 564, | ||
"percentage": 84 | ||
}, | ||
"pt_BR": { | ||
"tokenCount": 662, | ||
"translatedCount": 657, | ||
"percentage": 99 | ||
"tokenCount": 669, | ||
"translatedCount": 655, | ||
"percentage": 98 | ||
}, | ||
"zh_Hans": { | ||
"tokenCount": 662, | ||
"translatedCount": 550, | ||
"percentage": 83 | ||
"tokenCount": 669, | ||
"translatedCount": 548, | ||
"percentage": 82 | ||
}, | ||
"zh_Hant": { | ||
"tokenCount": 662, | ||
"translatedCount": 550, | ||
"percentage": 83 | ||
"tokenCount": 669, | ||
"translatedCount": 548, | ||
"percentage": 82 | ||
} | ||
} | ||
} |
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
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
46 changes: 46 additions & 0 deletions
46
...es/admin-ui/src/lib/order/src/components/fulfillment-card/fulfillment-card.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,46 @@ | ||
<div class="card"> | ||
<div class="card-header fulfillment-header"> | ||
<div>{{ 'order.fulfillment' | translate }}</div> | ||
<div class="fulfillment-state"> | ||
<vdr-fulfillment-state-label [state]="fulfillment?.state"></vdr-fulfillment-state-label> | ||
</div> | ||
</div> | ||
<div class="card-block"> | ||
<vdr-fulfillment-detail | ||
*ngIf="!!fulfillment" | ||
[fulfillmentId]="fulfillment?.id" | ||
[order]="order" | ||
></vdr-fulfillment-detail> | ||
</div> | ||
<div class="card-footer"> | ||
<ng-container *ngIf="nextSuggestedState() as suggestedState"> | ||
<button class="btn btn-sm btn-primary" (click)="transitionState.emit(suggestedState)"> | ||
{{ 'order.set-fulfillment-state' | translate: { state: suggestedState } }} | ||
</button> | ||
</ng-container> | ||
<vdr-dropdown> | ||
<button class="icon-button" vdrDropdownTrigger> | ||
<clr-icon shape="ellipsis-vertical"></clr-icon> | ||
</button> | ||
<vdr-dropdown-menu vdrPosition="bottom-right"> | ||
<ng-container *ngFor="let nextState of nextOtherStates()"> | ||
<button | ||
type="button" | ||
class="btn" | ||
vdrDropdownItem | ||
(click)="transitionState.emit(nextState)" | ||
> | ||
<ng-container *ngIf="nextState !== 'Cancelled'; else cancel"> | ||
<clr-icon shape="step-forward-2"></clr-icon> | ||
{{ 'order.transition-to-state' | translate: { state: nextState } }} | ||
</ng-container> | ||
<ng-template #cancel> | ||
<clr-icon shape="error-standard" class="is-error"></clr-icon> | ||
{{ 'order.cancel-fulfillment' | translate }} | ||
</ng-template> | ||
</button> | ||
</ng-container> | ||
</vdr-dropdown-menu> | ||
</vdr-dropdown> | ||
</div> | ||
</div> |
12 changes: 12 additions & 0 deletions
12
...es/admin-ui/src/lib/order/src/components/fulfillment-card/fulfillment-card.component.scss
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,12 @@ | ||
|
||
.fulfillment-header { | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
} | ||
|
||
.card-footer { | ||
display: flex; | ||
align-items: center; | ||
justify-content: flex-end; | ||
} |
39 changes: 39 additions & 0 deletions
39
...ages/admin-ui/src/lib/order/src/components/fulfillment-card/fulfillment-card.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,39 @@ | ||
import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core'; | ||
import { Fulfillment, OrderDetail } from '@vendure/admin-ui/core'; | ||
|
||
@Component({ | ||
selector: 'vdr-fulfillment-card', | ||
templateUrl: './fulfillment-card.component.html', | ||
styleUrls: ['./fulfillment-card.component.scss'], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class FulfillmentCardComponent { | ||
@Input() fulfillment: Fulfillment.Fragment | undefined; | ||
@Input() order: OrderDetail.Fragment; | ||
@Output() transitionState = new EventEmitter<string>(); | ||
|
||
nextSuggestedState(): string | undefined { | ||
if (!this.fulfillment) { | ||
return; | ||
} | ||
const { nextStates } = this.fulfillment; | ||
const namedStateOrDefault = (targetState: string) => | ||
nextStates.includes(targetState) ? targetState : nextStates[0]; | ||
switch (this.fulfillment?.state) { | ||
case 'Pending': | ||
return namedStateOrDefault('Shipped'); | ||
case 'Shipped': | ||
return namedStateOrDefault('Delivered'); | ||
default: | ||
return nextStates.find(s => s !== 'Cancelled'); | ||
} | ||
} | ||
|
||
nextOtherStates(): string[] { | ||
if (!this.fulfillment) { | ||
return []; | ||
} | ||
const suggested = this.nextSuggestedState(); | ||
return this.fulfillment.nextStates.filter(s => s !== suggested); | ||
} | ||
} |
1 change: 0 additions & 1 deletion
1
.../admin-ui/src/lib/order/src/components/fulfillment-detail/fulfillment-detail.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
4 changes: 4 additions & 0 deletions
4
...c/lib/order/src/components/fulfillment-state-label/fulfillment-state-label.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,4 @@ | ||
<vdr-chip [title]="'order.payment-state' | translate" [colorType]="chipColorType"> | ||
<clr-icon shape="check-circle" *ngIf="state === 'Delivered'"></clr-icon> | ||
{{ state }} | ||
</vdr-chip> |
3 changes: 3 additions & 0 deletions
3
...c/lib/order/src/components/fulfillment-state-label/fulfillment-state-label.component.scss
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,3 @@ | ||
:host { | ||
font-size: 14px; | ||
} |
23 changes: 23 additions & 0 deletions
23
...src/lib/order/src/components/fulfillment-state-label/fulfillment-state-label.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,23 @@ | ||
import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'vdr-fulfillment-state-label', | ||
templateUrl: './fulfillment-state-label.component.html', | ||
styleUrls: ['./fulfillment-state-label.component.scss'], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class FulfillmentStateLabelComponent { | ||
@Input() state: string; | ||
|
||
get chipColorType() { | ||
switch (this.state) { | ||
case 'Pending': | ||
case 'Shipped': | ||
return 'warning'; | ||
case 'Delivered': | ||
return 'success'; | ||
case 'Cancelled': | ||
return 'error'; | ||
} | ||
} | ||
} |
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
Oops, something went wrong.