mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-24 11:22:19 +03:00
18a433debd
Issue #2846 -Implement custom RESTAdapter and serializer for settings data. -Convert theme selector to Ember.Select. -Finish upload modal and wire into settings page.
38 lines
1014 B
JavaScript
38 lines
1014 B
JavaScript
import ApplicationSerializer from 'ghost/serializers/application';
|
|
|
|
var SettingSerializer = ApplicationSerializer.extend({
|
|
serializeIntoHash: function (hash, type, record, options) {
|
|
// Settings API does not want ids
|
|
options = options || {};
|
|
options.includeId = false;
|
|
|
|
var root = Ember.String.pluralize(type.typeKey),
|
|
data = this.serialize(record, options),
|
|
payload = [];
|
|
|
|
delete data.id;
|
|
|
|
Object.keys(data).forEach(function (k) {
|
|
payload.push({ key: k, value: data[k] });
|
|
});
|
|
|
|
hash[root] = payload;
|
|
},
|
|
|
|
extractArray: function (store, type, _payload) {
|
|
var payload = { id: '0' };
|
|
|
|
_payload.settings.forEach(function (setting) {
|
|
payload[setting.key] = setting.value;
|
|
});
|
|
|
|
return [payload];
|
|
},
|
|
|
|
extractSingle: function (store, type, payload) {
|
|
return this.extractArray(store, type, payload).pop();
|
|
}
|
|
});
|
|
|
|
export default SettingSerializer;
|