feat: 🎸 Add managed groups create CRUD operation

This commit is contained in:
Carlos Alcaide Corvo committed 2021-11-10 07:54:49 -08:00
1 parent 2f1feab9d3
commit deb9847617
10 files changed
+120 -3

No files matched your search

@@ -1,8 +1,8 @@
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';
import { confirm } from 'core/decorators/confirm';
import { inject as service } from '@ember/service';
import loading from 'ember-loading/decorator';
import { confirm } from 'core/decorators/confirm';
import { notifySuccess, notifyError } from 'core/decorators/notify';
export default class ScopesScopeAuthMethodsAuthMethodManagedGroupsRoute extends Route {
@@ -33,6 +33,21 @@ export default class ScopesScopeAuthMethodsAuthMethodManagedGroupsRoute extends
}
}
@action
@loading
@notifyError(({ message }) => message)
@notifySuccess(({ isNew }) =>
isNew ? 'notifications.create-success' : 'notifications.save-success'
)
async save(managedGroup) {
await managedGroup.save();
await this.transitionTo(
'scopes.scope.auth-methods.auth-method.managed-groups.managed-group',
managedGroup
);
this.refresh();
}
/**
* Delete a managed group in current scope and redirect to index
* @param {ManagedGroupModel} managed group
@@ -0,0 +1,36 @@
import Route from '@ember/routing/route';
export default class ScopesScopeAuthMethodsAuthMethodManagedGroupsNewRoute extends Route {
// =methods
model() {
const { id: auth_method_id, type } = this.modelFor(
'scopes.scope.auth-methods.auth-method'
);
return this.store.createRecord('managed-group', {
type,
auth_method_id,
});
}
renderTemplate() {
super.renderTemplate(...arguments);
this.render(
'scopes/scope/auth-methods/auth-method/managed-groups/new/-header',
{
into: 'scopes/scope/auth-methods/auth-method',
outlet: 'header',
}
);
this.render('_empty', {
into: 'scopes/scope/auth-methods/auth-method',
outlet: 'actions',
});
this.render('_empty', {
into: 'scopes/scope/auth-methods/auth-method',
outlet: 'navigation',
});
}
}