mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 22:02:11 +03:00
e74e2e039e
no issue - switch `jscs` and `jshint` inline config to `eslint` config - fix eslint errors, predominantly in tests where the config now the main app config more closely
35 lines
988 B
JavaScript
35 lines
988 B
JavaScript
/* eslint-disable camelcase */
|
|
import {A as emberA, isEmberArray} from 'ember-array/utils';
|
|
import Transform from 'ember-data/transform';
|
|
import SlackObject from 'ghost-admin/models/slack-integration';
|
|
|
|
export default Transform.extend({
|
|
deserialize(serialized) {
|
|
let slackObj, settingsArray;
|
|
try {
|
|
settingsArray = JSON.parse(serialized) || [];
|
|
} catch (e) {
|
|
settingsArray = [];
|
|
}
|
|
|
|
slackObj = settingsArray.map((itemDetails) => {
|
|
return SlackObject.create(itemDetails);
|
|
});
|
|
return emberA(slackObj);
|
|
},
|
|
|
|
serialize(deserialized) {
|
|
let settingsArray;
|
|
if (isEmberArray(deserialized)) {
|
|
settingsArray = deserialized.map((item) => {
|
|
let url = (item.get('url') || '').trim();
|
|
|
|
return {url};
|
|
}).compact();
|
|
} else {
|
|
settingsArray = [];
|
|
}
|
|
return JSON.stringify(settingsArray);
|
|
}
|
|
});
|