[ACS-5686] add reselect to edit offline, shorten template (#3433)

* ACS-5686 add reselect to edit offline, shorten template

* ACS-5686 merge icon condition, use optional chain expression
This commit is contained in:
Grzegorz Jaśkowski
2023-09-19 11:14:58 +02:00
committed by GitHub
parent 4ed3f2d827
commit d1ff001040

View File

@@ -22,7 +22,14 @@
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>. * from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/ */
import { AppStore, DownloadNodesAction, EditOfflineAction, SnackbarErrorAction, getAppSelection } from '@alfresco/aca-shared/store'; import {
AppStore,
DownloadNodesAction,
EditOfflineAction,
SetSelectedNodesAction,
SnackbarErrorAction,
getAppSelection
} from '@alfresco/aca-shared/store';
import { NodeEntry, SharedLinkEntry, Node, NodesApi } from '@alfresco/js-api'; import { NodeEntry, SharedLinkEntry, Node, NodesApi } from '@alfresco/js-api';
import { Component, OnInit, ViewEncapsulation } from '@angular/core'; import { Component, OnInit, ViewEncapsulation } from '@angular/core';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
@@ -39,15 +46,8 @@ import { MatIconModule } from '@angular/material/icon';
selector: 'app-toggle-edit-offline', selector: 'app-toggle-edit-offline',
template: ` template: `
<button mat-menu-item [attr.title]="nodeTitle | translate" (click)="onClick()"> <button mat-menu-item [attr.title]="nodeTitle | translate" (click)="onClick()">
<ng-container *ngIf="isNodeLocked"> <mat-icon>{{ isNodeLocked ? 'cancel' : 'edit' }}</mat-icon>
<mat-icon>cancel</mat-icon> <span>{{ (isNodeLocked ? 'APP.ACTIONS.EDIT_OFFLINE_CANCEL' : 'APP.ACTIONS.EDIT_OFFLINE') | translate }}</span>
<span>{{ 'APP.ACTIONS.EDIT_OFFLINE_CANCEL' | translate }}</span>
</ng-container>
<ng-container *ngIf="!isNodeLocked">
<mat-icon>edit</mat-icon>
<span>{{ 'APP.ACTIONS.EDIT_OFFLINE' | translate }}</span>
</ng-container>
</button> </button>
`, `,
encapsulation: ViewEncapsulation.None, encapsulation: ViewEncapsulation.None,
@@ -84,6 +84,7 @@ export class ToggleEditOfflineComponent implements OnInit {
this.update(response?.entry); this.update(response?.entry);
this.store.dispatch(new EditOfflineAction(this.selection)); this.store.dispatch(new EditOfflineAction(this.selection));
this.store.dispatch(new SetSelectedNodesAction([this.selection]));
} catch { } catch {
this.onUnlockError(); this.onUnlockError();
} }
@@ -94,6 +95,7 @@ export class ToggleEditOfflineComponent implements OnInit {
this.update(response?.entry); this.update(response?.entry);
this.store.dispatch(new DownloadNodesAction([this.selection])); this.store.dispatch(new DownloadNodesAction([this.selection]));
this.store.dispatch(new EditOfflineAction(this.selection)); this.store.dispatch(new EditOfflineAction(this.selection));
this.store.dispatch(new SetSelectedNodesAction([this.selection]));
} catch { } catch {
this.onLockError(); this.onLockError();
} }
@@ -128,7 +130,7 @@ export class ToggleEditOfflineComponent implements OnInit {
} }
private update(data: Node) { private update(data: Node) {
if (data && data.properties) { if (data?.properties) {
const properties = this.selection.entry.properties || {}; const properties = this.selection.entry.properties || {};
properties['cm:lockLifetime'] = data.properties['cm:lockLifetime']; properties['cm:lockLifetime'] = data.properties['cm:lockLifetime'];