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..5208db9 100644
--- a/app/components/single-task.hbs
+++ b/app/components/single-task.hbs
@@ -5,12 +5,13 @@
- Pin
- {{#if this.task.isComplete}}
- Undo
- {{else}}
- Done
- {{/if}}
+
+ {{if this.task.isPinned "Unpin" "Pin" }}
+
+
+
+
+
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/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/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"}}
+
diff --git a/app/controllers/index.js b/app/controllers/index.js
index 78d8779..248c067 100644
--- a/app/controllers/index.js
+++ b/app/controllers/index.js
@@ -1,4 +1,33 @@
import Controller from '@ember/controller';
+import {action} from '@ember/object';
+import {filterBy} from '@ember/object/computed';
export default class IndexController extends Controller {
+
+ isPinnedTask = false;
+
+ @action
+ toggleTaskPin(task) {
+ task.toggleProperty('isPinned');
+ }
+
+ @filterBy('model', 'isPinned', true) pinnedTasks; //computed property using filterBy decorator
+
+
+ get unpinnedTasks() {
+ /**
+ * Filter unpinned tasks from tasks model
+ * returns @computed property : all task where isPinned key doesn't exit or it's value is false
+ */
+ return [...this.model.filterBy('isPinned', undefined),
+ ...this.model.filterBy('isPinned', false)];
+ }
+
+ get completedTasks() {
+ /**
+ * Get the total count of completed tasks
+ * returns @number: count of all tasks marked as complete
+ */
+ return this.model.filterBy('isComplete').length;
+ }
}
diff --git a/app/templates/index.hbs b/app/templates/index.hbs
index 13a70b0..579efd2 100644
--- a/app/templates/index.hbs
+++ b/app/templates/index.hbs
@@ -1,31 +1,12 @@
Task List
Pinned Task
-{{#if this.pinnedTask}}
-
-
-
- {{this.pinnedTask.name}}
-
-
-
- Unpin
- {{#if this.pinnedTask.isComplete}}
- Undo
- {{else}}
- Done
- {{/if}}
-
-
-
-
- {{this.pinnedTask.description}}
-
-
+{{#if this.pinnedTasks}}
+
{{else}}
No Pinned Tasks
{{/if}}
Other Tasks
-
+