mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-25 19:48:50 +03:00
983110d931
no issue - add eslint-plugin-ember, configure no-old-shims rule - run `eslint --fix` on `app`, `lib`, `mirage`, and `tests` to move imports to the new module imports - further cleanup of Ember globals usage - remove event-dispatcher initializer now that `canDispatchToEventManager` is deprecated
43 lines
1.3 KiB
JavaScript
43 lines
1.3 KiB
JavaScript
import ApplicationSerializer from 'ghost-admin/serializers/application';
|
|
import {pluralize} from 'ember-inflector';
|
|
|
|
export default ApplicationSerializer.extend({
|
|
serializeIntoHash(hash, type, record, options) {
|
|
// Settings API does not want ids
|
|
options = options || {};
|
|
options.includeId = false;
|
|
|
|
let root = pluralize(type.modelName);
|
|
let data = this.serialize(record, options);
|
|
let payload = [];
|
|
|
|
delete data.id;
|
|
|
|
Object.keys(data).forEach((k) => {
|
|
payload.push({key: k, value: data[k]});
|
|
});
|
|
|
|
hash[root] = payload;
|
|
},
|
|
|
|
normalizeArrayResponse(store, primaryModelClass, _payload, id, requestType) {
|
|
let payload = {settings: [this._extractObjectFromArrayPayload(_payload)]};
|
|
return this._super(store, primaryModelClass, payload, id, requestType);
|
|
},
|
|
|
|
normalizeSingleResponse(store, primaryModelClass, _payload, id, requestType) {
|
|
let payload = {setting: this._extractObjectFromArrayPayload(_payload)};
|
|
return this._super(store, primaryModelClass, payload, id, requestType);
|
|
},
|
|
|
|
_extractObjectFromArrayPayload(_payload) {
|
|
let payload = {id: '0'};
|
|
|
|
_payload.settings.forEach((setting) => {
|
|
payload[setting.key] = setting.value;
|
|
});
|
|
|
|
return payload;
|
|
}
|
|
});
|