Merge branch 'master' of ssh://git.iqser.com:2222/sl/common-ui
This commit is contained in:
commit
b35ed3f2f2
@ -1,6 +1,6 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { BehaviorSubject, Observable, Subject } from 'rxjs';
|
||||
import { filter, startWith } from 'rxjs/operators';
|
||||
import { BehaviorSubject, Observable, Subject, switchMap } from 'rxjs';
|
||||
import { filter, map, startWith } from 'rxjs/operators';
|
||||
import { Entity } from '../listing';
|
||||
import { RequiredParam, shareLast, Validate } from '../utils';
|
||||
import { Id } from '../listing/models/trackable';
|
||||
@ -11,6 +11,7 @@ export abstract class EntitiesMapService<Interface, Class extends Entity<Interfa
|
||||
|
||||
protected readonly _map = new Map<Id, BehaviorSubject<Class[]>>();
|
||||
readonly #entityChanged$ = new Subject<Class>();
|
||||
readonly #entitiesChanged$ = new BehaviorSubject<boolean>(false);
|
||||
readonly #entityDeleted$ = new Subject<Class>();
|
||||
|
||||
get empty(): boolean {
|
||||
@ -68,6 +69,10 @@ export abstract class EntitiesMapService<Interface, Class extends Entity<Interfa
|
||||
|
||||
// Emit observables only after entities have been updated
|
||||
|
||||
if(changedEntities.length || deletedEntities.length) {
|
||||
this.#entitiesChanged$.next(true);
|
||||
}
|
||||
|
||||
for (const entity of changedEntities) {
|
||||
this.#entityChanged$.next(entity);
|
||||
}
|
||||
@ -105,6 +110,15 @@ export abstract class EntitiesMapService<Interface, Class extends Entity<Interfa
|
||||
);
|
||||
}
|
||||
|
||||
@Validate()
|
||||
watchChanged$(@RequiredParam() key: Id): Observable<boolean> {
|
||||
return this.#entityChanged$.pipe(
|
||||
startWith(this.get(key)),
|
||||
map(entities => entities as Class[]),
|
||||
map(entities => !!entities.length)
|
||||
);
|
||||
}
|
||||
|
||||
watchDeleted$(entityId: Id): Observable<Class> {
|
||||
return this.#entityDeleted$.pipe(filter(entity => entity.id === entityId));
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
<div (click)="triggerAttachFile()" (fileDropped)="attachFile($event)" *ngIf="!file" class="upload-area" iqserDragDropFileUpload>
|
||||
<mat-icon svgIcon="iqser:upload"></mat-icon>
|
||||
|
||||
<div translate="import-redactions-dialog.upload-area-text"></div>
|
||||
<div translate="upload-file.upload-area-text"></div>
|
||||
</div>
|
||||
<div *ngIf="file" class="file-area">
|
||||
<mat-icon svgIcon="iqser:document"></mat-icon>
|
||||
|
||||
@ -3,12 +3,13 @@ import { UploadFileComponent } from './upload-file.component';
|
||||
import { DragDropFileUploadDirective } from './drag-drop-file-upload.directive';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
|
||||
const components = [UploadFileComponent, DragDropFileUploadDirective];
|
||||
|
||||
@NgModule({
|
||||
declarations: [...components],
|
||||
exports: [...components],
|
||||
imports: [MatIconModule, CommonModule],
|
||||
imports: [MatIconModule, CommonModule, TranslateModule]
|
||||
})
|
||||
export class IqserUploadFileModule {}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user