Skip to content

Commit

Permalink
Merge pull request #43 from velrest/fix-uk-tab
Browse files Browse the repository at this point in the history
fix(form navigation): update to ember 2.24 to fix `<LinkTo>` issues in engines
  • Loading branch information
velrest authored Apr 12, 2021
2 parents 02958e4 + d592c14 commit 6cbf10d
Show file tree
Hide file tree
Showing 11 changed files with 849 additions and 238 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# misc
/coverage/
!.*
.eslintcache

# ember-try
/.node_modules.ember-try/
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
/.env*
/.pnp*
/.sass-cache
/.eslintcache
/connect.lock
/coverage/
/libpeerconnection.log
Expand Down
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
/.editorconfig
/.ember-cli
/.env*
/.eslintcache
/.eslintignore
/.eslintrc.js
/.git/
Expand Down
52 changes: 50 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,55 @@ ember install ember-ebau-gwr
Usage
------------------------------------------------------------------------------

[Longer description of how to use the addon in apps.]
> **Note**
> If this addon is used in `ember < 3.24.1` the project and buildings navigation
> won't work since ember does not yet support `@ember/routing/link-component`
> in engines (which the `uk-tab/link-item` component from `ember-uikit` extends).
>
> The normal workaround for this is to use the `ember-engines/components/link-to-component` if `ember-uikit` is used by an engine but since we would need to add `ember-engines` as dependency of `ember-uikit` this is still an open issue for now.
Mount the engine in your router file. You can specify a param in the url which
will then be used to filter the `gwr-links` by their attribute `local_id`.

```js
this.mount("ember-ebau-gwr", { as: "gwr", path: "gwr/:id" });
```

### Services

The engine takes following services as argument:

```js
dependencies = {
services: [
"config",
"intl",
"notification",
"dataImport",
"store",
"router",
],
};
```

#### `config`

The config service is used to pass config to the engine. The following properties can be configured:

| Name | Type |
| ------------------------------ | -------- |
| `municipalityId` | `Number` |
| `municipalityName` | `String` |
| `cantonAbbreviation` | `String` |
| `constructionSurveyDeptNumber` | `Number` |

All values should follow the officially used format.

#### `dataImport`

In the `dataImport` service the consuming application fetches and formats the data into the expected format. The format is the same data structure as the model properties which can be found in `/addon/models`.

The service should define a `fetchProject: async () -> Promise<Object>` function.


Contributing
Expand All @@ -43,4 +91,4 @@ See the [Contributing](CONTRIBUTING.md) guide for details.
License
------------------------------------------------------------------------------

This project is licensed under the [MIT License](LICENSE.md).
This project is licensed under the [AGPLv3](LICENSE.md).
26 changes: 11 additions & 15 deletions addon/templates/project.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,17 @@
@activeProject={{this.activeProject}}
@removeProject={{this.removeProjectLink}}
/>
<ul uk-tab>
<li>
<LinkTo @route="project.form" @model={{this.activeProject}}>
{{t "ember-gwr.models.project"}}
</LinkTo>
</li>
<li>
<LinkTo
@route="project.linked-buildings"
@model={{this.activeProject}}
>
{{t "ember-gwr.models.building"}}
</LinkTo>
</li>
</ul>
<UkTab as |Tab|>
<Tab.link-item @route="project.form" @model={{this.activeProject}}>
{{t "ember-gwr.models.project"}}
</Tab.link-item>
<Tab.link-item
@route="project.linked-buildings"
@model={{this.activeProject}}
>
{{t "ember-gwr.models.building"}}
</Tab.link-item>
</UkTab>
{{outlet}}
{{/if}}
{{/if}}
Expand Down
2 changes: 0 additions & 2 deletions addon/templates/project/form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
{{t "ember-gwr.components.projectForm.applyAll"}}
</button>
<LinkTo
@route={{this.currentRoute}}
@query={{hash import=false}}
class="uk-button uk-button-default"
>
Expand All @@ -41,7 +40,6 @@
</button>
{{else}}
<LinkTo
@route={{this.currentRoute}}
@query={{hash import=true}}
class="uk-button uk-button-primary"
>
Expand Down
42 changes: 25 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,24 @@
},
"scripts": {
"build": "ember build --environment=production",
"lint": "npm-run-all --aggregate-output --continue-on-error --parallel lint:*",
"lint": "npm-run-all --aggregate-output --continue-on-error --parallel 'lint:!(fix)'",
"lint:fix": "npm-run-all --aggregate-output --continue-on-error --parallel lint:*:fix",
"lint:hbs": "ember-template-lint .",
"lint:js": "eslint .",
"lint:hbs:fix": "ember-template-lint . --fix",
"lint:js": "eslint . --cache",
"lint:js:fix": "eslint . --fix",
"start": "ember serve",
"proxy": "lcp --proxyUrl https://www-r.housing-stat.ch",
"test": "npm-run-all lint:* test:*",
"test": "npm-run-all lint test:*",
"test:ember": "ember test",
"test:ember-compatibility": "ember try:each"
},
"dependencies": {
"@ember/render-modifiers": "^1.0.2",
"dayjs": "^1.10.3",
"ember-auto-import": "^1.10.1",
"ember-cli-babel": "^7.22.1",
"ember-cli-htmlbars": "^5.3.1",
"ember-cli-babel": "^7.23.1",
"ember-cli-htmlbars": "^5.3.2",
"ember-concurrency": "^1.3.0",
"ember-concurrency-decorators": "^2.0.2",
"ember-intl": "^5.5.1",
Expand All @@ -42,40 +45,45 @@
"@adfinis-sygroup/eslint-config": "^1.3.2",
"@adfinis-sygroup/semantic-release-config": "^3.1.0",
"@ember/optional-features": "^2.0.0",
"@glimmer/component": "^1.0.2",
"@glimmer/tracking": "^1.0.2",
"@ember/test-helpers": "^2.2.0",
"@glimmer/component": "^1.0.3",
"@glimmer/tracking": "^1.0.3",
"babel-eslint": "^10.1.0",
"broccoli-asset-rev": "^3.0.0",
"ember-cli": "~3.22.0",
"ember-cli": "~3.25.3",
"ember-cli-dependency-checker": "^3.2.0",
"ember-cli-inject-live-reload": "^2.0.2",
"ember-cli-mirage": "^2.0.1",
"ember-cli-sass": "^10.0.1",
"ember-cli-sri": "^2.1.1",
"ember-cli-terser": "^4.0.0",
"ember-cli-terser": "^4.0.1",
"ember-data": "^3.25.0",
"ember-disable-prototype-extensions": "^1.1.3",
"ember-engines": "^0.8.8",
"ember-export-application-global": "^2.0.1",
"ember-load-initializers": "^2.1.1",
"ember-load-initializers": "^2.1.2",
"ember-maybe-import-regenerator": "^0.1.6",
"ember-qunit": "^4.6.0",
"ember-page-title": "^6.2.1",
"ember-qunit": "^5.1.2",
"ember-resolver": "^8.0.2",
"ember-source": "~3.22.0",
"ember-source": "~3.25.1",
"ember-source-channel-url": "^3.0.0",
"ember-template-lint": "^2.14.0",
"ember-template-lint": "^2.18.1",
"ember-template-lint-plugin-prettier": "^2.0.0",
"ember-test-selectors": "^5.0.0",
"ember-try": "^1.4.0",
"eslint": "^7.14.0",
"eslint-plugin-ember": "^9.6.0",
"eslint": "^7.20.0",
"eslint-config-prettier": "^7.2.0",
"eslint-plugin-ember": "^10.2.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-prettier": "^3.3.1",
"loader.js": "^4.7.0",
"local-cors-proxy": "^1.1.0",
"npm-run-all": "^4.1.5",
"qunit-dom": "^1.5.0",
"prettier": "^2.2.1",
"qunit": "^2.14.0",
"qunit-dom": "^1.6.0",
"sass": "^1.29.0"
},
"engines": {
Expand Down
5 changes: 2 additions & 3 deletions tests/dummy/config/ember-cli-update.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
"packages": [
{
"name": "ember-cli",
"version": "3.22.0",
"version": "3.25.3",
"blueprints": [
{
"name": "addon",
"outputRepo": "https://github.com/ember-cli/ember-addon-output",
"codemodsSource": "ember-addon-codemods-manifest@1",
"isBaseBlueprint": true,
"options": []
"isBaseBlueprint": true
}
]
}
Expand Down
7 changes: 7 additions & 0 deletions tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@
{{content-for "body"}}
{{content-for "test-body"}}

<div id="qunit"></div>
<div id="qunit-fixture">
<div id="ember-testing-container">
<div id="ember-testing"></div>
</div>
</div>

<script src="/testem.js" integrity=""></script>
<script src="{{rootURL}}assets/vendor.js"></script>
<script src="{{rootURL}}assets/test-support.js"></script>
Expand Down
4 changes: 4 additions & 0 deletions tests/test-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import { setApplication } from "@ember/test-helpers";
import Application from "dummy/app";
import config from "dummy/config/environment";
import { start } from "ember-qunit";
import * as QUnit from "qunit";
import { setup } from "qunit-dom";

setApplication(Application.create(config.APP));

setup(QUnit.assert);

start();
Loading

0 comments on commit 6cbf10d

Please sign in to comment.