diff --git a/src/app/components/changelog/detail/changelog-detail.component.html b/src/app/components/changelog/detail/changelog-detail.component.html index b57e4e0269d82c09e79dfb365faf75d6b0f79bf3..4c4fb3fff5f023ad41c79c189b39a3208802973f 100644 --- a/src/app/components/changelog/detail/changelog-detail.component.html +++ b/src/app/components/changelog/detail/changelog-detail.component.html @@ -17,11 +17,11 @@ </p> <p> <span class="has-text-weight-bold">Date de création: </span> - <span>{{changelog.createDate}}</span> + <span>{{changelog.createDate | date:'dd-LL-yyyy HH:mm:ss'}}</span> </p> <p> <span class="has-text-weight-bold">Date de dernière mise à jour: </span> - <span>{{changelog.updateDate}}</span> + <span>{{changelog.updateDate | date:'dd-LL-yyyy HH:mm:ss'}}</span> </p> <p> <span class="has-text-weight-bold">Langue: </span> diff --git a/src/app/components/reuses/detail/reuse-detail.component.html b/src/app/components/reuses/detail/reuse-detail.component.html index 200cbfc73fcbba91437a1261225b38fe66f52062..def3b4638daf1cf80179be0aa615741d63343e61 100644 --- a/src/app/components/reuses/detail/reuse-detail.component.html +++ b/src/app/components/reuses/detail/reuse-detail.component.html @@ -26,11 +26,11 @@ </p> <p> <span class="has-text-weight-bold">Date de création: </span> - <span>{{reuse.createDate}}</span> + <span>{{reuse.createDate | date:'dd-LL-yyyy HH:mm:ss'}}</span> </p> <p> <span class="has-text-weight-bold">Date de dernière mise à jour: </span> - <span>{{reuse.updateDate}}</span> + <span>{{reuse.updateDate | date:'dd-LL-yyyy HH:mm:ss'}}</span> </p> <p> @@ -45,7 +45,7 @@ <div class="list-container" *ngIf="reuse.reuseTypes && reuse.reuseTypes.length > 0"> <span class="has-text-weight-bold">Type(s) de réutilisation: </span> <ul> - <li *ngFor="let reuseType of reuse.reuseTypes"> + <li *ngFor="let reuseType of reuseTypes"> {{ reuseType }} </li> </ul> diff --git a/src/app/components/reuses/detail/reuse-detail.component.ts b/src/app/components/reuses/detail/reuse-detail.component.ts index ffada589a724d80bbaef86d9556a373f4b0f9dd9..22d807d39a94a065d9317fcd328333769f9e21f3 100644 --- a/src/app/components/reuses/detail/reuse-detail.component.ts +++ b/src/app/components/reuses/detail/reuse-detail.component.ts @@ -2,7 +2,7 @@ import { switchMap } from 'rxjs/operators'; import { Component, OnInit } from '@angular/core'; import { ActivatedRoute, ParamMap } from '@angular/router'; -import { Reuse } from '../../../models/reuse.model'; +import { Reuse, ReuseTypes } from '../../../models/reuse.model'; import { ReuseService } from '../../../services'; @Component({ @@ -27,4 +27,8 @@ export class ReuseDetailComponent implements OnInit { switchMap((params: ParamMap) => this._reuseService.findById(params.get('id')))) .subscribe((reuse: Reuse) => this.reuse = reuse); } + + get reuseTypes() { + return this.reuse.reuseTypes.map(e => ReuseTypes[e]); + } } diff --git a/src/app/components/reuses/edit/reuse-form.component.html b/src/app/components/reuses/edit/reuse-form.component.html index b3a448ebc261ec2c7fb5193164bc06679f8c6648..331d49d63dc3b9f4ad9ac1a66d5548509c3451b6 100644 --- a/src/app/components/reuses/edit/reuse-form.component.html +++ b/src/app/components/reuses/edit/reuse-form.component.html @@ -69,7 +69,8 @@ <div class="select"> <select type="text" [formControlName]="i" required> <option hidden value="" disabled selected>Selectionnez un type</option> - <option *ngFor="let opt of reuseTypesList" [value]="opt.value">{{opt.label}}</option> + <option *ngFor="let key of objectKeys(reuseTypesList)" [value]="key">{{reuseTypesList[key]}} + </option> </select> </div> </div> diff --git a/src/app/components/reuses/edit/reuse-form.component.ts b/src/app/components/reuses/edit/reuse-form.component.ts index 5a6b9241735b5f9fd799e32e5e7f37a5f0980402..d22ba3c9ca952fe4b825ccbbad660fa955554c59 100644 --- a/src/app/components/reuses/edit/reuse-form.component.ts +++ b/src/app/components/reuses/edit/reuse-form.component.ts @@ -3,7 +3,7 @@ import { ActivatedRoute, ParamMap, Router } from '@angular/router'; import { FormBuilder, FormGroup, Validators, FormArray, FormControl, MaxLengthValidator } from '@angular/forms'; import { filter, switchMap, catchError, mergeMap } from 'rxjs/operators'; import { NotificationService, ReuseService, MediaService } from 'src/app/services'; -import { Reuse } from '../../../models/reuse.model'; +import { Reuse, ReuseTypes } from '../../../models/reuse.model'; import { IImageUploadFieldParams } from '../../../models/image-upload.model'; import { throwError } from 'rxjs'; @@ -24,6 +24,7 @@ export class ReuseFormComponent implements OnInit { isRequired: true, }; title: string; + objectKeys = Object.keys; // User to iterate over the keys of an object in the template html constructor( private _reuseService: ReuseService, @@ -167,7 +168,7 @@ export class ReuseFormComponent implements OnInit { } addReuseType() { - if (this.reuseTypes.length < this.reuseTypesList.length) { + if (this.reuseTypes.length < Object.keys(this.reuseTypesList).length) { this.reuseTypes.push(new FormControl('')); } } @@ -214,20 +215,7 @@ export class ReuseFormComponent implements OnInit { } get reuseTypesList() { - return [ - { - value: 'app', - label: 'Application', - }, - { - value: 'web', - label: 'Web', - }, - { - value: 'article', - label: 'Article', - }, - ]; + return ReuseTypes; } logoChanged(fileList: FileList) { diff --git a/src/app/components/reuses/list/reuses.component.html b/src/app/components/reuses/list/reuses.component.html index 5f1019fb1b7da7879287bf6a68525b10514e0787..98c61f33cb9010a27295a02527db69794d72df7a 100644 --- a/src/app/components/reuses/list/reuses.component.html +++ b/src/app/components/reuses/list/reuses.component.html @@ -89,7 +89,7 @@ <span>{{ reuse.website }}</span> </div> <div class="column is-2"> - <span>{{ reuse.reuseTypes.join(', ') }}</span> + <span>{{ formatReuseTypes(reuse.reuseTypes) }}</span> </div> <div class="column is-offset-1 is-1 has-text-centered actions"> <app-crud-buttons [id]="reuse._id" (delete)="displayDeletePopup($event)"></app-crud-buttons> diff --git a/src/app/components/reuses/list/reuses.component.scss b/src/app/components/reuses/list/reuses.component.scss index 978f6d78add7477d6ec2489a7877af9107e7d228..a499549dab89fa427fa767977d8722ef1158eb67 100644 --- a/src/app/components/reuses/list/reuses.component.scss +++ b/src/app/components/reuses/list/reuses.component.scss @@ -1,3 +1,3 @@ -.has-text-centered { +.has-text-centered .is-sortable { justify-content: center; } diff --git a/src/app/components/reuses/list/reuses.component.ts b/src/app/components/reuses/list/reuses.component.ts index 13b5572558af69a2970c10b65b1159c462ec8f03..17f361c7d22cf538c6da21297336a6d62693c8ae 100644 --- a/src/app/components/reuses/list/reuses.component.ts +++ b/src/app/components/reuses/list/reuses.component.ts @@ -3,7 +3,7 @@ import { PaginatorOptions } from 'src/app/models/paginator-options.model'; import { IPageHeaderInfo } from '../../../models/page.model'; import { Subscription } from 'rxjs'; import { ReuseService, NotificationService } from '../../../services'; -import { Reuse, ReuseRO } from '../../../models/reuse.model'; +import { Reuse, ReuseRO, ReuseTypes } from '../../../models/reuse.model'; @Component({ selector: 'app-reuses', @@ -110,6 +110,10 @@ export class ReusesComponent implements OnInit, OnDestroy { return this._reuseService.sortOptions; } + formatReuseTypes(types: string[]) { + return types.map(e => ReuseTypes[e]).join(', '); + } + displayDeletePopup(id) { this.objectToBeDeletedId = id; } diff --git a/src/app/models/reuse.model.ts b/src/app/models/reuse.model.ts index 6b80b2315a1b1bbc04a043c644cab9d673583f91..8c3970e6f20490c844050c2172f329425da520c2 100644 --- a/src/app/models/reuse.model.ts +++ b/src/app/models/reuse.model.ts @@ -51,3 +51,10 @@ export interface IReuse { updateDate: Date; published: boolean; } + +// tslint:disable-next-line: variable-name +export const ReuseTypes = { + app: 'Application', + web: 'Web', + article: 'Article', +};