RED-3800 small rename
This commit is contained in:
parent
532ee9fa06
commit
cc789aabf0
@ -1,7 +1,6 @@
|
|||||||
import { computed, effect, Injectable, Injector, Signal } from '@angular/core';
|
import { computed, effect, inject, Injectable, Signal } from '@angular/core';
|
||||||
import { firstValueFrom, from, merge, Observable, of, pairwise, Subject, switchMap } from 'rxjs';
|
import { firstValueFrom, from, merge, Observable, of, pairwise, Subject, switchMap } from 'rxjs';
|
||||||
import { Dictionary, Dossier, DOSSIER_ID, DOSSIER_TEMPLATE_ID, File, FILE_ID } from '@red/domain';
|
import { Dictionary, Dossier, DOSSIER_ID, DOSSIER_TEMPLATE_ID, File, FILE_ID } from '@red/domain';
|
||||||
import { Router } from '@angular/router';
|
|
||||||
import { FilesMapService } from '@services/files/files-map.service';
|
import { FilesMapService } from '@services/files/files-map.service';
|
||||||
import { PermissionsService } from '@services/permissions.service';
|
import { PermissionsService } from '@services/permissions.service';
|
||||||
import { getParam, LoadingService, wipeCache } from '@iqser/common-ui';
|
import { getParam, LoadingService, wipeCache } from '@iqser/common-ui';
|
||||||
@ -34,7 +33,6 @@ function isDownload(event: HttpEvent<Blob>): event is HttpProgressEvent {
|
|||||||
export class FilePreviewStateService {
|
export class FilePreviewStateService {
|
||||||
readonly file$: Observable<File>;
|
readonly file$: Observable<File>;
|
||||||
readonly file: Signal<File>;
|
readonly file: Signal<File>;
|
||||||
readonly dossier$: Observable<Dossier>;
|
|
||||||
readonly dossier: Signal<Dossier>;
|
readonly dossier: Signal<Dossier>;
|
||||||
readonly isReadonly: Signal<boolean>;
|
readonly isReadonly: Signal<boolean>;
|
||||||
readonly isWritable: Signal<boolean>;
|
readonly isWritable: Signal<boolean>;
|
||||||
@ -54,23 +52,17 @@ export class FilePreviewStateService {
|
|||||||
// );
|
// );
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
router: Router,
|
|
||||||
private readonly _filesMapService: FilesMapService,
|
|
||||||
private readonly _injector: Injector,
|
|
||||||
private readonly _permissionsService: PermissionsService,
|
private readonly _permissionsService: PermissionsService,
|
||||||
private readonly _filesService: FilesService,
|
private readonly _filesService: FilesService,
|
||||||
private readonly _dossiersService: DossiersService,
|
private readonly _dossiersService: DossiersService,
|
||||||
private readonly _fileManagementService: FileManagementService,
|
private readonly _fileManagementService: FileManagementService,
|
||||||
private readonly _dossierDictionariesMapService: DossierDictionariesMapService,
|
|
||||||
private readonly _dictionariesMapService: DictionariesMapService,
|
private readonly _dictionariesMapService: DictionariesMapService,
|
||||||
private readonly _translateService: TranslateService,
|
private readonly _translateService: TranslateService,
|
||||||
private readonly _loadingService: LoadingService,
|
private readonly _loadingService: LoadingService,
|
||||||
private readonly _viewModeService: ViewModeService,
|
private readonly _viewModeService: ViewModeService,
|
||||||
) {
|
) {
|
||||||
const dossiersService = dossiersServiceResolver(_injector, router);
|
this.dossier = toSignal(dossiersServiceResolver().getEntityChanged$(this.dossierId));
|
||||||
this.dossier$ = dossiersService.getEntityChanged$(this.dossierId);
|
this.file$ = inject(FilesMapService).watch$(this.dossierId, this.fileId);
|
||||||
this.dossier = toSignal(this.dossier$);
|
|
||||||
this.file$ = _filesMapService.watch$(this.dossierId, this.fileId);
|
|
||||||
this.file = toSignal(this.file$);
|
this.file = toSignal(this.file$);
|
||||||
// this.file$ = combineLatest([this.isAttached, file$]).pipe(
|
// this.file$ = combineLatest([this.isAttached, file$]).pipe(
|
||||||
// filter(([isAttached]) => isAttached),
|
// filter(([isAttached]) => isAttached),
|
||||||
@ -83,7 +75,7 @@ export class FilePreviewStateService {
|
|||||||
|
|
||||||
this.blob$ = this.#blob$;
|
this.blob$ = this.#blob$;
|
||||||
|
|
||||||
this.dossierDictionary = toSignal(this._dossierDictionariesMapService.watch$(this.dossierId, 'dossier_redaction'));
|
this.dossierDictionary = toSignal(inject(DossierDictionariesMapService).watch$(this.dossierId, 'dossier_redaction'));
|
||||||
this.#dossierFileChange = toSignal(this.#dossierFilesChange$);
|
this.#dossierFileChange = toSignal(this.#dossierFilesChange$);
|
||||||
effect(() => {
|
effect(() => {
|
||||||
if (this.#dossierFileChange()) {
|
if (this.#dossierFileChange()) {
|
||||||
|
|||||||
@ -42,9 +42,8 @@ export class EditorComponent implements OnInit, OnChanges {
|
|||||||
editorOptions: IStandaloneEditorConstructionOptions = {};
|
editorOptions: IStandaloneEditorConstructionOptions = {};
|
||||||
codeEditor: ICodeEditor;
|
codeEditor: ICodeEditor;
|
||||||
value: string;
|
value: string;
|
||||||
protected _initialEntriesMap = new Set<string>();
|
|
||||||
|
|
||||||
protected readonly _editorTextChanged$ = new Subject<string>();
|
protected readonly _editorTextChanged$ = new Subject<string>();
|
||||||
|
#initialEntriesSet = new Set<string>();
|
||||||
private _diffEditor: IDiffEditor;
|
private _diffEditor: IDiffEditor;
|
||||||
private _decorations: string[] = [];
|
private _decorations: string[] = [];
|
||||||
|
|
||||||
@ -120,7 +119,7 @@ export class EditorComponent implements OnInit, OnChanges {
|
|||||||
|
|
||||||
revert() {
|
revert() {
|
||||||
this.value = this.initialEntries.join('\n');
|
this.value = this.initialEntries.join('\n');
|
||||||
this._initialEntriesMap = new Set<string>(this.initialEntries);
|
this.#initialEntriesSet = new Set<string>(this.initialEntries);
|
||||||
this.diffValue = this.value;
|
this.diffValue = this.value;
|
||||||
this._diffEditor?.getModifiedEditor().setValue(this.diffValue);
|
this._diffEditor?.getModifiedEditor().setValue(this.diffValue);
|
||||||
this._editorTextChanged$.next(this.value);
|
this._editorTextChanged$.next(this.value);
|
||||||
@ -136,7 +135,7 @@ export class EditorComponent implements OnInit, OnChanges {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._initialEntriesMap.has(entry)) {
|
if (this.#initialEntriesSet.has(entry)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { Injector, ProviderToken } from '@angular/core';
|
import { inject, Injector, ProviderToken } from '@angular/core';
|
||||||
import { DossiersService } from '../dossiers/dossiers.service';
|
import { DossiersService } from '../dossiers/dossiers.service';
|
||||||
|
|
||||||
/** Usage in components or services is only allowed in guards or in constructors.
|
/** Usage in components or services is only allowed in guards or in constructors.
|
||||||
* Otherwise, it causes errors on navigation to other screens if the component is reused. */
|
* Otherwise, it causes errors on navigation to other screens if the component is reused. */
|
||||||
export const dossiersServiceResolver = (injector: Injector, router: Router) => {
|
export const dossiersServiceResolver = (injector = inject(Injector), router = inject(Router)) => {
|
||||||
let route = router.routerState.root;
|
let route = router.routerState.root;
|
||||||
while (route.firstChild) {
|
while (route.firstChild) {
|
||||||
route = route.firstChild;
|
route = route.firstChild;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user