Skip to content
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
11 changes: 5 additions & 6 deletions app/components/single-task.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
</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.togglePinned}}>
{{if this.isPinned "Pinned" "Pin"}}
</BsButton>

<ToggleComplete @isComplete={{this.task.isComplete}} @onClick={{this.toggleComplete}} />
</div>
</div>
</div>
Expand Down
27 changes: 23 additions & 4 deletions app/components/single-task.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
import Component from '@ember/component';
import { tagName } from '@ember-decorators/component';
import Component from "@ember/component";
import { tagName } from "@ember-decorators/component";
import { tracked } from "@glimmer/tracking";
import { action } from "@ember/object";

export default
@tagName('')
export default
@tagName("")
class SingleTaskComponent extends Component {
@tracked isPinned = false;

@action
togglePinned() {
if (this.isPinned) {
this.setPinned(null);
this.isPinned = false;
} else {
this.setPinned(this.task);
this.isPinned = true;
}
}

@action
toggleComplete() {
this.task.isComplete = !this.task.isComplete;
}
}
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}} @setPinned={{this.setPinned}} @pinnedTask={{this.pinnedTask}} />
{{/each}}
</ul>
</div>
3 changes: 3 additions & 0 deletions app/components/toggle-complete.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<BsButton @type="primary" onClick={{this.onClick}}>
{{if this.isComplete "Undo" "Done"}}
</BsButton>
6 changes: 6 additions & 0 deletions app/components/toggle-complete.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Component from "@ember/component";
import { tagName } from "@ember-decorators/component";

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

export default class IndexController extends Controller {
@tracked pinnedTask = null;

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

@action
setPinned(task) {
this.pinnedTask = task;
}
}
36 changes: 17 additions & 19 deletions app/templates/index.hbs
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
<h1>Task List</h1>
<h4>Pinned Task</h4>
{{#if this.pinnedTask}}
<div class="list-group-item {{if this.pinnedTask.isComplete "is-complete"}}">
<div class="d-flex">
<h5 class="card-title flex-fill">
{{this.pinnedTask.name}}
</h5>
<div class="toggle-done ml-auto">
<div class="btn-group btn-group-sm" role="group">
<BsButton @type="secondary">Unpin</BsButton>
{{#if this.pinnedTask.isComplete}}
<BsButton @type="primary">Undo</BsButton>
{{else}}
<BsButton @type="primary">Done</BsButton>
{{/if}}
</div>
<div class="list-group-item {{if this.pinnedTask.isComplete "is-complete"}}">
<div class="d-flex">
<h5 class="card-title flex-fill">
{{this.pinnedTask.name}}
</h5>
<div class="toggle-done ml-auto">
<div class="btn-group btn-group-sm" role="group">
<BsButton @type="secondary" disabled={{true}}>
{{if this.pinnedTask.isComplete "Complete" "Incomplete"}}
</BsButton>
</div>
</div>
<div class="task-description">
{{this.pinnedTask.description}}
</div>
</div>
<div class="task-description">
{{this.pinnedTask.description}}
</div>
</div>
{{else}}
No Pinned Tasks
No Pinned Tasks
{{/if}}
<h4>Other Tasks</h4>
<TaskList @tasks={{this.model}} />

<TaskList @tasks={{this.model}} @pinnedTask={{this.pinnedTask}} @setPinned={{this.setPinned}} />

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