Hook up remove

This commit is contained in:
shamoon 2025-03-01 11:40:14 -08:00
parent 9de605d2e6
commit 04504c3d42
4 changed files with 24 additions and 7 deletions

View File

@ -189,7 +189,11 @@
<pngx-input-select i18n-title title="Assign correspondent" [items]="correspondents" [allowNull]="true" formControlName="assign_correspondent"></pngx-input-select>
<pngx-input-select i18n-title title="Assign storage path" [items]="storagePaths" [allowNull]="true" formControlName="assign_storage_path"></pngx-input-select>
<pngx-input-select i18n-title title="Assign custom fields" multiple="true" [items]="customFields" [allowNull]="true" formControlName="assign_custom_fields"></pngx-input-select>
<pngx-input-custom-fields-values i18n-title title="Assign custom field values" [selectedFields]="formGroup.get('assign_custom_fields').value" formControlName="assign_custom_fields_values"></pngx-input-custom-fields-values>
<pngx-input-custom-fields-values
i18n-title title="Assign custom field values"
formControlName="assign_custom_fields_values"
[selectedFields]="formGroup.get('assign_custom_fields').value"
(removeSelectedField)="removeSelectedCustomField($event, formGroup)"></pngx-input-custom-fields-values>
</div>
<div class="col">
<pngx-input-select i18n-title title="Assign owner" [items]="users" bindLabel="username" formControlName="assign_owner" [allowNull]="true"></pngx-input-select>

View File

@ -654,4 +654,12 @@ export class WorkflowEditDialogComponent
public getCustomField(id: number): CustomField {
return this.customFields.find((field) => field.id === id)
}
public removeSelectedCustomField(fieldId: number, group: FormGroup) {
group
.get('assign_custom_fields')
.setValue(
group.get('assign_custom_fields').value.filter((id) => id !== fieldId)
)
}
}

View File

@ -69,7 +69,7 @@
[horizontal]="true"></pngx-input-select>
}
}
<button type="button" class="btn btn-link text-danger" (click)="removeField(fieldId)">
<button type="button" class="btn btn-link text-danger" (click)="removeSelectedField.next(fieldId)">
<i-bs name="trash"></i-bs>
</button>
</div>

View File

@ -1,4 +1,10 @@
import { Component, forwardRef, Input } from '@angular/core'
import {
Component,
EventEmitter,
forwardRef,
Input,
Output,
} from '@angular/core'
import {
FormsModule,
NG_VALUE_ACCESSOR,
@ -75,11 +81,10 @@ export class CustomFieldsValuesComponent extends AbstractInputComponent<Object>
return this._selectedFields
}
@Output()
public removeSelectedField: EventEmitter<number> = new EventEmitter<number>()
public getCustomField(id: number): CustomField {
return this.fields.find((field) => field.id === id)
}
public removeField(fieldId: number): void {
this.selectedFields = this.selectedFields.filter((id) => id !== fieldId)
}
}