Преглед изворни кода

add templateTags on tagLabels

yusuketk пре 7 година
родитељ
комит
28835474aa
2 измењених фајлова са 7 додато и 1 уклоњено
  1. 1 1
      src/client/js/app.js
  2. 6 0
      src/client/js/components/Page/TagLabels.jsx

+ 1 - 1
src/client/js/app.js

@@ -315,7 +315,7 @@ if (pageId) {
 if (pagePath) {
   componentMappings.page = <Page crowi={crowi} crowiRenderer={crowiRenderer} markdown={markdown} pagePath={pagePath} onSaveWithShortcut={saveWithShortcut} />;
   componentMappings['revision-path'] = <RevisionPath pagePath={pagePath} crowi={crowi} />;
-  componentMappings['tag-label'] = <I18nextProvider i18n={i18n}><TagLabels crowi={crowi} pageId={pageId} sendTagData={setTagData} /></I18nextProvider>;
+  componentMappings['tag-label'] = <I18nextProvider i18n={i18n}><TagLabels crowi={crowi} pageId={pageId} sendTagData={setTagData} templateTags={templateTags} /></I18nextProvider>;
 }
 
 Object.keys(componentMappings).forEach((key) => {

+ 6 - 0
src/client/js/components/Page/TagLabels.jsx

@@ -20,11 +20,16 @@ class TagLabels extends React.Component {
   async componentWillMount() {
     // set pageTag on button
     const pageId = this.props.pageId;
+    const templateTags = this.props.templateTags;
     if (pageId) {
       const res = await this.props.crowi.apiGet('/pages.getPageTag', { pageId });
       this.setState({ tags: res.tags });
       this.props.sendTagData(res.tags);
     }
+    else if (templateTags) {
+      this.setState({ tags: templateTags });
+      this.props.sendTagData(templateTags);
+    }
   }
 
   showEditor() {
@@ -82,6 +87,7 @@ TagLabels.propTypes = {
   crowi: PropTypes.object.isRequired,
   pageId: PropTypes.string,
   sendTagData: PropTypes.func.isRequired,
+  templateTags: PropTypes.string,
 };
 
 export default withTranslation()(TagLabels);