Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Adjust code for @nextcloud/vue 8.12 providing native app sidebar toggle #2170

Merged
merged 1 commit into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 16 additions & 25 deletions src/components/TopBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
-
-->
<template>
<div class="top-bar" role="toolbar">
<div class="top-bar"
:class="{
'top-bar--has-sidebar': sidebarOpened,
}"
role="toolbar">
<PillMenu v-if="!canOnlySubmit"
:active="currentView"
:options="availableViews"
Expand All @@ -36,16 +40,6 @@
{{ t('forms', 'Share') }}
</template>
</NcButton>
<NcButton v-if="showSidebarToggle"
:aria-label="t('forms', 'Toggle settings')"
:title="t('forms', 'Toggle settings')"
type="tertiary"
@click="toggleSidebar">
<template #icon>
<IconMenuOpen :size="24"
:class="{ 'icon--flipped' : sidebarOpened }" />
</template>
</NcButton>
</div>
</template>

Expand All @@ -54,7 +48,6 @@ import { mdiEye, mdiPencil, mdiPoll } from '@mdi/js'
import { useIsMobile } from '@nextcloud/vue'

import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
import IconMenuOpen from 'vue-material-design-icons/MenuOpen.vue'
import IconShareVariant from 'vue-material-design-icons/ShareVariant.vue'

import logger from '../utils/Logger.js'
Expand Down Expand Up @@ -84,7 +77,6 @@ export default {
name: 'TopBar',

components: {
IconMenuOpen,
IconShareVariant,
NcButton,
PillMenu,
Expand All @@ -100,8 +92,9 @@ export default {

sidebarOpened: {
type: Boolean,
default: null,
default: false,
},

permissions: {
type: Array,
default: () => [],
Expand Down Expand Up @@ -147,16 +140,9 @@ export default {
canOnlySubmit() {
return this.permissions.length === 1 && this.permissions.includes(this.PERMISSION_TYPES.PERMISSION_SUBMIT)
},
showSidebarToggle() {
return this.permissions.includes(this.PERMISSION_TYPES.PERMISSION_EDIT) && this.sidebarOpened !== null
},
},

methods: {
toggleSidebar() {
this.$emit('update:sidebarOpened', !this.sidebarOpened)
},

/**
* Router methods
*
Expand Down Expand Up @@ -191,17 +177,22 @@ export default {
display: flex;
align-items: center;
align-self: flex-end;
// allow to wrap on small screens - wrap reverse so the sidebar toggle keeps aligned with the navigation toggle
flex-wrap: wrap-reverse;
// allow to wrap on small screens
flex-wrap: wrap;
justify-content: flex-end;

// align with navigation toggle, but ensure it is not overlayed
// align with navigation and sidebar toggle, but ensure it is not overlayed
padding: var(--app-navigation-padding);
margin-inline-start: var(--default-clickable-area, 44px);
margin-inline: var(--default-clickable-area, 44px);

position: sticky;
top: 0;
z-index: 100;

&--has-sidebar {
// Remove margin as the toggle button does not exist when open
margin-inline-end: 0;
}
}

.icon--flipped {
Expand Down
1 change: 0 additions & 1 deletion src/views/Create.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
<TopBar :archived="isFormArchived"
:permissions="form?.permissions"
:sidebar-opened="sidebarOpened"
@update:sidebarOpened="onSidebarChange"
@share-form="onShareForm" />

<NcEmptyContent v-if="isLoadingForm"
Expand Down
1 change: 0 additions & 1 deletion src/views/Results.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
<TopBar :archived="isFormArchived"
:permissions="form?.permissions"
:sidebar-opened="sidebarOpened"
@update:sidebarOpened="onSidebarChange"
@share-form="onShareForm" />

<!-- Loading submissions -->
Expand Down
15 changes: 3 additions & 12 deletions src/views/Sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
-->

<template>
<NcAppSidebar v-show="sidebarOpened"
<NcAppSidebar :open="sidebarOpened"
:active="active"
:name="t('forms', 'Form settings')"
@close="onClose"
@update:active="onUpdateActive">
@update:active="onUpdateActive"
@update:open="$emit('update:sidebarOpened', $event)">
<NcAppSidebarTab id="forms-sharing"
:order="0"
:name="t('forms', 'Sharing')">
Expand Down Expand Up @@ -84,15 +84,6 @@ export default {
},

methods: {
/**
* Sidebar state methods
*/
onClose() {
this.$emit('update:sidebarOpened', false)
},
onToggle() {
this.$emit('update:sidebarOpened', !this.sidebarOpened)
},
onUpdateActive(active) {
this.$emit('update:active', active)
},
Expand Down
1 change: 0 additions & 1 deletion src/views/Submit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
:archived="isArchived"
:permissions="form?.permissions"
:sidebar-opened="sidebarOpened"
@update:sidebarOpened="onSidebarChange"
@share-form="onShareForm" />

<!-- Form is loading -->
Expand Down
Loading