From a2e45705c1957c00a1e0b0372ce9b3fc62a50dea Mon Sep 17 00:00:00 2001 From: Ava Gaiety Wroten Date: Sun, 22 Dec 2019 23:02:11 -0600 Subject: [PATCH] Getting started instructions --- app/controllers/index.js | 23 +++++++++++++++++++++++ app/index.html | 2 +- app/templates/index.hbs | 18 +++++++++++++++++- app/templates/meal.hbs | 2 +- tests/unit/controllers/index-test.js | 12 ++++++++++++ 5 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 app/controllers/index.js create mode 100644 tests/unit/controllers/index-test.js diff --git a/app/controllers/index.js b/app/controllers/index.js new file mode 100644 index 0000000..be16633 --- /dev/null +++ b/app/controllers/index.js @@ -0,0 +1,23 @@ +import Controller from '@ember/controller'; +import { tracked } from "@glimmer/tracking"; +import { A } from '@ember/array'; +import { inject as service } from '@ember/service'; + +export default class IndexController extends Controller { + @service store; + @tracked items = A([]); + + constructor() { + super(...arguments); + this.assignExistingItems(); + } + + async assignExistingItems() { + let items = await this.store.peekAll('meal'); + this.items = items; + } + + get userHasMeals() { + return this.items.length >= 1; + } +} diff --git a/app/index.html b/app/index.html index eebbdb9..a8d54df 100644 --- a/app/index.html +++ b/app/index.html @@ -14,7 +14,7 @@ {{content-for "head-footer"}} - + {{content-for "body"}} diff --git a/app/templates/index.hbs b/app/templates/index.hbs index 73d371e..461797a 100644 --- a/app/templates/index.hbs +++ b/app/templates/index.hbs @@ -1 +1,17 @@ -Browser Recipes on the Left :) +{{#if this.userHasMeals}} +

+ Great, you have meals! +

+ +

+ You can see more details of any meal by clicking on them. You may also reorder meals via drag and drop (or your keyboard). +

+{{else}} +

+ Welcome to Sortable Recipes! +

+ +

+ Add some recipes to get started. +

+{{/if}} diff --git a/app/templates/meal.hbs b/app/templates/meal.hbs index 192a06a..9eb6472 100644 --- a/app/templates/meal.hbs +++ b/app/templates/meal.hbs @@ -1,4 +1,4 @@ -

+

{{@model.name}}

diff --git a/tests/unit/controllers/index-test.js b/tests/unit/controllers/index-test.js new file mode 100644 index 0000000..aa94c64 --- /dev/null +++ b/tests/unit/controllers/index-test.js @@ -0,0 +1,12 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; + +module('Unit | Controller | index', function(hooks) { + setupTest(hooks); + + // Replace this with your real tests. + test('it exists', function(assert) { + let controller = this.owner.lookup('controller:index'); + assert.ok(controller); + }); +});