-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(emeisOptions): add custom column option
- Loading branch information
1 parent
3d1bfce
commit 9a2b6e2
Showing
12 changed files
with
120 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
import { inject as service } from "@ember/service"; | ||
|
||
import PaginationController from "ember-emeis/-private/controllers/pagination"; | ||
|
||
export default class PermissionsIndexController extends PaginationController {} | ||
export default class PermissionsIndexController extends PaginationController { | ||
@service emeisOptions; | ||
|
||
get customColumns() { | ||
return this.emeisOptions.permission?.customColumns; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
import { inject as service } from "@ember/service"; | ||
|
||
import PaginationController from "ember-emeis/-private/controllers/pagination"; | ||
|
||
export default class RolesIndexController extends PaginationController {} | ||
export default class RolesIndexController extends PaginationController { | ||
@service emeisOptions; | ||
|
||
get customColumns() { | ||
return this.emeisOptions.role?.customColumns; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import Helper from "@ember/component/helper"; | ||
import { inject as service } from "@ember/service"; | ||
|
||
export default class OptionalLocalizedValue extends Helper { | ||
@service intl; | ||
@service emeisOptions; | ||
|
||
getFieldLocale(modelName) { | ||
return modelName | ||
? this.emeisOptions.forceLocale?.[modelName] | ||
: undefined || this.intl.localizedFieldLocale || this.intl.primaryLocale; | ||
} | ||
|
||
compute([field, modelName]) { | ||
if (typeof field === "string") { | ||
return field; | ||
} | ||
return field[this.getFieldLocale(modelName)]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from "ember-emeis/helpers/optional-localized-value"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
tests/integration/helpers/optional-localized-value-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { render } from "@ember/test-helpers"; | ||
import { hbs } from "ember-cli-htmlbars"; | ||
import { setupIntl } from "ember-intl/test-support"; | ||
import { setupRenderingTest } from "ember-qunit"; | ||
import { module, test } from "qunit"; | ||
|
||
module("Integration | Helper | optional-localized-value", function (hooks) { | ||
setupRenderingTest(hooks); | ||
setupIntl(hooks, ["en"]); | ||
|
||
test("it renders a localized field", async function (assert) { | ||
this.set("inputValue", { en: "english", de: "deutsch" }); | ||
|
||
await render(hbs`{{optional-localized-value this.inputValue}}`); | ||
|
||
assert.dom(this.element).hasText("english"); | ||
}); | ||
test("it renders a unlocalized field", async function (assert) { | ||
this.set("inputValue", "1234-string"); | ||
|
||
await render(hbs`{{optional-localized-value this.inputValue}}`); | ||
|
||
assert.dom(this.element).hasText("1234-string"); | ||
}); | ||
}); |