Skip to content

Commit

Permalink
Merge branch 'main' into forms-960-idp-refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
usingtechnology authored Mar 13, 2024
2 parents 0a39ed1 + db11b0e commit c2ff5f4
Show file tree
Hide file tree
Showing 18 changed files with 914 additions and 236 deletions.
29 changes: 18 additions & 11 deletions app/frontend/src/components/base/BaseNotificationBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,24 @@ export default {
...mapState(useFormStore, ['form', 'isRTL', 'lang']),
},
created() {
if (
this.notification.consoleError &&
this.notification.consoleError instanceof String
) {
// eslint-disable-next-line no-console
console.error(
i18n.t(
this.notification.consoleError,
this.notification.consoleError.options
)
);
if (this.notification.consoleError) {
if (typeof this.notification.consoleError === 'string') {
// eslint-disable-next-line no-console
console.error(this.notification.consoleError);
} else if (this.notification.consoleError.text) {
if (this.notification.consoleError.options) {
// eslint-disable-next-line no-console
console.error(
i18n.t(
this.notification.consoleError.text,
this.notification.consoleError.options
)
);
} else {
// eslint-disable-next-line no-console
console.error(i18n.t(this.notification.consoleError.text));
}
}
}
},
mounted() {
Expand Down
7 changes: 4 additions & 3 deletions app/frontend/src/components/designer/FormViewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -986,10 +986,11 @@ export default {
this.saveDraftState = 0;
if (
(this.submissionId == undefined || this.formDataEntered) &&
this.showModal
)
this.showModal &&
this.form.enableSubmitterDraft
) {
this.doYouWantToSaveTheDraft = true;
else this.leaveThisPage();
} else this.leaveThisPage();
} else {
this.leaveThisPage();
}
Expand Down
20 changes: 15 additions & 5 deletions app/frontend/src/components/forms/ExportSubmissions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ export default {
},
FILTER_HEADERS() {
return this.versionSelected !== ''
? this.formFields.map((f) => ({ name: f, value: f }))
? this.formFields.length > 0
? this.formFields.map((f) => ({ name: f, value: f }))
: []
: [];
},
},
Expand Down Expand Up @@ -199,11 +201,13 @@ export default {
{
minDate: from,
maxDate: to,
// deleted: true,
// drafts: true
},
fieldToExport,
emailExport
emailExport,
{
deleted: false,
drafts: false,
}
);
if (response && response.data && !emailExport) {
Expand All @@ -224,8 +228,13 @@ export default {
throw new Error(i18n.t('trans.exportSubmissions.noResponseDataErr'));
}
} catch (error) {
const data = error?.response?.data
? JSON.parse(await error.response.data.text())
: undefined;
this.addNotification({
text: i18n.t('trans.exportSubmissions.apiCallErrorMsg'),
text: data?.detail
? data.detail
: i18n.t('trans.exportSubmissions.apiCallErrorMsg'),
consoleError:
i18n.t('trans.exportSubmissions.apiCallConsErrorMsg') +
`${this.form.id}: ${error}`,
Expand Down Expand Up @@ -268,6 +277,7 @@ export default {
<h1 :lang="lang">
{{ $t('trans.exportSubmissions.exportSubmissionsToFile') }}
</h1>
<h3>{{ formId ? form.name : '' }}</h3>
</v-col>
<v-col :class="isRTL ? 'text-left' : 'text-right'" cols="1">
<span>
Expand Down
1 change: 1 addition & 0 deletions app/frontend/src/components/forms/SubmissionsTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,7 @@ export default {
<!-- page title -->
<div>
<h1 :lang="lang">{{ $t('trans.formsTable.submissions') }}</h1>
<h3>{{ formId ? form.name : 'All Forms' }}</h3>
</div>
<!-- buttons -->
<div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ export default {
<h1 class="mr-auto" :lang="lang">
{{ $t('trans.teamManagement.teamManagement') }}
</h1>
<h3>{{ formId ? form.name : '' }}</h3>
</div>
<div style="z-index: 50">
<span>
Expand Down
8 changes: 5 additions & 3 deletions app/frontend/src/views/File.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<template>
<v-container>
<transition name="component-fade" mode="out-in">
<router-view />
</transition>
<RouterView v-slot="{ Component }">
<transition name="component-fade" mode="out-in">
<component :is="Component" class="main" />
</transition>
</RouterView>
</v-container>
</template>

Expand Down
6 changes: 1 addition & 5 deletions app/frontend/src/views/file/Download.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,7 @@ export default {
async getFile(fileId) {
this.showDownloadLink = false;
await this.downloadFile(fileId);
if (
this.downloadedFile &&
this.downloadedFile.data &&
this.downloadedFile.headers
) {
if (this.downloadedFile && this.downloadedFile.headers) {
this.showDownloadLink = true;
const data = this.downloadedFile.headers['content-type'].includes(
'application/json'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createTestingPinia } from '@pinia/testing';
import { mount } from '@vue/test-utils';
import { flushPromises, mount } from '@vue/test-utils';
import { describe, expect, it, vi } from 'vitest';

import BaseNotificationBar from '~/components/base/BaseNotificationBar.vue';
Expand All @@ -12,6 +12,73 @@ describe('BaseNotificationBar.vue', () => {
...NotificationTypes.ERROR,
};

it('notification is just a string', async () => {
vi.spyOn(console, 'error').mockImplementation(() => {});
mount(BaseNotificationBar, {
props: {
notification: {
id: 1,
consoleError: 'Hello',
},
},
global: {
plugins: [createTestingPinia()],
},
});

await flushPromises();

// eslint-disable-next-line no-console
expect(console.error).toHaveBeenLastCalledWith('Hello');
});

it('notification is an object', async () => {
vi.spyOn(console, 'error').mockImplementation(() => {});
mount(BaseNotificationBar, {
props: {
notification: {
id: 1,
consoleError: {
text: 'Just an object',
},
},
},
global: {
plugins: [createTestingPinia()],
},
});

await flushPromises();

// eslint-disable-next-line no-console
expect(console.error).toHaveBeenLastCalledWith('Just an object');
});

it('notification is an object with options', async () => {
vi.spyOn(console, 'error').mockImplementation(() => {});
mount(BaseNotificationBar, {
props: {
notification: {
id: 1,
consoleError: {
text: 'Object with options',
options: {
to: 'nowhere',
},
},
},
},
global: {
plugins: [createTestingPinia()],
},
});

await flushPromises();

// eslint-disable-next-line no-console
expect(console.error).toHaveBeenLastCalledWith('Object with options');
});

it('renders', async () => {
const wrapper = mount(BaseNotificationBar, {
props: {
Expand Down
Loading

0 comments on commit c2ff5f4

Please sign in to comment.