forked from allors/allors2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Implements SalesOrder Transfer feature (WIP)
- Loading branch information
1 parent
091d47e
commit d8ebe8d
Showing
13 changed files
with
3,685 additions
and
1 deletion.
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
3,028 changes: 3,028 additions & 0 deletions
3,028
Base/Database/Domain.Tests/Order/SalesOrderTransferTests.cs
Large diffs are not rendered by default.
Oops, something went wrong.
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
19 changes: 19 additions & 0 deletions
19
...et/src/allors/material/base/objects/salesordertransfer/edit/salesterm-edit.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,19 @@ | ||
<form *ngIf="object" #form="ngForm" (submit)="save()" novalidate> | ||
|
||
<h3 mat-dialog-title>{{title}}</h3> | ||
|
||
<mat-dialog-content> | ||
|
||
<div class="row"> | ||
<a-mat-select class="col-md" [object]="object" [roleType]="m.SalesTerm.TermType" [options]="termTypes" display="Name"></a-mat-select> | ||
<a-mat-input class="col-md" [object]="object" [roleType]="m.SalesTerm.TermValue" label="Value"></a-mat-input> | ||
</div> | ||
|
||
</mat-dialog-content> | ||
|
||
<div mat-dialog-actions> | ||
<button mat-button (click)="dialogRef.close()" type="button">CANCEL</button> | ||
<button mat-button class="ml-2" color="primary" type="submit" [disabled]="!form.form.valid || !allors.context.hasChanges">SAVE</button> | ||
</div> | ||
|
||
</form> |
119 changes: 119 additions & 0 deletions
119
...anet/src/allors/material/base/objects/salesordertransfer/edit/salesterm-edit.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,119 @@ | ||
import { Component, OnDestroy, OnInit, Self, Inject } from '@angular/core'; | ||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; | ||
import { BehaviorSubject, Subscription, combineLatest } from 'rxjs'; | ||
|
||
import { Saved, ContextService, MetaService, RefreshService, TestScope } from '../../../../../angular'; | ||
import { SalesTerm, TermType } from '../../../../../domain'; | ||
import { PullRequest, Sort, Equals, ISessionObject, IObject } from '../../../../../framework'; | ||
import { ObjectData, SaveService } from '../../../../../material'; | ||
import { Meta } from '../../../../../meta'; | ||
import { switchMap, map } from 'rxjs/operators'; | ||
|
||
@Component({ | ||
templateUrl: './salesterm-edit.component.html', | ||
providers: [ContextService] | ||
}) | ||
export class SalesTermEditComponent extends TestScope implements OnInit, OnDestroy { | ||
|
||
public m: Meta; | ||
|
||
public title = 'Edit Term Type'; | ||
|
||
public container: ISessionObject; | ||
public object: SalesTerm; | ||
public termTypes: TermType[]; | ||
|
||
private subscription: Subscription; | ||
|
||
constructor( | ||
@Self() public allors: ContextService, | ||
@Inject(MAT_DIALOG_DATA) public data: ObjectData, | ||
public dialogRef: MatDialogRef<SalesTermEditComponent>, | ||
public metaService: MetaService, | ||
public refreshService: RefreshService, | ||
private saveService: SaveService, | ||
) { | ||
super(); | ||
|
||
this.m = this.metaService.m; | ||
} | ||
|
||
public ngOnInit(): void { | ||
|
||
const { m, pull, x } = this.metaService; | ||
|
||
this.subscription = combineLatest(this.refreshService.refresh$) | ||
.pipe( | ||
switchMap(() => { | ||
|
||
const create = (this.data as IObject).id === undefined; | ||
const { objectType, associationRoleType } = this.data; | ||
|
||
const pulls = [ | ||
pull.SalesTerm( | ||
{ | ||
object: this.data.id, | ||
include: { | ||
TermType: x, | ||
} | ||
}), | ||
pull.TermType({ | ||
predicate: new Equals({ propertyType: m.TermType.IsActive, value: true }), | ||
sort: [ | ||
new Sort(m.TermType.Name), | ||
], | ||
}) | ||
]; | ||
|
||
if (create && this.data.associationId) { | ||
pulls.push( | ||
pull.SalesInvoice({ object: this.data.associationId }), | ||
pull.SalesOrder({ object: this.data.associationId }), | ||
); | ||
} | ||
|
||
return this.allors.context.load(new PullRequest({ pulls })) | ||
.pipe( | ||
map((loaded) => ({ loaded, create, objectType, associationRoleType })) | ||
); | ||
}) | ||
) | ||
.subscribe(({ loaded, create, objectType, associationRoleType }) => { | ||
this.allors.context.reset(); | ||
|
||
this.container = loaded.objects.SalesInvoice || loaded.objects.SalesOrder; | ||
this.object = loaded.objects.SalesTerm as SalesTerm; | ||
this.termTypes = loaded.collections.TermTypes as TermType[]; | ||
this.termTypes = this.termTypes.filter(v => v.objectType.name === `${objectType.name}Type`); | ||
|
||
if (create) { | ||
this.title = 'Add Sales Term'; | ||
this.object = this.allors.context.create(objectType.name) as SalesTerm; | ||
this.container.add(associationRoleType, this.object); | ||
} | ||
|
||
}); | ||
} | ||
|
||
public ngOnDestroy(): void { | ||
if (this.subscription) { | ||
this.subscription.unsubscribe(); | ||
} | ||
} | ||
|
||
public save(): void { | ||
|
||
this.allors.context.save() | ||
.subscribe((saved: Saved) => { | ||
const data: IObject = { | ||
id: this.object.id, | ||
objectType: this.object.objectType, | ||
}; | ||
|
||
this.dialogRef.close(data); | ||
this.refreshService.refresh(); | ||
}, | ||
this.saveService.errorHandler | ||
); | ||
} | ||
} |
Oops, something went wrong.