diff --git a/lib/core/datatable/components/datatable/datatable-cell.component.ts b/lib/core/datatable/components/datatable/datatable-cell.component.ts index 999c263a07..bc62199a0b 100644 --- a/lib/core/datatable/components/datatable/datatable-cell.component.ts +++ b/lib/core/datatable/components/datatable/datatable-cell.component.ts @@ -25,7 +25,7 @@ import { DataTableAdapter } from '../../data/datatable-adapter'; changeDetection: ChangeDetectionStrategy.OnPush, template: ` - {{value}} + {{value}} `, encapsulation: ViewEncapsulation.None, host: { class: 'adf-datatable-cell' } diff --git a/lib/core/datatable/components/datatable/datatable.component.html b/lib/core/datatable/components/datatable/datatable.component.html index 65154e94a8..6f10a45e27 100644 --- a/lib/core/datatable/components/datatable/datatable.component.html +++ b/lib/core/datatable/components/datatable/datatable.component.html @@ -104,6 +104,7 @@ {{ iconAltTextKey(data.getValue(row, col)) | translate }} diff --git a/lib/core/datatable/components/datatable/date-cell.component.ts b/lib/core/datatable/components/datatable/date-cell.component.ts index c64c1cb27a..89e32d6262 100644 --- a/lib/core/datatable/components/datatable/date-cell.component.ts +++ b/lib/core/datatable/components/datatable/date-cell.component.ts @@ -27,12 +27,12 @@ import { template: ` - + {{ value | adfTimeAgo: currentLocale }} - + {{ value | date:format }} diff --git a/lib/core/datatable/components/datatable/filesize-cell.component.ts b/lib/core/datatable/components/datatable/filesize-cell.component.ts index 47a6d0effc..803463b69e 100644 --- a/lib/core/datatable/components/datatable/filesize-cell.component.ts +++ b/lib/core/datatable/components/datatable/filesize-cell.component.ts @@ -22,7 +22,7 @@ import { DataTableCellComponent } from './datatable-cell.component'; selector: 'adf-filesize-cell', template: ` - {{ value | adfFileSize }} + {{ value | adfFileSize }} `, encapsulation: ViewEncapsulation.None, diff --git a/lib/core/pipes/file-type.pipe.spec.ts b/lib/core/pipes/file-type.pipe.spec.ts new file mode 100644 index 0000000000..c563f61a62 --- /dev/null +++ b/lib/core/pipes/file-type.pipe.spec.ts @@ -0,0 +1,34 @@ +/*! + * @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 { FileTypePipe } from './file-type.pipe'; +import { async } from '@angular/core/testing'; + +describe('FileTypePipe', () => { + + const altText = 'ft_ic_ms_word'; + let pipe: FileTypePipe; + + beforeEach(async(() => { + pipe = new FileTypePipe(); + })); + + it('should return file type from alt text', () => { + expect(pipe.transform(altText)).toBe('word'); + }); + +}); diff --git a/lib/core/pipes/file-type.pipe.ts b/lib/core/pipes/file-type.pipe.ts new file mode 100644 index 0000000000..3c4a27df80 --- /dev/null +++ b/lib/core/pipes/file-type.pipe.ts @@ -0,0 +1,36 @@ +/*! + * @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 { PipeTransform, Pipe } from '@angular/core'; + +@Pipe({ + name: 'fileType', + pure: true +}) +export class FileTypePipe implements PipeTransform { + + transform(value: string) { + + if ( value == null || value === undefined ) { + return ''; + } else { + const fileInfo = value.substring(value.lastIndexOf('/') + 1).replace(/\.[a-z]+/, ''); + return fileInfo.split('_').pop(); + } + } + +} diff --git a/lib/core/pipes/pipe.module.ts b/lib/core/pipes/pipe.module.ts index 4213891756..2323414275 100644 --- a/lib/core/pipes/pipe.module.ts +++ b/lib/core/pipes/pipe.module.ts @@ -26,6 +26,7 @@ import { TimeAgoPipe } from './time-ago.pipe'; import { InitialUsernamePipe } from './user-initial.pipe'; import { FullNamePipe } from './full-name.pipe'; import { FormatSpacePipe } from './format-space.pipe'; +import { FileTypePipe } from './file-type.pipe'; @NgModule({ imports: [ @@ -39,7 +40,8 @@ import { FormatSpacePipe } from './format-space.pipe'; InitialUsernamePipe, FullNamePipe, NodeNameTooltipPipe, - FormatSpacePipe + FormatSpacePipe, + FileTypePipe ], providers: [ FileSizePipe, @@ -58,7 +60,8 @@ import { FormatSpacePipe } from './format-space.pipe'; InitialUsernamePipe, FullNamePipe, NodeNameTooltipPipe, - FormatSpacePipe + FormatSpacePipe, + FileTypePipe ] }) export class PipeModule {