WIP fixing creation mirage model error

This commit is contained in:
Carlos Alcaide Corvo committed 2021-11-10 09:07:17 -08:00
1 parent deb9847617
commit 4e41ac531d
4 files changed
+39 -25

No files matched your search

+14 -13
View File
@@ -523,19 +523,20 @@ export default function () {
); );
this.get('/managed-groups/:id'); this.get('/managed-groups/:id');
this.del('/managed-groups/:id'); this.del('/managed-groups/:id');
this.post( this.post('/managed-groups');
'/managed-groups/:idMethod', // this.post(
function ({ managedGroups }, { params: { idMethod } }) { // '/managed-groups/:idMethod',
const attrs = this.normalizedRequestAttrs(); // function ({ managedGroups }, { params: { idMethod } }) {
const id = idMethod.split(':')[0]; // const attrs = this.normalizedRequestAttrs();
const managedGroup = managedGroups.find(id); // const id = idMethod.split(':')[0];
const updatedAttrs = { // const managedGroup = managedGroups.find(id);
version: attrs.version, // const updatedAttrs = {
attributes: managedGroup.attributes, // version: attrs.version,
}; // attributes: managedGroup.attributes,
return managedGroup.update(updatedAttrs); // };
} // return managedGroup.update(updatedAttrs);
); // }
// );
/* Uncomment the following line and the Response import above /* Uncomment the following line and the Response import above
* Then change the response code to simulate error responses. * Then change the response code to simulate error responses.
@@ -1,4 +1,5 @@
import factory from '../generated/factories/managed-group'; import factory from '../generated/factories/managed-group';
import { random } from 'faker';
import permissions from '../helpers/permissions'; import permissions from '../helpers/permissions';
export default factory.extend({ export default factory.extend({
@@ -11,4 +12,17 @@ export default factory.extend({
'update', 'update',
'delete', 'delete',
], ],
attributes() {
switch (this.type) {
case 'oidc':
return {
filter: random.word(),
};
default:
return {
filter: '',
};
}
},
}); });
@@ -11,15 +11,4 @@ export default Factory.extend({
created_time: () => date.recent(), created_time: () => date.recent(),
updated_time: () => date.recent(), updated_time: () => date.recent(),
version: () => datatype.number(), version: () => datatype.number(),
type: 'oidc',
attributes: function () {
switch (this.type) {
case 'oidc':
return {
filter: random.words(),
};
default:
return;
}
},
}); });
@@ -8,7 +8,12 @@ import { notifySuccess, notifyError } from 'core/decorators/notify';
export default class ScopesScopeAuthMethodsAuthMethodManagedGroupsRoute extends Route { export default class ScopesScopeAuthMethodsAuthMethodManagedGroupsRoute extends Route {
// =services // =services
@service intl;
@service notify; @service notify;
@service can;
//=methods
/** /**
* *
* @returns {Promise{[ManagedGroupsModel]}} * @returns {Promise{[ManagedGroupsModel]}}
@@ -33,6 +38,10 @@ export default class ScopesScopeAuthMethodsAuthMethodManagedGroupsRoute extends
} }
} }
/**
* Save a managed group in current scope.
* @param {ManagedGroupModel} managedGroup
*/
@action @action
@loading @loading
@notifyError(({ message }) => message) @notifyError(({ message }) => message)
@@ -40,9 +49,10 @@ export default class ScopesScopeAuthMethodsAuthMethodManagedGroupsRoute extends
isNew ? 'notifications.create-success' : 'notifications.save-success' isNew ? 'notifications.create-success' : 'notifications.save-success'
) )
async save(managedGroup) { async save(managedGroup) {
debugger;
await managedGroup.save(); await managedGroup.save();
await this.transitionTo( await this.transitionTo(
'scopes.scope.auth-methods.auth-method.managed-groups.managed-group', 'scopes.scope.auth-methods.auth-method.managed-groups',
managedGroup managedGroup
); );
this.refresh(); this.refresh();