Skip to content

Commit de7c930

Browse files
Add «Add to favorites» functionality;
add small changes in calendar functionality
1 parent 47958c0 commit de7c930

15 files changed

+123
-86
lines changed

app/app.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
}
1616

1717
.action-item {
18-
padding-right: 10;
18+
padding-right: 20;
1919
font-size: 16pt;
2020
}

app/list/list.component.css

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,8 @@
33
vertical-align: middle;
44
color: #7d7d7d;
55
font-size: 14pt;
6-
padding-right: 20pt;
6+
}
7+
8+
.list-group-item-favorite {
9+
vertical-align: middle;
710
}

app/list/list.component.html

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
<ListView row="1"
2-
[items]="items"
3-
class="list-group">
2+
[items]="items"
3+
class="list-group">
44
<ng-template let-item="item">
55
<GridLayout row="0"
6-
columns="*, auto, 10">
6+
columns="*, 100, 100, 100">
77
<Label [nsRouterLink]="['/cost', item.id]"
88
[text]="item.quantity"
99
class="list-group-item"
1010
col="0"></Label>
1111
<Label [nsRouterLink]="['/cost', item.id]"
1212
[text]="item.changesDate"
1313
class="list-group-item-date"
14-
col="0"></Label>
14+
col="1"></Label>
1515
<Label [nsRouterLink]="['/cost', item.id]"
1616
[text]="item.type"
1717
class="tag-item"
18-
col="1"></Label>
18+
col="2"></Label>
19+
<Label [nsRouterLink]="['/cost', item.id]"
20+
[text]="item.isFavorite === true ? 'Favorite' : 'Not Favorite'"
21+
class="list-group-item-favorite"
22+
col="3"></Label>
1923
</GridLayout>
2024
</ng-template>
2125
</ListView>

app/tabs/calendar/calendar.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
(stateChanged)="onDateRangeStateChangedHandler()"></calendar-date-range>
66
<calendar-date-range-cost-list *ngIf="state == 'dateFilteredList'"
77
(stateChanged)="onDateRangeCostListChangedHandler()"
8-
[filteredCostList]="filteredCostList"></calendar-date-range-cost-list>
8+
[filteredCosts]="filteredCosts"></calendar-date-range-cost-list>
99
</StackLayout>

app/tabs/calendar/calendar.component.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,31 @@ import { Cost } from "../cost/cost";
1212
})
1313
export class CalendarComponent {
1414
private state: string = 'dateSelect';
15-
private costList:Array<Cost> = new Array<Cost>();
16-
public filteredCostList:Array<Cost> = new Array<Cost>();
15+
public filteredCosts: Cost[] = new Array<Cost>();
16+
public allCosts: Cost[] = new Array<Cost>();
1717

1818
constructor(private costService:CostService){}
19+
20+
ngOnInit() {
21+
this.costService.costsListObservable.subscribe((costs) => {
22+
this.allCosts = costs;
23+
});
24+
}
1925

2026
onSendDateChange(args) {
2127
let startDateRange = new Date(args.startDate);
2228
let endDateRange = new Date(args.endDate);
29+
let costs: Cost[] = new Array<Cost>();
2330

24-
this.costService.costsListObservable.subscribe((costs) => {
25-
for (var index = 0; index < costs.length; index++) {
26-
let currentCostDate = new Date(costs[index].changesDate);
27-
if(currentCostDate >= startDateRange && currentCostDate <= endDateRange) {
28-
this.costList.push(costs[index]);
29-
}
31+
this.allCosts.forEach(cost => {
32+
let currentCostDate = new Date(cost.changesDate);
33+
if(currentCostDate >= startDateRange && currentCostDate <= endDateRange) {
34+
costs.push(cost);
3035
}
31-
this.filteredCostList = this.costList;
32-
//this.costList.pop();
33-
//this.filterDate.pop();
3436
});
37+
this.filteredCosts = costs;
38+
//this.costList.pop();
39+
//this.filterDate.pop();
3540
}
3641

3742
onDateRangeStateChangedHandler() {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
<list [items]="filteredCostList"></list>
1+
<list [items]="filteredCosts"></list>
22
<Label text="Back to 'Calendar'" (tap)="onTap()"></Label>

app/tabs/calendar/date-range-cost-list/calendar-date-range-cost-list.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { CostService } from "../../../tabs/cost/cost.service";
1212
export class CalendarDateRangeCostListComponent {
1313

1414
@Output() stateChanged = new EventEmitter();
15-
@Input() filteredCostList:Array<Cost>;
15+
@Input() filteredCosts:Array<Cost>;
1616

1717
onTap(){
1818
this.stateChanged.next("");

app/tabs/calendar/date-range/calendar-date-range.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<StackLayout orientation="vertical"
22
id="date-picker-from">
3-
<DatePicker (loaded)="onPickerLoaded($event)"
3+
<DatePicker (loaded)="onStartPickerLoaded($event)"
44
(dateChange)="onStartDateChange($event)"></DatePicker>
55
</StackLayout>
66
<StackLayout orientation="vertical"
77
id="date-picker-to">
8-
<DatePicker (loaded)="onPickerLoaded($event)"
8+
<DatePicker (loaded)="onEndPickerLoaded($event)"
99
(dateChange)="onEndDateChange($event)"></DatePicker>
1010
</StackLayout>
1111

app/tabs/calendar/date-range/calendar-date-range.component.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,29 @@ export class CalendarDateRangeComponent {
2828
this.sendDateChange.next(dateRange);
2929
}
3030

31-
onPickerLoaded(args) {
31+
onStartPickerLoaded(args) {
3232
let datePicker = <DatePicker>args.object;
33-
34-
datePicker.minDate = new Date(2017, 0, 1);
35-
datePicker.maxDate = new Date(2017, 11, 12);
33+
datePicker.date = new Date();
34+
this._startDate = datePicker.date.toDateString();
35+
console.log(this._startDate);
36+
}
37+
38+
onEndPickerLoaded(args) {
39+
let datePicker = <DatePicker>args.object;
40+
datePicker.date = new Date();
41+
this._endDate = datePicker.date.toDateString();
42+
console.log(this._endDate);
3643
}
3744

3845
onStartDateChange(args) {
3946
let startDateStr: string = args.value;
4047
this._startDate = startDateStr;
48+
console.log(this._startDate);
4149
}
4250

4351
onEndDateChange(args) {
4452
let endDateStr: string = args.value;
4553
this._endDate = endDateStr;
54+
console.log(this._endDate);
4655
}
4756
}

app/tabs/cost/cost.service.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ export class CostService {
1414
}
1515

1616
private costs = new Array<Cost>(
17-
{ id: 0, quantity: 310, type: "Products", changesDate: "Jul 01 2017" },
18-
{ id: 1, quantity: 25, type: "Products", changesDate: "Aug 03 2017" },
19-
{ id: 2, quantity: 127, type: "ForHome", changesDate: "Jun 09 2017" },
20-
{ id: 3, quantity: 80, type: "Products", changesDate: "May 22 2017" },
21-
{ id: 4, quantity: 32, type: "Products", changesDate: "Nov 13 2017" },
22-
{ id: 5, quantity: 235, type: "Products", changesDate: "Jan 31 2017" },
23-
{ id: 6, quantity: 98, type: "ForHome", changesDate: "Feb 20 2017" },
24-
{ id: 7, quantity: 105, type: "Products", changesDate: "Oct 01 2017" },
25-
{ id: 8, quantity: 80, type: "Products", changesDate: "Aug 15 2017" },
26-
{ id: 9, quantity: 75, type: "Products", changesDate: "Aug 08 2017" },
27-
{ id: 10, quantity: 235, type: "Products", changesDate: "Aug 26 2017" },
28-
{ id: 11, quantity: 264, type: "ForHome", changesDate: "May 30 2017" },
29-
{ id: 12, quantity: 78, type: "Products", changesDate: "April 04 2017" }
17+
{ id: 0, quantity: 310, type: "Products", changesDate: "Jul 01 2017", isFavorite: false },
18+
{ id: 1, quantity: 25, type: "Products", changesDate: "Aug 03 2017", isFavorite: false },
19+
{ id: 2, quantity: 127, type: "ForHome", changesDate: "Aug 29 2017", isFavorite: false },
20+
{ id: 3, quantity: 80, type: "Products", changesDate: "Aug 29 2017", isFavorite: false },
21+
{ id: 4, quantity: 32, type: "Products", changesDate: "Nov 13 2017", isFavorite: false },
22+
{ id: 5, quantity: 235, type: "Products", changesDate: "Jan 31 2017", isFavorite: false },
23+
{ id: 6, quantity: 98, type: "ForHome", changesDate: "Feb 20 2017", isFavorite: false },
24+
{ id: 7, quantity: 105, type: "Products", changesDate: "Oct 01 2017", isFavorite: false },
25+
{ id: 8, quantity: 80, type: "Products", changesDate: "Aug 29 2017", isFavorite: false },
26+
{ id: 9, quantity: 75, type: "Products", changesDate: "Aug 08 2017", isFavorite: false },
27+
{ id: 10, quantity: 235, type: "Products", changesDate: "Aug 26 2017", isFavorite: false },
28+
{ id: 11, quantity: 264, type: "ForHome", changesDate: "May 30 2017", isFavorite: false },
29+
{ id: 12, quantity: 78, type: "Products", changesDate: "April 04 2017", isFavorite: false }
3030
);
3131

3232
public get costsListObservable(): Rx.Observable<Cost[]> {

0 commit comments

Comments
 (0)