Skip to content

Commit 0080173

Browse files
author
Ihor Khomiak
committed
implement favorite service functionality
1 parent 2686448 commit 0080173

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

app/components/cost/detail/cost-detail.component.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ ActionBar {
1212
}
1313

1414
.favorite-label {
15+
padding: 15;
16+
font-size: 17pt;
1517
text-align: center;
1618
vertical-align: middle;
1719
}

app/components/cost/detail/cost-detail.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@
3030

3131
<Label class="favorite-label"
3232
[text]="cost.isFavorite === true ? 'Favorite' : 'Not Favorite'"
33-
(tap)="onTap()"></Label>
33+
(tap)="onFavoriteTap()"></Label>
3434

3535
</StackLayout>

app/components/cost/detail/cost-detail.component.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ export class CostDetailComponent implements OnInit {
2424
ngOnInit(): void {
2525
const id = this.route.snapshot.params["id"];
2626
this.cost = this.costService.getCost(id);
27-
console.log(JSON.stringify(this.cost));
2827
}
2928

3029
onEditButtonTap(): void{
@@ -44,8 +43,12 @@ export class CostDetailComponent implements OnInit {
4443
this.routerExtensions.back();
4544
}
4645

47-
onTap() {
48-
this.cost.isFavorite = !this.cost.isFavorite;
46+
onFavoriteTap() {
47+
let costForUpdate = Object.assign({}, this.cost);
48+
costForUpdate.isFavorite = !this.cost.isFavorite;
49+
this.costService.updateCost(costForUpdate).then(result => {
50+
this.cost.isFavorite = !this.cost.isFavorite;
51+
});
4952
}
5053

5154
private formatChangesDate(changesDate: string) {

0 commit comments

Comments
 (0)