Browse Source

handle hidable timeline + handle click on last version in timeline

Skylsmoi 6 years ago
parent
commit
d4db49da07

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

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

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

10
   NewVersionBtn,
10
   NewVersionBtn,
11
   ArchiveDeleteContent,
11
   ArchiveDeleteContent,
12
   SelectStatus
12
   SelectStatus
13
-} from 'tracim_lib'
13
+} from 'tracim_lib/src/index.js'
14
 import { MODE, debug } from '../helper.js'
14
 import { MODE, debug } from '../helper.js'
15
 import {
15
 import {
16
   getHtmlDocContent,
16
   getHtmlDocContent,
71
 
71
 
72
     if (prevState.content.content_id !== state.content.content_id) this.loadContent()
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
     if (!prevState.timelineWysiwyg && state.timelineWysiwyg) wysiwyg('#wysiwygTimelineComment', this.handleChangeNewComment)
79
     if (!prevState.timelineWysiwyg && state.timelineWysiwyg) wysiwyg('#wysiwygTimelineComment', this.handleChangeNewComment)
77
     else if (prevState.timelineWysiwyg && !state.timelineWysiwyg) tinymce.remove('#wysiwygTimelineComment')
80
     else if (prevState.timelineWysiwyg && !state.timelineWysiwyg) tinymce.remove('#wysiwygTimelineComment')
240
   }
243
   }
241
 
244
 
242
   handleClickShowRevision = revision => {
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
     this.setState(prev => ({
258
     this.setState(prev => ({
244
       content: {
259
       content: {
245
         ...prev.content,
260
         ...prev.content,
275
         <PopinFixedOption customClass={`${config.slug}`} i18n={i18n}>
290
         <PopinFixedOption customClass={`${config.slug}`} i18n={i18n}>
276
           <div /* this div in display flex, justify-content space-between */>
291
           <div /* this div in display flex, justify-content space-between */>
277
             <div className='d-flex'>
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
               {mode === MODE.REVISION &&
295
               {mode === MODE.REVISION &&
281
                 <button
296
                 <button
306
           </div>
321
           </div>
307
         </PopinFixedOption>
322
         </PopinFixedOption>
308
 
323
 
309
-        <PopinFixedContent customClass={`${config.slug}__contentpage`}>
324
+        <PopinFixedContent
325
+          customClass={`${config.slug}__contentpage`}
326
+          showRightPartOnLoad={mode === MODE.VIEW}
327
+        >
310
           <HtmlDocumentComponent
328
           <HtmlDocumentComponent
311
             mode={mode}
329
             mode={mode}
312
             wysiwygNewVersion={'wysiwygNewVersion'}
330
             wysiwygNewVersion={'wysiwygNewVersion'}

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

72
               idWorkspace: resSave.body.workspace_id,
72
               idWorkspace: resSave.body.workspace_id,
73
               contentType: appName,
73
               contentType: appName,
74
               idContent: resSave.body.content_id
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
     firstname: 'Côme',
60
     firstname: 'Côme',
61
     lastname: 'Stoilenom',
61
     lastname: 'Stoilenom',
62
     email: 'osef@algoo.fr',
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
   content: {
66
   content: {
66
     author: {
67
     author: {