[ACA-1437] Custom row for search results DL (#414)

* custom row

* clean up
This commit is contained in:
Cilibiu Bogdan
2018-06-15 09:06:12 +03:00
committed by Denys Vuika
parent edc9d6ba32
commit b06dcd4391
8 changed files with 171 additions and 27 deletions

View File

@@ -159,7 +159,7 @@
}
},
"search": {
"include": ["path", "allowableOperations"],
"include": ["path", "allowableOperations", "properties"],
"sorting": {
"options": [
{
@@ -217,6 +217,7 @@
"filterQueries": [
{ "query": "TYPE:'cm:folder' OR TYPE:'cm:content'" },
{ "query": "NOT cm:creator:System" },
{ "query": "NOT TYPE:'dl:dataList' AND NOT TYPE:'dl:todoList' AND NOT TYPE:'dl:issue' AND NOT TYPE:'fm:topic' AND NOT TYPE:'lnk:link' AND NOT TYPE:'fm:post'" },
{ "query": "-(SITE: _REPOSITORY_)" }
],
"facetFields": [

View File

@@ -57,6 +57,7 @@ import { SearchInputComponent } from './components/search-input/search-input.com
import { SidenavComponent } from './components/sidenav/sidenav.component';
import { AboutComponent } from './components/about/about.component';
import { LocationLinkComponent } from './components/location-link/location-link.component';
import { CustomDlRowComponent } from './components/custom-dl-row/custom-dl-row.component';
import { NodeCopyDirective } from './common/directives/node-copy.directive';
import { NodeDeleteDirective } from './common/directives/node-delete.directive';
import { NodeMoveDirective } from './common/directives/node-move.directive';
@@ -139,6 +140,7 @@ import { ViewerEffects } from './store/effects/viewer.effects';
PreviewComponent,
AboutComponent,
LocationLinkComponent,
CustomDlRowComponent,
NodeCopyDirective,
NodeDeleteDirective,
NodeMoveDirective,

View File

@@ -0,0 +1,21 @@
<div class="app-custom-search-row">
<div class="line">
<a *ngIf="isFile" href="" (click)="showPreview()" class="link"> {{ name }} </a>
<span *ngIf="!isFile" class="bold"> {{ name }} </span>
<span *ngIf="hasTitle"> ( {{ title }} ) </span>
</div>
<div *ngIf="hasDescription" class="line"> {{ description }} </div>
<div class="line">
{{ 'APP.BROWSE.SEARCH.CUSTOM_ROW.MODIFIED' | translate }}: {{ modifiedAt | date:'medium' }}
by <span> {{ user }} </span>
<span *ngIf="size">| {{ size }} </span>
</div>
<div class="line">{{ 'APP.BROWSE.SEARCH.CUSTOM_ROW.LOCATION' | translate }}: <app-location-link [context]="context"></app-location-link></div>
</div>

View File

@@ -0,0 +1,24 @@
@import 'mixins';
.app-custom-search-row {
@include flex-column;
}
.line {
margin: 5px 0;
}
.bold {
font-weight: 400;
color: rgba(0, 0, 0, 0.87);
}
.link {
text-decoration: none;
color: rgba(0, 0, 0, 0.87);
}
.link:hover {
color: #2196F3;
text-decoration: underline;
}

View File

@@ -0,0 +1,108 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2018 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { Component, Input, OnInit } from '@angular/core';
import { MinimalNodeEntryEntity } from 'alfresco-js-api';
import { ViewNodeAction } from '../../store/actions/viewer.action';
import { Store } from '@ngrx/store';
import { AppStore } from '../../store/states/app.state';
@Component({
selector: 'app-custom-dl-row',
templateUrl: './custom-dl-row.component.html',
styleUrls: ['./custom-dl-row.component.scss']
})
export class CustomDlRowComponent implements OnInit {
private node: MinimalNodeEntryEntity;
@Input()
context: any;
constructor(private store: Store<AppStore>) {}
ngOnInit() {
this.node = this.context.row.node.entry;
}
get name() {
return this.getValue('name');
}
get title() {
return this.getValue('properties["cm:title"]');
}
get description() {
return this.getValue('properties["cm:description"]');
}
get modifiedAt() {
return this.getValue('modifiedAt');
}
get size() {
return this.getValue('content.modifiedAt');
}
get user() {
return this.getValue('modifiedByUser.displayName');
}
get hasDescription() {
return this.description;
}
get hasTitle() {
return this.title;
}
get hasSize() {
return this.size;
}
get isFile() {
return this.getValue('isFile');
}
showPreview() {
const { id, name} = this.node;
this.store.dispatch(new ViewNodeAction({
id,
name
}));
}
private getValue(path) {
return path
.replace('["', '.')
.replace('"]', '')
.replace('[', '.')
.replace(']', '')
.split('.')
.reduce((acc, part) => acc ? acc[part] : null, this.node);
}
}

View File

@@ -78,7 +78,8 @@ export class LocationLinkComponent implements OnInit {
const data: DataTableAdapter = this.context.data;
const col: DataColumn = this.context.col;
const row: DataRow = this.context.row;
const value: PathInfoEntity = data.getValue(row, col);
const path: PathInfoEntity = data.getValue(row, col);
const value = path || this.context.row.node.entry.path;
if (value && value.name && value.elements) {
this.displayText = this.getDisplayText(value);

View File

@@ -100,32 +100,15 @@
[sr-title]="'ADF-DOCUMENT-LIST.LAYOUT.THUMBNAIL'"
[sortable]="false">
</data-column>
<data-column
[key]="'name'"
[type]="'text'"
[title]="'ADF-DOCUMENT-LIST.LAYOUT.NAME'"
[class]="'full-width ellipsis-cell'"
[sortable]="false">
</data-column>
<data-column
[key]="'content.sizeInBytes'"
[type]="'fileSize'"
[title]="'ADF-DOCUMENT-LIST.LAYOUT.SIZE'"
[sortable]="false">
</data-column>
<data-column
[key]="'modifiedAt'"
[type]="'date'"
[title]="'ADF-DOCUMENT-LIST.LAYOUT.MODIFIED_ON'"
[format]="'timeAgo'"
[sortable]="false">
</data-column>
<data-column
[key]="'modifiedByUser.displayName'"
[type]="'text'"
[title]="'ADF-DOCUMENT-LIST.LAYOUT.MODIFIED_BY'"
[sortable]="false">
key
type="text">
<ng-template let-context>
<app-custom-dl-row [context]="context"></app-custom-dl-row>
</ng-template>
</data-column>
</data-columns>
<empty-folder-content>

View File

@@ -98,7 +98,11 @@
},
"SEARCH": {
"TITLE": "Search Results",
"FOUND_RESULTS": "{{ number }} results found"
"FOUND_RESULTS": "{{ number }} results found",
"CUSTOM_ROW": {
"MODIFIED": "Modified",
"LOCATION": "Location"
}
}
},
"ACTIONS": {