Browse Source

handle hidable timeline + handle click on last version in timeline

Skylsmoi 5 years ago
parent
commit
d4db49da07

+ 1 - 0
src/component/HtmlDocument.jsx View File

@@ -16,6 +16,7 @@ const HtmlDocument = props => {
16 16
               </div>
17 17
             }
18 18
           </div>
19
+          {/* need try to inject html in stateless component () => <span>{props.text}</span> */}
19 20
           <div className='html-documents__contentpage__textnote__text' dangerouslySetInnerHTML={{__html: props.text}} />
20 21
         </div>
21 22
       }

+ 22 - 4
src/container/HtmlDocument.jsx View File

@@ -10,7 +10,7 @@ import {
10 10
   NewVersionBtn,
11 11
   ArchiveDeleteContent,
12 12
   SelectStatus
13
-} from 'tracim_lib'
13
+} from 'tracim_lib/src/index.js'
14 14
 import { MODE, debug } from '../helper.js'
15 15
 import {
16 16
   getHtmlDocContent,
@@ -71,7 +71,10 @@ class HtmlDocument extends React.Component {
71 71
 
72 72
     if (prevState.content.content_id !== state.content.content_id) this.loadContent()
73 73
 
74
-    if (state.mode === MODE.EDIT) wysiwyg('#wysiwygNewVersion', this.handleChangeText)
74
+    if (state.mode === MODE.EDIT) {
75
+      tinymce.remove('#wysiwygNewVersion')
76
+      wysiwyg('#wysiwygNewVersion', this.handleChangeText)
77
+    }
75 78
 
76 79
     if (!prevState.timelineWysiwyg && state.timelineWysiwyg) wysiwyg('#wysiwygTimelineComment', this.handleChangeNewComment)
77 80
     else if (prevState.timelineWysiwyg && !state.timelineWysiwyg) tinymce.remove('#wysiwygTimelineComment')
@@ -240,6 +243,18 @@ class HtmlDocument extends React.Component {
240 243
   }
241 244
 
242 245
   handleClickShowRevision = revision => {
246
+    const { mode, timeline } = this.state
247
+
248
+    const revisionArray = timeline.filter(t => t.timelineType === 'revision')
249
+    const isLastRevision = revision.revision_id === revisionArray[revisionArray.length - 1].revision_id
250
+
251
+    if (mode === MODE.REVISION && isLastRevision) {
252
+      this.handleClickLastVersion()
253
+      return
254
+    }
255
+
256
+    if (mode === MODE.VIEW && isLastRevision) return
257
+
243 258
     this.setState(prev => ({
244 259
       content: {
245 260
         ...prev.content,
@@ -275,7 +290,7 @@ class HtmlDocument extends React.Component {
275 290
         <PopinFixedOption customClass={`${config.slug}`} i18n={i18n}>
276 291
           <div /* this div in display flex, justify-content space-between */>
277 292
             <div className='d-flex'>
278
-              <NewVersionBtn onClickNewVersionBtn={this.handleClickNewVersion} disabled={mode === MODE.REVISION} />
293
+              <NewVersionBtn onClickNewVersionBtn={this.handleClickNewVersion} disabled={mode !== MODE.VIEW} />
279 294
 
280 295
               {mode === MODE.REVISION &&
281 296
                 <button
@@ -306,7 +321,10 @@ class HtmlDocument extends React.Component {
306 321
           </div>
307 322
         </PopinFixedOption>
308 323
 
309
-        <PopinFixedContent customClass={`${config.slug}__contentpage`}>
324
+        <PopinFixedContent
325
+          customClass={`${config.slug}__contentpage`}
326
+          showRightPartOnLoad={mode === MODE.VIEW}
327
+        >
310 328
           <HtmlDocumentComponent
311 329
             mode={mode}
312 330
             wysiwygNewVersion={'wysiwygNewVersion'}

+ 1 - 0
src/container/PopupCreateHtmlDocument.jsx View File

@@ -72,6 +72,7 @@ class PopupCreateHtmlDocument extends React.Component {
72 72
               idWorkspace: resSave.body.workspace_id,
73 73
               contentType: appName,
74 74
               idContent: resSave.body.content_id
75
+              // will be open in edit mode because revision.length === 1
75 76
             }
76 77
           })
77 78
         }

+ 2 - 1
src/helper.js View File

@@ -60,7 +60,8 @@ export const debug = {
60 60
     firstname: 'Côme',
61 61
     lastname: 'Stoilenom',
62 62
     email: 'osef@algoo.fr',
63
-    avatar_url: 'https://avatars3.githubusercontent.com/u/11177014?s=460&v=4'
63
+    avatar_url: 'https://avatars3.githubusercontent.com/u/11177014?s=460&v=4',
64
+    auth: btoa(`${'admin@admin.admin'}:${'admin@admin.admin'}`)
64 65
   },
65 66
   content: {
66 67
     author: {