Skip to content

Commit

Permalink
feat: add example route and model for group
Browse files Browse the repository at this point in the history
  • Loading branch information
anehx committed May 20, 2020
1 parent 9d31cfb commit 10b7843
Show file tree
Hide file tree
Showing 34 changed files with 581 additions and 37 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ The frontend for the [emeis](https://github.com/projectcaluma/emeis) user manage
$ ember install ember-emeis
```

Then add the following lines to your `app/styles/app.scss`:

```scss
@import "ember-uikit";
@import "ember-emeis";
```

## Contributing

See the [Contributing](CONTRIBUTING.md) guide for details.
Expand Down
2 changes: 1 addition & 1 deletion addon/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default class EmberEmeisEngine extends Engine {
Resolver = Resolver;

dependencies = {
services: ["store", "intl"],
services: ["store", "intl", "notification"],
};
}

Expand Down
9 changes: 9 additions & 0 deletions addon/models/scope.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Model, { attr, belongsTo, hasMany } from "@ember-data/model";

export default class GroupModel extends Model {
@attr("string") name;
@attr("string") description;

@belongsTo("scope", { inverse: "children" }) parent;
@hasMany("scope", { inverse: "parent" }) children;
}
4 changes: 3 additions & 1 deletion addon/routes.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import buildRoutes from "ember-engines/routes";

export default buildRoutes(function () {});
export default buildRoutes(function () {
this.route("scopes", function () {});
});
3 changes: 3 additions & 0 deletions addon/routes/scopes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Route from "@ember/routing/route";

export default class ScopesRoute extends Route {}
7 changes: 7 additions & 0 deletions addon/routes/scopes/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Route from "@ember/routing/route";

export default class GroupsIndexRoute extends Route {
model() {
return this.store.findAll("scope");
}
}
5 changes: 5 additions & 0 deletions addon/templates/application.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<h1>{{t "emeis.title"}}</h1>

<LinkTo @route="scopes.index">{{t "emeis.scopes.title"}}</LinkTo>

{{outlet}}
1 change: 1 addition & 0 deletions addon/templates/scopes.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{outlet}}
7 changes: 7 additions & 0 deletions addon/templates/scopes/index.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<h2>{{t "emeis.scopes.title"}}</h2>

<ul>
{{#each @model as |scope|}}
<li>{{scope.name}}, <em>{{scope.description}}</em></li>
{{/each}}
</ul>
1 change: 1 addition & 0 deletions app/models/scope.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from "ember-emeis/models/scope";
1 change: 1 addition & 0 deletions app/routes/scopes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from "ember-emeis/routes/scopes";
1 change: 1 addition & 0 deletions app/routes/scopes/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from "ember-emeis/routes/scopes/index";
3 changes: 3 additions & 0 deletions app/styles/ember-emeis.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@import "ember-uikit/variables-theme";

// you can use the uikit SCSS variables here
1 change: 1 addition & 0 deletions app/templates/scopes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from "ember-emeis/templates/scopes";
1 change: 1 addition & 0 deletions app/templates/scopes/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from "ember-emeis/templates/scopes/index";
6 changes: 5 additions & 1 deletion blueprints/ember-emeis/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ module.exports = {
normalizeEntityName() {},
afterInstall() {
return this.addAddonsToProject({
packages: [{ name: "ember-data" }, { name: "ember-intl" }],
packages: [
{ name: "ember-data" },
{ name: "ember-intl" },
{ name: "ember-uikit" },
],
});
},
};
11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"ember-cli-babel": "^7.20.0",
"ember-cli-htmlbars": "^5.1.2",
"ember-data": "^3.18.0",
"ember-intl": "^5.1.1"
"ember-intl": "^5.1.1",
"ember-uikit": "^2.1.2"
},
"devDependencies": {
"@adfinis-sygroup/eslint-config": "1.3.1",
Expand All @@ -41,10 +42,12 @@
"ember-cli": "3.18.0",
"ember-cli-dependency-checker": "3.2.0",
"ember-cli-inject-live-reload": "2.0.2",
"ember-cli-mirage": "^1.1.6",
"ember-cli-sass": "^10.0.1",
"ember-cli-sri": "2.1.1",
"ember-cli-uglify": "3.0.0",
"ember-disable-prototype-extensions": "1.1.3",
"ember-engines": "^0.8.5",
"ember-engines": "0.8.5",
"ember-export-application-global": "2.0.1",
"ember-load-initializers": "2.1.1",
"ember-maybe-import-regenerator": "0.1.6",
Expand All @@ -59,9 +62,11 @@
"eslint-plugin-import": "2.20.2",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-prettier": "3.1.3",
"faker": "4.1.0",
"loader.js": "4.7.0",
"npm-run-all": "4.1.5",
"qunit-dom": "1.2.0"
"qunit-dom": "1.2.0",
"sass": "1.26.5"
},
"engines": {
"node": "10.* || >= 12"
Expand Down
5 changes: 5 additions & 0 deletions tests/dummy/app/adapters/application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import JSONAPIAdapter from "@ember-data/adapter/json-api";

export default class ApplicationAdapter extends JSONAPIAdapter {
namespace = "api/v1";
}
2 changes: 1 addition & 1 deletion tests/dummy/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default class App extends Application {
this.engines = {
emberEmeis: {
dependencies: {
services: ["store", "intl"],
services: ["store", "intl", "notification"],
},
},
};
Expand Down
10 changes: 10 additions & 0 deletions tests/dummy/app/routes/application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Route from "@ember/routing/route";
import { inject as service } from "@ember/service";

export default class ApplicationRoute extends Route {
@service intl;

afterModel() {
this.intl.setLocale("en");
}
}
1 change: 1 addition & 0 deletions tests/dummy/app/serializers/application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from "@ember-data/serializer/json-api";
Empty file removed tests/dummy/app/styles/app.css
Empty file.
2 changes: 2 additions & 0 deletions tests/dummy/app/styles/app.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@import "ember-uikit";
@import "ember-emeis";
2 changes: 0 additions & 2 deletions tests/dummy/app/templates/application.hbs
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
<h2 id="title">Welcome to Ember</h2>

{{outlet}}
11 changes: 11 additions & 0 deletions tests/dummy/mirage/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export default function () {
this.urlPrefix = "";
this.namespace = "/api/v1";
this.timing = 400;

this.get("/scopes");
this.post("/scopes");
this.get("/scopes/:id");
this.put("/scopes/:id");
this.del("/scopes/:id");
}
7 changes: 7 additions & 0 deletions tests/dummy/mirage/factories/scope.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Factory } from "ember-cli-mirage";
import faker from "faker";

export default Factory.extend({
name: () => faker.company.companyName(),
description: () => faker.lorem.sentence(),
});
3 changes: 3 additions & 0 deletions tests/dummy/mirage/scenarios/default.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function (server) {
server.createList("scope", 10);
}
3 changes: 3 additions & 0 deletions tests/dummy/mirage/serializers/application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { JSONAPISerializer } from "ember-cli-mirage";

export default class extends JSONAPISerializer {}
13 changes: 13 additions & 0 deletions tests/unit/models/scope-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { setupTest } from "ember-qunit";
import { module, test } from "qunit";

module("Unit | Model | scope", function (hooks) {
setupTest(hooks);

// Replace this with your real tests.
test("it exists", function (assert) {
const store = this.owner.lookup("service:store");
const model = store.createRecord("scope", {});
assert.ok(model);
});
});
11 changes: 11 additions & 0 deletions tests/unit/routes/scopes-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { setupTest } from "ember-qunit";
import { module, test } from "qunit";

module("Unit | Route | scopes", function (hooks) {
setupTest(hooks);

test("it exists", function (assert) {
const route = this.owner.lookup("route:scopes");
assert.ok(route);
});
});
11 changes: 11 additions & 0 deletions tests/unit/routes/scopes/index-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { setupTest } from "ember-qunit";
import { module, test } from "qunit";

module("Unit | Route | scopes/index", function (hooks) {
setupTest(hooks);

test("it exists", function (assert) {
const route = this.owner.lookup("route:scopes/index");
assert.ok(route);
});
});
5 changes: 5 additions & 0 deletions translations/de.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
emeis:
title: "Emeis"

scopes:
title: "Scopes"
5 changes: 5 additions & 0 deletions translations/en.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
emeis:
title: "Emeis"

scopes:
title: "scopes"
Loading

0 comments on commit 10b7843

Please sign in to comment.