chore: 🤖 Add group edit view
This commit is contained in:
8 files changed
+104
-4
No files matched your search
@@ -24,7 +24,7 @@ Router.map(function () {
|
||||
});
|
||||
|
||||
this.route('groups', function() {
|
||||
this.route('group', { path: 'group_id' }, function() {});
|
||||
this.route('group', { path: ':group_id' }, function() {});
|
||||
this.route('new');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,4 +1,64 @@
|
||||
import Route from '@ember/routing/route';
|
||||
import { inject as service } from '@ember/service';
|
||||
import { action } from '@ember/object';
|
||||
|
||||
export default class OrgsOrgGroupsGroupRoute extends Route {
|
||||
// =services
|
||||
|
||||
@service intl;
|
||||
@service notify;
|
||||
|
||||
// =methods
|
||||
|
||||
/**
|
||||
* Return a group with id
|
||||
* @param {object} params
|
||||
* @return {Promise{GroupModel}}
|
||||
*/
|
||||
model({ group_id: id }) {
|
||||
return this.store.findRecord('group', id);
|
||||
}
|
||||
|
||||
// =actions
|
||||
|
||||
/**
|
||||
* Rollback changes on group.
|
||||
* @param {GroupModel} group
|
||||
*/
|
||||
@action
|
||||
cancel(group) {
|
||||
group.rollbackAttributes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle saving a group.
|
||||
* @param {GroupModel} group
|
||||
* @param {Event} e
|
||||
*/
|
||||
@action
|
||||
async save(group) {
|
||||
try {
|
||||
await group.save();
|
||||
this.notify.success(this.intl.t('notify.save-success'));
|
||||
} catch (error) {
|
||||
// TODO: replace with translated strings
|
||||
this.notify.error(error.message, { closeAfter: null });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete group and redirect to groups index.
|
||||
* @param {GroupModel} group
|
||||
*/
|
||||
@action
|
||||
async delete(group) {
|
||||
try {
|
||||
await group.destroyRecord();
|
||||
this.transitionTo('orgs.org.groups');
|
||||
this.notify.success(this.intl.t('notify.group.delete-success'));
|
||||
} catch (error) {
|
||||
// TODO: replace with translated strings
|
||||
this.notify.error(error.message, { closeAfter: null });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import Route from '@ember/routing/route';
|
||||
|
||||
export default class OrgsOrgGroupsGroupIndexRoute extends Route {
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
import Route from '@ember/routing/route';
|
||||
|
||||
export default class OrgsOrgGroupsIndexRoute extends Route {
|
||||
}
|
||||
export default class OrgsOrgGroupsIndexRoute extends Route {}
|
||||
@@ -1 +1,3 @@
|
||||
{{outlet}}
|
||||
{{title @model.name}}
|
||||
|
||||
{{outlet}}
|
||||
@@ -0,0 +1,23 @@
|
||||
<Rose::Layout::Page as |page|>
|
||||
|
||||
<page.header>
|
||||
<h2>{{t "resources.group"}}</h2>
|
||||
</page.header>
|
||||
|
||||
<page.body>
|
||||
<Form::Role
|
||||
@model={{@model}}
|
||||
@submit={{route-action "save" @model}}
|
||||
@cancel={{route-action "cancel" @model}}
|
||||
/>
|
||||
<Rose::Separator />
|
||||
<Rose::Button
|
||||
@style="warning"
|
||||
@disabled={{@model.canSave}}
|
||||
{{on "click" (route-action "delete" @model)}}
|
||||
>
|
||||
{{t 'actions.delete'}}
|
||||
</Rose::Button>
|
||||
</page.body>
|
||||
|
||||
</Rose::Layout::Page>
|
||||
@@ -0,0 +1,11 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Route | orgs/org/groups/group/index', function(hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function(assert) {
|
||||
let route = this.owner.lookup('route:orgs/org/groups/group/index');
|
||||
assert.ok(route);
|
||||
});
|
||||
});
|
||||
@@ -61,6 +61,7 @@ notify:
|
||||
delete-success: Deleted role successfully.
|
||||
group:
|
||||
create-success: Group created succesfully.
|
||||
delete-success: Deleted group successfully.
|
||||
dev:
|
||||
default-org: Default Org
|
||||
menu-item: Menu item
|
||||
|
||||
Reference in new issue
Block a user