Browse Source

added handledr to extended actions + it wont open the app anymore + moved component ExtendedAction

Skylsmoi 6 years ago
parent
commit
3ebd35ed38

+ 0 - 70
src/component/BtnExtandedAction/ExtandedAction.jsx View File

@@ -1,70 +0,0 @@
1
-import React, { Component } from 'react'
2
-
3
-class ExtandedAction extends Component {
4
-  render () {
5
-    return (
6
-      <div className='extandedaction dropdown'>
7
-        <button
8
-          className='extandedaction__button btn btn-outline-primary dropdown-toggle'
9
-          onClick={this.props.onClickStopEvent}
10
-          type='button'
11
-          id='dropdownMenuButton'
12
-          data-toggle='dropdown'
13
-          aria-haspopup='true'
14
-          aria-expanded='false'
15
-        >
16
-          <i className='fa fa-fw fa-ellipsis-h' />
17
-        </button>
18
-        <div className='extandedaction__subdropdown dropdown-menu' aria-labelledby='dropdownMenuButton'>
19
-          <div className='subdropdown__item dropdown-item d-flex align-items-center'>
20
-            <div className='subdropdown__item__icon mr-3'>
21
-              <i className='fa fa-fw fa-pencil' />
22
-            </div>
23
-            <div className='subdropdown__item__text'>
24
-              Modifier
25
-            </div>
26
-          </div>
27
-
28
-          <div className='subdropdown__item dropdown-item d-flex align-items-center'>
29
-            <div className='subdropdown__item__icon mr-3'>
30
-              <i className='fa fa-fw fa-arrows-alt' />
31
-            </div>
32
-            <div className='subdropdown__item__text'>
33
-              Déplacer
34
-            </div>
35
-          </div>
36
-
37
-          <div className='subdropdown__item dropdown-item d-flex align-items-center'>
38
-            <div className='subdropdown__item__icon mr-3'>
39
-              <i className='fa fa-fw fa-download' />
40
-            </div>
41
-            <div className='subdropdown__item__text'>
42
-              Télécharger
43
-            </div>
44
-          </div>
45
-
46
-          <div className='subdropdown__item dropdown-item d-flex align-items-center'>
47
-            <div className='subdropdown__item__icon mr-3'>
48
-              <i className='fa fa-fw fa-archive' />
49
-            </div>
50
-            <div className='subdropdown__item__text'>
51
-              Archiver
52
-            </div>
53
-          </div>
54
-
55
-          <div className='subdropdown__item dropdown-item d-flex align-items-center'>
56
-            <div className='subdropdown__item__icon mr-3'>
57
-              <i className='fa fa-fw fa-trash-o' />
58
-            </div>
59
-            <div className='subdropdown__item__text'>
60
-              Supprimer
61
-            </div>
62
-          </div>
63
-
64
-        </div>
65
-      </div>
66
-    )
67
-  }
68
-}
69
-
70
-export default ExtandedAction

+ 75 - 0
src/component/Workspace/BtnExtandedAction.jsx View File

@@ -0,0 +1,75 @@
1
+import React from 'react'
2
+import PropTypes from 'prop-types'
3
+
4
+const ExtandedAction = props => {
5
+  return (
6
+    <div className='extandedaction dropdown'>
7
+      <button
8
+        className='extandedaction__button btn btn-outline-primary dropdown-toggle'
9
+        type='button'
10
+        id='dropdownMenuButton'
11
+        data-toggle='dropdown'
12
+        aria-haspopup='true'
13
+        aria-expanded='false'
14
+        onClick={e => e.stopPropagation()}
15
+      >
16
+        <i className='fa fa-fw fa-ellipsis-h' />
17
+      </button>
18
+      <div className='extandedaction__subdropdown dropdown-menu' aria-labelledby='dropdownMenuButton'>
19
+        <div className='subdropdown__item dropdown-item d-flex align-items-center' onClick={props.onClickExtendedAction.edit}>
20
+          <div className='subdropdown__item__icon mr-3'>
21
+            <i className='fa fa-fw fa-pencil' />
22
+          </div>
23
+          <div className='subdropdown__item__text'>
24
+            Modifier
25
+          </div>
26
+        </div>
27
+
28
+        <div className='subdropdown__item dropdown-item d-flex align-items-center' onClick={props.onClickExtendedAction.move}>
29
+          <div className='subdropdown__item__icon mr-3'>
30
+            <i className='fa fa-fw fa-arrows-alt' />
31
+          </div>
32
+          <div className='subdropdown__item__text'>
33
+            Déplacer
34
+          </div>
35
+        </div>
36
+
37
+        <div className='subdropdown__item dropdown-item d-flex align-items-center' onClick={props.onClickExtendedAction.download}>
38
+          <div className='subdropdown__item__icon mr-3'>
39
+            <i className='fa fa-fw fa-download' />
40
+          </div>
41
+          <div className='subdropdown__item__text'>
42
+            Télécharger
43
+          </div>
44
+        </div>
45
+
46
+        <div className='subdropdown__item dropdown-item d-flex align-items-center' onClick={props.onClickExtendedAction.archive}>
47
+          <div className='subdropdown__item__icon mr-3'>
48
+            <i className='fa fa-fw fa-archive' />
49
+          </div>
50
+          <div className='subdropdown__item__text'>
51
+            Archiver
52
+          </div>
53
+        </div>
54
+
55
+        <div className='subdropdown__item dropdown-item d-flex align-items-center' onClick={props.onClickExtendedAction.delete}>
56
+          <div className='subdropdown__item__icon mr-3'>
57
+            <i className='fa fa-fw fa-trash-o' />
58
+          </div>
59
+          <div className='subdropdown__item__text'>
60
+            Supprimer
61
+          </div>
62
+        </div>
63
+
64
+      </div>
65
+    </div>
66
+  )
67
+}
68
+
69
+export default ExtandedAction
70
+
71
+ExtandedAction.propTypes = {
72
+  onClickExtendedAction: PropTypes.object.isRequired
73
+}
74
+
75
+ExtandedAction.defaultProps = {}

+ 2 - 2
src/component/Workspace/FileItem.jsx View File

@@ -1,7 +1,7 @@
1 1
 import React from 'react'
2 2
 import PropTypes from 'prop-types'
3 3
 import classnames from 'classnames'
4
-import BtnExtandedAction from '../BtnExtandedAction/ExtandedAction.jsx'
4
+import BtnExtandedAction from './BtnExtandedAction.jsx'
5 5
 
6 6
 const FileItem = props => {
7 7
   const iconStatus = (() => {
@@ -58,7 +58,7 @@ const FileItem = props => {
58 58
           </div>
59 59
 
60 60
           <div className='d-none d-md-flex'>
61
-            <BtnExtandedAction />
61
+            <BtnExtandedAction onClickExtendedAction={props.onClickExtendedAction} />
62 62
           </div>
63 63
 
64 64
           {/*

+ 18 - 20
src/component/Workspace/Folder.jsx View File

@@ -4,7 +4,7 @@ import PropTypes from 'prop-types'
4 4
 import classnames from 'classnames'
5 5
 import FileItem from './FileItem.jsx'
6 6
 // import PopupExtandedAction from '../../container/PopupExtandedAction.jsx'
7
-import BtnExtandedAction from '../BtnExtandedAction/ExtandedAction.jsx'
7
+import BtnExtandedAction from './BtnExtandedAction.jsx'
8 8
 
9 9
 class Folder extends React.Component {
10 10
   constructor (props) {
@@ -24,16 +24,12 @@ class Folder extends React.Component {
24 24
     console.log('new file') // @TODO
25 25
   }
26 26
 
27
-  handleClickStopEvent = e => {
28
-    e.stopPropagation()
29
-    console.log('stop')
30
-  }
31
-
32 27
   render () {
33 28
     const {
34 29
       app,
35 30
       folderData,
36 31
       onClickItem,
32
+      onClickExtendedAction,
37 33
       onClickFolder,
38 34
       isLast,
39 35
       t
@@ -144,7 +140,13 @@ class Folder extends React.Component {
144 140
                 </div>
145 141
 
146 142
                 <div className='d-none d-md-flex'>
147
-                  <BtnExtandedAction onClickStopEvent={this.handleClickStopEvent} />
143
+                  <BtnExtandedAction onClickExtendedAction={{
144
+                    edit: e => onClickExtendedAction.edit(e, folderData),
145
+                    move: e => onClickExtendedAction.move(e, folderData),
146
+                    download: e => onClickExtendedAction.download(e, folderData),
147
+                    archive: e => onClickExtendedAction.archive(e, folderData),
148
+                    delete: e => onClickExtendedAction.delete(e, folderData)
149
+                  }} />
148 150
                 </div>
149 151
 
150 152
               </div>
@@ -155,25 +157,13 @@ class Folder extends React.Component {
155 157
 
156 158
         </div>
157 159
 
158
-        {/*
159
-          <div className='col-5 col-sm-5 col-md-5 col-lg-4 col-xl-3 d-none'>
160
-            <div className='folder__header__contenttype d-none d-sm-flex'>
161
-              <div className='folder__header__contenttype__text d-none d-lg-flex'>
162
-                {t('Folder.content_type')} :
163
-              </div>
164
-              <div className='folder__header__contenttype__icon'>
165
-                { folderData.allowed_app.map(a => <i className={(app[a] || {icon: ''}).icon} key={`${folderData.id}_${a}`} />)}
166
-              </div>
167
-            </div>
168
-          </div>
169
-        */}
170
-
171 160
         <div className='folder__content'>
172 161
           { folderData.content.map((c, i) => c.type === 'folder'
173 162
             ? <Folder
174 163
               app={app}
175 164
               folderData={c}
176 165
               onClickItem={onClickItem}
166
+              onClickExtendedAction={onClickExtendedAction}
177 167
               onClickFolder={onClickFolder}
178 168
               isLast={isLast}
179 169
               t={t}
@@ -185,6 +175,14 @@ class Folder extends React.Component {
185 175
               type={c.type}
186 176
               status={c.status}
187 177
               onClickItem={() => onClickItem(c)}
178
+              onClickExtendedAction={{
179
+                // we have to use the event here because it is the only place where we also have the content (c)
180
+                edit: e => onClickExtendedAction.edit(e, c),
181
+                move: e => onClickExtendedAction.move(e, c),
182
+                download: e => onClickExtendedAction.download(e, c),
183
+                archive: e => onClickExtendedAction.archive(e, c),
184
+                delete: e => onClickExtendedAction.delete(e, c)
185
+              }}
188 186
               isLast={isLast && i === folderData.content.length - 1}
189 187
               key={c.id}
190 188
             />

+ 39 - 0
src/container/WorkspaceContent.jsx View File

@@ -43,6 +43,31 @@ class WorkspaceContent extends React.Component {
43 43
     // dispatch(setActiveFileContentActive(content))
44 44
   }
45 45
 
46
+  handleClickEditContentItem = (e, content) => {
47
+    e.stopPropagation()
48
+    console.log('edit nyi', content)
49
+  }
50
+
51
+  handleClickMoveContentItem = (e, content) => {
52
+    e.stopPropagation()
53
+    console.log('move nyi', content)
54
+  }
55
+
56
+  handleClickDownloadContentItem = (e, content) => {
57
+    e.stopPropagation()
58
+    console.log('download nyi', content)
59
+  }
60
+
61
+  handleClickArchiveContentItem = (e, content) => {
62
+    e.stopPropagation()
63
+    console.log('archive nyi', content)
64
+  }
65
+
66
+  handleClickDeleteContentItem = (e, content) => {
67
+    e.stopPropagation()
68
+    console.log('delete nyi', content)
69
+  }
70
+
46 71
   handleClickFolder = folderId => {
47 72
     this.props.dispatch(getFolderContent(this.props.workspace.id, folderId))
48 73
   }
@@ -81,6 +106,13 @@ class WorkspaceContent extends React.Component {
81 106
                     app={app}
82 107
                     folderData={c}
83 108
                     onClickItem={this.handleClickContentItem}
109
+                    onClickExtendedAction={{
110
+                      edit: this.handleClickEditContentItem,
111
+                      move: this.handleClickMoveContentItem,
112
+                      download: this.handleClickDownloadContentItem,
113
+                      archive: this.handleClickArchiveContentItem,
114
+                      delete: this.handleClickDeleteContentItem
115
+                    }}
84 116
                     onClickFolder={this.handleClickFolder}
85 117
                     isLast={i === filteredWorkspaceContent.length - 1}
86 118
                     key={c.id}
@@ -93,6 +125,13 @@ class WorkspaceContent extends React.Component {
93 125
                     icon={(app[c.type] || {icon: ''}).icon}
94 126
                     status={c.status}
95 127
                     onClickItem={() => this.handleClickContentItem(c)}
128
+                    onClickExtendedAction={{
129
+                      edit: e => this.handleClickEditContentItem(e, c),
130
+                      move: e => this.handleClickMoveContentItem(e, c),
131
+                      download: e => this.handleClickDownloadContentItem(e, c),
132
+                      archive: e => this.handleClickArchiveContentItem(e, c),
133
+                      delete: e => this.handleClickDeleteContentItem(e, c)
134
+                    }}
96 135
                     isLast={i === filteredWorkspaceContent.length - 1}
97 136
                     key={c.id}
98 137
                   />