Update not found text, support create field from select
This commit is contained in:
parent
4d6d95f0fb
commit
e06a98da37
@ -13,6 +13,8 @@
|
|||||||
bindLabel="name"
|
bindLabel="name"
|
||||||
[(ngModel)]="field"
|
[(ngModel)]="field"
|
||||||
[placeholder]="placeholderText"
|
[placeholder]="placeholderText"
|
||||||
|
[notFoundText]="notFoundText"
|
||||||
|
(createNew)="createField($event)"
|
||||||
bindValue="id">
|
bindValue="id">
|
||||||
</pngx-input-select>
|
</pngx-input-select>
|
||||||
<div class="btn-toolbar" role="toolbar">
|
<div class="btn-toolbar" role="toolbar">
|
||||||
|
@ -124,4 +124,14 @@ describe('CustomFieldsDropdownComponent', () => {
|
|||||||
expect(toastInfoSpy).toHaveBeenCalled()
|
expect(toastInfoSpy).toHaveBeenCalled()
|
||||||
expect(getFieldsSpy).toHaveBeenCalled()
|
expect(getFieldsSpy).toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should support creating field with name', () => {
|
||||||
|
let modal: NgbModalRef
|
||||||
|
modalService.activeInstances.subscribe((m) => (modal = m[m.length - 1]))
|
||||||
|
component.createField('Foo bar')
|
||||||
|
|
||||||
|
expect(modal).not.toBeUndefined()
|
||||||
|
const editDialog = modal.componentInstance as CustomFieldEditDialogComponent
|
||||||
|
expect(editDialog.object.name).toEqual('Foo bar')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
@ -44,6 +44,10 @@ export class CustomFieldsDropdownComponent implements OnDestroy {
|
|||||||
return $localize`Choose field`
|
return $localize`Choose field`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get notFoundText(): string {
|
||||||
|
return $localize`No unused fields found`
|
||||||
|
}
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private customFieldsService: CustomFieldsService,
|
private customFieldsService: CustomFieldsService,
|
||||||
private modalService: NgbModal,
|
private modalService: NgbModal,
|
||||||
@ -82,8 +86,9 @@ export class CustomFieldsDropdownComponent implements OnDestroy {
|
|||||||
this.added.emit(this.customFields.find((f) => f.id === this.field))
|
this.added.emit(this.customFields.find((f) => f.id === this.field))
|
||||||
}
|
}
|
||||||
|
|
||||||
createField() {
|
createField(newName: string = null) {
|
||||||
const modal = this.modalService.open(CustomFieldEditDialogComponent)
|
const modal = this.modalService.open(CustomFieldEditDialogComponent)
|
||||||
|
if (newName) modal.componentInstance.object = { name: newName }
|
||||||
modal.componentInstance.succeeded
|
modal.componentInstance.succeeded
|
||||||
.pipe(takeUntil(this.unsubscribeNotifier))
|
.pipe(takeUntil(this.unsubscribeNotifier))
|
||||||
.subscribe((newField) => {
|
.subscribe((newField) => {
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
</svg> <ng-container i18n>Remove</ng-container>
|
</svg> <ng-container i18n>Remove</ng-container>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div [class.col-md-9]="horizontal">
|
<div [ngClass]="{'col-md-9': horizontal, 'align-items-center': horizontal, 'd-flex': horizontal}">
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
<input #inputField type="checkbox" class="form-check-input" [id]="inputId" [(ngModel)]="value" (change)="onChange(value)" (blur)="onTouched()" [disabled]="disabled">
|
<input #inputField type="checkbox" class="form-check-input" [id]="inputId" [(ngModel)]="value" (change)="onChange(value)" (blur)="onTouched()" [disabled]="disabled">
|
||||||
<label *ngIf="!horizontal" class="form-check-label" [for]="inputId">{{title}}</label>
|
<label *ngIf="!horizontal" class="form-check-label" [for]="inputId">{{title}}</label>
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
addTagText="Add item"
|
addTagText="Add item"
|
||||||
i18n-addTagText="Used for both types, correspondents, storage paths"
|
i18n-addTagText="Used for both types, correspondents, storage paths"
|
||||||
[placeholder]="placeholder"
|
[placeholder]="placeholder"
|
||||||
|
[notFoundText]="notFoundText"
|
||||||
[multiple]="multiple"
|
[multiple]="multiple"
|
||||||
[bindLabel]="bindLabel"
|
[bindLabel]="bindLabel"
|
||||||
bindValue="id"
|
bindValue="id"
|
||||||
|
@ -88,6 +88,9 @@ export class SelectComponent extends AbstractInputComponent<number> {
|
|||||||
@Input()
|
@Input()
|
||||||
showFilter: boolean = false
|
showFilter: boolean = false
|
||||||
|
|
||||||
|
@Input()
|
||||||
|
notFoundText: string = $localize`No items found`
|
||||||
|
|
||||||
@Output()
|
@Output()
|
||||||
createNew = new EventEmitter<string>()
|
createNew = new EventEmitter<string>()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user