refactor: 💡 serialize scope_id by default

This commit is contained in:
Randall Morey committed 2020-09-10 18:32:17 -04:00
1 parent 974b557ae2
commit ab608c7544
21 files changed
+7 -266

No files matched your search

+5 -16
View File
@@ -8,18 +8,6 @@ import { copy } from 'ember-copy';
*/
export default class ApplicationSerializer extends RESTSerializer {
// =attributes
attrs = {
scope: { serialize: false }
};
/**
* Whether or not to serialize the scope ID into scope_id.
* @type {boolean}
*/
serializeScopeID = false;
// =methods
/**
@@ -81,10 +69,11 @@ export default class ApplicationSerializer extends RESTSerializer {
*/
serialize(snapshot) {
const serialized = super.serialize(...arguments);
if (this.serializeScopeID) {
const scope_id = snapshot?.attr('scope')?.attr('scope_id');
if (scope_id) serialized.scope_id = scope_id;
}
// Delete `scope` field
delete serialized.scope;
// And serialize `scope_id`
const scope_id = snapshot?.attr('scope')?.attr('scope_id');
if (scope_id) serialized.scope_id = scope_id;
return serialized;
}
@@ -1,13 +0,0 @@
import ApplicationSerializer from './application';
export default class AuthMethodSerializer extends ApplicationSerializer {
// =attributes
/**
* Serialized the scope ID into the `scope_id` field.
* @type {boolean}
*/
serializeScopeID = true;
}
-8
View File
@@ -2,14 +2,6 @@ import ApplicationSerializer from './application';
export default class GroupSerializer extends ApplicationSerializer {
// =attributes
/**
* Serialized the scope ID into the `scope_id` field.
* @type {boolean}
*/
serializeScopeID = true;
// =methods
/**
@@ -1,13 +0,0 @@
import ApplicationSerializer from './application';
export default class HostCatalogSerializer extends ApplicationSerializer {
// =attributes
/**
* Serialized the scope ID into the `scope_id` field.
* @type {boolean}
*/
serializeScopeID = true;
}
-8
View File
@@ -2,14 +2,6 @@ import ApplicationSerializer from './application';
export default class HostSetSerializer extends ApplicationSerializer {
// =attributes
/**
* Serialized the scope ID into the `scope_id` field.
* @type {boolean}
*/
serializeScopeID = true;
// =methods
/**
-13
View File
@@ -1,13 +0,0 @@
import ApplicationSerializer from './application';
export default class HostSerializer extends ApplicationSerializer {
// =attributes
/**
* Serialized the scope ID into the `scope_id` field.
* @type {boolean}
*/
serializeScopeID = true;
}
-8
View File
@@ -3,14 +3,6 @@ import { get } from '@ember/object';
export default class RoleSerializer extends ApplicationSerializer {
// =attributes
/**
* Serialized the scope ID into the `scope_id` field.
* @type {boolean}
*/
serializeScopeID = true;
// =methods
/**
-11
View File
@@ -1,11 +0,0 @@
import ApplicationSerializer from './application';
export default class ScopeSerializer extends ApplicationSerializer {
/**
* Serialize the scope ID into scope_id.
* @type {boolean}
*/
serializeScopeID = true;
}
-8
View File
@@ -2,14 +2,6 @@ import ApplicationSerializer from './application';
export default class TargetSerializer extends ApplicationSerializer {
// =attributes
/**
* Serialized the scope ID into the `scope_id` field.
* @type {boolean}
*/
serializeScopeID = true;
// =methods
/**
-13
View File
@@ -1,13 +0,0 @@
import ApplicationSerializer from './application';
export default class UserSerializer extends ApplicationSerializer {
// =attributes
/**
* Serialized the scope ID into the `scope_id` field.
* @type {boolean}
*/
serializeScopeID = true;
}