Skip to content

Commit

Permalink
KAAV-1473 keep track on timeline group collapse state
Browse files Browse the repository at this point in the history
  • Loading branch information
henrihaapalasiili committed Jul 12, 2024
1 parent 4bdfac7 commit 53694f0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/components/ProjectTimeline/VisTimelineGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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" : "";
Expand Down Expand Up @@ -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);
}
Expand Down
23 changes: 21 additions & 2 deletions src/components/project/EditProjectTimetableModal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ class EditProjectTimeTableModal extends Component {
item: null,
items: false,
groups: false,
showModal: false
showModal: false,
collapseData: {}
}
this.timelineRef = createRef();
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -869,6 +887,7 @@ class EditProjectTimeTableModal extends Component {
disabledDates={disabledDates}
lomapaivat={lomapaivat}
dateTypes={dateTypes}
trackExpandedGroups={this.trackExpandedGroups}
/>
<ConfirmModal
openConfirmModal={this.state.showModal}
Expand Down

0 comments on commit 53694f0

Please sign in to comment.