Skip to content

Commit

Permalink
[enh] minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
blavenie committed Mar 8, 2019
1 parent d81fe08 commit 4354a1b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
19 changes: 10 additions & 9 deletions src/app/shared/material/material.datetime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ export class MatDateTime implements OnInit, ControlValueAccessor {
) {
this.touchUi = platform.is('tablet');
this.mobile = !this.touchUi && platform.is('mobile');
console.log(`touchUI: ${this.touchUi} - mobile: ${this.mobile}`);
this.locale = (translate.currentLang || translate.defaultLang).substr(0, 2);
}

Expand Down Expand Up @@ -121,14 +120,8 @@ export class MatDateTime implements OnInit, ControlValueAccessor {
//this.formControl.updateValueAndValidity({ emitEvent: false, onlySelf: true });

// Get patterns to display date and date+time
this.translate.get(['COMMON.DATE_PATTERN', 'COMMON.DATE_TIME_PATTERN'])
.subscribe(patterns => {
this.displayPattern = (this.displayTime) ?
(patterns['COMMON.DATE_TIME_PATTERN'] != 'COMMON.DATE_TIME_PATTERN' ? patterns['COMMON.DATE_TIME_PATTERN'] : 'L LT') :
(this.displayPattern = patterns['COMMON.DATE_PATTERN'] != 'COMMON.DATE_PATTERN' ? patterns['COMMON.DATE_PATTERN'] : 'L');
this.dayPattern = (patterns['COMMON.DATE_PATTERN'] != 'COMMON.DATE_PATTERN' ? patterns['COMMON.DATE_PATTERN'] : 'L');
this.writing = false;
});
const patterns = this.translate.instant(['COMMON.DATE_PATTERN', 'COMMON.DATE_TIME_PATTERN']);
this.updatePattern(patterns);

this.form.valueChanges
.subscribe((value) => this.onFormChange(value));
Expand Down Expand Up @@ -236,6 +229,14 @@ export class MatDateTime implements OnInit, ControlValueAccessor {
this.disabling = false;
}

private updatePattern(patterns: string[]) {
this.displayPattern = (this.displayTime) ?
(patterns['COMMON.DATE_TIME_PATTERN'] != 'COMMON.DATE_TIME_PATTERN' ? patterns['COMMON.DATE_TIME_PATTERN'] : 'L LT') :
(this.displayPattern = patterns['COMMON.DATE_PATTERN'] != 'COMMON.DATE_PATTERN' ? patterns['COMMON.DATE_PATTERN'] : 'L');
this.dayPattern = (patterns['COMMON.DATE_PATTERN'] != 'COMMON.DATE_PATTERN' ? patterns['COMMON.DATE_PATTERN'] : 'L');
this.writing = false;
}

private onFormChange(json): void {
if (this.writing) return; // Skip if call by self
this.writing = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class IndividualMonitoringTable extends SubSamplesTable {
};

async ngOnInit() {
super.ngOnInit();
await super.ngOnInit();

// Listening on column 'IS_DEAD' value changes
this.registerCellValueChanges('isDead', "measurementValues." + PmfmIds.IS_DEAD.toString())
Expand Down
9 changes: 3 additions & 6 deletions src/app/trip/sample/samples.table.html
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@
<ion-label translate>TRIP.SAMPLE.TABLE.SAMPLE_DATE</ion-label>
</mat-header-cell>
<mat-cell *matCellDef="let row" class="mat-cell-date-time">
<mat-date-time floatLabel="never" [formControl]="row.validator.controls['sampleDate']" [placeholder]="'COMMON.DATE_PLACEHOLDER'|translate"
[compact]="true" [readonly]="!row.editing" [required]="true"></mat-date-time>
<mat-date-time floatLabel="never" [formControl]="row.validator.controls['sampleDate']" [placeholder]="'COMMON.DATE_PLACEHOLDER'|translate"
[compact]="true" [readonly]="!row.editing" [required]="true"></mat-date-time>
</mat-cell>
</ng-container>

Expand All @@ -105,10 +105,7 @@
<!-- Pmfm columns -->
<ng-container *ngFor="let pmfm of pmfms | async" matColumnDef="{{pmfm.pmfmId}}">
<mat-header-cell *matHeaderCellDef mat-sort-header [class.mat-cell-date-time]="pmfm.type=='date'">
<ion-label>{{getPmfmColumnHeader(pmfm)}}
<!--
<ion-label>{{pmfm}} {{pmfm.type}} {{pmfm.unit}}</ion-label>
-->
<ion-label>{{getPmfmColumnHeader(pmfm)}}
<small *ngIf="pmfm.unit && (pmfm.type == 'integer' || pmfm.type == 'double')"><br />({{pmfm.unit}})</small>
</ion-label>
</mat-header-cell>
Expand Down

0 comments on commit 4354a1b

Please sign in to comment.