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.del('/managed-groups/:id');
this.post(
'/managed-groups/:idMethod',
function ({ managedGroups }, { params: { idMethod } }) {
const attrs = this.normalizedRequestAttrs();
const id = idMethod.split(':')[0];
const managedGroup = managedGroups.find(id);
const updatedAttrs = {
version: attrs.version,
attributes: managedGroup.attributes,
};
return managedGroup.update(updatedAttrs);
}
);
this.post('/managed-groups');
// this.post(
// '/managed-groups/:idMethod',
// function ({ managedGroups }, { params: { idMethod } }) {
// const attrs = this.normalizedRequestAttrs();
// const id = idMethod.split(':')[0];
// const managedGroup = managedGroups.find(id);
// const updatedAttrs = {
// version: attrs.version,
// attributes: managedGroup.attributes,
// };
// return managedGroup.update(updatedAttrs);
// }
// );
/* Uncomment the following line and the Response import above
* Then change the response code to simulate error responses.
@@ -1,4 +1,5 @@
import factory from '../generated/factories/managed-group';
import { random } from 'faker';
import permissions from '../helpers/permissions';
export default factory.extend({
@@ -11,4 +12,17 @@ export default factory.extend({
'update',
'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(),
updated_time: () => date.recent(),
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 {
// =services
@service intl;
@service notify;
@service can;
//=methods
/**
*
* @returns {Promise{[ManagedGroupsModel]}}
@@ -33,6 +38,10 @@ export default class ScopesScopeAuthMethodsAuthMethodManagedGroupsRoute extends
}
}
/**
* Save a managed group in current scope.
* @param {ManagedGroupModel} managedGroup
*/
@action
@loading
@notifyError(({ message }) => message)
@@ -40,9 +49,10 @@ export default class ScopesScopeAuthMethodsAuthMethodManagedGroupsRoute extends
isNew ? 'notifications.create-success' : 'notifications.save-success'
)
async save(managedGroup) {
debugger;
await managedGroup.save();
await this.transitionTo(
'scopes.scope.auth-methods.auth-method.managed-groups.managed-group',
'scopes.scope.auth-methods.auth-method.managed-groups',
managedGroup
);
this.refresh();