mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
[ACS-5281] Changed editable state of metadata content based on change o… (#3400)
* ACS-5281 Changed editable state of metadata content based on change of file lock state * ACS-5281 Updated versions * ACS-5281 Reverted change * ACS-5281 Upgrade version * ACS-5281 Small correction * ACS-5281 Fixed e2e
This commit is contained in:
@@ -23,22 +23,29 @@
|
||||
*/
|
||||
|
||||
import { Component, Input, ViewEncapsulation, OnInit, OnDestroy } from '@angular/core';
|
||||
import { MinimalNodeEntryEntity } from '@alfresco/js-api';
|
||||
import { Node } from '@alfresco/js-api';
|
||||
import { NodePermissionService, isLocked, AppExtensionService } from '@alfresco/aca-shared';
|
||||
import { AppStore, infoDrawerMetadataAspect } from '@alfresco/aca-shared/store';
|
||||
import { AppStore, EditOfflineAction, infoDrawerMetadataAspect, NodeActionTypes } from '@alfresco/aca-shared/store';
|
||||
import { AppConfigService, NotificationService } from '@alfresco/adf-core';
|
||||
import { Observable, Subject } from 'rxjs';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { ContentMetadataModule, ContentMetadataService } from '@alfresco/adf-content-services';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
import { filter, takeUntil } from 'rxjs/operators';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { Actions, ofType } from '@ngrx/effects';
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
imports: [CommonModule, ContentMetadataModule],
|
||||
selector: 'app-metadata-tab',
|
||||
template: `
|
||||
<adf-content-metadata-card [readOnly]="!canUpdateNode" [preset]="'custom'" [node]="node" [displayAspect]="displayAspect$ | async">
|
||||
<adf-content-metadata-card
|
||||
[readOnly]="!canUpdateNode"
|
||||
[preset]="'custom'"
|
||||
[node]="node"
|
||||
[displayAspect]="displayAspect$ | async"
|
||||
[(editable)]="editable"
|
||||
>
|
||||
</adf-content-metadata-card>
|
||||
`,
|
||||
encapsulation: ViewEncapsulation.None,
|
||||
@@ -48,11 +55,11 @@ export class MetadataTabComponent implements OnInit, OnDestroy {
|
||||
protected onDestroy$ = new Subject<boolean>();
|
||||
|
||||
@Input()
|
||||
node: MinimalNodeEntryEntity;
|
||||
node: Node;
|
||||
|
||||
displayAspect$: Observable<string>;
|
||||
|
||||
canUpdateNode = false;
|
||||
editable = false;
|
||||
|
||||
constructor(
|
||||
private permission: NodePermissionService,
|
||||
@@ -60,7 +67,8 @@ export class MetadataTabComponent implements OnInit, OnDestroy {
|
||||
private appConfig: AppConfigService,
|
||||
private store: Store<AppStore>,
|
||||
private notificationService: NotificationService,
|
||||
private contentMetadataService: ContentMetadataService
|
||||
private contentMetadataService: ContentMetadataService,
|
||||
private actions$: Actions
|
||||
) {
|
||||
if (this.extensions.contentMetadata) {
|
||||
this.appConfig.config['content-metadata'].presets = this.extensions.contentMetadata.presets;
|
||||
@@ -72,13 +80,27 @@ export class MetadataTabComponent implements OnInit, OnDestroy {
|
||||
this.contentMetadataService.error.pipe(takeUntil(this.onDestroy$)).subscribe((err: { message: string }) => {
|
||||
this.notificationService.showError(err.message);
|
||||
});
|
||||
if (this.node && !isLocked({ entry: this.node })) {
|
||||
this.canUpdateNode = this.permission.check(this.node, ['update']);
|
||||
}
|
||||
this.checkIfNodeIsUpdatable(this.node);
|
||||
this.actions$
|
||||
.pipe(
|
||||
ofType<EditOfflineAction>(NodeActionTypes.EditOffline),
|
||||
filter((updatedNode) => this.node.id === updatedNode.payload.entry.id),
|
||||
takeUntil(this.onDestroy$)
|
||||
)
|
||||
.subscribe((updatedNode) => {
|
||||
this.checkIfNodeIsUpdatable(updatedNode?.payload.entry);
|
||||
if (!this.canUpdateNode) {
|
||||
this.editable = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.onDestroy$.next(true);
|
||||
this.onDestroy$.complete();
|
||||
}
|
||||
|
||||
private checkIfNodeIsUpdatable(node: Node) {
|
||||
this.canUpdateNode = node && !isLocked({ entry: node }) ? this.permission.check(node, ['update']) : false;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user