Browse Source

renamed app interface functions

Skylsmoi 6 years ago
parent
commit
a033d588cd

+ 1 - 1
README.md View File

58
 You also need to make the mock api able to tell tracim_frontend that it handle you app :
58
 You also need to make the mock api able to tell tracim_frontend that it handle you app :
59
 - add an entry for you App in tracim_frontend/jsonserver/static_db.json in the `app_config` property
59
 - add an entry for you App in tracim_frontend/jsonserver/static_db.json in the `app_config` property
60
 - reload your mock api server
60
 - reload your mock api server
61
-- add the source of your app in tracim_frontend/dist/index.html and an entry to the switch case of the function `GLOBAL_renderApp`. All of this will be handled by backend later on, this is all work in progress stuffs.
61
+- add the source of your app in tracim_frontend/dist/index.html and an entry to the switch case of the function `GLOBAL_renderAppFull`. All of this will be handled by backend later on, this is all work in progress stuffs.
62
 
62
 
63
 
63
 
64
 #### Urls list
64
 #### Urls list

+ 10 - 7
dist/appInterface.js View File

15
   }
15
   }
16
 
16
 
17
   //@TODO make a file action.tracimCustomEvent.js that will contains all customEvent that tracim_frontend call
17
   //@TODO make a file action.tracimCustomEvent.js that will contains all customEvent that tracim_frontend call
18
+  // => pb with that is that appInterface cant use import since it is not part of the build webpack
19
+  // use module.export and require
20
+  // doesn't work, cant resolve a file outside of the build dir
18
 
21
 
19
-  GLOBAL_renderApp = app => { //@TODO renderAppFull
20
-    console.log('%cGLOBAL_renderApp', 'color: #5cebeb', app)
22
+  GLOBAL_renderAppFull = app => {
23
+    console.log('%cGLOBAL_renderAppFull', 'color: #5cebeb', app)
21
 
24
 
22
     const selectedApp = getSelectedApp(app.config.slug)
25
     const selectedApp = getSelectedApp(app.config.slug)
23
 
26
 
24
     if (selectedApp.isRendered) {
27
     if (selectedApp.isRendered) {
25
       GLOBAL_dispatchEvent({type: `${app.config.slug}_showApp`, data: app}) // handled by html-documents:src/container/HtmlDocument.jsx
28
       GLOBAL_dispatchEvent({type: `${app.config.slug}_showApp`, data: app}) // handled by html-documents:src/container/HtmlDocument.jsx
26
     } else {
29
     } else {
27
-      selectedApp.renderApp(app)
30
+      selectedApp.renderAppFull(app)
28
       selectedApp.isRendered = true
31
       selectedApp.isRendered = true
29
       prevSelectedApp.isRendered = false
32
       prevSelectedApp.isRendered = false
30
       prevSelectedApp = selectedApp
33
       prevSelectedApp = selectedApp
31
     }
34
     }
32
   }
35
   }
33
 
36
 
34
-  GLOBAL_renderCreateContentApp = app => { //@TODO renderAppPopupCreation
35
-    console.log('%cGLOBAL_renderCreateContentApp', 'color: #5cebeb', app)
37
+  GLOBAL_renderAppPopupCreation = app => {
38
+    console.log('%cGLOBAL_renderAppPopupCreation', 'color: #5cebeb', app)
36
 
39
 
37
     const selectedApp = getSelectedApp(app.config.slug)
40
     const selectedApp = getSelectedApp(app.config.slug)
38
 
41
 
39
     if (!selectedApp) {
42
     if (!selectedApp) {
40
-      console.log('Error in GLOBAL_renderCreateContentApp, selectedApp is undefined', app)
43
+      console.log('Error in GLOBAL_renderAppPopupCreation, selectedApp is undefined', app)
41
       return
44
       return
42
     }
45
     }
43
 
46
 
44
-    getSelectedApp(app.config.slug).renderPopupCreation(app)
47
+    getSelectedApp(app.config.slug).renderAppPopupCreation(app)
45
   }
48
   }
46
 
49
 
47
   GLOBAL_dispatchEvent = ({type, data}) => {
50
   GLOBAL_dispatchEvent = ({type, data}) => {

+ 2 - 2
package.json View File

61
       "fetch",
61
       "fetch",
62
       "btoa",
62
       "btoa",
63
       "history",
63
       "history",
64
-      "GLOBAL_renderApp",
65
-      "GLOBAL_renderCreateContentApp",
64
+      "GLOBAL_renderAppFull",
65
+      "GLOBAL_renderAppPopupCreation",
66
       "GLOBAL_dispatchEvent",
66
       "GLOBAL_dispatchEvent",
67
       "GLOBAL_hideApp"
67
       "GLOBAL_hideApp"
68
     ],
68
     ],

+ 4 - 4
src/appFactory.js View File

3
 
3
 
4
 export function appFactory (WrappedComponent) {
4
 export function appFactory (WrappedComponent) {
5
   return class AppFactory extends React.Component {
5
   return class AppFactory extends React.Component {
6
-    renderApp = (appConfig, user, content) => GLOBAL_renderApp({
6
+    renderAppFull = (appConfig, user, content) => GLOBAL_renderAppFull({
7
       loggedUser: user.logged ? user : {},
7
       loggedUser: user.logged ? user : {},
8
       config: {
8
       config: {
9
         ...appConfig,
9
         ...appConfig,
15
       content
15
       content
16
     })
16
     })
17
 
17
 
18
-    renderCreateContentApp = (appConfig, user, idWorkspace, idFolder) => GLOBAL_renderCreateContentApp({
18
+    renderAppPopupCreation = (appConfig, user, idWorkspace, idFolder) => GLOBAL_renderAppPopupCreation({
19
       loggedUser: user.logged ? user : {},
19
       loggedUser: user.logged ? user : {},
20
       config: {
20
       config: {
21
         ...appConfig,
21
         ...appConfig,
34
       return (
34
       return (
35
         <WrappedComponent
35
         <WrappedComponent
36
           {...this.props}
36
           {...this.props}
37
-          renderApp={this.renderApp}
38
-          renderCreateContentApp={this.renderCreateContentApp}
37
+          renderAppFull={this.renderAppFull}
38
+          renderAppPopupCreation={this.renderAppPopupCreation}
39
           emitEventApp={this.emitEventApp}
39
           emitEventApp={this.emitEventApp}
40
           // hideApp={this.hideApp}
40
           // hideApp={this.hideApp}
41
         />
41
         />

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

5
 
5
 
6
 export class OpenContentApp extends React.Component {
6
 export class OpenContentApp extends React.Component {
7
   openContentApp = () => {
7
   openContentApp = () => {
8
-    const { idWorkspace, appOpenedType, user, workspaceContent, contentType, renderApp, match } = this.props
8
+    const { idWorkspace, appOpenedType, user, workspaceContent, contentType, renderAppFull, match } = this.props
9
 
9
 
10
     if (isNaN(idWorkspace) || idWorkspace === -1) return
10
     if (isNaN(idWorkspace) || idWorkspace === -1) return
11
 
11
 
29
         // if another app is already visible, hide it
29
         // if another app is already visible, hide it
30
         if (appOpenedType !== false) GLOBAL_dispatchEvent({type: `${appOpenedType}_hideApp`})
30
         if (appOpenedType !== false) GLOBAL_dispatchEvent({type: `${appOpenedType}_hideApp`})
31
         // open app
31
         // open app
32
-        renderApp(
32
+        renderAppFull(
33
           contentType.find(ct => ct.slug === contentToOpen.type),
33
           contentType.find(ct => ct.slug === contentToOpen.type),
34
           user,
34
           user,
35
           contentToOpen
35
           contentToOpen

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

7
 
7
 
8
 export class OpenCreateContentApp extends React.Component {
8
 export class OpenCreateContentApp extends React.Component {
9
   openCreateContentApp = () => {
9
   openCreateContentApp = () => {
10
-    const { idWorkspace, user, contentType, renderCreateContentApp, match, location } = this.props
10
+    const { idWorkspace, user, contentType, renderAppPopupCreation, match, location } = this.props
11
 
11
 
12
     if (isNaN(idWorkspace) || idWorkspace === -1) return
12
     if (isNaN(idWorkspace) || idWorkspace === -1) return
13
 
13
 
14
     if (['idws', 'type'].every(p => p in match.params) && contentType.map(c => c.slug).includes(match.params.type)) {
14
     if (['idws', 'type'].every(p => p in match.params) && contentType.map(c => c.slug).includes(match.params.type)) {
15
-      renderCreateContentApp(
15
+      renderAppPopupCreation(
16
         contentType.find(ct => ct.slug === match.params.type),
16
         contentType.find(ct => ct.slug === match.params.type),
17
         user,
17
         user,
18
         idWorkspace,
18
         idWorkspace,