[ADF-3863] - DocumentList add accesibility tags for file type and for… (#4186)

* [ADF-3863] - DocumentList add accesibility tags for file type and for rows template

* [ADF-3863] - DocumentList add pipe for file type accesibility tags

* [ADF-3863] - DocumentList add pipe for file type accesibility tags

* [ADF-3863] DocumentList - change FiletType pipe to pure
This commit is contained in:
Silviu Popa
2019-02-19 17:54:54 +02:00
committed by Eugenio Romano
parent 08231bbf33
commit 3739424953
7 changed files with 80 additions and 6 deletions

View File

@@ -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');
});
});

View File

@@ -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();
}
}
}

View File

@@ -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 {