Skip to content

Commit 18134b2

Browse files
committed
Updates
1 parent 8130e81 commit 18134b2

4 files changed

Lines changed: 56 additions & 12 deletions

File tree

modules/candidate_parameters/ajax/getData.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,13 @@ function getDODFields(): array
578578
$db = \NDB_Factory::singleton()->database();
579579

580580
$candidateData = $db->pselectRow(
581-
'SELECT PSCID,DoD, DoB FROM candidate where CandID =:candid',
581+
'SELECT
582+
PSCID,
583+
DoD,
584+
DoD_precision,
585+
DoB
586+
FROM candidate
587+
WHERE CandID =:candid',
582588
['candid' => $candID]
583589
);
584590
if ($candidateData === null) {
@@ -606,11 +612,12 @@ function getDODFields(): array
606612
$dob = $dobDate ? $dobDate->format($dobProcessedFormat) : null;
607613

608614
$result = [
609-
'pscid' => $candidateData['PSCID'],
610-
'candID' => $candID->__toString(),
611-
'dod' => $dod,
612-
'dob' => $dob,
613-
'dodFormat' => $config->getSetting('dodFormat'),
615+
'pscid' => $candidateData['PSCID'],
616+
'candID' => $candID->__toString(),
617+
'dod' => $dod,
618+
'dob' => $dob,
619+
'dod_precision' => $candidateData['DoD_precision'],
620+
'dodFormat' => $config->getSetting('dodFormat'),
614621
];
615622
return $result;
616623
}

modules/candidate_parameters/jsx/CandidateDOB.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ class CandidateDOB extends Component {
9191
}
9292

9393
let dateFormat = this.state.data.dobFormat;
94+
95+
let dobValue = this.state.formData.dob || '';
96+
if (dateFormat == 'Ym' && this.state.formData.dob) {
97+
dobValue = dobValue.slice(0, 7);
98+
}
99+
94100
let disabled = true;
95101
let updateButton = null;
96102
if (loris.userHasPermission('candidate_dob_edit')) {
@@ -126,7 +132,7 @@ class CandidateDOB extends Component {
126132
<DateElement
127133
label={t('DoB', {ns: 'loris'})}
128134
name='dob'
129-
dateFormat={dateFormat}
135+
dateFormat={dobValue}
130136
value={this.state.formData.dob}
131137
onUserInput={this.setFormData}
132138
disabled={disabled}

modules/candidate_parameters/jsx/CandidateDOD.js

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,13 @@ class CandidateDOD extends Component {
6565
* @param {*} value
6666
*/
6767
setFormData(formElement, value) {
68-
let formData = this.state.formData;
68+
let formData = {...this.state.formData};
69+
70+
// Clear the DOD if indicated as unknown
71+
if (formElement === 'dod_precision' && value === 'unknown') {
72+
formData.dod = '';
73+
}
74+
6975
formData[formElement] = value;
7076
this.setState({
7177
formData: formData,
@@ -89,20 +95,30 @@ class CandidateDOD extends Component {
8995
return <Loader/>;
9096
}
9197

92-
let dateFormat = this.state.data.dodFormat;
9398
let disabled = true;
9499
let updateButton = null;
95100
if (loris.userHasPermission('candidate_dod_edit')) {
96101
disabled = false;
97102
updateButton = <ButtonElement label={t('Update', {ns: 'loris'})}/>;
98103
}
104+
99105
let precisionOptions = {
100-
'known_year_month' : t('Known year and month'),
101-
'known_year' : t('Known year'),
102-
'unknown' : t('Unknown date'),
106+
'known_year_month': t('I know the year and month of death'),
107+
'known_year': t('I know the year of death'),
108+
'unknown': t('I do not know the date of death'),
103109
};
110+
104111
let required = this.state.formData.dod_precision != 'unknown';
105112

113+
let dateFormat = this.state.data.dodFormat;
114+
115+
let dodValue = this.state.formData.dod || '';
116+
if (dateFormat == 'Ymd') {
117+
precisionOptions['known_full'] = t('I know the full date of death');
118+
} else if (dateFormat == 'Ym' && this.state.formData.dod) {
119+
dodValue = dodValue.slice(0, 7);
120+
}
121+
106122
return (
107123
<div className='row'>
108124
<FormElement

modules/candidate_parameters/locale/candidate_parameters.pot

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,3 +227,18 @@ msgstr ""
227227

228228
msgid "Comments: "
229229
msgstr ""
230+
231+
msgid "I know the year and month of death"
232+
msgstr ""
233+
234+
msgid "I know the year of death"
235+
msgstr ""
236+
237+
msgid "I do not know the date of death"
238+
msgstr ""
239+
240+
msgid "I know the full date of death"
241+
msgstr ""
242+
243+
msgid "Precision of date:"
244+
msgstr ""

0 commit comments

Comments
 (0)