[ACA-2314] display "locked by" in search results (#1732)

* display "locked by" in search results

* Trigger build
This commit is contained in:
Denys Vuika
2020-10-09 15:44:40 +01:00
committed by GitHub
parent e9b837462a
commit 9f67cae204
9 changed files with 31 additions and 45 deletions

View File

@@ -1,7 +1,6 @@
.aca-locked-by { .aca-locked-by {
display: flex; display: flex;
align-items: center; align-items: center;
padding: 0 10px;
color: var(--theme-text-color, rgba(0, 0, 0, 0.54)); color: var(--theme-text-color, rgba(0, 0, 0, 0.54));
.locked_by--icon { .locked_by--icon {
@@ -10,6 +9,7 @@
height: 14px; height: 14px;
} }
.locked_by--label,
.locked_by--name { .locked_by--name {
font-size: 12px; font-size: 12px;
padding: 0 2px; padding: 0 2px;

View File

@@ -23,15 +23,15 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/ */
import { Component, Input, OnInit, ChangeDetectionStrategy, ViewEncapsulation } from '@angular/core'; import { Component, Input, ChangeDetectionStrategy, ViewEncapsulation } from '@angular/core';
import { NodeEntry } from '@alfresco/js-api'; import { NodeEntry } from '@alfresco/js-api';
@Component({ @Component({
selector: 'aca-locked-by', selector: 'aca-locked-by',
template: ` template: `
<mat-icon class="locked_by--icon">lock</mat-icon> <mat-icon class="locked_by--icon">lock</mat-icon>
<span class="locked_by--name">{{ writeLockedBy() }}</span> <span class="locked_by--label">{{ 'APP.LOCKED_BY' | translate }}</span>
<span class="locked_by--name">{{ text }}</span>
`, `,
styleUrls: ['./locked-by.component.scss'], styleUrls: ['./locked-by.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
@@ -40,19 +40,11 @@ import { NodeEntry } from '@alfresco/js-api';
class: 'aca-locked-by' class: 'aca-locked-by'
} }
}) })
export class LockedByComponent implements OnInit { export class LockedByComponent {
@Input() @Input()
context: any;
node: NodeEntry; node: NodeEntry;
constructor() {} get text(): string {
ngOnInit() {
this.node = this.context.row.node;
}
writeLockedBy() {
return ( return (
this.node && this.node.entry.properties && this.node.entry.properties['cm:lockOwner'] && this.node.entry.properties['cm:lockOwner'].displayName this.node && this.node.entry.properties && this.node.entry.properties['cm:lockOwner'] && this.node.entry.properties['cm:lockOwner'].displayName
); );

View File

@@ -27,9 +27,10 @@ import { NgModule } from '@angular/core';
import { LockedByComponent } from './locked-by.component'; import { LockedByComponent } from './locked-by.component';
import { MatIconModule } from '@angular/material/icon'; import { MatIconModule } from '@angular/material/icon';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { TranslateModule } from '@ngx-translate/core';
@NgModule({ @NgModule({
imports: [CommonModule, MatIconModule], imports: [CommonModule, MatIconModule, TranslateModule.forChild()],
declarations: [LockedByComponent], declarations: [LockedByComponent],
exports: [LockedByComponent] exports: [LockedByComponent]
}) })

View File

@@ -1,19 +1,14 @@
<div <div
class="aca-custom-name-column" class="aca-custom-name-column"
[ngClass]="{ [ngClass]="{
'aca-name-column-container': isFile() && isFileWriteLocked() 'aca-name-column-container': isFile && isFileWriteLocked
}" }"
> >
<span <span
role="link" role="link"
[attr.aria-label]=" [attr.aria-label]="
(isFile() (isFile ? 'CUSTOM_NAME_COLUMN.ACCESSIBILITY.FILE_LINK_ARIA_LABEL' : 'CUSTOM_NAME_COLUMN.ACCESSIBILITY.FOLDER_LINK_ARIA_LABEL')
? 'CUSTOM_NAME_COLUMN.ACCESSIBILITY.FILE_LINK_ARIA_LABEL' | translate: { name: displayText$ | async }
: 'CUSTOM_NAME_COLUMN.ACCESSIBILITY.FOLDER_LINK_ARIA_LABEL')
| translate
: {
name: displayText$ | async
}
" "
class="adf-datatable-cell-value" class="adf-datatable-cell-value"
title="{{ node | adfNodeNameTooltip }}" title="{{ node | adfNodeNameTooltip }}"
@@ -23,7 +18,7 @@
{{ displayText$ | async }} {{ displayText$ | async }}
</span> </span>
<ng-container *ngIf="isFile() && isFileWriteLocked()"> <ng-container *ngIf="isFile && isFileWriteLocked">
<aca-locked-by [context]="context"></aca-locked-by> <aca-locked-by [node]="context.row.node"></aca-locked-by>
</ng-container> </ng-container>
</div> </div>

View File

@@ -91,11 +91,11 @@ export class CustomNameColumnComponent extends NameColumnComponent implements On
this.onDestroy$$.complete(); this.onDestroy$$.complete();
} }
isFile(): boolean { get isFile(): boolean {
return this.node && this.node.entry && !this.node.entry.isFolder; return this.node && this.node.entry && !this.node.entry.isFolder;
} }
isFileWriteLocked(): boolean { get isFileWriteLocked(): boolean {
return isLocked(this.node); return isLocked(this.node);
} }
} }

View File

@@ -1,22 +1,8 @@
<div class="line"> <div class="line">
<span <span tabindex="0" role="link" *ngIf="isFile" (click)="showPreview($event)" (keyup.enter)="showPreview($event)" class="link">
tabindex="0"
role="link"
*ngIf="isFile"
(click)="showPreview($event)"
(keyup.enter)="showPreview($event)"
class="link"
>
{{ name$ | async }} {{ name$ | async }}
</span> </span>
<span <span tabindex="0" role="link" *ngIf="!isFile" (click)="navigate($event)" (keyup.enter)="navigate($event)" class="bold link">
tabindex="0"
role="link"
*ngIf="!isFile"
(click)="navigate($event)"
(keyup.enter)="navigate($event)"
class="bold link"
>
{{ name$ | async }} {{ name$ | async }}
</span> </span>
<span>{{ title$ | async }}</span> <span>{{ title$ | async }}</span>
@@ -35,6 +21,10 @@
</span> </span>
</div> </div>
<div class="line" *ngIf="isFile && isFileWriteLocked">
<aca-locked-by [node]="context.row.node"></aca-locked-by>
</div>
<div class="line"> <div class="line">
{{ 'APP.BROWSE.SEARCH.CUSTOM_ROW.LOCATION' | translate }}: {{ 'APP.BROWSE.SEARCH.CUSTOM_ROW.LOCATION' | translate }}:
<aca-location-link [context]="context"></aca-location-link> <aca-location-link [context]="context"></aca-location-link>

View File

@@ -31,6 +31,7 @@ import { BehaviorSubject, Subject } from 'rxjs';
import { AlfrescoApiService } from '@alfresco/adf-core'; import { AlfrescoApiService } from '@alfresco/adf-core';
import { takeUntil } from 'rxjs/operators'; import { takeUntil } from 'rxjs/operators';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { isLocked } from '@alfresco/aca-shared';
@Component({ @Component({
selector: 'aca-search-results-row', selector: 'aca-search-results-row',
@@ -55,7 +56,7 @@ export class SearchResultsRowComponent implements OnInit, OnDestroy {
ngOnInit() { ngOnInit() {
this.updateValues(); this.updateValues();
this.alfrescoApiService.nodeUpdated.pipe(takeUntil(this.onDestroy$)).subscribe((node: any) => { this.alfrescoApiService.nodeUpdated.pipe(takeUntil(this.onDestroy$)).subscribe((node) => {
const row = this.context.row; const row = this.context.row;
if (row) { if (row) {
const { entry } = row.node; const { entry } = row.node;
@@ -110,6 +111,10 @@ export class SearchResultsRowComponent implements OnInit, OnDestroy {
return this.node.entry.isFile; return this.node.entry.isFile;
} }
get isFileWriteLocked(): boolean {
return isLocked(this.node);
}
showPreview(event: MouseEvent) { showPreview(event: MouseEvent) {
event.stopPropagation(); event.stopPropagation();
this.store.dispatch(new ViewNodeAction(this.node.entry.id, { location: this.router.url })); this.store.dispatch(new ViewNodeAction(this.node.entry.id, { location: this.router.url }));

View File

@@ -27,6 +27,7 @@ import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { CoreModule } from '@alfresco/adf-core'; import { CoreModule } from '@alfresco/adf-core';
import { ContentModule } from '@alfresco/adf-content-services'; import { ContentModule } from '@alfresco/adf-content-services';
import { LockedByModule } from '@alfresco/aca-shared';
import { SearchResultsComponent } from './search-results/search-results.component'; import { SearchResultsComponent } from './search-results/search-results.component';
import { SearchResultsRowComponent } from './search-results-row/search-results-row.component'; import { SearchResultsRowComponent } from './search-results-row/search-results-row.component';
import { SearchLibrariesResultsComponent } from './search-libraries-results/search-libraries-results.component'; import { SearchLibrariesResultsComponent } from './search-libraries-results/search-libraries-results.component';
@@ -47,7 +48,8 @@ import { ContextMenuModule } from '../context-menu/context-menu.module';
AppToolbarModule, AppToolbarModule,
DirectivesModule, DirectivesModule,
AppLayoutModule, AppLayoutModule,
ContextMenuModule ContextMenuModule,
LockedByModule
], ],
declarations: [SearchResultsComponent, SearchLibrariesResultsComponent, SearchResultsRowComponent], declarations: [SearchResultsComponent, SearchLibrariesResultsComponent, SearchResultsRowComponent],
exports: [SearchResultsComponent, SearchLibrariesResultsComponent, SearchResultsRowComponent] exports: [SearchResultsComponent, SearchLibrariesResultsComponent, SearchResultsRowComponent]

View File

@@ -47,6 +47,7 @@
"RESET": "Reset", "RESET": "Reset",
"APPLY": "Apply" "APPLY": "Apply"
}, },
"LOCKED_BY": "Locked by: ",
"PREVIEW": { "PREVIEW": {
"TITLE": "Preview" "TITLE": "Preview"
}, },