-
Notifications
You must be signed in to change notification settings - Fork 76
Feature: Capture notes/comment at the time of Form publish #1546
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
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 |
|---|---|---|
|
|
@@ -40,37 +40,27 @@ except according to the terms contained in the LICENSE file. | |
|
|
||
| <hr v-if="draftVersionStringIsDuplicate"> | ||
| <p v-if="draftVersionStringIsDuplicate">{{ $t('introduction[2]') }}</p> | ||
|
|
||
| <p v-if="!draftVersionStringIsDuplicate && !versionConflict">{{ $t('introduction[3]') }}</p> | ||
| </div> | ||
| <form v-if="draftVersionStringIsDuplicate || versionConflict" @submit.prevent="publish"> | ||
| <form-group ref="versionString" v-model.trim="versionString" | ||
| :placeholder="$t('common.version')" required autocomplete="off"/> | ||
| <hr> | ||
| <form @submit.prevent="publish"> | ||
| <form-group v-if="draftVersionStringIsDuplicate || versionConflict" ref="versionString" v-model.trim="versionString" :placeholder="$t('common.version')" | ||
| required autocomplete="off"/> | ||
| <div class="form-group"> | ||
| <textarea id="form-draft-publish-note" ref="publishNote" v-model="notes" class="form-control" | ||
| :placeholder="$t('placeholder.note')" rows="3"></textarea> | ||
| <label for="form-draft-publish-note" class="form-label">{{ $t('field.note') }}</label> | ||
| </div> | ||
| <p>{{ $t('introduction[3]') }}</p> | ||
| <!-- We specify two nearly identical .modal-actions, because here we | ||
|
Contributor
Author
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. Since notes will always be displayed in the publish modal, I have removed the duplicate modal action buttons. |
||
| want the Proceed button to be a submit button (which means that browsers | ||
| will do some basic form validation when it is clicked). --> | ||
| <div class="modal-actions"> | ||
| <button type="button" class="btn btn-link" | ||
| :aria-disabled="awaitingResponse" @click="$emit('hide')"> | ||
| {{ $t('action.cancel') }} | ||
| </button> | ||
| <button type="submit" class="btn btn-primary" | ||
| :aria-disabled="awaitingResponse"> | ||
| <button type="submit" class="btn btn-primary" :aria-disabled="awaitingResponse"> | ||
| {{ $t('action.proceed') }} <spinner :state="awaitingResponse"/> | ||
| </button> | ||
| </div> | ||
| </form> | ||
| <div v-else class="modal-actions"> | ||
| <button type="button" class="btn btn-link" :aria-disabled="awaitingResponse" | ||
| @click="$emit('hide')"> | ||
| {{ $t('action.cancel') }} | ||
| </button> | ||
| <button type="button" class="btn btn-primary" | ||
| :aria-disabled="awaitingResponse" @click="publish"> | ||
| {{ $t('action.proceed') }} <spinner :state="awaitingResponse"/> | ||
| </button> | ||
| </div> | ||
| </template> | ||
| </modal> | ||
| </template> | ||
|
|
@@ -111,6 +101,7 @@ export default { | |
| data() { | ||
| return { | ||
| versionString: '', | ||
| notes: '', | ||
| // versionConflict is used in a scenario where a user tries to | ||
| // publish a form that conflicts with a form/version combo probably | ||
| // found in the trash. This component doesn't have access to trashed | ||
|
|
@@ -139,14 +130,21 @@ export default { | |
| }, | ||
| watch: { | ||
| state(state) { | ||
| if (state) this.versionString = this.formDraft.version; | ||
| if (state) { | ||
| this.versionString = this.formDraft.version; | ||
| this.notes = ''; | ||
|
Member
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. Could you add a test or modify an existing test to assert that the notes field is reset? There's a related test in form-draft/publish.spec.js for |
||
| } | ||
| } | ||
| }, | ||
| methods: { | ||
| focusInput() { | ||
| if (this.draftVersionStringIsDuplicate) this.$refs.versionString.focus(); | ||
| else this.$refs.publishNote.focus(); | ||
| }, | ||
| publish() { | ||
| const headers = {}; | ||
| if (this.notes !== '') | ||
| headers['X-Action-Notes'] = encodeURIComponent(this.notes); | ||
| this.request({ | ||
| method: 'POST', | ||
| url: apiPaths.publishFormDraft( | ||
|
|
@@ -156,6 +154,7 @@ export default { | |
| ? { version: this.versionString } | ||
| : null | ||
| ), | ||
| headers, | ||
| fulfillProblem: (problem) => problem.code === 409.6 | ||
| }) | ||
| .then(({ data }) => { | ||
|
|
@@ -198,6 +197,12 @@ export default { | |
| "newProperties": "Publishing this draft will create {count} property. | Publishing this draft will create {count} properties.", | ||
| "problem": { | ||
| "409_6": "The version name of this Draft conflicts with a past version of this Form or a deleted Form. Please use the field below to change it to something new or upload a new Form definition." | ||
| }, | ||
| "field": { | ||
| "note": "Notes" | ||
| }, | ||
| "placeholder": { | ||
| "note": "Add optional publishing notes…" | ||
| } | ||
| } | ||
| } | ||
|
|
||
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.
How about modifying
focusInput()so that it focuses the<textarea>if the<input>isn't rendered? I.e., focusing whichever form control comes first.