Party target modifications (#190)

This commit is contained in:
Aleksandra Usacheva 2020-10-09 13:54:09 +03:00 committed by GitHub
parent b723b13386
commit 8ad6e01d88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 43 additions and 29 deletions

View File

@ -9,7 +9,7 @@
[unitID]="unitID"
[partyID]="partyID"
[partyTarget]="getPartyTarget(action.type)"
[unsaved]="unsaved"
[fromClaim]="fromClaim"
(valueChanges)="unitIDChange($event)"
>
</cc-party-modification-target>

View File

@ -17,7 +17,7 @@ export interface CreateModificationData {
partyID: string;
unitID?: string;
modification?: ShopModificationUnit | ContractModificationUnit | ContractorModificationUnit;
unsaved: Modification[];
fromClaim: Modification[];
}
enum Step {
@ -43,7 +43,7 @@ export class CreateModificationDialogComponent implements OnInit {
currentStep = Step.prepareTarget;
unsaved: Modification[];
fromClaim: Modification[];
constructor(
private dialogRef: MatDialogRef<CreateModificationDialogComponent>,
@ -58,7 +58,7 @@ export class CreateModificationDialogComponent implements OnInit {
}
this.partyID = this.data.partyID;
this.action = this.data.action;
this.unsaved = this.data.unsaved;
this.fromClaim = this.data.fromClaim;
this.initialized = true;
}

View File

@ -11,5 +11,5 @@ export interface UnitActionData {
type: UnitActionType;
partyID: string;
unitID?: string;
unsaved: Modification[];
fromClaim: Modification[];
}

View File

@ -12,18 +12,18 @@ import { UnitActionsNavListComponent } from './unit-actions-nav-list';
export class PartyModificationCreatorDialogService {
private open$ = new Subject<{
partyID: PartyID;
unsaved: Modification[];
fromClaim: Modification[];
}>();
opened$ = this.open$.pipe(
switchMap(
({ partyID, unsaved }) =>
({ partyID, fromClaim }) =>
new Observable((observer) => {
this.bottomSheet.open(UnitActionsNavListComponent, {
data: {
type: UnitActionType.allActions,
partyID,
unsaved,
fromClaim,
},
});
observer.next();
@ -35,7 +35,7 @@ export class PartyModificationCreatorDialogService {
this.opened$.subscribe();
}
open(partyID: PartyID, unsaved: Modification[]) {
this.open$.next({ partyID, unsaved });
open(partyID: PartyID, fromClaim: Modification[]) {
this.open$.next({ partyID, fromClaim });
}
}

View File

@ -10,7 +10,7 @@ export class PartyItemNamePipe implements PipeTransform {
switch (value) {
case TargetType.partyItem:
const name = args.length > 0 ? args[0] : 'item';
return `Select ${name} from party or unsaved`;
return `Select ${name} from party or claim`;
case TargetType.fillIn:
return 'Fill in party modification unit ID';
default:

View File

@ -17,7 +17,7 @@
*ngIf="selectedTarget === t.partyItem"
[partyID]="partyID"
[partyTarget]="partyTarget"
[unsaved]="unsaved"
[fromClaim]="fromClaim"
(valueChanges)="unitIDChanges($event)"
>
</cc-target-table>

View File

@ -20,7 +20,7 @@ export class PartyModificationTargetComponent {
partyTarget: PartyTarget;
@Input()
unsaved: Modification[];
fromClaim: Modification[];
@Output()
valueChanges: EventEmitter<string> = new EventEmitter();

View File

@ -1,7 +1,7 @@
@import '~@angular/material/theming';
@mixin cc-target-table-theme($theme) {
.cc-target-table-unsaved {
.cc-target-table-from-claim {
color: map-get($theme, red);
}
}

View File

@ -36,6 +36,6 @@ export const modificationsToSelectableItems = (
return {
id: getOr(data, 'id', null),
data,
unsaved: true,
fromClaim: true,
};
});

View File

@ -17,5 +17,5 @@ export class SelectableItem {
| FileModificationUnit
| CommentModificationUnit;
checked?: boolean;
unsaved?: boolean;
fromClaim?: boolean;
}

View File

@ -28,7 +28,9 @@
<th mat-header-cell *matHeaderCellDef class="mat-column-id">ID</th>
<td mat-cell *matCellDef="let item" class="mat-column-id">
{{ item.id }}
<span class="cc-target-table-unsaved">{{ item.unsaved ? '*' : '' }}</span>
<span class="cc-target-table-from-claim">{{
item.fromClaim ? '*' : ''
}}</span>
</td>
</ng-container>
<ng-container matColumnDef="data">
@ -54,6 +56,8 @@
showFirstLastButtons
></mat-paginator>
<div fxLayout="row" fxLayoutAlign="end center">
<span class="mat-body-1"><span class="cc-target-table-unsaved">*</span> — unsaved</span>
<span class="mat-body-1"
><span class="cc-target-table-from-claim">*</span> — from claim</span
>
</div>
</div>

View File

@ -31,7 +31,7 @@ export class TargetTableComponent implements OnInit {
partyTarget: PartyTarget;
@Input()
unsaved: Modification[];
fromClaim: Modification[];
@Output()
valueChanges: EventEmitter<string> = new EventEmitter();
@ -60,7 +60,7 @@ export class TargetTableComponent implements OnInit {
}
ngOnInit() {
this.targetService.getSelectableItems(this.partyID, this.partyTarget, this.unsaved);
this.targetService.getSelectableItems(this.partyID, this.partyTarget, this.fromClaim);
}
applyFilter(filterValue: string) {

View File

@ -22,13 +22,13 @@ export class TargetTableService {
private getSelectableItems$ = new Subject<{
partyID: string;
targetName: PartyTarget;
unsaved: Modification[];
fromClaim: Modification[];
}>();
private hasError$ = new Subject();
selectableItems$: Observable<SelectableItem[]> = this.getSelectableItems$.pipe(
tap(() => this.hasError$.next()),
switchMap(({ partyID, targetName, unsaved }) =>
switchMap(({ partyID, targetName, fromClaim }) =>
combineLatest([
this.partyService.getParty(partyID).pipe(
map((party) => {
@ -46,18 +46,18 @@ export class TargetTableService {
}),
filter((result) => result !== 'error')
),
of(modificationsToSelectableItems(unsaved, targetName)),
of(modificationsToSelectableItems(fromClaim, targetName)),
])
),
map(([items, unsavedItems]) => [...unsavedItems, ...items])
map(([items, modsFromClaimItems]) => [...modsFromClaimItems, ...items])
);
inProgress$ = progress(this.getSelectableItems$, merge(this.selectableItems$, this.hasError$));
constructor(private partyService: PartyService, private snackBar: MatSnackBar) {}
getSelectableItems(partyID: string, targetName: PartyTarget, unsaved: Modification[]) {
this.getSelectableItems$.next({ partyID, targetName, unsaved });
getSelectableItems(partyID: string, targetName: PartyTarget, fromClaim: Modification[]) {
this.getSelectableItems$.next({ partyID, targetName, fromClaim });
}
private getTarget(

View File

@ -98,7 +98,7 @@ export class UnitActionsNavListComponent implements OnInit {
},
partyID: this.data.partyID,
unitID: this.data.unitID,
unsaved: this.data.unsaved,
fromClaim: this.data.fromClaim,
},
width: '900px',
disableClose: true,

View File

@ -10,7 +10,10 @@ import {
import { map, take } from 'rxjs/operators';
import { PartyModificationCreatorDialogService } from '../../../party-modification-creator';
import { ClaimStatus } from '../../../thrift-services/damsel/gen-model/claim_management';
import {
ClaimChangeset,
ClaimStatus,
} from '../../../thrift-services/damsel/gen-model/claim_management';
import { PartyID } from '../../../thrift-services/damsel/gen-model/domain';
import { UnsavedClaimChangesetService } from '../changeset/unsaved-changeset/unsaved-claim-changeset.service';
import { StatusChangerService } from './status-changer';
@ -31,6 +34,9 @@ export class PartyClaimActionsComponent implements OnInit, OnDestroy {
@Input()
status: ClaimStatus;
@Input()
changeset: ClaimChangeset;
@Output()
changesetUpdated = new EventEmitter();
@ -56,7 +62,10 @@ export class PartyClaimActionsComponent implements OnInit, OnDestroy {
map((infos) => infos.map((info) => info.modification))
)
.subscribe((unsaved) =>
this.partyModificationCreatorDialogService.open(this.partyID, unsaved)
this.partyModificationCreatorDialogService.open(this.partyID, [
...unsaved,
...this.changeset.map((item) => item.modification),
])
);
}

View File

@ -26,6 +26,7 @@
[partyID]="partyID$ | async"
[claimID]="claimID$ | async"
[status]="status$ | async"
[changeset]="changeset$ | async"
(changesetUpdated)="changesetUpdated()"
></cc-party-claim-actions>
</div>