|
@@ -33,44 +33,48 @@
|
33
|
33
|
<script src="/dev/bootstrap-4.0.0-beta.2.js"></script>
|
34
|
34
|
|
35
|
35
|
<script type='text/javascript'>
|
36
|
|
- const pageHtml = new appPageHtml()
|
37
|
|
-
|
|
36
|
+ let prevSelectedApp = {name: ''} // default value
|
38
|
37
|
/*
|
39
|
|
- app: {
|
40
|
|
- content: {id, type, title, status}, // version and/or text are useless for Tracim, only useful for app
|
41
|
|
- appConfig: {name, componentLeft, componentRight, customClass, icon}
|
|
38
|
+ app : {
|
|
39
|
+ loggedUser: {id, isLoggedIn, username, firstname, lastname, email, avatar}
|
|
40
|
+ workspace: {id, title},
|
|
41
|
+ appConfig: {name, componentLeft, componentRight, customClass, icon},
|
|
42
|
+ content: {id, title, type, status}
|
42
|
43
|
}
|
43
|
44
|
*/
|
44
|
45
|
GLOBAL_renderApp = app => {
|
45
|
|
- switch (app.appConfig.name) {
|
46
|
|
- case 'PageHtml':
|
47
|
|
- pageHtml.renderApp('appContainer', app); break
|
48
|
|
- case 'Thread':
|
49
|
|
- appThread.renderApp('appContainer', app); break
|
|
46
|
+ const selectedApp = (() => {
|
|
47
|
+ switch (app.appConfig.name) {
|
|
48
|
+ case 'PageHtml':
|
|
49
|
+ return appPageHtml
|
|
50
|
+ case 'Thread':
|
|
51
|
+ return appThread
|
|
52
|
+ }
|
|
53
|
+ })()
|
|
54
|
+
|
|
55
|
+ if (selectedApp.isRendered) {
|
|
56
|
+ GLOBAL_dispatchEvent(`${app.appConfig.name}_showApp`, app)
|
|
57
|
+ } else {
|
|
58
|
+ selectedApp.renderApp('appContainer', app)
|
|
59
|
+ selectedApp.isRendered = true
|
|
60
|
+ prevSelectedApp.isRendered = false
|
|
61
|
+ prevSelectedApp = selectedApp
|
50
|
62
|
}
|
51
|
63
|
}
|
52
|
64
|
|
53
|
65
|
GLOBAL_dispatchEvent = (type, data) => {
|
54
|
|
- var event = new CustomEvent('appCustomEvent', {type, data})
|
|
66
|
+ var event = new CustomEvent('appCustomEvent', {detail: {type, data}})
|
55
|
67
|
document.dispatchEvent(event)
|
56
|
68
|
}
|
57
|
69
|
|
58
|
|
- GLOBAL_unmountApp = appName => {
|
|
70
|
+ GLOBAL_hideApp = appName => {
|
59
|
71
|
switch (appName) {
|
60
|
72
|
case 'PageHtml':
|
61
|
|
- // pageHtml.hideApp('appContainer'); break
|
62
|
|
- GLOBAL_dispatchEvent('PageHtml_hideApp', {})
|
|
73
|
+ GLOBAL_dispatchEvent('PageHtml_hideApp', {}); break
|
63
|
74
|
case 'Thread':
|
64
|
|
- appThread.hideApp('appContainer'); break
|
|
75
|
+ GLOBAL_dispatchEvent('Thread_hideApp', {}); break
|
65
|
76
|
}
|
66
|
77
|
}
|
67
|
|
-
|
68
|
|
- // only usefull if plugin doesn't handle fileContent himself
|
69
|
|
- GLOBAL_handleRequireRedraw = () => {
|
70
|
|
- var rez = pluginA.destroyPlugin('plugin')
|
71
|
|
- if (rez) GLOBAL_drawPlugin('redraw')
|
72
|
|
- else console.log('Erreur, failed at destroying plugin')
|
73
|
|
- }
|
74
|
78
|
</script>
|
75
|
79
|
|
76
|
80
|
<script type='text/javascript'>
|