Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: indent scopes list according to level #260

Merged
merged 2 commits into from
Aug 11, 2021
Merged
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
9 changes: 7 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@
- `ember test --server` – Runs the test suite in "watch mode"
- `ember try:each` – Runs the test suite against multiple Ember versions

## Running the dummy application
## Running the dummy application (mirage backend)

- `ember serve`
- `yarn start`
- Visit the dummy application at [http://localhost:4200](http://localhost:4200).

## Running the dummy application (real backend)

- set up `emeis` (see [docs](https://github.com/projectcaluma/emeis))
- `yarn start-proxy`

For more information on using ember-cli, visit [https://ember-cli.com/](https://ember-cli.com/).
3 changes: 2 additions & 1 deletion addon/models/scope.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { belongsTo, hasMany } from "@ember-data/model";
import { attr, belongsTo, hasMany } from "@ember-data/model";

import localizedAttr from "ember-emeis/decorators/localized-attr";
import LocalizedModel from "ember-emeis/models/localized";

export default class ScopeModel extends LocalizedModel {
@localizedAttr name;
@localizedAttr description;
@attr level;

@belongsTo("scope", { inverse: "children" }) parent;
@hasMany("scope", { inverse: "parent" }) children;
Expand Down
1 change: 1 addition & 0 deletions addon/templates/scopes/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<body.row>
{{#let body.model as |scope|}}
<td class="uk-width-1-4" data-test-scope-name={{scope.id}}>
{{#each (repeat scope.level) as |empty|}}&nbsp;&nbsp;{{/each}}
<LinkTo @route="scopes.edit" @model={{scope}} class="uk-link-text">
{{scope.name}}
</LinkTo>
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,20 @@
"lint:hbs": "ember-template-lint .",
"lint:js": "eslint .",
"start": "ember serve",
"start-proxy": "ember server --proxy http://localhost:8000",
"test": "npm-run-all lint:* test:*",
"test:ember": "ember test",
"test:ember-compatibility": "ember try:each"
},
"dependencies": {
"@ember/optional-features": "1.3.0",
"@ember/render-modifiers": "^1.0.2",
"ember-cli-babel": "^7.23.0",
"@glimmer/component": "1.0.1",
"@glimmer/tracking": "1.0.1",
"ember-auto-import": "1.6.0",
"ember-cli-babel": "^7.23.0",
"ember-cli-htmlbars": "^5.3.1",
"ember-composable-helpers": "^4.5.0",
"ember-concurrency": "^1.3.0",
"ember-concurrency-decorators": "^2.0.1",
"ember-data": "^3.22.0",
Expand Down
5 changes: 4 additions & 1 deletion tests/acceptance/scopes-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ module("Acceptance | scopes", function (hooks) {
assert.equal(currentURL(), "/scopes");

assert.dom("[data-test-scope-name]").exists({ count: 10 });
assert.dom(`[data-test-scope-name="${scope.id}"]`).hasText(scope.name.en);
assert
.dom(`[data-test-scope-name="${scope.id}"]`)
// &nbsp; is represented as \xa0 in JS
.hasText("\xa0".repeat(2 * scope.level) + " " + scope.name.en);
assert
.dom(`[data-test-scope-desc="${scope.id}"]`)
.hasText(scope.description.en);
Expand Down
1 change: 1 addition & 0 deletions tests/dummy/mirage/factories/scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ import localize from "./localize";
export default Factory.extend({
name: () => localize(faker.company.companyName()),
description: () => localize(faker.lorem.paragraph()),
level: () => faker.random.number({ max: 3 }),
});
Loading