[ADF-4390]Added copyContent datatable cell tests (#4614)

* Modified data-table page on demo-shell to make copyClipboard possible to test

* Add a new page in demo-shell.
Add copyContent automated tests.
This commit is contained in:
cristinaj
2019-04-17 13:10:36 +03:00
committed by Eugenio Romano
parent 550c0006c9
commit bcdfcee397
11 changed files with 421 additions and 31 deletions

View File

@@ -377,6 +377,10 @@ export const appRoutes: Routes = [
path: 'datatable-lazy',
loadChildren: 'app/components/lazy-loading/lazy-loading.module#LazyLoadingModule'
},
{
path: 'copy-content',
loadChildren: 'app/components/datatable/copy-content/datatable.module#AppDataTableCopyModule'
},
{
path: 'template-list',
component: TemplateDemoComponent

View File

@@ -64,7 +64,8 @@ export class AppLayoutComponent implements OnInit {
{ href: '/datatable', icon: 'view_module', title: 'APP_LAYOUT.DATATABLE', children: [
{ href: '/datatable', icon: 'view_module', title: 'APP_LAYOUT.DATATABLE' },
{ href: '/datatable-lazy', icon: 'view_module', title: 'APP_LAYOUT.DATATABLE_LAZY' },
{ href: '/datatable/dnd', icon: 'view_module', title: 'Drag and Drop' }
{ href: '/datatable/dnd', icon: 'view_module', title: 'Drag and Drop' },
{ href: '/copy-content', icon: 'view_module', title: 'Copy Content' }
]},
{ href: '/template-list', icon: 'list_alt', title: 'APP_LAYOUT.TEMPLATE' },
{ href: '/webscript', icon: 'extension', title: 'APP_LAYOUT.WEBSCRIPT' },

View File

@@ -0,0 +1,23 @@
<div style="height: 310px; overflow-y: auto;" data-automation-id="datatable">
<adf-datatable
#dataTable
[data]="data">
</adf-datatable>
</div>
<div>
Paste clipboard:
<input data-automation-id="paste clipboard input">
</div>
<div style="height: 310px; overflow-y: auto;" data-automation-id="copyClipboard-datatable">
<adf-datatable
[data]="dataForCopy">
<data-columns>
<data-column key="id" title="Id" [copyContent]="true"></data-column>
<data-column key="name" title="Name" class="adf-full-width name-column" [copyContent]="false"></data-column>
<data-column key="createdBy" title="Created By"></data-column>
</data-columns>
</adf-datatable>
</div>

View File

@@ -0,0 +1,125 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Component, Input } from '@angular/core';
import { DataColumn, DataRow } from '@alfresco/adf-core';
import { ObjectDataTableAdapter } from '@alfresco/adf-core';
export class FilteredDataAdapter extends ObjectDataTableAdapter {
filterValue = '';
filterKey = 'name';
getRows(): Array<DataRow> {
let rows = super.getRows();
const filter = (this.filterValue || '').trim().toLowerCase();
if (this.filterKey && filter) {
rows = rows.filter((row) => {
const value = row.getValue(this.filterKey);
if (value !== undefined && value !== null) {
const stringValue: string = value.toString().trim().toLowerCase();
return stringValue.startsWith(filter);
}
return false;
});
}
return rows;
}
constructor(data?: any[], schema?: DataColumn[]) {
super(data, schema);
}
}
@Component({
selector: 'app-datatable',
templateUrl: './datatable.component.html'
})
export class DataTableComponent {
@Input()
selectionMode = 'single';
dataForCopy = new FilteredDataAdapter(
[
{
id: 1,
name: 'First',
createdBy: 'Created one'
},
{
id: 2,
name: 'Second',
createdBy: 'Created two'
},
{
id: 3,
name: 'Third',
createdBy: 'Created three'
}
]
);
data = new FilteredDataAdapter(
[
{
id: 1,
name: 'Name 1',
createdBy: 'Created One',
icon: 'material-icons://folder_open',
json: null
},
{
id: 2,
name: 'Name 2',
createdBy: 'Created Two',
icon: 'material-icons://accessibility',
json: null
},
{
id: 3,
name: 'Name 3',
createdBy: 'Created Three',
icon: 'material-icons://alarm',
json: null
},
{
id: 4,
name: 'Image 8',
createdBy: 'Created Four',
icon: 'material-icons://alarm',
json: {
id: 4,
name: 'Image 8',
createdOn: new Date(2016, 6, 2, 15, 8, 4),
createdBy: {
name: 'Felipe',
lastname: 'Melo'
},
icon: 'material-icons://alarm'
}
}
],
[
{ type: 'image', key: 'icon', title: '', srTitle: 'Thumbnail' },
{ type: 'text', key: 'id', title: 'Id', sortable: true , cssClass: '', copyContent: true },
{ type: 'text', key: 'name', title: 'Name', cssClass: 'adf-ellipsis-cell', sortable: true, copyContent: false },
{ type: 'text', key: 'createdBy', title: 'Created By', sortable: true, cssClass: ''},
{ type: 'json', key: 'json', title: 'Json', cssClass: 'adf-expand-cell-2'}
]
);
}

View File

@@ -0,0 +1,41 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { NgModule } from '@angular/core';
import { DataTableComponent } from './datatable.component';
import { Routes, RouterModule } from '@angular/router';
import { CommonModule } from '@angular/common';
import { CoreModule } from '@alfresco/adf-core';
import { ContentModule } from '@alfresco/adf-content-services';
const routes: Routes = [
{
path: '',
component: DataTableComponent
}
];
@NgModule({
imports: [
CommonModule,
CoreModule.forChild(),
RouterModule.forChild(routes),
ContentModule.forChild()
],
declarations: [DataTableComponent]
})
export class AppDataTableCopyModule {}

View File

@@ -10,7 +10,7 @@
Sticky header
</mat-slide-toggle>
<div style="height: 310px; overflow-y: auto;">
<div style="height: 310px; overflow-y: auto;" data-automation-id="datatable">
<adf-datatable
#dataTable
[data]="data"