Merge pull request #11787 from opf/implementation/45214-add-success-notification-toast-after-linking-files-from-op-side

[#45214] added success notification after creating file links
pull/11795/head
Eric Schubert 2 years ago committed by GitHub
commit a9ee223e28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 18
      frontend/src/app/core/state/file-links/file-links.service.ts
  2. 10
      frontend/src/app/shared/components/storages/file-picker-modal/file-picker-modal.component.ts
  3. 3
      modules/storages/config/locales/js-en.yml

@ -29,7 +29,7 @@
import { applyTransaction } from '@datorama/akita';
import { Injectable } from '@angular/core';
import { HttpHeaders } from '@angular/common/http';
import { from } from 'rxjs';
import { from, Observable } from 'rxjs';
import {
groupBy,
mergeMap,
@ -100,7 +100,12 @@ export class FileLinksResourceService extends ResourceCollectionService<IFileLin
);
}
addFileLinks(collectionKey:string, addFileLinksHref:string, storage:IHalResourceLink, filesToLink:IStorageFile[]):void {
addFileLinks(
collectionKey:string,
addFileLinksHref:string,
storage:IHalResourceLink,
filesToLink:IStorageFile[],
):Observable<IHALCollection<IFileLink>> {
const elements = filesToLink.map((file) => ({
originData: {
id: file.id,
@ -115,10 +120,10 @@ export class FileLinksResourceService extends ResourceCollectionService<IFileLin
_links: { storage },
}));
this.http
return this.http
.post<IHALCollection<IFileLink>>(addFileLinksHref, { _type: 'Collection', _embedded: { elements } })
.subscribe(
(collection) => {
.pipe(
tap((collection) => {
applyTransaction(() => {
const newFileLinks = collection._embedded.elements;
this.store.add(newFileLinks);
@ -136,8 +141,7 @@ export class FileLinksResourceService extends ResourceCollectionService<IFileLin
),
);
});
},
this.toastAndThrow.bind(this),
}),
);
}

@ -38,8 +38,9 @@ import { take } from 'rxjs/operators';
import { I18nService } from 'core-app/core/i18n/i18n.service';
import { TimezoneService } from 'core-app/core/datetime/timezone.service';
import { IFileLink } from 'core-app/core/state/file-links/file-link.model';
import { IStorageFile } from 'core-app/core/state/storage-files/storage-file.model';
import { ToastService } from 'core-app/shared/components/toaster/toast.service';
import { OpModalLocalsMap } from 'core-app/shared/components/modal/modal.types';
import { IStorageFile } from 'core-app/core/state/storage-files/storage-file.model';
import { OpModalLocalsToken } from 'core-app/shared/components/modal/modal.service';
import { SortFilesPipe } from 'core-app/shared/components/storages/pipes/sort-files.pipe';
import { StorageFilesResourceService } from 'core-app/core/state/storage-files/storage-files.service';
@ -69,6 +70,9 @@ export class FilePickerModalComponent extends FilePickerBaseModalComponent {
alreadyLinkedFile: this.i18n.t('js.storages.file_links.already_linked_file'),
alreadyLinkedDirectory: this.i18n.t('js.storages.file_links.already_linked_directory'),
},
toast: {
successFileLinksCreated: (count:number):string => this.i18n.t('js.storages.file_links.success_create', { count }),
},
};
public get selectedFileCount():number {
@ -86,6 +90,7 @@ export class FilePickerModalComponent extends FilePickerBaseModalComponent {
protected readonly sortFilesPipe:SortFilesPipe,
protected readonly storageFilesResourceService:StorageFilesResourceService,
private readonly i18n:I18nService,
private readonly toastService:ToastService,
private readonly timezoneService:TimezoneService,
private readonly fileLinksResourceService:FileLinksResourceService,
) {
@ -105,6 +110,9 @@ export class FilePickerModalComponent extends FilePickerBaseModalComponent {
this.locals.addFileLinksHref as string,
this.storageLink,
files,
).subscribe(
(fileLinks) => { this.toastService.addSuccess(this.text.toast.successFileLinksCreated(fileLinks.count)); },
(error) => { this.toastService.addError(error); },
);
this.service.close();

@ -42,6 +42,9 @@ en:
zero: "Select files to link"
one: "Link 1 file"
other: "Link %{count} files"
success_create:
one: "Successfully created 1 file link."
other: "Successfully created %{count} file links."
not_allowed_tooltip: "Please log in to Nextcloud to access this file"
already_linked_file: "This file is already linked to this work package."
already_linked_directory: "This directory is already linked to this work package."

Loading…
Cancel
Save