Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
"@angular/router": "^20.1.0",
"@ngneat/input-mask": "^6.1.0",
"@tailwindcss/postcss": "^4.1.11",
"@vality/domain-proto": "^2.0.1-7a97267.0",
"@vality/domain-proto": "^2.0.1-5c25c2e.0",
"@vality/fistful-proto": "^2.0.1-7c61ac5.0",
"@vality/machinegun-proto": "^1.0.1-cc2c27c.0",
"@vality/magista-proto": "^2.0.2-2de1ebf.0",
"@vality/magista-proto": "^2.0.2-6cafe01.0",
"@vality/ng-monaco-editor": "^20.0.0",
"@vality/repairer-proto": "^2.0.2-1a48729.0",
"@vality/scrooge-proto": "^0.1.1-42aba67.0",
Expand Down
9 changes: 8 additions & 1 deletion src/app/parties/parties.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,21 @@ export class PartiesComponent implements OnInit {
field: 'id',
cell: (party) => ({ value: party.ref.id }),
},
{
field: 'name',
cell: (party) => ({
value: party.data.name,
description: party.data.description,
link: () => `/parties/${party.ref.id}`,
}),
},
{
field: 'email',
cell: (party) => ({
value: party.data.contact_info.registration_email,
description: (party.data.contact_info.manager_contact_emails || [])
.filter(Boolean)
.join(', '),
link: () => `/parties/${party.ref.id}`,
}),
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
</button>
</div>
<mat-menu #menu="matMenu">
<button mat-menu-item (click)="editRule(item.idx)">
<button mat-menu-item (click)="advancedEdit(item.idx)">
<mat-icon>edit</mat-icon>
<span>Advanced edit</span>
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export class CandidatesComponent {
private log = inject(NotifyLogService);
private route = inject(ActivatedRoute);
private sidenavInfoService = inject(SidenavInfoService);
private destroyRef = inject(DestroyRef);
private dr = inject(DestroyRef);
protected appMode = inject(AppModeService);
protected domainObjectsStoreService = inject(DomainObjectsStoreService);
private injector = inject(Injector);
Expand Down Expand Up @@ -188,24 +188,10 @@ export class CandidatesComponent {
}, new Map<number, Row[]>());
return Array.from(groups.values())
.map((group) => {
const sum = group.reduce(
(acc, item) =>
acc + (item.candidate.allowed ? item.candidate.weight || 0 : 0),
0,
);
const allowedCount = group.filter((item) => item.allowed).length;
const sum = group.reduce((acc, item) => acc + (item.candidate.weight || 0), 0);
return group.map((item) => {
const weight = item.candidate.weight || 0;
let weightPercent = 0;
if (item.allowed === false) {
weightPercent = 0;
} else if (allowedCount === 1) {
weightPercent = 100;
} else if (sum > 0) {
weightPercent = Math.round((weight / sum) * 100);
} else {
weightPercent = 0;
}
const weightPercent = sum ? Math.round((weight / sum) * 100) : 0;
return {
value: { ...item, weightPercent },
width: weightPercent,
Expand Down Expand Up @@ -269,7 +255,7 @@ export class CandidatesComponent {
predicate: d.allowed,
toggle: () => {
this.getCandidateIdx(d)
.pipe(takeUntilDestroyed(this.destroyRef))
.pipe(takeUntilDestroyed(this.dr))
.subscribe((idx) => {
void this.toggleAllow(idx);
});
Expand All @@ -293,17 +279,17 @@ export class CandidatesComponent {
label: 'Edit',
click: () => {
this.getCandidateIdx(d)
.pipe(takeUntilDestroyed(this.destroyRef))
.pipe(takeUntilDestroyed(this.dr))
.subscribe((idx) => {
this.editRule(idx);
this.advancedEdit(idx);
});
},
},
{
label: 'Duplicate',
click: () => {
this.getCandidateIdx(d)
.pipe(takeUntilDestroyed(this.destroyRef))
.pipe(takeUntilDestroyed(this.dr))
.subscribe((idx) => {
void this.duplicateRule(idx);
});
Expand All @@ -313,7 +299,7 @@ export class CandidatesComponent {
label: getPredicateBoolean(d.allowed) ? 'Deny' : 'Allow',
click: () => {
this.getCandidateIdx(d)
.pipe(takeUntilDestroyed(this.destroyRef))
.pipe(takeUntilDestroyed(this.dr))
.subscribe((idx) => {
void this.toggleAllow(idx);
});
Expand All @@ -323,7 +309,7 @@ export class CandidatesComponent {
label: 'Remove',
click: () => {
this.getCandidateIdx(d)
.pipe(takeUntilDestroyed(this.destroyRef))
.pipe(takeUntilDestroyed(this.dr))
.subscribe((idx) => {
void this.removeRule(idx);
});
Expand All @@ -349,7 +335,7 @@ export class CandidatesComponent {
.afterClosed(),
),
)
.pipe(takeUntilDestroyed(this.destroyRef))
.pipe(takeUntilDestroyed(this.dr))
.subscribe({
next: (res) => {
if (res.status === DialogResponseStatus.Success) {
Expand All @@ -363,7 +349,7 @@ export class CandidatesComponent {
});
}

editRule(idx: number) {
advancedEdit(idx: number) {
this.routingRulesetService.refID$
.pipe(
first(),
Expand All @@ -383,7 +369,7 @@ export class CandidatesComponent {
.afterClosed(),
),
)
.pipe(takeUntilDestroyed(this.destroyRef))
.pipe(takeUntilDestroyed(this.dr))
.subscribe({
next: (res) => {
if (res.status === DialogResponseStatus.Success) {
Expand Down Expand Up @@ -415,7 +401,7 @@ export class CandidatesComponent {
.afterClosed(),
),
)
.pipe(takeUntilDestroyed(this.destroyRef))
.pipe(takeUntilDestroyed(this.dr))
.subscribe({
next: (res) => {
if (res.status === DialogResponseStatus.Success) {
Expand All @@ -430,46 +416,34 @@ export class CandidatesComponent {
}

edit(candidateIdx: number) {
this.routingRulesetService.refID$
combineLatest([this.routingRulesetService.refID$, this.candidates$])
.pipe(
switchCombineWith((refId) => [
this.routingRulesService.getCandidate(refId, candidateIdx),
this.candidates$,
]),
first(),
switchCombineWith(([_, candidate, candidates]) => {
const others = candidates.filter(
(c) => c !== candidate && c.priority === candidate.priority && c.allowed,
);
const ids = others.map((c) => candidates.findIndex((cd) => cd === c));
return [
this.dialog
.open(EditCandidateDialogComponent, {
candidate,
others,
})
.afterClosed(),
ids,
others,
];
}),
switchMap(([[refId], res, ids]) =>
switchCombineWith(([_, candidates]) => [
this.dialog
.open(EditCandidateDialogComponent, {
candidates: candidates
.map((candidate, idx) => ({ idx, candidate }))
.filter(
(c) =>
c.candidate.priority === candidates[candidateIdx].priority,
),
idx: candidateIdx,
})
.afterClosed(),
]),
switchMap(([[refId], res]) =>
res.status === DialogResponseStatus.Success
? this.routingRulesService.updateRules([
{
refId,
candidateIdx: candidateIdx,
newCandidate: res.data.candidate,
},
...res.data.others.map((newCandidate, idx) => ({
? this.routingRulesService.updateRules(
res.data.candidates.map((c) => ({
refId,
candidateIdx: ids[idx],
newCandidate,
candidateIdx: c.idx,
newCandidate: c.candidate,
})),
])
)
: of(null),
),
takeUntilDestroyed(this.destroyRef),
takeUntilDestroyed(this.dr),
)
.subscribe({
next: (res) => {
Expand All @@ -487,7 +461,7 @@ export class CandidatesComponent {
toggleAllow(candidateIdx: number) {
runInInjectionContext(this.injector, () =>
this.routingRulesetService.refID$
.pipe(first(), takeUntilDestroyed(this.destroyRef))
.pipe(first(), takeUntilDestroyed(this.dr))
.subscribe((refId) => {
changeCandidatesAllowed([{ refId, candidateIdx }]);
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,31 @@
<v-input-field formControlName="description" label="Description"></v-input-field>
<div class="flex gap-2">
<v-input-field
[label]="weightTypeControl.value === 'weight' ? 'Weight' : 'Percent'"
class="flex-1"
formControlName="weight"
label="Weight"
type="number"
></v-input-field>
<v-input-field
[formControl]="weightPercentControl"
<v-select-field
[formControl]="weightTypeControl"
[options]="weightOptions"
class="flex-1"
label="Percent"
type="number"
></v-input-field>
label="Type"
></v-select-field>
</div>
<div class="flex flex-col gap-1 -mt-6 mb-6">
<div class="flex flex-wrap gap-2">
@for (item of weightsPreview$ | async; track $index; let isFirst = $first) {
<div
[class.bg-neutral-200]="isFirst"
[class.text-neutral-900]="isFirst"
[title]="item.description"
class="px-2 py-1 border rounded text-sm"
>
{{ item.percent }}
</div>
}
</div>
</div>
<cc-domain-thrift-editor
formControlName="allowed"
Expand Down
Loading
Loading