RED-9788 - Adapt Annotation column to display only annotations per component if component is selected
This commit is contained in:
parent
e78dcff3a7
commit
fcba520003
@ -3,11 +3,11 @@ import { KeyValuePipe, NgClass, NgForOf, NgIf } from '@angular/common';
|
||||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { MatIcon } from '@angular/material/icon';
|
||||
import { FilterService } from '@common-ui/filtering';
|
||||
import { CircleButtonComponent, IconButtonComponent, IconButtonTypes, IqserDialog } from '@iqser/common-ui';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { IComponentLogEntry, IComponentValue } from '@red/domain';
|
||||
import { RevertValueDialogComponent } from '../../dialogs/docu-mine/revert-value-dialog/revert-value-dialog.component';
|
||||
import { FilePreviewStateService } from '../../services/file-preview-state.service';
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-editable-structured-component-value [entry] [canEdit]',
|
||||
@ -43,8 +43,8 @@ export class EditableStructuredComponentValueComponent implements OnInit {
|
||||
selected = false;
|
||||
|
||||
constructor(
|
||||
private readonly _filtersService: FilterService,
|
||||
private readonly _iqserDialog: IqserDialog,
|
||||
private readonly _state: FilePreviewStateService,
|
||||
) {}
|
||||
|
||||
get disabled() {
|
||||
@ -91,7 +91,7 @@ export class EditableStructuredComponentValueComponent implements OnInit {
|
||||
}
|
||||
this.deselectLast.emit();
|
||||
this.selected = true;
|
||||
this.#setWorkloadFilters();
|
||||
this._state.componentReferenceIds = this.#getUniqueReferencesIds(this.entry.componentValues);
|
||||
}
|
||||
}
|
||||
|
||||
@ -106,7 +106,7 @@ export class EditableStructuredComponentValueComponent implements OnInit {
|
||||
$event?.stopImmediatePropagation();
|
||||
this.selected = false;
|
||||
this.editing = false;
|
||||
this._filtersService.deactivateFilters({ primaryFiltersSlug: 'primaryFilters' });
|
||||
this._state.componentReferenceIds = null;
|
||||
}
|
||||
|
||||
removeValue(index: number) {
|
||||
@ -150,41 +150,14 @@ export class EditableStructuredComponentValueComponent implements OnInit {
|
||||
return value.replace(/\n/g, '<br>');
|
||||
}
|
||||
|
||||
#setWorkloadFilters() {
|
||||
this._filtersService.deactivateFilters({ primaryFiltersSlug: 'primaryFilters' });
|
||||
const uniqueLabels = this.#getUniqueReferencesLabels(this.entry.componentValues);
|
||||
let setFilterCount = 0;
|
||||
for (const label of uniqueLabels) {
|
||||
const setFilter = this.#setFilter(label);
|
||||
if (setFilter) {
|
||||
setFilterCount++;
|
||||
}
|
||||
}
|
||||
if (!setFilterCount) {
|
||||
this.#setFilter('no-annotations-filter');
|
||||
}
|
||||
}
|
||||
|
||||
#setFilter(label: string) {
|
||||
const filterGroup = this._filtersService.getGroup('primaryFilters');
|
||||
for (const filter of filterGroup.filters) {
|
||||
const nestedFilter = filter.children.find(f => f.label.toLowerCase() === label);
|
||||
if (nestedFilter) {
|
||||
this._filtersService.filterCheckboxClicked({ nestedFilter, filterGroup, primaryFiltersSlug: 'primaryFilters' });
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#getUniqueReferencesLabels(values: IComponentValue[]) {
|
||||
const labels: Set<string> = new Set();
|
||||
#getUniqueReferencesIds(values: IComponentValue[]) {
|
||||
const ids: Set<string> = new Set();
|
||||
for (const value of values) {
|
||||
for (const reference of value.entityReferences) {
|
||||
const label = reference.type?.replace(/_/g, ' ')?.toLowerCase();
|
||||
labels.add(label);
|
||||
ids.add(reference.id);
|
||||
}
|
||||
}
|
||||
return labels;
|
||||
return Array.from(ids);
|
||||
}
|
||||
|
||||
#updateTextAreaHeight() {
|
||||
|
||||
@ -186,7 +186,7 @@
|
||||
</ng-container>
|
||||
|
||||
<ng-container
|
||||
*ngIf="(fileDataService.allLength$ | async) === 0 || filterService.noAnnotationsFilterChecked"
|
||||
*ngIf="(fileDataService.allLength$ | async) === 0 || state.componentReferenceIds?.length === 0"
|
||||
>
|
||||
{{ 'file-preview.tabs.annotations.no-annotations' | translate }}
|
||||
</ng-container>
|
||||
|
||||
@ -20,7 +20,7 @@ import { AutoUnsubscribe, Debounce, IqserEventTarget } from '@iqser/common-ui/li
|
||||
import { AnnotationWrapper } from '@models/file/annotation.wrapper';
|
||||
import { ListItem } from '@models/file/list-item';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { WorkflowFileStatuses } from '@red/domain';
|
||||
import { ComponentLogEntry, WorkflowFileStatuses } from '@red/domain';
|
||||
import { workloadTranslations } from '@translations/workload-translations';
|
||||
import { UserPreferenceService } from '@users/user-preference.service';
|
||||
import { getLocalStorageDataByFileId } from '@utils/local-storage';
|
||||
@ -176,11 +176,14 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On
|
||||
this.fileDataService.all$,
|
||||
primary$,
|
||||
secondary$,
|
||||
this.state.componentReferenceIds$,
|
||||
this.listingService.selected$,
|
||||
this._pageRotationService.rotations$,
|
||||
]).pipe(
|
||||
delay(0),
|
||||
map(([annotations, primary, secondary]) => this.#filterAnnotations(annotations, primary, secondary)),
|
||||
map(([annotations, primary, secondary, componentReferenceIds]) =>
|
||||
this.#filterAnnotations(annotations, primary, secondary, componentReferenceIds),
|
||||
),
|
||||
map(annotations => this.#mapListItemsFromAnnotationWrapperArray(annotations)),
|
||||
tap(annotations => this.#scrollToFirstAnnotationPage(annotations)),
|
||||
);
|
||||
@ -399,6 +402,7 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On
|
||||
annotations: AnnotationWrapper[],
|
||||
primary: INestedFilter[],
|
||||
secondary: INestedFilter[] = [],
|
||||
componentReferenceIds: string[],
|
||||
): Map<number, AnnotationWrapper[]> {
|
||||
const onlyPageWithAnnotations = this.viewModeService.onlyPagesWithAnnotations();
|
||||
if (!primary || primary.length === 0) {
|
||||
@ -410,8 +414,13 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On
|
||||
annotations = annotations.filter(a => !a.isRemoved);
|
||||
}
|
||||
|
||||
if (this.isDocumine && !this.#isIqserDevMode) {
|
||||
annotations = annotations.filter(a => !a.isOCR);
|
||||
if (this.isDocumine) {
|
||||
if (!this.#isIqserDevMode) {
|
||||
annotations = annotations.filter(a => !a.isOCR);
|
||||
}
|
||||
if (componentReferenceIds) {
|
||||
annotations = annotations.filter(a => componentReferenceIds.includes(a.id));
|
||||
}
|
||||
}
|
||||
|
||||
this.displayedAnnotations = this._annotationProcessingService.filterAndGroupAnnotations(annotations, primary, secondary);
|
||||
@ -424,7 +433,7 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On
|
||||
this.displayedPages = [];
|
||||
}
|
||||
this.displayedAnnotations.clear();
|
||||
} else if (enabledFilters.length || onlyPageWithAnnotations) {
|
||||
} else if (enabledFilters.length || onlyPageWithAnnotations || componentReferenceIds) {
|
||||
this.displayedPages = pagesThatDisplayAnnotations;
|
||||
} else {
|
||||
this.displayedPages = this.#allPages;
|
||||
|
||||
@ -3,7 +3,6 @@ import { List } from '@common-ui/utils';
|
||||
import { IconButtonTypes, LoadingService } from '@iqser/common-ui';
|
||||
import { ComponentLogEntry, Dictionary, File, IComponentLogEntry, WorkflowFileStatuses } from '@red/domain';
|
||||
import { ComponentLogService } from '@services/files/component-log.service';
|
||||
import { UserPreferenceService } from '@users/user-preference.service';
|
||||
import { combineLatest, firstValueFrom, Observable } from 'rxjs';
|
||||
import { EditableStructuredComponentValueComponent } from '../editable-structured-component-value/editable-structured-component-value.component';
|
||||
import { FilterService, PopupFilterComponent } from '@common-ui/filtering';
|
||||
@ -23,7 +22,6 @@ import { TranslateModule } from '@ngx-translate/core';
|
||||
export class StructuredComponentManagementComponent implements OnInit {
|
||||
protected readonly componentLogData = signal<ComponentLogEntry[] | undefined>(undefined);
|
||||
protected readonly componentLogData$ = toObservable(this.componentLogData);
|
||||
protected readonly openScmDialogByDefault = signal(this.userPreferences.getOpenScmDialogByDefault());
|
||||
protected readonly iconButtonTypes = IconButtonTypes;
|
||||
protected displayedComponents$: Observable<ComponentLogEntry[]>;
|
||||
@Input() file: File;
|
||||
@ -35,7 +33,6 @@ export class StructuredComponentManagementComponent implements OnInit {
|
||||
private readonly _loadingService: LoadingService,
|
||||
private readonly _componentLogFilterService: ComponentLogFilterService,
|
||||
private readonly _filterService: FilterService,
|
||||
readonly userPreferences: UserPreferenceService,
|
||||
) {}
|
||||
|
||||
get canEdit() {
|
||||
@ -54,12 +51,6 @@ export class StructuredComponentManagementComponent implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
async toggleOpenScmDialogByDefault() {
|
||||
await this.userPreferences.toggleOpenScmDialogByDefault();
|
||||
await this.userPreferences.reload();
|
||||
this.openScmDialogByDefault.set(this.userPreferences.getOpenScmDialogByDefault());
|
||||
}
|
||||
|
||||
async revertOverride(originalKey: string) {
|
||||
this._loadingService.start();
|
||||
await firstValueFrom(
|
||||
|
||||
@ -14,7 +14,7 @@ import { FilesMapService } from '@services/files/files-map.service';
|
||||
import { FilesService } from '@services/files/files.service';
|
||||
import { PermissionsService } from '@services/permissions.service';
|
||||
import { NGXLogger } from 'ngx-logger';
|
||||
import { firstValueFrom, from, merge, Observable, of, pairwise, Subject, switchMap } from 'rxjs';
|
||||
import { BehaviorSubject, firstValueFrom, from, merge, Observable, of, pairwise, Subject, switchMap } from 'rxjs';
|
||||
import { filter, map, startWith, tap, withLatestFrom } from 'rxjs/operators';
|
||||
import { ViewModeService } from './view-mode.service';
|
||||
|
||||
@ -41,6 +41,8 @@ export class FilePreviewStateService {
|
||||
readonly isWritable: Signal<boolean>;
|
||||
readonly dossierDictionary: Signal<Dictionary>;
|
||||
readonly blob$: Observable<Blob>;
|
||||
readonly componentReferenceIds$: Observable<string[] | null>;
|
||||
readonly #componentReferenceIds$ = new BehaviorSubject<string[] | null>(null);
|
||||
readonly dossierId = getParam(DOSSIER_ID);
|
||||
readonly dossierTemplateId = getParam(DOSSIER_TEMPLATE_ID);
|
||||
readonly fileId = getParam(FILE_ID);
|
||||
@ -62,6 +64,7 @@ export class FilePreviewStateService {
|
||||
this.dossier = toSignal(dossiersServiceResolver().getEntityChanged$(this.dossierId));
|
||||
this.file$ = inject(FilesMapService).watch$(this.dossierId, this.fileId);
|
||||
this.file = toSignal(this.file$);
|
||||
this.componentReferenceIds$ = this.#componentReferenceIds$.asObservable();
|
||||
this.excludedPages = signal(this.file().excludedPages);
|
||||
this.isWritable = computed(() => {
|
||||
const isWritable = this._permissionsService.canPerformAnnotationActions(this.file(), this.dossier());
|
||||
@ -91,6 +94,10 @@ export class FilePreviewStateService {
|
||||
);
|
||||
}
|
||||
|
||||
set componentReferenceIds(ids: string[]) {
|
||||
this.#componentReferenceIds$.next(ids);
|
||||
}
|
||||
|
||||
get dictionaries(): Dictionary[] {
|
||||
const dictionaries = this._dictionariesMapService.get(this.dossierTemplateId);
|
||||
if (this.dossierDictionary()) {
|
||||
@ -126,6 +133,10 @@ export class FilePreviewStateService {
|
||||
);
|
||||
}
|
||||
|
||||
get componentReferenceIds() {
|
||||
return this.#componentReferenceIds$.getValue();
|
||||
}
|
||||
|
||||
reloadBlob(): void {
|
||||
this.#reloadBlob$.next(true);
|
||||
}
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
{
|
||||
"ADMIN_CONTACT_NAME": null,
|
||||
"ADMIN_CONTACT_URL": null,
|
||||
"API_URL": "https://dan2.iqser.cloud",
|
||||
"API_URL": "https://frontend2.iqser.cloud",
|
||||
"APP_NAME": "RedactManager",
|
||||
"IS_DOCUMINE": false,
|
||||
"IS_DOCUMINE": true,
|
||||
"RULE_EDITOR_DEV_ONLY": false,
|
||||
"AUTO_READ_TIME": 3,
|
||||
"BACKEND_APP_VERSION": "4.4.40",
|
||||
@ -13,13 +13,13 @@
|
||||
"MAX_RETRIES_ON_SERVER_ERROR": 3,
|
||||
"OAUTH_CLIENT_ID": "redaction",
|
||||
"OAUTH_IDP_HINT": null,
|
||||
"OAUTH_URL": "https://dan2.iqser.cloud/auth",
|
||||
"OAUTH_URL": "https://frontend2.iqser.cloud/auth",
|
||||
"RECENT_PERIOD_IN_HOURS": 24,
|
||||
"SELECTION_MODE": "structural",
|
||||
"MANUAL_BASE_URL": "https://docs.redactmanager.com/preview",
|
||||
"ANNOTATIONS_THRESHOLD": 1000,
|
||||
"THEME": "redact",
|
||||
"BASE_TRANSLATIONS_DIRECTORY": "/assets/i18n/redact/",
|
||||
"THEME": "scm",
|
||||
"BASE_TRANSLATIONS_DIRECTORY": "/assets/i18n/scm/",
|
||||
"AVAILABLE_NOTIFICATIONS_DAYS": 30,
|
||||
"AVAILABLE_OLD_NOTIFICATIONS_MINUTES": 60,
|
||||
"NOTIFICATIONS_THRESHOLD": 1000,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user