From 727cbfd8a9fdcd59a5d96664d4ba148d9dedf23d Mon Sep 17 00:00:00 2001 From: Wahyu Ramadhan Date: Wed, 9 Aug 2023 15:12:03 +0700 Subject: [PATCH] Send storage to parent --- edit-mode/function/function.js | 8 ++++++-- edit-mode/function/restActivityLink.js | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/edit-mode/function/function.js b/edit-mode/function/function.js index 4e66384..19c3e0f 100644 --- a/edit-mode/function/function.js +++ b/edit-mode/function/function.js @@ -677,6 +677,7 @@ function batchUpdate(){ }).then(function (response) { $("body").removeClass("loading"); localStorage.setItem('batchEntity', ''); + sendStorage(); refresData(); }).catch(function (error) { $("body").removeClass("loading") @@ -691,11 +692,14 @@ function batchUpdate(){ $(window).on('beforeunload', function(event) { let batchEntity = localStorage.getItem('batchEntity'); + sendStorage(); if (batchEntity && batchEntity != '') { event.preventDefault() return event.returnValue = 'You have unsaved changes. Are you sure you want to leave this page?'; } }); -const batchEntityData = localStorage.getItem('batchEntity'); -window.parent.postMessage({ batchEntity: batchEntityData }, '*'); \ No newline at end of file +function sendStorage(){ + const batchEntityData = localStorage.getItem('batchEntity'); + window.parent.postMessage({ batchEntity: batchEntityData }, '*'); +} \ No newline at end of file diff --git a/edit-mode/function/restActivityLink.js b/edit-mode/function/restActivityLink.js index 5fdaff1..6e6600c 100644 --- a/edit-mode/function/restActivityLink.js +++ b/edit-mode/function/restActivityLink.js @@ -198,6 +198,7 @@ var dp = gantt.createDataProcessor(function (entity, action, data, id) { toBeSet = [batchEntity] } localStorage.setItem('batchEntity', JSON.stringify(toBeSet)); + sendStorage(); // $("body").addClass("loading"); // return gantt.ajax.put({ // headers: {