-
Notifications
You must be signed in to change notification settings - Fork 59
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
Add project settings to Collect QR codes #475
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,26 +70,31 @@ import DocLink from '../doc-link.vue'; | |
|
||
import FieldKey from '../../presenters/field-key'; | ||
import { apiPaths } from '../../util/request'; | ||
import { requestData } from '../../store/modules/request'; | ||
|
||
export default { | ||
name: 'FieldKeyQrPanel', | ||
components: { CollectQr, DocLink }, | ||
props: { | ||
fieldKey: FieldKey, // eslint-disable-line vue/require-default-prop | ||
managed: { | ||
type: Boolean, | ||
default: false | ||
} | ||
Comment on lines
-78
to
-82
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The linter no longer flags |
||
fieldKey: FieldKey, | ||
managed: Boolean | ||
}, | ||
computed: { | ||
...requestData(['project']), | ||
settings() { | ||
const { token, projectId } = this.fieldKey; | ||
const url = apiPaths.serverUrlForFieldKey( | ||
this.fieldKey.token, | ||
this.project.id | ||
); | ||
const settings = { | ||
server_url: apiPaths.serverUrlForFieldKey(token, projectId) | ||
general: { server_url: `${window.location.origin}${url}` }, | ||
project: { name: this.project.name }, | ||
// Collect requires the settings to have an `admin` property. | ||
admin: {} | ||
}; | ||
if (this.managed) { | ||
settings.form_update_mode = 'match_exactly'; | ||
settings.autosend = 'wifi_and_cellular'; | ||
settings.general.form_update_mode = 'match_exactly'; | ||
settings.general.autosend = 'wifi_and_cellular'; | ||
} | ||
return settings; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,16 +90,24 @@ export default { | |
// component is created. | ||
...requestData([{ key: 'formDraft', getOption: true }, 'keys']), | ||
qrSettings() { | ||
const url = apiPaths.serverUrlForFormDraft( | ||
this.formDraft.draftToken, | ||
this.projectId, | ||
this.xmlFormId | ||
); | ||
return { | ||
server_url: apiPaths.serverUrlForFormDraft( | ||
this.formDraft.draftToken, | ||
this.projectId, | ||
this.xmlFormId | ||
) | ||
general: { | ||
server_url: `${window.location.origin}${url}`, | ||
form_update_mode: 'match_exactly', | ||
autosend: 'wifi_and_cellular' | ||
}, | ||
project: { | ||
name: this.$t('collectProjectName', this.formDraft), | ||
icon: '📝' | ||
}, | ||
// Collect requires the settings to have an `admin` property. | ||
admin: {} | ||
}; | ||
}, | ||
baseUrl() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I randomly noticed that this computed property isn't used anywhere anymore! Probably it should have been removed as part of 43ceaa0. |
||
return apiPaths.formDraft(this.projectId, this.xmlFormId); | ||
} | ||
}, | ||
created() { | ||
|
@@ -152,7 +160,10 @@ export default { | |
"body": [ | ||
"You can use the configuration code to the right to set up a mobile device to download this Draft. You can also click the New button above to create a new Submission from your web browser.", | ||
"Draft Submissions go into the test table below, where you can preview and download them. When you publish this Draft Form, its test Submissions will be permanently removed." | ||
] | ||
], | ||
// This text will be shown in ODK Collect when testing a Draft Form. {name} | ||
// is the title of the Draft Form. | ||
"collectProjectName": "[Draft] {name}" | ||
} | ||
} | ||
</i18n> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FieldKeyQrPanel
andFormDraftTesting
now do this work. I thought about leaving it here, but the code would have been surprisingly hairy, sincesettings
now contains nested objects. I also think the new approach is a little clearer. Part of me doesn't love thatFieldKeyQrPanel
andFormDraftTesting
now have some duplicate code, but it's just two components and not a lot of duplicate code. And probably we'll return to all this before too long once we start working on project settings.