diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/SchedulingUnitList.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/SchedulingUnitList.js index 82c4f18fd4dd8601a52fe13a0aafe48af2897064..e726aa18c3a653b071d631304702309e16f080b4 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/SchedulingUnitList.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/SchedulingUnitList.js @@ -24,6 +24,21 @@ import { useParsedDataWebSocket } from '../../utils/websocket'; const derviedscheduleconstraints = {}; +const getUIAttr = (props) => { + let uistore = UtilService.localStore({ + type: 'get', + key: props.project ? 'PROJECT_VIEW_UI_ATTR' : 'SCHEDULE_LIST_UI_ATTR' + }) || {}; + + return uistore +} + +function getStoredSuType(props) { + let store = getUIAttr(props); + let sutype = store?.['listType']?.replaceAll("_", " ") || "Draft" + return sutype +} + export function SchedulingUnitList(props) { const viewtable = useRef(null); let defaultSortColumn = [{ id: "Name", desc: false }]; @@ -121,8 +136,8 @@ export function SchedulingUnitList(props) { let statusList = []; const [definitionCache, setDefinitionCache] = useState([]); - const [suUIAttr, setSuUIAttr] = useState(); - const [suType, setSuType] = useState("Draft"); + + const [suType, setSuType] = useState(getStoredSuType(props)); const [tmpDefaulColumns, setTmpDefaulColumns] = useState(); const [tmpOptionalColumns, setTmpOptionalColumns] = useState(); const [tmpColumnOrders, setTmpColumnOrders] = useState(); @@ -131,7 +146,7 @@ export function SchedulingUnitList(props) { const [totalPage, setTotalPage] = useState([]); const [userrole, setUserrole] = useState(); - const [timelineCommonUtils, setTimelineCommonUtils] = useState(); + const timelineCommonUtils = new TimelineCommonUtils(); const [priorityQueueTypes, setPriorityQueueTypes] = useState(); const [columnclassname, setColumnclassname] = useState([{ "Scheduling Unit ID": "filter-input-100", @@ -419,6 +434,7 @@ export function SchedulingUnitList(props) { */ const getSchedulingUnitList = async (isInitial, suType, filterQry, orderBy, limit, offset) => { //set query param for project if url has project param + console.log("getSchedulingUnitList",suType) if (props.project) { filterQry += (filterQry === '' ? 'project=' : '&project=') + props.project; } @@ -453,7 +469,7 @@ export function SchedulingUnitList(props) { params = 'blueprint'; } - if (suType == "drafts without blueprint") { + if (suType.toLowerCase() == "drafts without blueprint") { filterQry = filterQry + "&blueprinted=false" } let response = await ScheduleService.getSchedulingUnitsExpandWithFilter(params.toLowerCase(), expand, filterQry, orderBy, limit, offset, fields.join(",")); @@ -548,31 +564,20 @@ export function SchedulingUnitList(props) { }, []); const init = async () => { - let store = getUIAttr(); - let sutype = store?.['listType']?.replaceAll("_", " ") || "Draft" - setSuType(sutype) - lsKeySortColumn = "SchedulingUnit_" + changesutype(sutype) + "_SortData" + lsKeySortColumn = "SchedulingUnit_" + changesutype(suType) + "_SortData" const permission = await AuthUtil.getUserRolePermission(); let priorityQueueTypes = await UtilService.getPriorityQueueType(); setPriorityQueueTypes(priorityQueueTypes) setUserrole(permission); setPageUpdated(true); getFilterColumns(changesutype()); - setTimelineCommonUtils(new TimelineCommonUtils()); + } /** * Function to get the UI attributes from local storage that are stored in the previous view */ - const getUIAttr = () => { - let uistore = UtilService.localStore({ - type: 'get', - key: props.project ? 'PROJECT_VIEW_UI_ATTR' : 'SCHEDULE_LIST_UI_ATTR' - }) || {}; - - setSuUIAttr(uistore) - return uistore - } + /** * Function that stores the preferred values in local storage to restore the same in the next view @@ -580,11 +585,13 @@ export function SchedulingUnitList(props) { * @param {Object} value */ const storeUIAttr = (key, value) => { - suUIAttr[key] = value; + let uiAttri = getUIAttr(props) + uiAttri[key] = value; + UtilService.localStore({ type: 'set', key: props.project ? 'PROJECT_VIEW_UI_ATTR' : 'SCHEDULE_LIST_UI_ATTR', - value: suUIAttr + value: uiAttri }); } @@ -720,7 +727,7 @@ export function SchedulingUnitList(props) { } setIsLoading(false) - await getSchedulingUnitList(false, changesutype(), filterQry, newOrderBy, tablestate?.rows || 15, tablestate?.first || 0); + await getSchedulingUnitList(false, suType, filterQry, newOrderBy, tablestate?.rows || 15, tablestate?.first || 0); return [scheduleunit, totalPage]; }