mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
[ADF-4342] Create localized pipe and centralize date format (#4813)
* [ADF-4342] Date Format defined in app config * [ADF-4342] Create localized pipe and centralize date format * Add unit test for new date pipe * Add info internationalization docs * Fix lining * Fix linting * Fix date pipe unit test * [ADF-4342] Add supported language files * Fix e2e tests
This commit is contained in:
committed by
Denys Vuika
parent
990fa4625b
commit
7497822a46
32
demo-shell/src/app/components/date/date.component.html
Normal file
32
demo-shell/src/app/components/date/date.component.html
Normal file
@@ -0,0 +1,32 @@
|
||||
<div class="adf-date-pipes-container">
|
||||
<h2>Date Pipes</h2>
|
||||
|
||||
<mat-form-field class="adf-date-field">
|
||||
<input matInput
|
||||
placeholder="Format"
|
||||
[(ngModel)]="format">
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field class="adf-date-field">
|
||||
<mat-select placeholder="Locale dropdown" [(ngModel)]="locale">
|
||||
<mat-option *ngFor="let language of languages" [value]="language.key">
|
||||
{{language.label}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
|
||||
<h3>AdfLocalizedDate Pipe - Default</h3>
|
||||
<div>{{ today | adfLocalizedDate }} </div>
|
||||
<br>
|
||||
<h3>AdfLocalizedDate Pipe - Custom format</h3>
|
||||
<div>{{ today | adfLocalizedDate : format }} </div>
|
||||
<br>
|
||||
<h3>AdfLocalizedDate Pipe - Custom format and locale</h3>
|
||||
<div>{{ today | adfLocalizedDate : format : locale }} </div>
|
||||
<br>
|
||||
<h3>AdfTimeAgo Pipe</h3>
|
||||
<div>{{ today | adfTimeAgo }} </div>
|
||||
<br>
|
||||
<h3>AdfTimeAgo Pipe - Custom locale</h3>
|
||||
<div>{{ today | adfTimeAgo : locale}} </div>
|
||||
</div>
|
7
demo-shell/src/app/components/date/date.component.scss
Normal file
7
demo-shell/src/app/components/date/date.component.scss
Normal file
@@ -0,0 +1,7 @@
|
||||
.adf-date-pipes-container {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.adf-date-field {
|
||||
margin: 20px;
|
||||
}
|
36
demo-shell/src/app/components/date/date.component.ts
Normal file
36
demo-shell/src/app/components/date/date.component.ts
Normal 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 { Component } from '@angular/core';
|
||||
import { AppConfigService } from '@alfresco/adf-core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-date-page',
|
||||
templateUrl: './date.component.html',
|
||||
styleUrls: ['date.component.scss']
|
||||
})
|
||||
export class DateComponent {
|
||||
|
||||
today = new Date();
|
||||
locale: string;
|
||||
format: string;
|
||||
languages: any[];
|
||||
|
||||
constructor(private appConfig: AppConfigService) {
|
||||
this.languages = this.appConfig.get('languages', []);
|
||||
}
|
||||
}
|
39
demo-shell/src/app/components/date/date.module.ts
Normal file
39
demo-shell/src/app/components/date/date.module.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
/*!
|
||||
* @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 { Routes, RouterModule } from '@angular/router';
|
||||
import { DateComponent } from './date.component';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { CoreModule } from '@alfresco/adf-core';
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: DateComponent
|
||||
}
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
CoreModule.forChild(),
|
||||
RouterModule.forChild(routes)
|
||||
],
|
||||
declarations: [DateComponent]
|
||||
})
|
||||
export class AppDateModule {}
|
Reference in New Issue
Block a user