Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
gcouairon committed Mar 4, 2020
1 parent c500ccf commit 383d7b8
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 36 deletions.
65 changes: 37 additions & 28 deletions src/app/goals/goals.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,41 +17,50 @@
<ion-card *ngFor="let goal of data.getGoals(); let i = index" [attr.data-index]="i">
<ion-card-header>
<ion-card-subtitle>
{{ data.getTips()[goal.tipId].tags }}
{{ data.getTipById(goal.tipId).tags }}
<ion-note class="ion-float-right" style="font-weight: normal">Added: {{ goal.added | date }}</ion-note>
</ion-card-subtitle>
<ion-card-title>Goal {{ i + 1 }}: {{ data.getTips()[goal.tipId].title }}</ion-card-title>
<ion-card-title>Goal {{ i + 1 }}: {{ data.getTipById(goal.tipId).title }}</ion-card-title>
</ion-card-header>

<ion-card-content>
<ion-grid>
<ion-row>
<ion-col>Did you keep it up for seven days?</ion-col>
<ion-col size="auto"><ion-button shape="round" size="small">
<ion-icon name="thumbs-up"></ion-icon>
</ion-button></ion-col>
<ion-col size="auto"><ion-button shape="round" size="small" color="tertiary">
<ion-icon name="thumbs-down"></ion-icon>
</ion-button></ion-col>
</ion-row>
<ion-row>
<ion-col>Did it you find it helpful?</ion-col>
<ion-col size="auto"><ion-button shape="round" size="small" color="success">
<ion-icon name="happy-outline"></ion-icon>
</ion-button></ion-col>
<ion-col size="auto"><ion-button shape="round" size="small" color="danger">
<ion-icon name="sad-outline"></ion-icon>
</ion-button></ion-col>
</ion-row>
</ion-grid>
<p>{{ data.getTipById(goal.tipId).subtitle }} </p>
<br/>
<div class="ion-text-center">
How long did you keep it up ?
</div>
<ion-segment value="{{goal.duration}}">
<ion-segment-button (click)="data.setDuration(goal.tipId, 1)" value="1">
<ion-label>A Day</ion-label>
</ion-segment-button>
<ion-segment-button (click)="data.setDuration(goal.tipId, 7)" value="7">
<ion-label>A Week</ion-label>
</ion-segment-button>
<ion-segment-button (click)="data.setDuration(goal.tipId, 30)" value="30">
<ion-label>A Month</ion-label>
</ion-segment-button>
</ion-segment>
<br/>
<div class="ion-text-center">
Did you find it helpful ?
</div><br/>
<ion-segment value="{{goal.helpful}}">
<ion-segment-button (click)="data.setHelpful(goal.tipId, -1)" value="-1">
<ion-label><ion-icon name="sad-outline" size="large" color="danger"></ion-icon></ion-label>
</ion-segment-button>
<ion-segment-button (click)="data.setHelpful(goal.tipId, 0)" value="0">
<ion-label><ion-icon name="happy-outline" size="large" color='medium'></ion-icon></ion-label>
</ion-segment-button>
<ion-segment-button (click)="data.setHelpful(goal.tipId, 1)" value="1">
<ion-label><ion-icon name="happy-outline" size="large" color="success"></ion-icon></ion-label>
</ion-segment-button>
</ion-segment>


<!--<p>
{{ data.getTips()[goal.tipId].subtitle }}
</p>-->
<div class="ion-text-center">
<ion-button (click)="data.toggleGoal(goal.tipId)">
Remove goal
</ion-button>
</div>


</ion-card-content>

<!--<ion-footer>
Expand Down
19 changes: 16 additions & 3 deletions src/app/services/data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import data from './data.json';
export interface Goal {
tipId: number;
added: Date;
helpful: boolean;
helpful: number;
daysStreak: number;
duration: number;
}

export interface Tip {
Expand Down Expand Up @@ -76,8 +77,9 @@ export class DataService {
const goal: Goal = {
tipId,
added: new Date(),
helpful: null,
daysStreak: 0
helpful: 0,
daysStreak: 0,
duration: 1
};

this.goals.push(goal);
Expand All @@ -89,6 +91,17 @@ export class DataService {
this.storage.set('goals', this.goals.filter( value => value !== undefined));
}

public setDuration(tipId: number, duration: number) {
const goal = this.goals[this.findGoal(tipId)];
goal.duration = duration;
this.saveGoals();
}
public setHelpful(tipId: number, helpful: number) {
const goal = this.goals[this.findGoal(tipId)];
goal.helpful = helpful;
this.saveGoals();
}

public getGoals(): Goal[] {
return this.goals;
}
Expand Down
10 changes: 5 additions & 5 deletions src/app/tip/tip.component.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<ion-card *ngIf="tip" [routerLink]="'/goal/' + tip.id">
<ion-card *ngIf="tip">


<ion-button color='light'>
<ion-icon *ngIf="data.findGoal(tip.id) == -1" name="star-outline" (click)="data.toggleGoal(tip.id)"></ion-icon>
<ion-icon *ngIf="data.findGoal(tip.id) >=0 " name="star"></ion-icon>
</ion-button>
<ion-card-header>
<ion-button color='light' (click)="data.toggleGoal(tip.id)">
<ion-icon *ngIf="data.findGoal(tip.id) == -1" name="star-outline"></ion-icon>
<ion-icon *ngIf="data.findGoal(tip.id) >=0 " name="star"></ion-icon>
</ion-button>
<ion-card-subtitle>{{ tip.tags }}
</ion-card-subtitle>
<ion-card-title size="auto">
Expand Down

0 comments on commit 383d7b8

Please sign in to comment.