forked from projectcaluma/ember-emeis
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
209 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import Controller from "@ember/controller"; | ||
import { action } from "@ember/object"; | ||
|
||
export default class RolesEditController extends Controller { | ||
get permissionFilter() { | ||
return { roles: this.model.id }; | ||
} | ||
|
||
get displayPermissionTable() { | ||
return !this.model.isNew && this.model.permissions; | ||
} | ||
|
||
@action | ||
updateModel(model, formElements) { | ||
model.slug = formElements.slug.value; | ||
model.name = formElements.name.value; | ||
model.description = formElements.description.value; | ||
|
||
return model; | ||
} | ||
} |
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,14 @@ | ||
import Route from "@ember/routing/route"; | ||
import { inject as service } from "@ember/service"; | ||
|
||
import handleModelErrors from "ember-emeis/decorators/handle-model-errors"; | ||
|
||
export default class RolesEditRoute extends Route { | ||
@service notification; | ||
@service intl; | ||
|
||
@handleModelErrors({ routeFor404: "roles.index" }) | ||
async model({ role_id: id }) { | ||
return await this.store.findRecord("role", id); | ||
} | ||
} |
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,85 @@ | ||
<EditForm @model={{@model}} @updateModel={{this.updateModel}} class="uk-margin"> | ||
<EditForm::Element @label={{t "emeis.roles.headings.slug"}}> | ||
<input | ||
class="uk-input" | ||
type="text" | ||
name="slug" | ||
pattern="^[-a-zA-Z0-9_]+$" | ||
disabled={{not @model.isNew}} | ||
value={{@model.slug}} | ||
/> | ||
<span class="uk-text-meta"> | ||
{{t "emeis.form.slug-hint"}} | ||
</span> | ||
</EditForm::Element> | ||
|
||
<EditForm::Element @label={{t "emeis.roles.headings.name"}}> | ||
<input | ||
class="uk-input" | ||
type="text" | ||
name="name" | ||
placeholder="{{t "emeis.roles.headings.name"}}..." | ||
required | ||
value={{@model.name}} | ||
/> | ||
</EditForm::Element> | ||
|
||
<EditForm::Element @label={{t "emeis.roles.headings.description"}}> | ||
<textarea | ||
class="uk-textarea" | ||
rows="5" | ||
name="description" | ||
placeholder="{{t "emeis.roles.headings.description"}}..." | ||
value={{@model.description}} | ||
required | ||
></textarea> | ||
</EditForm::Element> | ||
</EditForm> | ||
|
||
{{#if this.displayPermissionTable}} | ||
<SectionTitle @model="permissions" @noCreateLink="true" /> | ||
<DataTable | ||
@modelName="permission" | ||
@filter={{this.permissionFilter}} | ||
class="uk-margin" | ||
data-test-permissions as |table| | ||
> | ||
<table.head> | ||
<th> | ||
{{t "emeis.permissions.headings.name"}} | ||
</th> | ||
<th> | ||
{{t "emeis.permissions.headings.slug"}} | ||
</th> | ||
<th> | ||
{{t "emeis.permissions.headings.description"}} | ||
</th> | ||
</table.head> | ||
<table.body as |body|> | ||
<body.row data-test-row> | ||
{{#with body.model as |permission|}} | ||
<td class="uk-width-1-4" data-test-permission-name={{permission.id}}> | ||
<LinkTo | ||
@route="permissions.edit" | ||
@model={{permission}} | ||
class="uk-link-text" | ||
> | ||
{{permission.name}} | ||
</LinkTo> | ||
</td> | ||
|
||
<td class="uk-width-1-4" data-test-permission-slug={{permission.id}}> | ||
{{permission.slug}} | ||
</td> | ||
|
||
<td | ||
class="uk-width-expand" | ||
data-test-permission-desc={{permission.id}} | ||
> | ||
{{permission.description}} | ||
</td> | ||
{{/with}} | ||
</body.row> | ||
</table.body> | ||
</DataTable> | ||
{{/if}} |
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/controllers/roles/edit"; |
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/routes/roles/edit"; |
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/templates/roles/edit"; |
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