Removed tag.parent from Admin API v2 response

refs #10438

- this is an unused field
- no need to expose this field
- if we start working on nested tags, this field might become interesting/used
This commit is contained in:
kirrg001 2019-02-12 19:26:31 +01:00
parent 20300cf002
commit db148e653f
4 changed files with 22 additions and 22 deletions

View File

@ -1,25 +1,28 @@
const _ = require('lodash');
const localUtils = require('../../../index');
const tag = (attrs) => {
const tag = (attrs, frame) => {
if (localUtils.isContentAPI(frame)) {
delete attrs.created_at;
delete attrs.updated_at;
// We are standardising on returning null from the Content API for any empty values
if (attrs.meta_title === '') {
attrs.meta_title = null;
}
if (attrs.meta_description === '') {
attrs.meta_description = null;
}
if (attrs.description === '') {
attrs.description = null;
}
}
// Already deleted in model.toJSON, but leaving here so that we can clean that up when we deprecate v0.1
delete attrs.parent_id;
// Extra properties removed from v2
delete attrs.parent;
delete attrs.created_at;
delete attrs.updated_at;
// We are standardising on returning null from the Content API for any empty values
if (attrs.meta_title === '') {
attrs.meta_title = null;
}
if (attrs.meta_description === '') {
attrs.meta_description = null;
}
if (attrs.description === '') {
attrs.description = null;
}
return attrs;
};

View File

@ -21,10 +21,7 @@ const mapTag = (model, frame) => {
const jsonModel = model.toJSON ? model.toJSON(frame.options) : model;
url.forTag(model.id, jsonModel);
if (utils.isContentAPI(frame)) {
clean.tag(jsonModel);
}
clean.tag(jsonModel, frame);
return jsonModel;
};

View File

@ -35,8 +35,8 @@ const expectedProperties = {
,
tag: _(schema.tags)
.keys()
// Tag API swaps parent_id to parent
.without('parent_id').concat('parent')
// unused field
.without('parent_id')
,
setting: _(schema.settings)
.keys()

View File

@ -32,8 +32,8 @@ const expectedProperties = {
,
tag: _(schema.tags)
.keys()
// Tag API swaps parent_id to parent
.without('parent_id').concat('parent')
// unused field
.without('parent_id')
,
setting: _(schema.settings)
.keys()