Skip to content

Commit

Permalink
[survey_accounts] notices, warnings and filter options
Browse files Browse the repository at this point in the history
  • Loading branch information
ridz1208 committed Aug 9, 2023
1 parent f8f123d commit 56f1694
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 13 deletions.
14 changes: 8 additions & 6 deletions modules/survey_accounts/js/survey_accounts_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ $(document).ready(function () {
// Handles cases where there was an error on the page and we're resubmitting
var email2 = $("input[name=Email2]").val();
var email = $("input[name=Email]").val();
if (email.length > 0 && email2.length > 0 && email == email2)
{
$('#email_survey').removeAttr('disabled');
} else {
$('#email_survey').attr('disabled','disabled');
if (email && email2) {
if (email.length > 0 && email2.length > 0 && email == email2)
{
$('#email_survey').removeAttr('disabled');
} else {
$('#email_survey').attr('disabled','disabled');
}
}
// Reset Test_name so that the template can be loaded by ajax below
$("select[name=Test_name]").val("");
Expand Down Expand Up @@ -93,7 +95,7 @@ $(document).ready(function () {
$("#emailContent").val(content);
}
);


});
});
6 changes: 5 additions & 1 deletion modules/survey_accounts/jsx/surveyAccountsIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@ class SurveyAccountsIndex extends Component {
options: options.instruments,
}},
{label: 'URL', show: true},
{label: 'Status', show: true},
{label: 'Status', show: true, filter: {
name: 'Status',
type: 'select',
options: options.statusOptions,
}},
];
const addSurvey = () => {
location.href='/survey_accounts/addSurvey/';
Expand Down
9 changes: 5 additions & 4 deletions modules/survey_accounts/php/addsurvey.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,9 @@ class AddSurvey extends \NDB_Form
];
}
}

if ($_REQUEST['fire_away'] !== 'Create survey') {
if (!isset($_REQUEST['fire_away'])
|| ($_REQUEST['fire_away'] !== 'Create survey')
) {
if (!filter_var(
$values['Email'],
FILTER_VALIDATE_EMAIL
Expand Down Expand Up @@ -241,11 +242,11 @@ class AddSurvey extends \NDB_Form
'CommentID' => $commentID,
]
);
$this->tpl_data['success'] = true;
} catch (\DatabaseException $e) {
error_log($e->getMessage());
$this->tpl_data['success'] = false;
}
$this->tpl_data['success'] = true;

if ($email && ($values['send_email'] == 'true')) {
$config = \NDB_Config::singleton();
Expand Down Expand Up @@ -291,7 +292,7 @@ class AddSurvey extends \NDB_Form
"Instrument",
array_merge(
['' => ''],
\Utility::getDirectInstruments()
\NDB_BVL_Instrument::getDirectEntryInstrumentNamesList($this->loris)
)
);
$this->addBasicText("Email", "Email address");
Expand Down
12 changes: 10 additions & 2 deletions modules/survey_accounts/php/survey_accounts.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,22 @@ class Survey_Accounts extends \DataFrameworkMenu
*/
public function getFieldOptions() : array
{
$statusOptions = [
'Created' => 'Created',
'Sent' => 'Sent',
'In Progress' => 'In Progress',
'Complete' => 'Complete',
];

$instruments
= \NDB_BVL_Instrument::getDirectEntryInstrumentNamesList(
$this->loris
);

return [
'visits' => \Utility::getVisitList(),
'instruments' => $instruments,
'visits' => \Utility::getVisitList(),
'instruments' => $instruments,
'statusOptions' => $statusOptions,
];
}

Expand Down

0 comments on commit 56f1694

Please sign in to comment.