Skip to content
This repository was archived by the owner on Mar 25, 2023. It is now read-only.

Commit fe3d54c

Browse files
authored
Merge pull request #247 from bwsw/232-activity-log
(closes #232) Fix activity log dates
2 parents cc5b5f7 + da2ef0b commit fe3d54c

File tree

6 files changed

+34
-9
lines changed

6 files changed

+34
-9
lines changed

src/app/events/event-list.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
[DateTimeFormat]="dateTimeFormat"
99
[cancelLabel]="'CANCEL' | translate"
1010
[(ngModel)]="date"
11-
(ngModelChange)="getEvents({ reload: true })"
11+
(change)="getEvents({ reload: true })"
1212
></cs-date-picker>
1313

1414
<mdl-select

src/app/events/event-list.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export class EventListComponent implements OnInit {
5555
this.translate.get(['DESCRIPTION', 'LEVEL', 'TYPE', 'TIME'])
5656
.subscribe(translations => this.initTableModel(translations));
5757
this.initFilters();
58+
this.getEvents({ reload: true });
5859

5960
this.languageService.getFirstDayOfWeek()
6061
.subscribe(day => this.firstDayOfWeek = day);
@@ -148,7 +149,6 @@ export class EventListComponent implements OnInit {
148149
this.selectedLevels = params['levels'];
149150
this.selectedTypes = params['types'];
150151
this.query = params['query'];
151-
this.getEvents();
152152
}
153153

154154
private setDateTimeFormat(): void {

src/app/shared/components/date-picker/calendar-month.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<div
44
class="day"
55
[class.none]="!day"
6+
[class.today]="isToday(day)"
67
*ngFor="let day of week"
78
(click)="setSelectedDate($event, day)"
89
>

src/app/shared/components/date-picker/calendar-month.component.scss

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
z-index: 1;
3737
width: 42px;
3838
background: none;
39+
line-height: 25px;
3940

4041
&.none {
4142
cursor: auto;
@@ -51,6 +52,13 @@
5152
color: white;
5253
}
5354
}
55+
56+
&.today {
57+
.button-state {
58+
transform: scale(1);
59+
opacity: 0.2;
60+
}
61+
}
5462
}
5563

5664
.label {
@@ -84,3 +92,8 @@
8492
color: white;
8593
}
8694
}
95+
96+
.today {
97+
font-weight: bold;
98+
//font-size: 15px;
99+
}

src/app/shared/components/date-picker/calendar-month.component.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ export class CalendarMonthComponent {
3939
return isEqualDate(this.selectedDate, date);
4040
}
4141

42+
public isToday(date): boolean {
43+
return isEqualDate(date, new Date());
44+
}
45+
4246
public setSelectedDate(_e: Event, day: Date): void {
4347
if (!day) {
4448
return;

src/app/shared/components/date-picker/date-picker.component.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
import {
22
Component,
3+
EventEmitter,
34
forwardRef,
45
Input,
5-
AfterViewInit
6+
OnChanges,
7+
Output,
8+
SimpleChanges
69
} from '@angular/core';
7-
import { NG_VALUE_ACCESSOR, ControlValueAccessor } from '@angular/forms';
10+
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
11+
import { DialogService } from '../../../dialog/dialog-module/dialog.service';
812

913
import { DatePickerDialogComponent } from './date-picker-dialog.component';
1014
import { dateTimeFormat as DateTimeFormat, formatIso } from './dateUtils';
11-
import { DialogService } from '../../../dialog/dialog-module/dialog.service';
1215

1316

1417
interface DatePickerConfig {
@@ -32,12 +35,13 @@ interface DatePickerConfig {
3235
}
3336
]
3437
})
35-
export class DatePickerComponent implements ControlValueAccessor, AfterViewInit {
38+
export class DatePickerComponent implements ControlValueAccessor, OnChanges {
3639
@Input() public okLabel = 'Ok';
3740
@Input() public cancelLabel = 'Cancel';
3841
@Input() public firstDayOfWeek = 1;
3942
@Input() public DateTimeFormat = DateTimeFormat;
4043
@Input() public locale = 'en';
44+
@Output() public change = new EventEmitter();
4145

4246
public displayDate: string;
4347

@@ -46,8 +50,11 @@ export class DatePickerComponent implements ControlValueAccessor, AfterViewInit
4650

4751
constructor(private dialogService: DialogService) {}
4852

49-
public ngAfterViewInit(): void {
50-
this.date = new Date();
53+
public ngOnChanges(changes: SimpleChanges): void {
54+
const DateTimeFormatChange = changes['DateTimeFormat'];
55+
if (DateTimeFormatChange) {
56+
this.displayDate = this._formatDate();
57+
}
5158
}
5259

5360
public propagateChange: any = () => {};
@@ -59,7 +66,6 @@ export class DatePickerComponent implements ControlValueAccessor, AfterViewInit
5966

6067
public set date(newDate) {
6168
this._date = newDate;
62-
6369
this.displayDate = this._formatDate();
6470

6571
this.propagateChange(this.date);
@@ -106,6 +112,7 @@ export class DatePickerComponent implements ControlValueAccessor, AfterViewInit
106112
this.isDialogOpen = false;
107113
if (date) {
108114
this.date = date;
115+
this.change.emit();
109116
}
110117
});
111118
}

0 commit comments

Comments
 (0)