Skip to content

Commit

Permalink
adds dimensionbuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
jhmullen authored and davelandry committed May 30, 2019
1 parent d064166 commit 48c5dcd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
11 changes: 3 additions & 8 deletions packages/cms/src/api/cmsRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -420,14 +420,8 @@ module.exports = function(app) {

app.post("/api/cms/profile/addDimension", isEnabled, async(req, res) => {
const profileData = req.body;
await db.profile_meta.create({
profile_id: profileData.profile_id,
slug: profileData.slug,
ordering: profileData.ordering,
dimension: profileData.dimName,
levels: profileData.levels,
measure: profileData.measure
});
profileData.dimension = profileData.dimName;
await db.profile_meta.create(profileData);
let profiles = await db.profile.findAll(profileReqTreeOnly).catch(catcher);
profiles = sortProfileTree(db, profiles);
populateSearch(profileData, db);
Expand Down Expand Up @@ -455,6 +449,7 @@ module.exports = function(app) {
* and "parent" refers to the foreign key that need be referenced in the associated where clause.
*/
const deleteList = [
{elements: ["profile_meta"], parent: "profile_id"},
{elements: ["author", "story_description", "story_footnote"], parent: "story_id"},
{elements: ["topic_subtitle", "topic_description", "topic_stat", "topic_visualization"], parent: "topic_id"},
{elements: ["storytopic_subtitle", "storytopic_description", "storytopic_stat", "storytopic_visualization"], parent: "storytopic_id"}
Expand Down
2 changes: 2 additions & 0 deletions packages/cms/src/components/cards/DimensionCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export default class DimensionCard extends Component {
render() {
const {meta, preview} = this.props;

if (!preview) return <div>test</div>;

return (
<div className="cms-card">
slug: <strong>{meta.slug}</strong>
Expand Down
21 changes: 13 additions & 8 deletions packages/cms/src/profile/ProfileBuilder.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,15 @@ class ProfileBuilder extends Component {
this.setState({nodes});
}
else {
let nodeToOpen = nodes[0];
/*if (profileSlug) {
nodeToOpen = nodes.find(p => p.data.slug === profileSlug);
}*/
this.setState({nodes}, this.handleNodeClick.bind(this, nodeToOpen));
if (typeof openNode !== "boolean") {
const nodeToOpen = this.locateProfileNodeByPid(openNode);
this.setState({nodes}, this.handleNodeClick.bind(this, nodeToOpen, true));
}
else {
const nodeToOpen = nodes[0];
this.setState({nodes}, this.handleNodeClick.bind(this, nodeToOpen));
}

}
}

Expand Down Expand Up @@ -307,7 +311,7 @@ class ProfileBuilder extends Component {
}
}

handleNodeClick(node) {
handleNodeClick(node, force) {
node = this.locateNode(node.itemType, node.data.id);
const {nodes, currentNode} = this.state;
let parentLength = 0;
Expand All @@ -329,7 +333,7 @@ class ProfileBuilder extends Component {
}
if (this.props.setPath) this.props.setPath(node);
// If the slugs match, the master profile is the same, so keep the same preview
if (this.state.currentPid === node.masterPid) {
if (this.state.currentPid === node.masterPid && !force) {
this.setState({currentNode: node});
}
// If they don't match, update the currentPid and reset the preview
Expand Down Expand Up @@ -447,7 +451,7 @@ class ProfileBuilder extends Component {
axios.post("/api/cms/profile/addDimension", payload).then(resp => {
// todo bivariate, this entire profile refresh may be overkill
const profiles = resp.data;
this.setState({profiles}, this.buildNodes.bind(this));
this.setState({profiles}, this.buildNodes.bind(this, currentPid));
});
}

Expand Down Expand Up @@ -570,6 +574,7 @@ class ProfileBuilder extends Component {
</div>;
}
*/

let profileSearch = "";
if (currentNode && currentPid) {
profileSearch = <div>
Expand Down

0 comments on commit 48c5dcd

Please sign in to comment.