Skip to content

Commit

Permalink
Merge pull request #2532 from nextcloud/fix/2531-sidebar-toggle
Browse files Browse the repository at this point in the history
Fix: Show sidebar toggle in all views
  • Loading branch information
Chartman123 authored Jan 31, 2025
2 parents b5a1197 + 425ba29 commit 1280b9c
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 70 deletions.
9 changes: 5 additions & 4 deletions src/Forms.vue
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,11 @@
:form.sync="selectedForm"
:sidebar-opened.sync="sidebarOpened"
@open-sharing="openSharing" />
<router-view
<Sidebar
v-if="!selectedForm.partial && canEdit"
:form="selectedForm"
:sidebar-opened.sync="sidebarOpened"
:active.sync="sidebarActive"
name="sidebar" />
:active.sync="sidebarActive" />
</template>

<!-- Archived forms modal -->
Expand Down Expand Up @@ -162,8 +161,9 @@ import IconPlus from 'vue-material-design-icons/Plus.vue'
import ArchivedFormsModal from './components/ArchivedFormsModal.vue'
import AppNavigationForm from './components/AppNavigationForm.vue'
import FormsIcon from './components/Icons/FormsIcon.vue'
import PermissionTypes from './mixins/PermissionTypes.js'
import OcsResponse2Data from './utils/OcsResponse2Data.js'
import PermissionTypes from './mixins/PermissionTypes.js'
import Sidebar from './views/Sidebar.vue'
import logger from './utils/Logger.js'
import { FormState } from './models/FormStates.ts'

Expand All @@ -184,6 +184,7 @@ export default {
NcContent,
NcEmptyContent,
NcLoadingIcon,
Sidebar,
},

mixins: [PermissionTypes],
Expand Down
10 changes: 5 additions & 5 deletions src/components/Results/ResultsSummary.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<meter
:id="`option-${option.questionId}-${option.id}`"
min="0"
:max="submissions.length"
:max="submissions?.length"
:value="option.count" />
</li>
</ol>
Expand Down Expand Up @@ -113,7 +113,7 @@ export default {
})

// Go through submissions to check which options have how many responses
this.submissions.forEach((submission) => {
this.submissions?.forEach((submission) => {
const answers = submission.answers.filter(
(answer) => answer.questionId === this.question.id,
)
Expand Down Expand Up @@ -151,7 +151,7 @@ export default {
questionOptionsStats.forEach((questionOptionsStat) => {
// Fill percentage values
questionOptionsStat.percentage = Math.round(
(100 * questionOptionsStat.count) / this.submissions.length,
(100 * questionOptionsStat.count) / this.submissions?.length,
)
// Mark all best results. First one is best for sure due to sorting
questionOptionsStat.best =
Expand All @@ -169,7 +169,7 @@ export default {
let noResponseCount = 0

// Go through submissions to check which options have how many responses
this.submissions.forEach((submission) => {
this.submissions?.forEach((submission) => {
const answers = submission.answers.filter(
(answer) => answer.questionId === this.question.id,
)
Expand Down Expand Up @@ -199,7 +199,7 @@ export default {

// Calculate no response percentage
const noResponsePercentage = Math.round(
(100 * noResponseCount) / this.submissions.length,
(100 * noResponseCount) / this.submissions?.length,
)
answersModels.unshift({
id: 0,
Expand Down
16 changes: 0 additions & 16 deletions src/components/TopBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,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 Down Expand Up @@ -204,8 +192,4 @@ export default {
margin-inline-end: 0;
}
}

.icon--flipped {
transform: scaleX(-1);
}
</style>
4 changes: 0 additions & 4 deletions src/mixins/ViewsMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,6 @@ export default {
this.$emit('open-sharing', this.form.hash)
},

onSidebarChange(newState) {
this.$emit('update:sidebarOpened', newState)
},

/**
* Focus title after form load
*/
Expand Down
4 changes: 0 additions & 4 deletions src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { generateUrl } from '@nextcloud/router'

import Create from './views/Create.vue'
import Results from './views/Results.vue'
import Sidebar from './views/Sidebar.vue'
import Submit from './views/Submit.vue'

Vue.use(Router)
Expand Down Expand Up @@ -37,7 +36,6 @@ export default new Router({
path: '/:hash/edit',
components: {
default: Create,
sidebar: Sidebar,
},
name: 'edit',
props: { default: true },
Expand All @@ -46,7 +44,6 @@ export default new Router({
path: '/:hash/results',
components: {
default: Results,
sidebar: Sidebar,
},
name: 'results',
props: { default: true },
Expand All @@ -55,7 +52,6 @@ export default new Router({
path: '/:hash/submit',
components: {
default: Submit,
sidebar: Sidebar,
},
name: 'submit',
props: { default: true },
Expand Down
69 changes: 32 additions & 37 deletions src/views/Results.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<p>
{{
t('forms', '{amount} responses', {
amount: form.submissions.length,
amount: form.submissions?.length ?? 0,
})
}}
</p>
Expand All @@ -64,6 +64,14 @@
@blur="isDownloadActionOpened = false"
@close="isDownloadActionOpened = false">
<template v-if="!isDownloadActionOpened">
<NcActionButton
v-if="canEditForm && !form.fileId"
@click="onLinkFile">
<template #icon>
<IconLink :size="20" />
</template>
{{ t('forms', 'Create spreadsheet') }}
</NcActionButton>
<template v-if="canEditForm && form.fileId">
<NcActionButton
:href="fileUrl"
Expand All @@ -89,16 +97,8 @@
</template>
{{ t('forms', 'Unlink spreadsheet') }}
</NcActionButton>
<NcActionSeparator />
<NcActionSeparator v-if="!noSubmissions" />
</template>
<NcActionButton
v-else-if="canEditForm"
@click="onLinkFile">
<template #icon>
<IconLink :size="20" />
</template>
{{ t('forms', 'Create spreadsheet') }}
</NcActionButton>
<NcActionButton
v-if="!noSubmissions"
close-after-click
Expand Down Expand Up @@ -344,7 +344,6 @@ export default {

picker: null,
showConfirmDeleteDialog: false,
showLinkedFileNotAvailableDialog: false,

linkedFileNotAvailableButtons: [
{
Expand Down Expand Up @@ -419,19 +418,27 @@ export default {
}
return window.location.href
},

showLinkedFileNotAvailableDialog() {
if (this.form.partial) {
return false
}
return this.canEditForm && this.form.fileId && !this.form.filePath
},
},

watch: {
// Reload results, when form changes
async hash() {
await this.fetchFullForm(this.form.id)
this.loadFormResults()
await this.fetchLinkedFileInfo()
SetWindowTitle(this.formTitle)
},
},

async beforeMount() {
await this.fetchFullForm(this.form.id)
this.loadFormResults()
await this.fetchLinkedFileInfo()
SetWindowTitle(this.formTitle)
},

Expand All @@ -449,11 +456,16 @@ export default {
},
)

this.form.fileFormat = null
this.form.fileId = null
this.form.filePath = null
const updatedForm = {
...this.form,
fileFormat: null,
fileId: null,
filePath: null,
}
this.$emit('update:form', updatedForm)
emit('forms:last-updated:set', this.form.id)
},

async loadFormResults() {
this.loadingResults = true
logger.debug(`Loading results for form ${this.form.hash}`)
Expand Down Expand Up @@ -502,7 +514,7 @@ export default {
.pick()
.then(async (path) => {
try {
const response = await axios.patch(
await axios.patch(
generateOcsUrl('apps/forms/api/v3/forms/{id}', {
id: this.form.id,
}),
Expand All @@ -513,15 +525,12 @@ export default {
},
},
)
const responseData = OcsResponse2Data(response)

this.form.fileFormat = responseData.fileFormat
this.form.fileId = responseData.fileId
this.form.filePath = responseData.filePath
await this.fetchFullForm(this.form.id)
await this.loadFormResults()

showSuccess(
t('forms', 'File {file} successfully linked', {
file: responseData.fileName,
file: this.form.filePath.split('/').pop(),
}),
)
emit('forms:last-updated:set', this.form.id)
Expand Down Expand Up @@ -586,20 +595,6 @@ export default {
}
},

async fetchLinkedFileInfo() {
const response = await axios.get(
generateOcsUrl('apps/forms/api/v3/forms/{id}', {
id: this.form.id,
}),
)
const form = OcsResponse2Data(response)
this.$set(this.form, 'fileFormat', form.fileFormat)
this.$set(this.form, 'fileId', form.fileId)
this.$set(this.form, 'filePath', form.filePath)
this.showLinkedFileNotAvailableDialog =
this.canEditForm && form.fileId && !form.filePath
},

async onReExport() {
if (!this.form.fileId) {
// Theoretically this will never fire
Expand Down

0 comments on commit 1280b9c

Please sign in to comment.