From 53694f0d094bec66e5a79bdf996206f203a05985 Mon Sep 17 00:00:00 2001 From: henrihaapalasiili Date: Fri, 12 Jul 2024 14:22:59 +0300 Subject: [PATCH] KAAV-1473 keep track on timeline group collapse state --- .../ProjectTimeline/VisTimelineGroup.js | 7 +++++- .../EditProjectTimetableModal/index.js | 23 +++++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/components/ProjectTimeline/VisTimelineGroup.js b/src/components/ProjectTimeline/VisTimelineGroup.js index 5d15b9553..f83823c9b 100644 --- a/src/components/ProjectTimeline/VisTimelineGroup.js +++ b/src/components/ProjectTimeline/VisTimelineGroup.js @@ -17,7 +17,7 @@ import { removeDeadlines } from '../../actions/projectActions'; import './VisTimeline.css' Moment().locale('fi'); -const VisTimelineGroup = forwardRef(({ groups, items, deadlines, visValues, deadlineSections, formSubmitErrors, projectPhaseIndex, archived, allowedToEdit, isAdmin, disabledDates, lomapaivat, dateTypes}, ref) => { +const VisTimelineGroup = forwardRef(({ groups, items, deadlines, visValues, deadlineSections, formSubmitErrors, projectPhaseIndex, archived, allowedToEdit, isAdmin, disabledDates, lomapaivat, dateTypes, trackExpandedGroups}, ref) => { const dispatch = useDispatch(); const moment = extendMoment(Moment); @@ -80,6 +80,10 @@ const VisTimelineGroup = forwardRef(({ groups, items, deadlines, visValues, dead } } + const trackExpanded = (event) => { + trackExpandedGroups(event) + } + const checkConfirmedGroups = (esillaoloConfirmed, lautakuntaConfirmed, attributeKeys, visValRef, phase, canAddEsillaolo, nextEsillaoloClean, canAddLautakunta, nextLautakuntaClean, data) => { // Check if more Esillaolo groups can be added let esillaoloReason = !esillaoloConfirmed ? "noconfirmation" : ""; @@ -720,6 +724,7 @@ const VisTimelineGroup = forwardRef(({ groups, items, deadlines, visValues, dead timelineGroupClick(timeline.itemSet.options,groups) } else { + trackExpanded(event) // if not add button, forward the event to the vis event handler timeline.itemSet._onGroupClick(event); } diff --git a/src/components/project/EditProjectTimetableModal/index.js b/src/components/project/EditProjectTimetableModal/index.js index 49ee4eb83..be2426e29 100644 --- a/src/components/project/EditProjectTimetableModal/index.js +++ b/src/components/project/EditProjectTimetableModal/index.js @@ -27,7 +27,8 @@ class EditProjectTimeTableModal extends Component { item: null, items: false, groups: false, - showModal: false + showModal: false, + collapseData: {} } this.timelineRef = createRef(); } @@ -209,10 +210,19 @@ class EditProjectTimeTableModal extends Component { lautakuntakerta++ } }); + + let expanded + if(this.state.collapseData[deadlineSections[i].title]){ + expanded = this.state.collapseData[deadlineSections[i].title] + } + else{ + expanded = deadlineSections[i].title === ongoingPhase ? true : false + } + deadLineGroups.push({ id: deadlineSections[i].title, content: deadlineSections[i].title, - showNested: deadlineSections[i].title === ongoingPhase ? true : false, + showNested: expanded, nestedGroups: [], maxEsillaolo: esillaolokerta, maxLautakunta: lautakuntakerta @@ -819,6 +829,14 @@ class EditProjectTimeTableModal extends Component { this.props.handleClose() } + trackExpandedGroups = (e) => { + const { collapseData } = this.state; + const key = e.target.innerText; + const value = e.target.classList.value.includes("expanded") ? false : true; + const updatedCollapseData = { ...collapseData, [key]: value }; + this.setState({ collapseData: updatedCollapseData }); + } + render() { const { loading } = this.state const { @@ -869,6 +887,7 @@ class EditProjectTimeTableModal extends Component { disabledDates={disabledDates} lomapaivat={lomapaivat} dateTypes={dateTypes} + trackExpandedGroups={this.trackExpandedGroups} />