Skip to content

Commit

Permalink
[new_timepoint] only show null language option when multiple exist (#…
Browse files Browse the repository at this point in the history
…8253)

The language drop down for timepoints is only contains a null option when creating a new timepoint if there are more than one languages to choose from in the language table. Otherwise the field automatically selected.
  • Loading branch information
CamilleBeau committed Dec 20, 2022
1 parent 840448c commit 13b3f8a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
4 changes: 3 additions & 1 deletion modules/create_timepoint/jsx/createTimepointIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,8 @@ class CreateTimepoint extends React.Component {
/>
) : null;
// Include languages select.
const emptyLangOption =
Object.keys(this.state.form.options.languages).length > 1;
const languages = this.state.form.display.languages ? (
<SelectElement
id={'languageID'}
Expand All @@ -409,7 +411,7 @@ class CreateTimepoint extends React.Component {
value={this.state.form.value.languages}
options={this.state.form.options.languages}
onUserInput={this.setForm}
emptyOption={true}
emptyOption={emptyLangOption}
disabled={false}
autoSelect={true}
required={this.state.form.options.required.languages}
Expand Down
6 changes: 1 addition & 5 deletions modules/create_timepoint/php/timepoint.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,7 @@ class Timepoint extends \NDB_Page implements ETagCalculator
$values['visitGroups'] = $visitGroups;

// List languages
$languages = \Utility::getLanguageList();
if (count($languages) > 1) {
$languages = [null] + $languages;
}
$values['languages'] = $languages;
$values['languages'] = \Utility::getLanguageList();

if (!empty($conflict)) {
return new \LORIS\Http\Response\JSON\Conflict(
Expand Down
6 changes: 5 additions & 1 deletion modules/create_timepoint/test/TestPlan.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ visit label already exists for the candidate.
successful form submission. Click on "Ok" button and ensure that it brings you back
to timepoint list page for that candidate and confirm that the new timepoint appears in the list.
[Manual Testing]
14. Check that page is inaccessible if either the user does not have data_entry
14. Ensure that there is no empty option in the language select element and a language is automatically selected when only one
language exists in the `language` table.
15. Ensure that there is an empty option in the language select element and the field is required when more than one
lagnuage exists in the `language` table
16. Check that page is inaccessible if either the user does not have data_entry
permission or the user and candidate are not the same site.
[Manual Testing]

0 comments on commit 13b3f8a

Please sign in to comment.