@@ -44,7 +44,11 @@ export interface IBaseTimelineStore {
4444 updateActiveBlockId : ( blockId : string | null ) => void ;
4545 updateRenderView : ( data : any ) => void ;
4646 updateAllBlocksOnChartChangeWhileDragging : ( addedWidth : number ) => void ;
47- getUpdatedPositionAfterDrag : ( id : string , ignoreDependencies ?: boolean ) => IBlockUpdateDependencyData [ ] ;
47+ getUpdatedPositionAfterDrag : (
48+ id : string ,
49+ shouldUpdateHalfBlock : boolean ,
50+ ignoreDependencies ?: boolean
51+ ) => IBlockUpdateDependencyData [ ] ;
4852 updateBlockPosition : ( id : string , deltaLeft : number , deltaWidth : number , ignoreDependencies ?: boolean ) => void ;
4953 getNumberOfDaysFromPosition : ( position : number | undefined ) => number | undefined ;
5054 setIsDragging : ( isDragging : boolean ) => void ;
@@ -271,24 +275,30 @@ export class BaseTimeLineStore implements IBaseTimelineStore {
271275 /**
272276 * returns updates dates of blocks post drag.
273277 * @param id
278+ * @param shouldUpdateHalfBlock if is a half block then update the incomplete block only if this is true
274279 * @returns
275280 */
276- getUpdatedPositionAfterDrag = action ( ( id : string ) => {
281+ getUpdatedPositionAfterDrag = action ( ( id : string , shouldUpdateHalfBlock : boolean ) => {
277282 const currBlock = this . blocksMap [ id ] ;
278283
279284 if ( ! currBlock ?. position || ! this . currentViewData ) return [ ] ;
280285
281- return [
282- {
283- id,
284- start_date : renderFormattedPayloadDate (
285- getDateFromPositionOnGantt ( currBlock . position . marginLeft , this . currentViewData )
286- ) ,
287- target_date : renderFormattedPayloadDate (
288- getDateFromPositionOnGantt ( currBlock . position . marginLeft + currBlock . position . width , this . currentViewData , - 1 )
289- ) ,
290- } ,
291- ] as IBlockUpdateDependencyData [ ] ;
286+ const updatePayload : IBlockUpdateDependencyData = { id } ;
287+
288+ // If shouldUpdateHalfBlock or the start date is available then update start date
289+ if ( shouldUpdateHalfBlock || currBlock . start_date ) {
290+ updatePayload . start_date = renderFormattedPayloadDate (
291+ getDateFromPositionOnGantt ( currBlock . position . marginLeft , this . currentViewData )
292+ ) ;
293+ }
294+ // If shouldUpdateHalfBlock or the target date is available then update target date
295+ if ( shouldUpdateHalfBlock || currBlock . target_date ) {
296+ updatePayload . target_date = renderFormattedPayloadDate (
297+ getDateFromPositionOnGantt ( currBlock . position . marginLeft + currBlock . position . width , this . currentViewData , - 1 )
298+ ) ;
299+ }
300+
301+ return [ updatePayload ] ;
292302 } ) ;
293303
294304 /**
0 commit comments