Removing «none» values from a custom field (issue: https://github.com/CinemaPress/CinemaPress/issues/33)
This commit is contained in:
parent
2521ddc336
commit
2a9d3fa4bc
|
@ -172,6 +172,28 @@ function saveContent(content_raw, name, callback) {
|
||||||
? result.custom
|
? result.custom
|
||||||
: {}
|
: {}
|
||||||
: {};
|
: {};
|
||||||
|
Object.keys(cnt).forEach(function(key) {
|
||||||
|
if (typeof cnt[key] === 'string' && cnt[key] === 'none') {
|
||||||
|
delete cnt[key];
|
||||||
|
if (res && res[key]) delete res[key];
|
||||||
|
} else if (
|
||||||
|
typeof cnt[key] === 'object' &&
|
||||||
|
!Array.isArray(cnt[key]) &&
|
||||||
|
cnt[key]
|
||||||
|
) {
|
||||||
|
Object.keys(cnt[key]).forEach(function(key2) {
|
||||||
|
if (
|
||||||
|
typeof cnt[key][key2] === 'string' &&
|
||||||
|
cnt[key][key2] === 'none'
|
||||||
|
) {
|
||||||
|
delete cnt[key][key2];
|
||||||
|
if (res && res[key] && res[key][key2]) {
|
||||||
|
delete res[key][key2];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
cnt = Object.assign({}, res, cnt);
|
cnt = Object.assign({}, res, cnt);
|
||||||
content.custom = JSON.stringify(cnt);
|
content.custom = JSON.stringify(cnt);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
Loading…
Reference in New Issue