mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
adfTimeAgo pipe and demo (#2182)
This commit is contained in:
committed by
Mario Romano
parent
3d65b49af7
commit
2955d8ec23
@@ -103,8 +103,10 @@ import { DataColumnListComponent } from './src/components/data-column/data-colum
|
||||
import { DataColumnComponent } from './src/components/data-column/data-column.component';
|
||||
import { NodePermissionDirective } from './src/directives/node-permission.directive';
|
||||
import { UploadDirective } from './src/directives/upload.directive';
|
||||
|
||||
import { FileSizePipe } from './src/pipes/file-size.pipe';
|
||||
import { HighlightPipe } from './src/pipes/text-highlight.pipe';
|
||||
import { TimeAgoPipe } from './src/pipes/time-ago.pipe';
|
||||
|
||||
import { AlfrescoMdlMenuDirective } from './src/components/material/mdl-menu.directive';
|
||||
import { AlfrescoMdlTextFieldDirective } from './src/components/material/mdl-textfield.directive';
|
||||
@@ -219,7 +221,8 @@ export function createTranslateLoader(http: Http, logService: LogService) {
|
||||
DataColumnComponent,
|
||||
DataColumnListComponent,
|
||||
FileSizePipe,
|
||||
HighlightPipe
|
||||
HighlightPipe,
|
||||
TimeAgoPipe
|
||||
],
|
||||
providers: [...providers(), ...deprecatedProviders(), MomentDateAdapter],
|
||||
exports: [
|
||||
@@ -240,7 +243,8 @@ export function createTranslateLoader(http: Http, logService: LogService) {
|
||||
DataColumnComponent,
|
||||
DataColumnListComponent,
|
||||
FileSizePipe,
|
||||
HighlightPipe
|
||||
HighlightPipe,
|
||||
TimeAgoPipe
|
||||
]
|
||||
})
|
||||
export class CoreModule {
|
||||
|
@@ -60,6 +60,7 @@
|
||||
"hammerjs": "2.0.8",
|
||||
"material-design-icons": "2.2.3",
|
||||
"material-design-lite": "1.2.1",
|
||||
"moment": "2.18.1",
|
||||
"reflect-metadata": "0.1.10",
|
||||
"rxjs": "5.1.0",
|
||||
"systemjs": "0.19.27",
|
||||
|
32
ng2-components/ng2-alfresco-core/src/pipes/time-ago.pipe.ts
Normal file
32
ng2-components/ng2-alfresco-core/src/pipes/time-ago.pipe.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2016 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 * as moment from 'moment';
|
||||
|
||||
import { Pipe, PipeTransform } from '@angular/core';
|
||||
|
||||
@Pipe({
|
||||
name: 'adfTimeAgo'
|
||||
})
|
||||
export class TimeAgoPipe implements PipeTransform {
|
||||
|
||||
transform(value: Date) {
|
||||
const then = moment(value);
|
||||
const diff = moment().diff(then, 'days');
|
||||
return diff > 7 ? then.format('DD/MM/YYYY HH:mm') : then.fromNow();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user