|
|
@@ -13,12 +13,15 @@ import * as DateUtils from "utils/DateUtils"; |
|
|
|
// ==============================|| DASHBOARD - DEFAULT ||============================== // |
|
|
|
|
|
|
|
|
|
|
|
const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria }) => { |
|
|
|
const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria,issueComboData |
|
|
|
}) => { |
|
|
|
|
|
|
|
const [type, setType] = React.useState([]); |
|
|
|
const [status, setStatus] = React.useState({ key: 0, label: 'All', type: 'all' }); |
|
|
|
const [status, setStatus] = React.useState({ key: 0, label: 'All', type: 'all' }); |
|
|
|
const [orgSelected, setOrgSelected] = React.useState({}); |
|
|
|
const [orgCombo, setOrgCombo] = React.useState(); |
|
|
|
const [issueSelected, setIssueSelected] = React.useState({}); |
|
|
|
const [issueCombo, setIssueCombo] = React.useState([]); |
|
|
|
|
|
|
|
const [minDate, setMinDate] = React.useState(searchCriteria.dateFrom); |
|
|
|
const [maxDate, setMaxDate] = React.useState(searchCriteria.dateTo); |
|
|
@@ -38,8 +41,10 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria }) = |
|
|
|
dateFrom: data.dateFrom, |
|
|
|
dateTo: data.dateTo, |
|
|
|
contact: data.contact, |
|
|
|
status: (status?.type&&status?.type!= 'all')?status?.type:"", |
|
|
|
orgId: (orgSelected?.key&&orgSelected?.key>0)?orgSelected?.key:"", |
|
|
|
status: (status?.type && status?.type != 'all') ? status?.type : "", |
|
|
|
orgId: (orgSelected?.key && orgSelected?.key > 0) ? orgSelected?.key : "", |
|
|
|
issueId: issueSelected?.id, |
|
|
|
groupNo: data.groupNo, |
|
|
|
}; |
|
|
|
applySearch(temp); |
|
|
|
}; |
|
|
@@ -50,13 +55,34 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria }) = |
|
|
|
} |
|
|
|
}, [orgComboData]); |
|
|
|
|
|
|
|
React.useEffect(() => { |
|
|
|
if (issueComboData && issueComboData.length > 0) { |
|
|
|
setIssueCombo(issueComboData); |
|
|
|
} |
|
|
|
}, [issueComboData]); |
|
|
|
|
|
|
|
function resetForm() { |
|
|
|
setType([]); |
|
|
|
setStatus({ key: 0, label: 'All', type: 'all' }); |
|
|
|
setStatus({ key: 0, label: 'All', type: 'all' }); |
|
|
|
setOrgSelected({}); |
|
|
|
setIssueSelected({}); |
|
|
|
reset(); |
|
|
|
} |
|
|
|
|
|
|
|
function getIssueLabel(data){ |
|
|
|
if(data=={}) return ""; |
|
|
|
return data.year |
|
|
|
+" Vol. "+zeroPad(data.volume,3) |
|
|
|
+", No. "+zeroPad(data.issueNo,2) |
|
|
|
+", "+DateUtils.dateFormat(data.issueDate, "D MMM YYYY (ddd)"); |
|
|
|
} |
|
|
|
|
|
|
|
function zeroPad(num, places) { |
|
|
|
num=num?num:0; |
|
|
|
var zero = places - num.toString().length + 1; |
|
|
|
return Array(+(zero > 0 && zero)).join("0") + num; |
|
|
|
} |
|
|
|
|
|
|
|
return ( |
|
|
|
<MainCard xs={12} md={12} lg={12} |
|
|
|
border={false} |
|
|
@@ -93,8 +119,8 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria }) = |
|
|
|
type="date" |
|
|
|
label="Submit Date(From)" |
|
|
|
defaultValue={searchCriteria.dateFrom} |
|
|
|
InputProps={{inputProps: { max: maxDate} }} |
|
|
|
onChange={(newValue)=>{ |
|
|
|
InputProps={{ inputProps: { max: maxDate } }} |
|
|
|
onChange={(newValue) => { |
|
|
|
setMinDate(DateUtils.dateStr(newValue)); |
|
|
|
}} |
|
|
|
InputLabelProps={{ |
|
|
@@ -110,8 +136,8 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria }) = |
|
|
|
shrink: true |
|
|
|
}} |
|
|
|
{...register("dateTo")} |
|
|
|
InputProps={{inputProps: { min: minDate} }} |
|
|
|
onChange={(newValue)=>{ |
|
|
|
InputProps={{ inputProps: { min: minDate } }} |
|
|
|
onChange={(newValue) => { |
|
|
|
setMaxDate(DateUtils.dateStr(newValue)); |
|
|
|
}} |
|
|
|
id="dateTo" |
|
|
@@ -132,7 +158,7 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria }) = |
|
|
|
shrink: true |
|
|
|
}} |
|
|
|
/> |
|
|
|
|
|
|
|
|
|
|
|
</Grid> |
|
|
|
|
|
|
|
<Grid item xs={9} s={6} md={5} lg={3} sx={{ ml: 3, mr: 3, mb: 3 }}> |
|
|
@@ -140,7 +166,7 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria }) = |
|
|
|
{...register("status")} |
|
|
|
disablePortal |
|
|
|
id="status" |
|
|
|
filterOptions={(options)=>options} |
|
|
|
filterOptions={(options) => options} |
|
|
|
options={ComboData.publicNoticeStaticEng} |
|
|
|
value={status} |
|
|
|
inputValue={status?.label} |
|
|
@@ -169,7 +195,7 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria }) = |
|
|
|
id="orgId" |
|
|
|
options={orgCombo} |
|
|
|
value={orgSelected} |
|
|
|
inputValue={(orgSelected?.label)?orgSelected?.label: ""} |
|
|
|
inputValue={(orgSelected?.label) ? orgSelected?.label : ""} |
|
|
|
onChange={(event, newValue) => { |
|
|
|
if (newValue !== null) { |
|
|
|
setOrgSelected(newValue); |
|
|
@@ -183,12 +209,49 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria }) = |
|
|
|
}} |
|
|
|
/> |
|
|
|
)} |
|
|
|
|
|
|
|
/> |
|
|
|
</Grid> |
|
|
|
: <></> |
|
|
|
} |
|
|
|
|
|
|
|
<Grid item xs={9} s={6} md={5} lg={3} sx={{ ml: 3, mr: 3, mb: 3 }}> |
|
|
|
<Autocomplete |
|
|
|
{...register("issueId")} |
|
|
|
disablePortal |
|
|
|
id="issueId" |
|
|
|
options={issueCombo} |
|
|
|
value={issueSelected} |
|
|
|
inputValue={(issueSelected?.id) ? getIssueLabel(issueSelected) : ""} |
|
|
|
getOptionLabel={(option)=>getIssueLabel(option)} |
|
|
|
onChange={(event, newValue) => { |
|
|
|
if (newValue !== null) { |
|
|
|
setIssueSelected(newValue); |
|
|
|
} |
|
|
|
}} |
|
|
|
renderInput={(params) => ( |
|
|
|
<TextField {...params} |
|
|
|
label="Gazette Issue" |
|
|
|
InputLabelProps={{ |
|
|
|
shrink: true |
|
|
|
}} |
|
|
|
/> |
|
|
|
)} |
|
|
|
/> |
|
|
|
</Grid> |
|
|
|
|
|
|
|
<Grid item xs={9} s={6} md={5} lg={3} sx={{ ml: 3, mr: 3, mb: 3 }}> |
|
|
|
<TextField |
|
|
|
fullWidth |
|
|
|
{...register("groupNo")} |
|
|
|
id='groupNo' |
|
|
|
label="Gazette Code." |
|
|
|
defaultValue={searchCriteria.groupNo} |
|
|
|
InputLabelProps={{ |
|
|
|
shrink: true |
|
|
|
}} |
|
|
|
/> |
|
|
|
</Grid> |
|
|
|
|
|
|
|
|
|
|
|
</Grid> |
|
|
|
|
|
|
|