Browse Source

change method name and add tooltips

yusuketk 7 years ago
parent
commit
1693e71a0b
1 changed files with 18 additions and 13 deletions
  1. 18 13
      src/client/js/components/Page/EditTagModal.jsx

+ 18 - 13
src/client/js/components/Page/EditTagModal.jsx

@@ -13,13 +13,13 @@ export default class EditTagModal extends React.Component {
     this.state = {
     this.state = {
       pageTags: [],
       pageTags: [],
       newPageTags: [],
       newPageTags: [],
-      isOpenEditTagModal: false,
+      isOpenModal: false,
     };
     };
 
 
     this.updateTags = this.updateTags.bind(this);
     this.updateTags = this.updateTags.bind(this);
-    this.handleShowEditTagModal = this.handleShowEditTagModal.bind(this);
-    this.handleCloseEditTagModal = this.handleCloseEditTagModal.bind(this);
-    this.handleSubmitEditTagModal = this.handleSubmitEditTagModal.bind(this);
+    this.handleShowModal = this.handleShowModal.bind(this);
+    this.handleCloseModal = this.handleCloseModal.bind(this);
+    this.handleSubmit = this.handleSubmit.bind(this);
   }
   }
 
 
   async componentWillMount() {
   async componentWillMount() {
@@ -35,18 +35,18 @@ export default class EditTagModal extends React.Component {
     this.setState({ newPageTags });
     this.setState({ newPageTags });
   }
   }
 
 
-  handleCloseEditTagModal() {
-    this.setState({ isOpenEditTagModal: false });
+  handleCloseModal() {
+    this.setState({ isOpenModal: false });
   }
   }
 
 
-  handleShowEditTagModal() {
-    this.setState({ isOpenEditTagModal: true });
+  handleShowModal() {
+    this.setState({ isOpenModal: true });
   }
   }
 
 
-  handleSubmitEditTagModal() {
+  handleSubmit() {
     try {
     try {
       this.props.crowi.apiPost('/pages.updateTags', { pageId: this.props.pageId, newTags: this.state.newPageTags });
       this.props.crowi.apiPost('/pages.updateTags', { pageId: this.props.pageId, newTags: this.state.newPageTags });
-      this.setState({ pageTags: this.state.newPageTags, isOpenEditTagModal: false });
+      this.setState({ pageTags: this.state.newPageTags, isOpenModal: false });
       toastr.success(undefined, 'Updated tags successfully', {
       toastr.success(undefined, 'Updated tags successfully', {
         closeButton: true,
         closeButton: true,
         progressBar: true,
         progressBar: true,
@@ -75,13 +75,18 @@ export default class EditTagModal extends React.Component {
       <span className="btn-tag-container">
       <span className="btn-tag-container">
         <Button
         <Button
           variant="primary"
           variant="primary"
-          onClick={this.handleShowEditTagModal}
+          onClick={this.handleShowModal}
           className="btn btn-default btn-tag"
           className="btn btn-default btn-tag"
           style={this.props.style}
           style={this.props.style}
+          data-toggle="tooltip"
+          data-placement="bottom"
+          title={this.state.pageTags.map((tag) => {
+            return `#${tag}`;
+          })}
         >
         >
           <i className="fa fa-tags"></i>{this.state.pageTags.length}
           <i className="fa fa-tags"></i>{this.state.pageTags.length}
         </Button>
         </Button>
-        <Modal show={this.state.isOpenEditTagModal} onHide={this.handleCloseEditTagModal} id="editTagModal">
+        <Modal show={this.state.isOpenModal} onHide={this.handleCloseModal} id="editTagModal">
           <Modal.Header closeButton className="bg-primary">
           <Modal.Header closeButton className="bg-primary">
             <Modal.Title className="text-white">ページタグ</Modal.Title>
             <Modal.Title className="text-white">ページタグ</Modal.Title>
           </Modal.Header>
           </Modal.Header>
@@ -89,7 +94,7 @@ export default class EditTagModal extends React.Component {
             <PageTagForm crowi={this.props.crowi} defaultPageTags={this.state.pageTags} updateTags={this.updateTags} />
             <PageTagForm crowi={this.props.crowi} defaultPageTags={this.state.pageTags} updateTags={this.updateTags} />
           </Modal.Body>
           </Modal.Body>
           <Modal.Footer>
           <Modal.Footer>
-            <Button variant="primary" onClick={this.handleSubmitEditTagModal}>
+            <Button variant="primary" onClick={this.handleSubmit} onSubmit={this.handleSubmit}>
               更新
               更新
             </Button>
             </Button>
           </Modal.Footer>
           </Modal.Footer>