From 443006bc355cebcde4737d30b17f9131b4a02152 Mon Sep 17 00:00:00 2001 From: mimidots Date: Mon, 11 Jan 2021 05:51:47 +0300 Subject: [PATCH 1/4] -Added `isPinned` tracked property on the application index route since the controllers are singleton. - Added `togglePin` action on controller to provide a way for user to toggle pinned tasks. (Passed in to component as children attribute) --- .gitignore | 3 +++ app/components/single-task.hbs | 4 +++- app/components/task-list.hbs | 2 +- app/controllers/index.js | 8 ++++++++ app/templates/index.hbs | 2 +- package.json | 2 +- 6 files changed, 17 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index c40a1b2..b43fa38 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,6 @@ /.node_modules.ember-try/ /bower.json.ember-try /package.json.ember-try + + +/.idea/ diff --git a/app/components/single-task.hbs b/app/components/single-task.hbs index d644ec8..b8d2e85 100644 --- a/app/components/single-task.hbs +++ b/app/components/single-task.hbs @@ -5,7 +5,9 @@
- Pin + + {{if this.task.isPinned "Unpin" "Pin" }} + {{#if this.task.isComplete}} Undo {{else}} diff --git a/app/components/task-list.hbs b/app/components/task-list.hbs index 41b6c7c..c81cc5e 100644 --- a/app/components/task-list.hbs +++ b/app/components/task-list.hbs @@ -1,7 +1,7 @@
    {{#each this.tasks as |task|}} - + {{/each}}
\ No newline at end of file diff --git a/app/controllers/index.js b/app/controllers/index.js index 78d8779..e470f7a 100644 --- a/app/controllers/index.js +++ b/app/controllers/index.js @@ -1,4 +1,12 @@ import Controller from '@ember/controller'; +import {action} from '@ember/object'; export default class IndexController extends Controller { + + isPinnedTask=false; + + @action + toggleTaskPin(task) { + task.toggleProperty('isPinned'); + } } diff --git a/app/templates/index.hbs b/app/templates/index.hbs index 13a70b0..1b7635c 100644 --- a/app/templates/index.hbs +++ b/app/templates/index.hbs @@ -25,7 +25,7 @@ No Pinned Tasks {{/if}}

Other Tasks

- +
diff --git a/app/components/single-task.js b/app/components/single-task.js index 30b0515..4a2891e 100644 --- a/app/components/single-task.js +++ b/app/components/single-task.js @@ -1,7 +1,14 @@ import Component from '@ember/component'; -import { tagName } from '@ember-decorators/component'; +import {tagName} from '@ember-decorators/component'; +import {action} from '@ember/object'; -export default +export default @tagName('') class SingleTaskComponent extends Component { + + @action + toggleComplete(complete) { + this.task.isComplete = !complete; + } + } diff --git a/app/components/toggle-complete.hbs b/app/components/toggle-complete.hbs new file mode 100644 index 0000000..50c06ad --- /dev/null +++ b/app/components/toggle-complete.hbs @@ -0,0 +1,4 @@ + + + {{if @isComplete "Undo" "Done"}} +