Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tunapanda Ember Frontend Challenge #4

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions app/components/single-task.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@
</h5>
<div class="toggle-done ml-auto">
<div class="btn-group btn-group-sm" role="group">
<BsButton @type="secondary">Pin</BsButton>
{{#if this.task.isComplete}}
<BsButton @type="primary" onClick={{action (mut this.task.isComplete) false}}>Undo</BsButton>
{{else}}
<BsButton @type="primary" onClick={{action (mut this.task.isComplete) true}}>Done</BsButton>
{{/if}}
<BsButton @type="secondary" onClick={{ action this.setPinnedTask this.task }}>Pin</BsButton>
<ToggleComplete @task={{this.task}}/>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/components/task-list.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="card">
<ul class="list-group list-group-flush">
{{#each this.tasks as |task|}}
<SingleTask @task={{task}} />
<SingleTask @task={{task}} @setPinnedTask={{this.setPinnedTask}}/>
{{/each}}
</ul>
</div>
5 changes: 5 additions & 0 deletions app/components/toggle-complete.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<BsButton
@type="primary"
onClick={{action (mut this.task.isComplete) (if this.task.isComplete false true)}}>
{{if this.task.isComplete "Undo" "Done"}}
</BsButton>
7 changes: 7 additions & 0 deletions app/components/toggle-complete.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Component from '@ember/component';
import { tagName } from '@ember-decorators/component';

export default
@tagName('')
class ToggleCompleteComponent extends Component {
}
13 changes: 13 additions & 0 deletions app/controllers/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
import Controller from '@ember/controller';
import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';

export default class IndexController extends Controller {
@tracked pinnedTask;

get completedTasks() {
return this.model.filter(task => task.get('isComplete')).length;
}

// A function that takes task to be pinned
@action
pinTask(task) {
this.pinnedTask = task.toJSON();
}
}
4 changes: 2 additions & 2 deletions app/templates/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</h5>
<div class="toggle-done ml-auto">
<div class="btn-group btn-group-sm" role="group">
<BsButton @type="secondary">Unpin</BsButton>
<BsButton @type="secondary" onClick={{action (mut this.pinnedTask) null}}>Unpin</BsButton>
{{#if this.pinnedTask.isComplete}}
<BsButton @type="primary">Undo</BsButton>
{{else}}
Expand All @@ -25,7 +25,7 @@
No Pinned Tasks
{{/if}}
<h4>Other Tasks</h4>
<TaskList @tasks={{this.model}} />
<TaskList @tasks={{this.model}} @setPinnedTask={{this.pinTask}}/>

<nav class="navbar navbar-light bg-light">
<span class="navbar-text">
Expand Down
Loading