chore: 🤖 Add new group view
This commit is contained in:
4 files changed
+110
-1
No files matched your search
@@ -0,0 +1,49 @@
|
||||
<Rose::Form
|
||||
@onSubmit={{@submit}}
|
||||
@cancel={{@cancel}}
|
||||
@disabled={{@model.isSaving}}
|
||||
@error={{true}}
|
||||
as |form|
|
||||
>
|
||||
|
||||
<form.input
|
||||
name="name"
|
||||
@type="name"
|
||||
@value={{@model.name}}
|
||||
@label={{t "form.label.name"}}
|
||||
@error={{@model.errors.name}}
|
||||
readonly={{false}}
|
||||
as |field|>
|
||||
{{#if @model.errors.name}}
|
||||
<field.errors as |errors|>
|
||||
{{#each @model.errors.name as |error|}}
|
||||
<errors.message>{{error.message}}</errors.message>
|
||||
{{/each}}
|
||||
</field.errors>
|
||||
{{/if}}
|
||||
</form.input>
|
||||
|
||||
<form.textarea
|
||||
name="description"
|
||||
@type="description"
|
||||
@value={{@model.description}}
|
||||
@label={{t "form.label.description"}}
|
||||
@error={{@model.errors.description}}
|
||||
disabled={{@model.isSaving}}
|
||||
readonly={{false}}
|
||||
as |field|>
|
||||
{{#if @model.errors.description}}
|
||||
<field.errors as |errors|>
|
||||
{{#each @model.errors.description as |error|}}
|
||||
<errors.message>{{error.message}}</errors.message>
|
||||
{{/each}}
|
||||
</field.errors>
|
||||
{{/if}}
|
||||
</form.textarea>
|
||||
|
||||
<form.actions
|
||||
@disabled={{if @model.cannotSave @model.cannotSave}}
|
||||
@submitText={{t "actions.save"}}
|
||||
@cancelText={{t "actions.cancel"}} />
|
||||
|
||||
</Rose::Form>
|
||||
@@ -1,4 +1,50 @@
|
||||
import Route from '@ember/routing/route';
|
||||
import { inject as service } from '@ember/service';
|
||||
import { action } from '@ember/object';
|
||||
|
||||
export default class OrgsOrgGroupsNewRoute extends Route {
|
||||
// =services
|
||||
|
||||
@service intl;
|
||||
@service notify;
|
||||
|
||||
// =methods
|
||||
|
||||
/**
|
||||
* Returns a new unsaved group.
|
||||
* @return {Promise{GroupModel}}
|
||||
*/
|
||||
model() {
|
||||
return this.store.createRecord('group');
|
||||
}
|
||||
|
||||
// =actions
|
||||
|
||||
/**
|
||||
* Rollback changes on group by destroying unsaved instance
|
||||
* and redirect to group index.
|
||||
* @param {GroupModel} group
|
||||
*/
|
||||
@action
|
||||
cancel(group) {
|
||||
group.rollbackAttributes();
|
||||
this.transitionTo('orgs.org.groups');
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle saving a group.
|
||||
* @param {GroupModel} group
|
||||
* @param {Event} e
|
||||
*/
|
||||
@action
|
||||
async save(group) {
|
||||
try {
|
||||
await group.save();
|
||||
this.transitionTo('orgs.org.groups.group', group);
|
||||
this.notify.success(this.intl.t('notify.group.create-success'));
|
||||
} catch (error) {
|
||||
// TODO: replace with translated strings
|
||||
this.notify.error(error.message, { closeAfter: null });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1 +1,13 @@
|
||||
{{outlet}}
|
||||
<Rose::Layout::Page as |page|>
|
||||
<page.header>
|
||||
<h2>{{t "titles.new"}}</h2>
|
||||
</page.header>
|
||||
|
||||
<page.body>
|
||||
<Form::Group
|
||||
@model={{@model}}
|
||||
@submit={{route-action "save" @model}}
|
||||
@cancel={{route-action "cancel" @model}}
|
||||
/>
|
||||
</page.body>
|
||||
</Rose::Layout::Page>
|
||||
@@ -59,6 +59,8 @@ notify:
|
||||
role:
|
||||
create-success: Role created succesfully.
|
||||
delete-success: Deleted role successfully.
|
||||
group:
|
||||
create-success: Group created succesfully.
|
||||
dev:
|
||||
default-org: Default Org
|
||||
menu-item: Menu item
|
||||
|
||||
Reference in new issue
Block a user