fcad-core-dragon 2.0.0-beta.0 → 2.0.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. package/.editorconfig +6 -31
  2. package/.prettierrc +11 -0
  3. package/.vscode/extensions.json +8 -0
  4. package/.vscode/settings.json +16 -0
  5. package/CHANGELOG +153 -0
  6. package/README.md +28 -43
  7. package/documentation/.vitepress/config.js +114 -0
  8. package/documentation/api-examples.md +49 -0
  9. package/documentation/composants/app-base-button.md +58 -0
  10. package/documentation/composants/app-base-error-display.md +59 -0
  11. package/documentation/composants/app-base-popover.md +68 -0
  12. package/documentation/composants/app-comp-audio.md +75 -0
  13. package/documentation/composants/app-comp-branch-buttons.md +111 -0
  14. package/documentation/composants/app-comp-button-progress.md +53 -0
  15. package/documentation/composants/app-comp-carousel.md +53 -0
  16. package/documentation/composants/app-comp-container.md +53 -0
  17. package/documentation/composants/app-comp-input-checkbox-next.md +42 -0
  18. package/documentation/composants/app-comp-input-dropdown-next.md +34 -0
  19. package/documentation/composants/app-comp-input-radio-next.md +39 -0
  20. package/documentation/composants/app-comp-input-text-next.md +35 -0
  21. package/documentation/composants/app-comp-input-text-table-next.md +34 -0
  22. package/documentation/composants/app-comp-input-text-to-fill-dropdown-next.md +53 -0
  23. package/documentation/composants/app-comp-input-text-to-fill-next.md +31 -0
  24. package/documentation/composants/app-comp-jauge.md +31 -0
  25. package/documentation/composants/app-comp-menu-item.md +55 -0
  26. package/documentation/composants/app-comp-menu.md +29 -0
  27. package/documentation/composants/app-comp-navigation.md +41 -0
  28. package/documentation/composants/app-comp-note-call.md +53 -0
  29. package/documentation/composants/app-comp-note-credit.md +53 -0
  30. package/documentation/composants/app-comp-play-bar-next.md +53 -0
  31. package/documentation/composants/app-comp-pop-up-next.md +93 -0
  32. package/documentation/composants/app-comp-quiz-next.md +235 -0
  33. package/documentation/composants/app-comp-quiz-recall.md +53 -0
  34. package/documentation/composants/app-comp-svg-next.md +53 -0
  35. package/documentation/composants/app-comp-table-of-content.md +50 -0
  36. package/documentation/composants/app-comp-video-player.md +82 -0
  37. package/documentation/composants.md +46 -0
  38. package/documentation/composants_critiques/ModelPageComposant.md +53 -0
  39. package/documentation/composants_critiques/app-base-module.md +43 -0
  40. package/documentation/composants_critiques/app-base-page.md +48 -0
  41. package/documentation/composants_critiques/app-base.md +311 -0
  42. package/documentation/composants_critiques/main.md +15 -0
  43. package/documentation/demarrage.md +50 -0
  44. package/documentation/deploiement.md +58 -0
  45. package/documentation/index.md +33 -0
  46. package/documentation/markdown-examples.md +85 -0
  47. package/documentation/public/npm_version.png +0 -0
  48. package/documentation/public/vite.svg +15 -0
  49. package/documentation/public/vuejs.svg +2 -0
  50. package/documentation/public/vuetify.svg +6 -0
  51. package/eslint.config.js +60 -0
  52. package/package.json +43 -49
  53. package/src/$locales/en.json +94 -92
  54. package/src/$locales/fr.json +77 -113
  55. package/src/assets/data/onboardingMessages.json +1 -1
  56. package/src/components/AppBase.vue +971 -437
  57. package/src/components/AppBaseButton.test.js +21 -0
  58. package/src/components/AppBaseButton.vue +42 -10
  59. package/src/components/AppBaseErrorDisplay.vue +209 -162
  60. package/src/components/AppBaseFlipCard.vue +1 -0
  61. package/src/components/AppBaseModule.vue +1021 -976
  62. package/src/components/AppBasePage.vue +656 -128
  63. package/src/components/AppBasePopover.vue +41 -0
  64. package/src/components/AppBaseSkeleton.vue +66 -0
  65. package/src/components/AppCompAudio.vue +256 -0
  66. package/src/components/AppCompBranchButtons.vue +108 -181
  67. package/src/components/AppCompButtonProgress.vue +44 -70
  68. package/src/components/AppCompCarousel.vue +284 -233
  69. package/src/components/AppCompContainer.vue +29 -0
  70. package/src/components/AppCompInputCheckBoxNx.vue +323 -0
  71. package/src/components/AppCompInputDropdownNx.vue +299 -0
  72. package/src/components/AppCompInputRadioNx.vue +284 -0
  73. package/src/components/AppCompInputTextNx.vue +153 -0
  74. package/src/components/AppCompInputTextTableNx.vue +202 -0
  75. package/src/components/AppCompInputTextToFillDropdownNx.vue +340 -0
  76. package/src/components/AppCompInputTextToFillNx.vue +313 -0
  77. package/src/components/AppCompJauge.vue +36 -11
  78. package/src/components/AppCompMenu.vue +312 -92
  79. package/src/components/AppCompMenuItem.vue +129 -105
  80. package/src/components/AppCompNavigation.vue +972 -0
  81. package/src/components/AppCompNoteCall.vue +161 -0
  82. package/src/components/AppCompNoteCredit.vue +491 -0
  83. package/src/components/AppCompPlayBarNext.vue +2288 -0
  84. package/src/components/AppCompPopUpNext.vue +504 -0
  85. package/src/components/AppCompQuizNext.vue +510 -0
  86. package/src/components/AppCompQuizRecall.vue +350 -0
  87. package/src/components/AppCompSVGNext.vue +346 -0
  88. package/src/components/AppCompSettingsMenu.vue +18 -16
  89. package/src/components/AppCompTableOfContent.vue +340 -122
  90. package/src/components/AppCompVideoPlayer.vue +377 -0
  91. package/src/components/BaseModule.vue +24 -117
  92. package/src/components/tests__/AppBaseButton.spec.js +53 -0
  93. package/src/components/tests__/useTimer.spec.js +91 -0
  94. package/src/composables/useIdleDetector.js +56 -0
  95. package/src/composables/useQuiz.js +89 -0
  96. package/src/composables/useTimer.js +172 -0
  97. package/src/directives/nvdaFix.js +53 -0
  98. package/src/externalComps/ModuleView.vue +22 -0
  99. package/src/externalComps/SummaryView.vue +91 -0
  100. package/src/main.js +400 -142
  101. package/src/module/stores/appStore.js +947 -0
  102. package/src/module/xapi/ADL.js +241 -60
  103. package/src/module/xapi/Crypto/Hasher.js +8 -8
  104. package/src/module/xapi/Crypto/WordArray.js +6 -6
  105. package/src/module/xapi/Crypto/algorithms/BufferedBlockAlgorithm.js +4 -4
  106. package/src/module/xapi/Crypto/algorithms/C_algo.js +14 -18
  107. package/src/module/xapi/Crypto/algorithms/HMAC.js +1 -1
  108. package/src/module/xapi/Crypto/algorithms/SHA1.js +1 -1
  109. package/src/module/xapi/Crypto/encoders/Base.js +7 -7
  110. package/src/module/xapi/Crypto/encoders/Base64.js +3 -3
  111. package/src/module/xapi/Crypto/encoders/Hex.js +4 -3
  112. package/src/module/xapi/Crypto/encoders/Latin1.js +3 -3
  113. package/src/module/xapi/Crypto/encoders/Utf8.js +3 -3
  114. package/src/module/xapi/Statement/index.js +3 -3
  115. package/src/module/xapi/launch.js +10 -10
  116. package/src/module/xapi/utils.js +17 -17
  117. package/src/module/xapi/wrapper.js +223 -218
  118. package/src/module/xapi/xapiStatement.js +29 -29
  119. package/src/plugins/analytics.js +34 -0
  120. package/src/plugins/bus.js +7 -2
  121. package/src/plugins/gsap.js +9 -8
  122. package/src/plugins/helper.js +141 -43
  123. package/src/plugins/i18n.js +13 -18
  124. package/src/plugins/idb.js +46 -30
  125. package/src/plugins/save.js +1 -1
  126. package/src/plugins/scorm.js +15 -15
  127. package/src/plugins/xapi.js +2 -2
  128. package/src/public/index.html +23 -11
  129. package/src/router/index.js +57 -0
  130. package/src/router/routes.js +312 -0
  131. package/src/shared/generalfuncs.js +241 -10
  132. package/src/shared/validators.js +1018 -0
  133. package/vitest.config.js +19 -0
  134. package/.eslintignore +0 -29
  135. package/.eslintrc.js +0 -86
  136. package/.prettierrc.js +0 -5
  137. package/babel.config.js +0 -3
  138. package/src/components/AppBaseDragChoice.vue +0 -91
  139. package/src/components/AppBaseDropZone.vue +0 -112
  140. package/src/components/AppCompDragAndDrop.vue +0 -339
  141. package/src/components/AppCompInputAssociation.vue +0 -332
  142. package/src/components/AppCompInputCheckBox.vue +0 -227
  143. package/src/components/AppCompInputDropdown.vue +0 -184
  144. package/src/components/AppCompInputRadio.vue +0 -169
  145. package/src/components/AppCompInputTextBox.vue +0 -91
  146. package/src/components/AppCompInputTextTable.vue +0 -155
  147. package/src/components/AppCompInputTextToFillDropdown.vue +0 -255
  148. package/src/components/AppCompInputTextToFillText.vue +0 -164
  149. package/src/components/AppCompMediaPlayer.vue +0 -365
  150. package/src/components/AppCompNavigationFull.vue +0 -1791
  151. package/src/components/AppCompPlayBar.vue +0 -1540
  152. package/src/components/AppCompPopUp.vue +0 -523
  153. package/src/components/AppCompQuiz.vue +0 -2998
  154. package/src/components/AppCompToolTip.vue +0 -94
  155. package/src/mixins/$pageMixins.js +0 -381
  156. package/src/mixins/$quizMixins.js +0 -456
  157. package/src/mixins/timerMixin.js +0 -132
  158. package/src/module/store.js +0 -874
  159. package/src/plugins/timeManager.js +0 -77
  160. package/src/routes.js +0 -734
  161. package/vue.config.js +0 -83
@@ -1,31 +1,26 @@
1
+ import _ from 'lodash'
1
2
  /**
2
3
  * Merge locales message in project.
3
4
  * @summary To merge the locales dictionnary of this library with the locales that user will create
4
5
  * @param {Object} i18n - vue-i18n internalization object.
5
6
  */
6
7
  export default function mergeLocales(i18n) {
7
- const deep = require('lodash') // provide deep merge of Object cf: https://attacomsian.com/blog/javascript-merge-objects
8
-
9
- /* I18n internal methods for mutating messages property
10
- * mergeLocaleMessage: ƒ mergeLocaleMessage(locale, message)// will merge message with new message object. But does not do a deep merge of object
11
- * setLocaleMessage: ƒ setLocaleMessage(locale, message)// set the message with new message object
12
- */
13
-
14
- // This library locales files
15
- const thisLocales = require.context(
16
- '../$locales',
17
- true,
18
- /[A-Za-z0-9-_,\s]+\.json$/i
19
- )
20
-
21
- thisLocales.keys().forEach((key) => {
22
- const matched = key.match(/([A-Za-z0-9-_]+)\./i)
8
+ const thisLocales = import.meta.glob('../$locales/*.json', {
9
+ import: 'default',
10
+ eager: true
11
+ })
12
+ for (const path in thisLocales) {
13
+ const matched = path.match(/([A-Za-z0-9-_]+)\./i)
23
14
  if (matched && matched.length > 1) {
24
15
  const locale = matched[1]
16
+
25
17
  // Using lodash to deeply merge objects
26
- const mergedMessages = deep.merge(i18n.messages[locale], thisLocales(key))
18
+ const coreMessages = JSON.parse(JSON.stringify(thisLocales[path]))
19
+ const templateMessages = JSON.parse(JSON.stringify(i18n.messages[locale]))
20
+ const mergedMessages = _.merge(coreMessages, templateMessages)
21
+
27
22
  // Since merLocalMessage will do a shallow merge of the object. We will use setLocalMessage to replace the message with new message object
28
23
  i18n.setLocaleMessage(locale, mergedMessages)
29
24
  }
30
- })
25
+ }
31
26
  }
@@ -1,16 +1,19 @@
1
1
  /*
2
2
  * idb library by jakearchibald: https://github.com/jakearchibald/idb
3
3
  */
4
- import { openDB, deleteDB, wrap, unwrap } from 'idb'
4
+ import { openDB } from 'idb'
5
+ import $_ from 'lodash'
6
+ //import { createApp } from 'vue'
5
7
  //import {*} from "idb";
6
8
  let dataBase = null
7
9
  let dbName = '$crsDataBase' //test
8
10
  let storeName = '$lessonsStore' //test
9
- openDB, deleteDB, wrap, unwrap
11
+ //openDB, deleteDB, wrap, unwrap
10
12
  //$_id
13
+ //const app = createApp({})
11
14
  export const $idb = {
12
- install(Vue) {
13
- Vue.prototype.$idb = {
15
+ install(app) {
16
+ app.config.globalProperties.$idb = {
14
17
  /*
15
18
  * @ Description: create a indexedDB database
16
19
  * Open a data base in indexedDB if does not exist and create a store for the lessons package
@@ -41,7 +44,7 @@ export const $idb = {
41
44
  }
42
45
  })
43
46
  dataBase = db
44
- //return (dataBase = db);
47
+ return dataBase
45
48
  }
46
49
  } catch (err) {
47
50
  console.log('==> Erro ', err)
@@ -64,9 +67,10 @@ export const $idb = {
64
67
  searchIndex,
65
68
  data[searchIndex]
66
69
  )
70
+
67
71
  //Add entry to database if does not exist
68
72
  if (!value) {
69
- const addedItem = await dataBase.add(storeName, data)
73
+ const addedItem = await dataBase.add(storeName, $_.cloneDeep(data))
70
74
 
71
75
  return addedItem
72
76
  }
@@ -136,7 +140,10 @@ export const $idb = {
136
140
  if (existingRecord) {
137
141
  existingRecord.$record = newValue
138
142
  existingRecord.$last_edit = Date.now()
139
- const updatedItem = await dataBase.put(storeName, existingRecord)
143
+ const updatedItem = await dataBase.put(
144
+ storeName,
145
+ $_.cloneDeep(existingRecord)
146
+ )
140
147
  //await this.getAllFromDB(storeName)
141
148
  return updatedItem
142
149
  }
@@ -177,33 +184,42 @@ export const $idb = {
177
184
  },
178
185
  /**
179
186
  * @description creating a small save plug-in to save store state in the localStorage
180
- * the plugin listen for mutations made to the Vuex store and store them in the local browser storage.
181
- * Since the The handler is called after every mutation we want to limite the saving of data to application storage only
182
- * when the mutation is affecting the user interaction.
187
+ * the plugin listen for changes made to the Pinia store store to store them in the browser storage.
188
+ * Since the The handler is called after every actions we want to limit the saving of data to storage only
189
+ * when the changes are affecting the user interaction.
183
190
  * This prevent resetting the store to initial state when the browser refreshes
184
- * Note: the plugin is used in the store.js
185
- * @param {Object} store vuex Store
191
+ * @param {Object} store Pinia Store
186
192
  * @param {String} item package $idb_id
187
193
  */
188
- saveState(store, item) {
189
- store.subscribe(async (mutation, state) => {
190
- // Watch only for user interaction related mutation to save the data
191
- if (mutation.type === 'UPDATE_USER_METADATA') {
192
- // Open DB with a store
193
- const search = await this.getFromDB(item)
194
- if (Object.entries(state.$appStore.userMetaData).length && search) {
195
- // Update the db store
196
- await this.updateDataInDB(item, state.$appStore.userMetaData)
197
- //==================================================
198
- } else {
199
- //Add Entry to db store
200
- await this.insertDataInDB({
201
- $idb_id: item,
202
- $record: state.$appStore.userMetaData,
203
- $last_edit: Date.now()
204
- })
205
- }
194
+ async saveState(store, item) {
195
+ store.$onAction(async ({ name, store, args, after }) => {
196
+ //Should only track changes actions on userMetadata
197
+ if (!['updateUserMetaData', 'setUserMetaData'].includes(name)) return
198
+
199
+ // Open DB with a store
200
+ const search = await this.getFromDB(item)
201
+
202
+ if (Object.entries(store.$state.userMetaData).length && search) {
203
+ // Update the db store
204
+ await this.updateDataInDB(item, {
205
+ progress: store.$state.userMetaData,
206
+ userSettings: store.$state.applicationSettings,
207
+ routeHistory: store.getRouteHistory
208
+ })
209
+ //==================================================
210
+ } else {
211
+ //Add Entry to db store
212
+ await this.insertDataInDB({
213
+ $idb_id: item,
214
+ $record: {
215
+ progress: store.$state.userMetaData,
216
+ userSettings: store.$state.applicationSettings,
217
+ routeHistory: store.getRouteHistory
218
+ },
219
+ $last_edit: Date.now()
220
+ })
206
221
  }
222
+ //})
207
223
  })
208
224
  }
209
225
  }
@@ -1,5 +1,5 @@
1
1
  /* creating a small save plug-in to save store state in the localStorage
2
- * the plugin listen for mutations made to the Vuex store and store them in the local browser storage.
2
+ * the plugin listen for mutations made to the Pinia store and store them in the local browser storage.
3
3
  * This prevent reseting the store to initial state when the browser refreshes
4
4
  * Note: the plugin is used in the store.js
5
5
  */
@@ -4,9 +4,9 @@
4
4
  */
5
5
 
6
6
  export const scormPlugin = {
7
- install: function(Vue) {
7
+ install: function (app) {
8
8
  {
9
- Vue.prototype.$scorm = {
9
+ app.config.globalProperties.$scorm = {
10
10
  nFindAPITries: 0,
11
11
  API: null,
12
12
  maxTries: 500,
@@ -41,7 +41,7 @@ export const scormPlugin = {
41
41
  // value to the win parameter passed in, based on the number of
42
42
  // parents. At the end of the function call, the win variable will be
43
43
  // set to the upper most parent in the chain of parents.
44
- ScanForAPI: function(win) {
44
+ ScanForAPI: function (win) {
45
45
  while (win.API == null && win.parent != null && win.parent != win) {
46
46
  this.nFindAPITries++
47
47
  if (this.nFindAPITries > this.maxTries) {
@@ -60,7 +60,7 @@ export const scormPlugin = {
60
60
  // function then checks to see if there are any opener windows. If
61
61
  // the window has an opener, the function begins to look for the
62
62
  // this.API Instance in the opener window.
63
- GetAPI: function(win) {
63
+ GetAPI: function (win) {
64
64
  if (win.parent != null && win.parent != win) {
65
65
  this.API = this.ScanForAPI(win.parent)
66
66
  }
@@ -70,7 +70,7 @@ export const scormPlugin = {
70
70
  },
71
71
 
72
72
  // Initalize
73
- Initialize: function() {
73
+ Initialize: function () {
74
74
  let result
75
75
 
76
76
  this.GetAPI(window)
@@ -104,7 +104,7 @@ export const scormPlugin = {
104
104
  this.initialized = true
105
105
  },
106
106
  //Termitate the communication with the LMS
107
- Finish: function(finalState) {
107
+ Finish: function (finalState) {
108
108
  let result
109
109
  //Don't terminate if we haven't initialized or if we've already terminated
110
110
  if (this.initialized === false || this.terminateCalled === true) {
@@ -144,7 +144,7 @@ export const scormPlugin = {
144
144
  //There are situations where a GetValue call is expected to have an error
145
145
  //and should not alert the user.
146
146
 
147
- GetValue: function(element, checkError) {
147
+ GetValue: function (element, checkError) {
148
148
  let result
149
149
 
150
150
  if (this.initialized == false || this.terminateCalled == true) {
@@ -179,7 +179,7 @@ export const scormPlugin = {
179
179
  return result
180
180
  },
181
181
 
182
- SetValue: function(element, value) {
182
+ SetValue: function (element, value) {
183
183
  let result
184
184
 
185
185
  if (this.initialized == false || this.terminateCalled == true) {
@@ -209,7 +209,7 @@ export const scormPlugin = {
209
209
  }
210
210
  },
211
211
 
212
- Commit: function() {
212
+ Commit: function () {
213
213
  let result
214
214
 
215
215
  result = this.API.LMSCommit('')
@@ -235,7 +235,7 @@ export const scormPlugin = {
235
235
  }
236
236
  },
237
237
  //==================== CUSTOME METHODS =============================
238
- checkForError: function() {
238
+ checkForError: function () {
239
239
  let error_type = null
240
240
  let errorNumber = this.API.LMSGetLastError()
241
241
  if (errorNumber !== '' || errorNumber !== '0') {
@@ -249,24 +249,24 @@ export const scormPlugin = {
249
249
  } else return error_type
250
250
  },
251
251
 
252
- formateMsg: function(msg, data) {
252
+ formateMsg: function (msg, data) {
253
253
  msg.replace('$@errorDescription', data)
254
254
  },
255
255
 
256
- getScormStatus: function() {
256
+ getScormStatus: function () {
257
257
  return this.initialized
258
258
  },
259
259
 
260
- getScormAPI: function() {
260
+ getScormAPI: function () {
261
261
  return this.API
262
262
  },
263
263
 
264
- setCompletionStatus: function(newStatus) {
264
+ setCompletionStatus: function (newStatus) {
265
265
  this.API.RunTimeData.CompletionStatus = newStatus
266
266
  this.Commit()
267
267
  },
268
268
 
269
- setSucessStatus: function(newStatus) {
269
+ setSucessStatus: function (newStatus) {
270
270
  this.API.RunTimeData.SuccessStatus = newStatus
271
271
  this.Commit()
272
272
  },
@@ -3,9 +3,9 @@ import ADL from '../module/xapi/ADL'
3
3
  const _ADL = new ADL()
4
4
 
5
5
  export const xapiPlugin = {
6
- install(Vue) {
6
+ install(app) {
7
7
  {
8
- Vue.prototype.$xapi = _ADL
8
+ app.config.globalProperties.$xapi = _ADL
9
9
  }
10
10
  }
11
11
  }
@@ -1,19 +1,31 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
1
+ <!doctype html>
2
+ <html lang="en" data-build-time="<%= new Date().toLocaleString() %>">
3
3
  <head>
4
- <meta charset="utf-8">
5
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
- <meta name="viewport" content="width=device-width,initial-scale=1.0">
7
- <meta name="apple-mobile-web-app-capable" content="yes">
8
- <link rel="icon" href="<%= BASE_URL %>favicon.ico">
9
- <link href="https://fonts.googleapis.com/css?family=Roboto:100,100i,300,300i,400,400i,500,500i,700,700i,900,900i&display=swap" rel="stylesheet">
4
+ <meta charset="utf-8" />
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge" />
6
+ <meta name="viewport" content="width=device-width,initial-scale=1.0" />
7
+ <meta name="apple-mobile-web-app-capable" content="yes" />
8
+ <link rel="icon" href="<%= BASE_URL %>favicon.ico" />
9
+ <link
10
+ href="https://fonts.googleapis.com/css?family=Roboto:100,100i,300,300i,400,400i,500,500i,700,700i,900,900i&display=swap"
11
+ rel="stylesheet"
12
+ />
10
13
  <title>dfcad-prototype</title>
11
- <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900">
12
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@mdi/font@latest/css/materialdesignicons.min.css">
14
+ <link
15
+ rel="stylesheet"
16
+ href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900"
17
+ />
18
+ <link
19
+ rel="stylesheet"
20
+ href="https://cdn.jsdelivr.net/npm/@mdi/font@latest/css/materialdesignicons.min.css"
21
+ />
13
22
  </head>
14
23
  <body>
15
24
  <noscript>
16
- <strong>We're sorry but dfcad-prototype doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
25
+ <strong>
26
+ We're sorry but dfcad-prototype doesn't work properly without JavaScript
27
+ enabled. Please enable it to continue.
28
+ </strong>
17
29
  </noscript>
18
30
  <div id="app"></div>
19
31
  <!-- built files will be auto injected -->
@@ -0,0 +1,57 @@
1
+ //import VueRouter from 'vue-router'
2
+ import { createRouter, createWebHashHistory } from 'vue-router'
3
+ import routes from './routes'
4
+ import { useAppStore } from '../module/stores/appStore'
5
+ import { inject } from 'vue'
6
+
7
+ //Vue.use(VueRouter)
8
+
9
+ const router = createRouter({
10
+ history: createWebHashHistory(),
11
+ routes,
12
+ scrollBehavior(to, from, savedPosition) {
13
+ if (to.hash) {
14
+ ;(from, savedPosition)
15
+ return {
16
+ selector: to.hash
17
+ // , offset: { x: 0, y: 10 }
18
+ }
19
+ }
20
+ }
21
+ })
22
+
23
+ router.beforeResolve((to, from, next) => {
24
+ const app = inject('app')
25
+ const appStore = useAppStore()
26
+ const { getWidgetOpen, getPopupIsOpen, getSidebarIsOpen } = appStore
27
+ const noNavigationToMenu = appStore.getSettingsFromStore('no_menu')
28
+
29
+ if (to.name == 'module') return next({ name: 'menu' }) //redirect to 404 if trying to access module directly
30
+
31
+ if (getWidgetOpen) app.config.globalProperties.$bus.$emit('close-widget') //close opened widget
32
+ if (getPopupIsOpen) app.config.globalProperties.$bus.$emit('close-popup') //close the popup
33
+ if (getSidebarIsOpen) app.config.globalProperties.$bus.$emit('close-sidebar') //close the sidebar
34
+
35
+ if (from.name !== 'module')
36
+ app.config.globalProperties.$bus.$emit('update-route-history', from)
37
+
38
+ app.config.globalProperties.$bus.$emit('update-content', to) //update the content of the current page
39
+ //hidle detector should be stopped in menu
40
+ if (to.name == 'menu') {
41
+ app.config.globalProperties.$bus.$emit('stop-app-timer')
42
+ app.config.globalProperties.$bus.$emit('stop-idle-detector')
43
+ }
44
+
45
+ if ((noNavigationToMenu && to.name == 'menu') || to.name == 'module') {
46
+ const r = app.config.globalProperties.$helper.getRoutesFromVueRouter() //This return all the routes defined for the module
47
+ let safeRoute = r.meta.children[0] //get the first navigable route from the module routes
48
+
49
+ return next({
50
+ name: safeRoute._namedRoute // redirect to safety route //
51
+ })
52
+ }
53
+
54
+ return next(true)
55
+ })
56
+
57
+ export default router