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

[stable4] Fix: Show sidebar toggle in all views #2536

Merged
merged 2 commits into from
Jan 31, 2025
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
9 changes: 5 additions & 4 deletions src/Forms.vue
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,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 @@ -177,8 +176,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 @@ -199,6 +199,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 @@ -49,7 +49,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 @@ -130,7 +130,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 @@ -168,7 +168,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 @@ -186,7 +186,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 @@ -216,7 +216,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 @@ -44,18 +44,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 @@ -221,8 +209,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 @@ -116,10 +116,6 @@
this.$emit('open-sharing', this.form.hash)
},

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

/**
* Focus title after form load
*/
Expand Down Expand Up @@ -159,7 +155,7 @@
this.$emit('update:form', OcsResponse2Data(response))
this.isLoadingForm = false
} catch (error) {
if (axios.isCancel(error)) {

Check warning on line 158 in src/mixins/ViewsMixin.js

View workflow job for this annotation

GitHub Actions / NPM lint

Caution: `axios` also has a named export `isCancel`. Check if you meant to write `import {isCancel} from '@nextcloud/axios'` instead
logger.debug(`The request for form ${id} has been canceled`, {
error,
})
Expand Down
4 changes: 0 additions & 4 deletions src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,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 @@ -56,7 +55,6 @@ export default new Router({
path: '/:hash/edit',
components: {
default: Create,
sidebar: Sidebar,
},
name: 'edit',
props: { default: true },
Expand All @@ -65,7 +63,6 @@ export default new Router({
path: '/:hash/results',
components: {
default: Results,
sidebar: Sidebar,
},
name: 'results',
props: { default: true },
Expand All @@ -74,7 +71,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 @@ -105,7 +105,7 @@
<p>
{{
t('forms', '{amount} responses', {
amount: form.submissions.length,
amount: form.submissions?.length ?? 0,
})
}}
</p>
Expand All @@ -125,6 +125,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 @@ -150,16 +158,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
close-after-click
@click="onStoreToFiles">
Expand Down Expand Up @@ -381,7 +381,6 @@ export default {

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

linkedFileNotAvailableButtons: [
{
Expand Down Expand Up @@ -456,19 +455,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 @@ -486,11 +493,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 @@ -539,7 +551,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 @@ -550,15 +562,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 @@ -621,20 +630,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
Loading