|
4 | 4 | --> |
5 | 5 |
|
6 | 6 | <template> |
7 | | - <NcContent app-name="forms"> |
| 7 | + <NcContent appName="forms"> |
8 | 8 | <NcAppNavigation |
9 | 9 | v-if="canCreateForms || hasForms" |
10 | 10 | :aria-label="t('forms', 'Forms navigation')"> |
|
20 | 20 | <!-- Form-Owner--> |
21 | 21 | <template v-if="ownedForms.length > 0"> |
22 | 22 | <NcAppNavigationCaption |
23 | | - is-heading |
| 23 | + isHeading |
24 | 24 | class="forms-navigation__list-heading" |
25 | | - heading-id="forms-navigation-your-forms" |
| 25 | + headingId="forms-navigation-your-forms" |
26 | 26 | :name="t('forms', 'Your forms')" /> |
27 | 27 | <ul aria-labelledby="forms-navigation-your-forms"> |
28 | 28 | <AppNavigationForm |
29 | 29 | v-for="form in ownedForms" |
30 | 30 | :key="form.id" |
31 | 31 | :form="form" |
32 | | - @open-sharing="openSharing" |
33 | | - @mobile-close-navigation="mobileCloseNavigation" |
| 32 | + @openSharing="openSharing" |
| 33 | + @mobileCloseNavigation="mobileCloseNavigation" |
34 | 34 | @clone="onCloneForm" |
35 | 35 | @delete="onDeleteForm" /> |
36 | 36 | </ul> |
|
39 | 39 | <!-- Shared Forms--> |
40 | 40 | <template v-if="sharedForms.length > 0"> |
41 | 41 | <NcAppNavigationCaption |
42 | | - is-heading |
| 42 | + isHeading |
43 | 43 | class="forms-navigation__list-heading" |
44 | | - heading-id="forms-navigation-shared-forms" |
| 44 | + headingId="forms-navigation-shared-forms" |
45 | 45 | :name="t('forms', 'Shared with you')" /> |
46 | 46 | <ul aria-labelledby="forms-navigation-shared-forms"> |
47 | 47 | <AppNavigationForm |
48 | 48 | v-for="form in sharedForms" |
49 | 49 | :key="form.id" |
50 | 50 | :form="form" |
51 | | - read-only |
52 | | - @open-sharing="openSharing" |
53 | | - @mobile-close-navigation="mobileCloseNavigation" /> |
| 51 | + readOnly |
| 52 | + @openSharing="openSharing" |
| 53 | + @mobileCloseNavigation="mobileCloseNavigation" /> |
54 | 54 | </ul> |
55 | 55 | </template> |
56 | 56 |
|
|
119 | 119 | <template v-else> |
120 | 120 | <router-view |
121 | 121 | :form="selectedForm" |
122 | | - :sidebar-opened="sidebarOpened" |
| 122 | + :sidebarOpened="sidebarOpened" |
123 | 123 | @update:form="updateSelectedForm" |
124 | | - @update:sidebar-opened="sidebarOpened = $event" |
125 | | - @open-sharing="openSharing" /> |
| 124 | + @update:sidebarOpened="sidebarOpened = $event" |
| 125 | + @openSharing="openSharing" /> |
126 | 126 | <Sidebar |
127 | 127 | v-if="!selectedForm.partial && canEdit" |
128 | 128 | :form="selectedForm" |
129 | | - :sidebar-opened="sidebarOpened" |
| 129 | + :sidebarOpened="sidebarOpened" |
130 | 130 | :active="sidebarActive" |
131 | | - @update:sidebar-opened="sidebarOpened = $event" |
| 131 | + @update:sidebarOpened="sidebarOpened = $event" |
132 | 132 | @update:active="sidebarActive = $event" /> |
133 | 133 | </template> |
134 | 134 |
|
@@ -207,6 +207,35 @@ export default { |
207 | 207 |
|
208 | 208 | const PERMISSION_TYPES = PermissionTypes.data().PERMISSION_TYPES |
209 | 209 |
|
| 210 | + const routeHash = computed(() => route.params.hash) |
| 211 | +
|
| 212 | + const routeAllowed = computed(() => { |
| 213 | + if (loading.value && loadState(appName, 'formId') === 'invalid') { |
| 214 | + return false |
| 215 | + } |
| 216 | +
|
| 217 | + if (!routeHash.value) { |
| 218 | + return false |
| 219 | + } |
| 220 | +
|
| 221 | + const form = [...forms.value, ...allSharedForms.value].find( |
| 222 | + (form) => form.hash === routeHash.value, |
| 223 | + ) |
| 224 | +
|
| 225 | + if (form === undefined) { |
| 226 | + fetchPartialForm(routeHash.value) |
| 227 | + return false |
| 228 | + } |
| 229 | +
|
| 230 | + if (route.name === 'results') { |
| 231 | + return ( |
| 232 | + form.permissions.includes(route.name) || form.submissionCount > 0 |
| 233 | + ) |
| 234 | + } |
| 235 | +
|
| 236 | + return form?.permissions.includes(route.name) |
| 237 | + }) |
| 238 | +
|
210 | 239 | const selectedForm = computed(() => { |
211 | 240 | if (routeAllowed.value) { |
212 | 241 | return ( |
@@ -263,36 +292,6 @@ export default { |
263 | 292 | ) |
264 | 293 | }) |
265 | 294 |
|
266 | | - const routeHash = computed(() => route.params.hash) |
267 | | -
|
268 | | - const routeAllowed = computed(() => { |
269 | | - if (loading.value && loadState(appName, 'formId') === 'invalid') { |
270 | | - return false |
271 | | - } |
272 | | -
|
273 | | - if (!routeHash.value) { |
274 | | - return false |
275 | | - } |
276 | | -
|
277 | | - const form = [...forms.value, ...allSharedForms.value].find( |
278 | | - (form) => form.hash === routeHash.value, |
279 | | - ) |
280 | | -
|
281 | | - if (form === undefined) { |
282 | | - fetchPartialForm(routeHash.value) |
283 | | - return false |
284 | | - } |
285 | | -
|
286 | | - if (route.name === 'results') { |
287 | | - return ( |
288 | | - form.permissions.includes(route.name) |
289 | | - || form.submissionCount > 0 |
290 | | - ) |
291 | | - } |
292 | | -
|
293 | | - return form?.permissions.includes(route.name) |
294 | | - }) |
295 | | -
|
296 | 295 | const mobileCloseNavigation = () => { |
297 | 296 | if (isMobile.value) { |
298 | 297 | emit('toggle-navigation', { open: false }) |
@@ -341,7 +340,12 @@ export default { |
341 | 340 | loading.value = false |
342 | 341 | } |
343 | 342 |
|
344 | | - const fetchPartialForm = async (hash) => { |
| 343 | + /** |
| 344 | + * Fetch a partial form by its hash after initial load completes. |
| 345 | + * |
| 346 | + * @param {string} hash The hash of the form to fetch. |
| 347 | + */ |
| 348 | + async function fetchPartialForm(hash) { |
345 | 349 | await new Promise((resolve) => { |
346 | 350 | const wait = () => { |
347 | 351 | if (loading.value) { |
|
0 commit comments