Skip to content
This repository has been archived by the owner on Oct 25, 2021. It is now read-only.

Commit

Permalink
Merge pull request #134 from Financial-Times/subset-bug
Browse files Browse the repository at this point in the history
Subset and validation bugs
  • Loading branch information
wheresrhys authored Jan 16, 2020
2 parents 76e815d + c21b86d commit 27506b8
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion demo/cms/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const wrapCmsHandler = handler => async (req, res) => {

res.status(status).send(body);
} catch (e) {
logger.err(e);
logger.error(e);
res.send(500).end();
}
};
Expand Down
4 changes: 4 additions & 0 deletions example-schema/types/MainType.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: MainType
description: Description of MainType.
moreInformation: |
More information for MainType
minimumViableRecord:
- code
- children
- someString
properties:
code:
type: Code
Expand Down
14 changes: 6 additions & 8 deletions packages/tc-ui/src/lib/get-schema-subset.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
const { getType } = require('@financial-times/tc-schema-sdk');

const getTypeOptions = {
groupProperties: true,
includeMetaFields: false,
};

const getSchemaSubset = (event, type, isCreate = false) => {
const properties = event.query && event.query.properties;

if (!properties) {
return {
schema: getType(type, {
...getTypeOptions,
groupProperties: true,
includeMetaFields: false,
useMinimumViableRecord: isCreate,
}),
isSubset: false,
};
}

const title = event.query && event.query.title;
const fullSchema = getType(type, getTypeOptions);
const fullSchema = getType(type, {
groupProperties: false,
includeMetaFields: false,
});
const propertyKeys = properties.split(',');

return {
schema: {
...fullSchema,
Expand Down
2 changes: 1 addition & 1 deletion packages/tc-ui/src/pages/edit/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const fieldValueCheckers = {
!![...field.querySelectorAll('input')].some(input => input.checked),
relationship: field =>
!![...field.querySelectorAll('input[type="hidden"]')].every(
input => !!input.value,
input => !!input.value && input.value !== '[]',
),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ class RelationshipPicker extends React.Component {
return (
<div
data-props={JSON.stringify(props)}
data-property-name={props.propertyName}
data-component="relationship-picker"
data-disabled={disabled ? true : null}
data-is-unresolved={isUnresolved ? true : null}
Expand Down

0 comments on commit 27506b8

Please sign in to comment.