mirror of
https://dev.azure.com/hugendubel/ISA/_git/ISA-Frontend
synced 2025-12-28 22:42:11 +01:00
Merged PR 846: #2189 Action Reorder Modal Implementation
#2189 Action Reorder Modal Implementation
This commit is contained in:
committed by
Andreas Schickinger
parent
4adb5f074e
commit
20c95a8a26
40
angular.json
40
angular.json
@@ -3136,6 +3136,46 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@modal/reorder": {
|
||||
"projectType": "library",
|
||||
"root": "apps/modal/reorder",
|
||||
"sourceRoot": "apps/modal/reorder/src",
|
||||
"prefix": "lib",
|
||||
"architect": {
|
||||
"build": {
|
||||
"builder": "@angular-devkit/build-angular:ng-packagr",
|
||||
"options": {
|
||||
"tsConfig": "apps/modal/reorder/tsconfig.lib.json",
|
||||
"project": "apps/modal/reorder/ng-package.json"
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
"tsConfig": "apps/modal/reorder/tsconfig.lib.prod.json"
|
||||
}
|
||||
}
|
||||
},
|
||||
"test": {
|
||||
"builder": "@angular-devkit/build-angular:karma",
|
||||
"options": {
|
||||
"main": "apps/modal/reorder/src/test.ts",
|
||||
"tsConfig": "apps/modal/reorder/tsconfig.spec.json",
|
||||
"karmaConfig": "apps/modal/reorder/karma.conf.js"
|
||||
}
|
||||
},
|
||||
"lint": {
|
||||
"builder": "@angular-devkit/build-angular:tslint",
|
||||
"options": {
|
||||
"tsConfig": [
|
||||
"apps/modal/reorder/tsconfig.lib.json",
|
||||
"apps/modal/reorder/tsconfig.spec.json"
|
||||
],
|
||||
"exclude": [
|
||||
"**/node_modules/**"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"defaultProject": "sales"
|
||||
|
||||
@@ -27,6 +27,7 @@ export * from './preperation-for-shipping.action-handler';
|
||||
export * from './print-compartment-label.action-handler';
|
||||
export * from './print-shipping-note.action-handler';
|
||||
export * from './re-ordered.action-handler';
|
||||
export * from './re-order.action-handler';
|
||||
export * from './redirected-internally.action-handler';
|
||||
export * from './requested.action-handler';
|
||||
export * from './reserved.action-handler';
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ActionHandler } from '@core/command';
|
||||
import { OrderItemsContext } from './order-items.context';
|
||||
import { UiModalService } from '@ui/modal';
|
||||
import { ReorderModalComponent } from '@modal/reorder';
|
||||
|
||||
@Injectable()
|
||||
export class ReOrderActionHandler extends ActionHandler<OrderItemsContext> {
|
||||
constructor(private _uiModal: UiModalService) {
|
||||
super('REORDER');
|
||||
}
|
||||
|
||||
async handler(data: OrderItemsContext): Promise<OrderItemsContext> {
|
||||
await this._uiModal
|
||||
.open({
|
||||
content: ReorderModalComponent,
|
||||
data: data.items[0],
|
||||
})
|
||||
.afterClosed$.toPromise();
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import { ChangeOrderItemStatusBaseActionHandler } from './change-order-item-stat
|
||||
import { OrderItemsContext } from './order-items.context';
|
||||
|
||||
@Injectable()
|
||||
export class ReOrderActionHandler extends ChangeOrderItemStatusBaseActionHandler {
|
||||
export class ReOrderedActionHandler extends ChangeOrderItemStatusBaseActionHandler {
|
||||
constructor(domainOmsService: DomainOmsService) {
|
||||
super(domainOmsService, 'REORDERED');
|
||||
}
|
||||
|
||||
25
apps/modal/reorder/README.md
Normal file
25
apps/modal/reorder/README.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# Reorder
|
||||
|
||||
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 10.2.4.
|
||||
|
||||
## Code scaffolding
|
||||
|
||||
Run `ng generate component component-name --project reorder` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project reorder`.
|
||||
|
||||
> Note: Don't forget to add `--project reorder` or else it will be added to the default project in your `angular.json` file.
|
||||
|
||||
## Build
|
||||
|
||||
Run `ng build reorder` to build the project. The build artifacts will be stored in the `dist/` directory.
|
||||
|
||||
## Publishing
|
||||
|
||||
After building your library with `ng build reorder`, go to the dist folder `cd dist/reorder` and run `npm publish`.
|
||||
|
||||
## Running unit tests
|
||||
|
||||
Run `ng test reorder` to execute the unit tests via [Karma](https://karma-runner.github.io).
|
||||
|
||||
## Further help
|
||||
|
||||
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
|
||||
32
apps/modal/reorder/karma.conf.js
Normal file
32
apps/modal/reorder/karma.conf.js
Normal file
@@ -0,0 +1,32 @@
|
||||
// Karma configuration file, see link for more information
|
||||
// https://karma-runner.github.io/1.0/config/configuration-file.html
|
||||
|
||||
module.exports = function (config) {
|
||||
config.set({
|
||||
basePath: '',
|
||||
frameworks: ['jasmine', '@angular-devkit/build-angular'],
|
||||
plugins: [
|
||||
require('karma-jasmine'),
|
||||
require('karma-chrome-launcher'),
|
||||
require('karma-jasmine-html-reporter'),
|
||||
require('karma-coverage-istanbul-reporter'),
|
||||
require('@angular-devkit/build-angular/plugins/karma'),
|
||||
],
|
||||
client: {
|
||||
clearContext: false, // leave Jasmine Spec Runner output visible in browser
|
||||
},
|
||||
coverageIstanbulReporter: {
|
||||
dir: require('path').join(__dirname, '../../../coverage/modal/reorder'),
|
||||
reports: ['html', 'lcovonly', 'text-summary'],
|
||||
fixWebpackSourcePaths: true,
|
||||
},
|
||||
reporters: ['progress', 'kjhtml'],
|
||||
port: 9876,
|
||||
colors: true,
|
||||
logLevel: config.LOG_INFO,
|
||||
autoWatch: true,
|
||||
browsers: ['Chrome'],
|
||||
singleRun: false,
|
||||
restartOnFileChange: true,
|
||||
});
|
||||
};
|
||||
7
apps/modal/reorder/ng-package.json
Normal file
7
apps/modal/reorder/ng-package.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"$schema": "../../../node_modules/ng-packagr/ng-package.schema.json",
|
||||
"dest": "../../../dist/modal/reorder",
|
||||
"lib": {
|
||||
"entryFile": "src/public-api.ts"
|
||||
}
|
||||
}
|
||||
11
apps/modal/reorder/package.json
Normal file
11
apps/modal/reorder/package.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "@modal/reorder",
|
||||
"version": "0.0.1",
|
||||
"peerDependencies": {
|
||||
"@angular/common": "^10.2.4",
|
||||
"@angular/core": "^10.2.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"tslib": "^2.0.0"
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import { ProductImageModule, ProductImageService } from '@cdn/product-image';
|
||||
import { DomainAvailabilityService } from '@domain/availability';
|
||||
import { DomainCheckoutService } from '@domain/checkout';
|
||||
import { DomainOmsService } from '@domain/oms';
|
||||
import { ReorderModalComponent } from '@modal/reorder';
|
||||
import { createComponentFactory, mockProvider, Spectator } from '@ngneat/spectator';
|
||||
import { AvailabilityDTO2, AvailabilityType } from '@swagger/oms';
|
||||
import { UiCommonModule } from '@ui/common';
|
||||
@@ -12,11 +13,10 @@ import { UiQuantityDropdownModule } from '@ui/quantity-dropdown';
|
||||
import { UiSelectBulletModule } from '@ui/select-bullet';
|
||||
import { UiSpinnerModule } from 'apps/ui/spinner/src/lib/ui-spinner.module';
|
||||
import { of } from 'rxjs';
|
||||
import { GoodsInListReorderModalComponent } from './goods-in-list-reorder-modal.component';
|
||||
import { SupplierNamePipe } from './supplier-name.pipe';
|
||||
|
||||
describe('GoodsInListReorderModalComponent', () => {
|
||||
let spectator: Spectator<GoodsInListReorderModalComponent>;
|
||||
describe('ReorderModalComponent', () => {
|
||||
let spectator: Spectator<ReorderModalComponent>;
|
||||
let modalRefMock: jasmine.SpyObj<UiModalRef>;
|
||||
let domainAvailabilityServiceMock: jasmine.SpyObj<DomainAvailabilityService>;
|
||||
let domainCheckoutServiceMock: jasmine.SpyObj<DomainCheckoutService>;
|
||||
@@ -34,7 +34,7 @@ describe('GoodsInListReorderModalComponent', () => {
|
||||
} as AvailabilityDTO2;
|
||||
|
||||
const createComponent = createComponentFactory({
|
||||
component: GoodsInListReorderModalComponent,
|
||||
component: ReorderModalComponent,
|
||||
imports: [
|
||||
UiCommonModule,
|
||||
UiSelectBulletModule,
|
||||
@@ -5,7 +5,7 @@ import { DomainOmsService } from '@domain/oms';
|
||||
import { ComponentStore } from '@ngrx/component-store';
|
||||
import { AvailabilityDTO2, OrderItemListItemDTO } from '@swagger/oms';
|
||||
import { UiModalRef } from '@ui/modal';
|
||||
import { combineLatest, Subject } from 'rxjs';
|
||||
import { combineLatest } from 'rxjs';
|
||||
import { catchError, map, switchMap, tap } from 'rxjs/operators';
|
||||
|
||||
interface GoodsInListReorderModalState {
|
||||
@@ -17,12 +17,12 @@ interface GoodsInListReorderModalState {
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'goods-in-list-reorder-modal',
|
||||
templateUrl: 'goods-in-list-reorder-modal.component.html',
|
||||
styleUrls: ['goods-in-list-reorder-modal.component.scss'],
|
||||
selector: 'modal-reorder',
|
||||
templateUrl: 'reorder.component.html',
|
||||
styleUrls: ['reorder.component.scss'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class GoodsInListReorderModalComponent extends ComponentStore<GoodsInListReorderModalState> {
|
||||
export class ReorderModalComponent extends ComponentStore<GoodsInListReorderModalState> {
|
||||
readonly orderItem$ = this.select((s) => s.orderItem);
|
||||
get orderItem() {
|
||||
return this.get((s) => s.orderItem);
|
||||
@@ -6,7 +6,7 @@ import { UiIconModule } from '@ui/icon';
|
||||
import { UiQuantityDropdownModule } from '@ui/quantity-dropdown';
|
||||
import { UiSelectBulletModule } from '@ui/select-bullet';
|
||||
import { UiSpinnerModule } from 'apps/ui/spinner/src/lib/ui-spinner.module';
|
||||
import { GoodsInListReorderModalComponent } from './goods-in-list-reorder-modal.component';
|
||||
import { ReorderModalComponent } from './reorder.component';
|
||||
import { SupplierNamePipe } from './supplier-name.pipe';
|
||||
|
||||
@NgModule({
|
||||
@@ -20,8 +20,8 @@ import { SupplierNamePipe } from './supplier-name.pipe';
|
||||
UiSpinnerModule,
|
||||
UiQuantityDropdownModule,
|
||||
],
|
||||
exports: [GoodsInListReorderModalComponent, SupplierNamePipe],
|
||||
declarations: [GoodsInListReorderModalComponent, SupplierNamePipe],
|
||||
exports: [ReorderModalComponent, SupplierNamePipe],
|
||||
declarations: [ReorderModalComponent, SupplierNamePipe],
|
||||
providers: [],
|
||||
})
|
||||
export class GoodsInListReorderModalModule {}
|
||||
export class ReorderModalModule {}
|
||||
7
apps/modal/reorder/src/public-api.ts
Normal file
7
apps/modal/reorder/src/public-api.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
/*
|
||||
* Public API Surface of reorder
|
||||
*/
|
||||
|
||||
export * from './lib/supplier-name.pipe';
|
||||
export * from './lib/reorder.component';
|
||||
export * from './lib/reorder.module';
|
||||
24
apps/modal/reorder/src/test.ts
Normal file
24
apps/modal/reorder/src/test.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
|
||||
|
||||
import 'zone.js/dist/zone';
|
||||
import 'zone.js/dist/zone-testing';
|
||||
import { getTestBed } from '@angular/core/testing';
|
||||
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
|
||||
|
||||
declare const require: {
|
||||
context(
|
||||
path: string,
|
||||
deep?: boolean,
|
||||
filter?: RegExp
|
||||
): {
|
||||
keys(): string[];
|
||||
<T>(id: string): T;
|
||||
};
|
||||
};
|
||||
|
||||
// First, initialize the Angular testing environment.
|
||||
getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting());
|
||||
// Then we find all the tests.
|
||||
const context = require.context('./', true, /\.spec\.ts$/);
|
||||
// And load the modules.
|
||||
context.keys().map(context);
|
||||
25
apps/modal/reorder/tsconfig.lib.json
Normal file
25
apps/modal/reorder/tsconfig.lib.json
Normal file
@@ -0,0 +1,25 @@
|
||||
/* To learn more about this file see: https://angular.io/config/tsconfig. */
|
||||
{
|
||||
"extends": "../../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../../../out-tsc/lib",
|
||||
"target": "es2015",
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"inlineSources": true,
|
||||
"types": [],
|
||||
"lib": [
|
||||
"dom",
|
||||
"es2018"
|
||||
]
|
||||
},
|
||||
"angularCompilerOptions": {
|
||||
"skipTemplateCodegen": true,
|
||||
"strictMetadataEmit": true,
|
||||
"enableResourceInlining": true
|
||||
},
|
||||
"exclude": [
|
||||
"src/test.ts",
|
||||
"**/*.spec.ts"
|
||||
]
|
||||
}
|
||||
10
apps/modal/reorder/tsconfig.lib.prod.json
Normal file
10
apps/modal/reorder/tsconfig.lib.prod.json
Normal file
@@ -0,0 +1,10 @@
|
||||
/* To learn more about this file see: https://angular.io/config/tsconfig. */
|
||||
{
|
||||
"extends": "./tsconfig.lib.json",
|
||||
"compilerOptions": {
|
||||
"declarationMap": false
|
||||
},
|
||||
"angularCompilerOptions": {
|
||||
"enableIvy": false
|
||||
}
|
||||
}
|
||||
17
apps/modal/reorder/tsconfig.spec.json
Normal file
17
apps/modal/reorder/tsconfig.spec.json
Normal file
@@ -0,0 +1,17 @@
|
||||
/* To learn more about this file see: https://angular.io/config/tsconfig. */
|
||||
{
|
||||
"extends": "../../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../../../out-tsc/spec",
|
||||
"types": [
|
||||
"jasmine"
|
||||
]
|
||||
},
|
||||
"files": [
|
||||
"src/test.ts"
|
||||
],
|
||||
"include": [
|
||||
"**/*.spec.ts",
|
||||
"**/*.d.ts"
|
||||
]
|
||||
}
|
||||
17
apps/modal/reorder/tslint.json
Normal file
17
apps/modal/reorder/tslint.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"extends": "../../../tslint.json",
|
||||
"rules": {
|
||||
"directive-selector": [
|
||||
true,
|
||||
"attribute",
|
||||
"lib",
|
||||
"camelCase"
|
||||
],
|
||||
"component-selector": [
|
||||
true,
|
||||
"element",
|
||||
"lib",
|
||||
"kebab-case"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
import { ChangeDetectionStrategy, Component, EventEmitter, Input, OnDestroy, Output } from '@angular/core';
|
||||
import { DomainOmsService } from '@domain/oms';
|
||||
import { ReorderModalComponent } from '@modal/reorder';
|
||||
import { ComponentStore } from '@ngrx/component-store';
|
||||
import { OrderItemListItemDTO } from '@swagger/oms';
|
||||
import { UiModalService } from '@ui/modal';
|
||||
import { isEqual } from 'lodash';
|
||||
import { Subject } from 'rxjs';
|
||||
import { catchError, first, shareReplay, switchMap, takeUntil } from 'rxjs/operators';
|
||||
import { GoodsInListReorderModalComponent } from '../goods-in-list-reorder-modal/goods-in-list-reorder-modal.component';
|
||||
|
||||
interface GoodsInListItemComponentState {
|
||||
item: OrderItemListItemDTO;
|
||||
@@ -155,7 +155,7 @@ export class GoodsInListItemComponent extends ComponentStore<GoodsInListItemComp
|
||||
|
||||
showReorderModal() {
|
||||
const modal = this._uiModal.open({
|
||||
content: GoodsInListReorderModalComponent,
|
||||
content: ReorderModalComponent,
|
||||
data: this.item,
|
||||
});
|
||||
modal.afterClosed$.pipe(takeUntil(this._onDestroy$)).subscribe((modal) => {
|
||||
|
||||
@@ -5,20 +5,11 @@ import { UiIconModule } from '@ui/icon';
|
||||
import { UiScrollContainerModule } from '@ui/scroll-container';
|
||||
import { UiSpinnerModule } from 'apps/ui/spinner/src/lib/ui-spinner.module';
|
||||
import { GoodsInListItemModule } from './goods-in-list-item/goods-in-list-item.module';
|
||||
import { GoodsInListReorderModalModule } from './goods-in-list-reorder-modal/goods-in-list-reorder-modal.module';
|
||||
|
||||
import { GoodsInListComponent } from './goods-in-list.component';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
UiCommonModule,
|
||||
UiIconModule,
|
||||
GoodsInListItemModule,
|
||||
GoodsInListReorderModalModule,
|
||||
UiScrollContainerModule,
|
||||
UiSpinnerModule,
|
||||
],
|
||||
imports: [CommonModule, UiCommonModule, UiIconModule, GoodsInListItemModule, UiScrollContainerModule, UiSpinnerModule],
|
||||
exports: [],
|
||||
declarations: [GoodsInListComponent],
|
||||
providers: [],
|
||||
|
||||
@@ -37,6 +37,7 @@ import {
|
||||
ReturnedByBuyerActionHandler,
|
||||
ShippingNoteActionHandler,
|
||||
SupplierTemporarilyOutOfStockActionHandler,
|
||||
ReOrderedActionHandler,
|
||||
} from '@domain/oms';
|
||||
@NgModule({
|
||||
declarations: [GoodsInComponent],
|
||||
@@ -71,6 +72,7 @@ import {
|
||||
PrintCompartmentLabelActionHandler,
|
||||
PrintShippingNoteActionHandler,
|
||||
ReOrderActionHandler,
|
||||
ReOrderedActionHandler,
|
||||
RedirectedInternaqllyActionHandler,
|
||||
RequestedActionHandler,
|
||||
ReserverdActionHandler,
|
||||
|
||||
@@ -36,6 +36,7 @@ import {
|
||||
ReturnedByBuyerActionHandler,
|
||||
ShippingNoteActionHandler,
|
||||
SupplierTemporarilyOutOfStockActionHandler,
|
||||
ReOrderedActionHandler,
|
||||
} from '@domain/oms';
|
||||
import { CoreCommandModule } from '@core/command';
|
||||
import { ShellBreadcrumbModule } from '@shell/breadcrumb';
|
||||
@@ -75,6 +76,7 @@ import { GoodsInRoutingModule } from './good-out-routing.module';
|
||||
PrintCompartmentLabelActionHandler,
|
||||
PrintShippingNoteActionHandler,
|
||||
ReOrderActionHandler,
|
||||
ReOrderedActionHandler,
|
||||
RedirectedInternaqllyActionHandler,
|
||||
RequestedActionHandler,
|
||||
ReserverdActionHandler,
|
||||
|
||||
@@ -272,6 +272,9 @@
|
||||
],
|
||||
"@ui/loader": [
|
||||
"apps/ui/loader/src/public-api.ts"
|
||||
],
|
||||
"@modal/reorder": [
|
||||
"apps/modal/reorder/src/public-api.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user