diff --git a/frontend/src/Metamaps/Views/TopicCard.js b/frontend/src/Metamaps/Views/TopicCard.js index a7e176ac..8c19bbdd 100644 --- a/frontend/src/Metamaps/Views/TopicCard.js +++ b/frontend/src/Metamaps/Views/TopicCard.js @@ -9,14 +9,20 @@ import ReactTopicCard from '../../components/TopicCard' const TopicCard = { openTopicCard: null, // stores the topic that's currently open + metacodeSets: [], + init: function(serverData) { + const self = TopicCard + self.metacodeSets = serverData.metacodeSets + }, populateShowCard: function(topic) { - var self = TopicCard + const self = TopicCard const topicCardObj = { topic: topic, ActiveMapper: Active.Mapper, updateTopic: obj => { topic.save(obj, { success: topic => self.populateShowCard(topic) }) - } + }, + metacodeSets: self.metacodeSets } ReactDOM.render( React.createElement(ReactTopicCard, topicCardObj), diff --git a/frontend/src/components/TopicCard/Links.js b/frontend/src/components/TopicCard/Links.js index 93517965..34b4f5e9 100644 --- a/frontend/src/components/TopicCard/Links.js +++ b/frontend/src/components/TopicCard/Links.js @@ -72,6 +72,7 @@ class Links extends Component { metacode={metacode} ActiveMapper={ActiveMapper} updateTopic={this.props.updateTopic} + metacodeSets={this.props.metacodeSets} />
@@ -102,7 +103,15 @@ class Links extends Component { Links.propTypes = { topic: PropTypes.object, // backbone object ActiveMapper: PropTypes.object, - updateTopic: PropTypes.func + updateTopic: PropTypes.func, + metacodeSets: PropTypes.arrayOf(PropTypes.shape({ + name: PropTypes.string, + metacodes: PropTypes.arrayOf(PropTypes.shape({ + id: PropTypes.number, + icon_path: PropTypes.string, // url + name: PropTypes.string + })) + })) } export default Links diff --git a/frontend/src/components/TopicCard/Metacode.js b/frontend/src/components/TopicCard/Metacode.js index 98c03749..8ccd76a0 100644 --- a/frontend/src/components/TopicCard/Metacode.js +++ b/frontend/src/components/TopicCard/Metacode.js @@ -91,35 +91,36 @@ const bindShowCardListeners = (topic, ActiveMapper) => { } } -function metacodeOptions(metacodeSets) { - return ( -
- -
- ) -} - class Metacode extends Component { componentDidMount = () => { bindShowCardListeners(this.props.topic, this.props.ActiveMapper) } + metacodeOptions = () => { + return ( +
+ +
+ ) + } + + render = () => { const { metacode } = this.props // the code for this is stored in /views/main/_metacodeOptions.html.erb @@ -132,7 +133,9 @@ class Metacode extends Component {
-
+
+ {this.metacodeOptions()} +
) } @@ -142,7 +145,15 @@ Metacode.propTypes = { topic: PropTypes.object, // backbone object metacode: PropTypes.object, // backbone object ActiveMapper: PropTypes.object, - updateTopic: PropTypes.func + updateTopic: PropTypes.func, + metacodeSets: PropTypes.arrayOf(PropTypes.shape({ + name: PropTypes.string, + metacodes: PropTypes.arrayOf(PropTypes.shape({ + id: PropTypes.number, + icon_path: PropTypes.string, // url + name: PropTypes.string + })) + })) } export default Metacode diff --git a/frontend/src/components/TopicCard/index.js b/frontend/src/components/TopicCard/index.js index a7603257..548c6b4f 100644 --- a/frontend/src/components/TopicCard/index.js +++ b/frontend/src/components/TopicCard/index.js @@ -30,6 +30,7 @@ class ReactTopicCard extends Component {