Fixhancement: tag plus button should add tag to doc (#9762)

This commit is contained in:
shamoon 2025-04-22 08:02:55 -07:00 committed by GitHub
parent fcb7349e8e
commit 15d4ac8ba2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 9 additions and 8 deletions

View File

@ -405,7 +405,7 @@ describe('GlobalSearchComponent', () => {
expect(toastErrorSpy).toHaveBeenCalled() expect(toastErrorSpy).toHaveBeenCalled()
// succeed // succeed
editDialog.succeeded.emit(true) editDialog.succeeded.emit(object as any)
expect(toastInfoSpy).toHaveBeenCalled() expect(toastInfoSpy).toHaveBeenCalled()
}) })
@ -456,7 +456,7 @@ describe('GlobalSearchComponent', () => {
expect(toastErrorSpy).toHaveBeenCalled() expect(toastErrorSpy).toHaveBeenCalled()
// succeed // succeed
editDialog.succeeded.emit(true) editDialog.succeeded.emit(searchResults.tags[0] as any)
expect(toastInfoSpy).toHaveBeenCalled() expect(toastInfoSpy).toHaveBeenCalled()
}) })

View File

@ -47,7 +47,7 @@ export abstract class EditDialogComponent<
object: T object: T
@Output() @Output()
succeeded = new EventEmitter() succeeded = new EventEmitter<T>()
@Output() @Output()
failed = new EventEmitter() failed = new EventEmitter()

View File

@ -33,7 +33,7 @@
</ng-template> </ng-template>
</ng-select> </ng-select>
@if (allowCreate && !hideAddButton) { @if (allowCreate && !hideAddButton) {
<button class="btn btn-outline-secondary" type="button" (click)="createTag()" [disabled]="disabled"> <button class="btn btn-outline-secondary" type="button" (click)="createTag(null, true)" [disabled]="disabled">
<i-bs width="1.2em" height="1.2em" name="plus"></i-bs> <i-bs width="1.2em" height="1.2em" name="plus"></i-bs>
</button> </button>
} }

View File

@ -130,7 +130,7 @@ export class TagsComponent implements OnInit, ControlValueAccessor {
} }
} }
createTag(name: string = null) { createTag(name: string = null, add: boolean = false) {
var modal = this.modalService.open(TagEditDialogComponent, { var modal = this.modalService.open(TagEditDialogComponent, {
backdrop: 'static', backdrop: 'static',
}) })
@ -143,9 +143,10 @@ export class TagsComponent implements OnInit, ControlValueAccessor {
return firstValueFrom( return firstValueFrom(
(modal.componentInstance as TagEditDialogComponent).succeeded.pipe( (modal.componentInstance as TagEditDialogComponent).succeeded.pipe(
first(), first(),
tap(() => { tap((newTag) => {
this.tagService.listAll().subscribe((tags) => { this.tagService.listAll().subscribe((tags) => {
this.tags = tags.results this.tags = tags.results
add && this.addTag(newTag.id)
}) })
}) })
) )

View File

@ -188,7 +188,7 @@ describe('MailComponent', () => {
const toastInfoSpy = jest.spyOn(toastService, 'showInfo') const toastInfoSpy = jest.spyOn(toastService, 'showInfo')
editDialog.failed.emit() editDialog.failed.emit()
expect(toastErrorSpy).toBeCalled() expect(toastErrorSpy).toBeCalled()
editDialog.succeeded.emit(mailAccounts[0]) editDialog.succeeded.emit(mailAccounts[0] as any)
expect(toastInfoSpy).toHaveBeenCalledWith( expect(toastInfoSpy).toHaveBeenCalledWith(
`Saved account "${mailAccounts[0].name}".` `Saved account "${mailAccounts[0].name}".`
) )
@ -246,7 +246,7 @@ describe('MailComponent', () => {
const toastInfoSpy = jest.spyOn(toastService, 'showInfo') const toastInfoSpy = jest.spyOn(toastService, 'showInfo')
editDialog.failed.emit() editDialog.failed.emit()
expect(toastErrorSpy).toBeCalled() expect(toastErrorSpy).toBeCalled()
editDialog.succeeded.emit(mailRules[0]) editDialog.succeeded.emit(mailRules[0] as any)
expect(toastInfoSpy).toHaveBeenCalledWith( expect(toastInfoSpy).toHaveBeenCalledWith(
`Saved rule "${mailRules[0].name}".` `Saved rule "${mailRules[0].name}".`
) )