Skip to content

Commit d9ece97

Browse files
committed
Merge pull request #57 from rishabhdixit/master
Fixed issue : Initial data is showing on the app before the content is loaded, #119334307
2 parents a8fd325 + a041b7f commit d9ece97

2 files changed

Lines changed: 23 additions & 16 deletions

File tree

control/content/content.controller.js

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,20 @@ folderPluginApp.controller('folderPluginCtrl', ['$scope', function ($scope) {
1010

1111
$scope.editorOptions = folderPluginShared.getEditorOptions();
1212

13-
$scope.data = folderPluginShared.getDefaultScopeData();
13+
// $scope.data = folderPluginShared.getDefaultScopeData();
1414

15-
$scope.data._buildfire = {
16-
"plugins": {
17-
"dataType": "pluginInstance",
18-
"data": []
19-
}
20-
};
15+
$scope.masterData = folderPluginShared.getDefaultScopeData();
2116

2217
$scope.datastoreInitialized = false;
2318

19+
function isUnchanged(data) {
20+
return angular.equals(data, $scope.masterData);
21+
}
22+
23+
function updateMasterItem(data) {
24+
$scope.masterData = angular.copy(data);
25+
}
26+
2427
/*
2528
* Go pull any previously saved data
2629
* */
@@ -40,11 +43,11 @@ folderPluginApp.controller('folderPluginCtrl', ['$scope', function ($scope) {
4043

4144
$scope.data = result.data;
4245
$scope.id = result.id;
43-
if ($scope.data.content && $scope.data.content.carouselImages) {
46+
if ($scope.data && $scope.data.content && $scope.data.content.carouselImages) {
4447
editor.loadItems($scope.data.content.carouselImages);
4548
}
4649

47-
if ($scope.data._buildfire && $scope.data._buildfire.plugins && $scope.data._buildfire.plugins.result) {
50+
if ($scope.data && $scope.data._buildfire && $scope.data._buildfire.plugins && $scope.data._buildfire.plugins.result) {
4851
var pluginsData = folderPluginShared.getPluginDetails($scope.data._buildfire.plugins.result, $scope.data._buildfire.plugins.data);
4952
if ($scope.data.content && $scope.data.content.loadAllPlugins) {
5053
if(pluginsData.length){
@@ -60,7 +63,7 @@ folderPluginApp.controller('folderPluginCtrl', ['$scope', function ($scope) {
6063
}
6164
}
6265

63-
if (!$scope.data._buildfire) {
66+
if ($scope.data && !$scope.data._buildfire) {
6467
$scope.data._buildfire = {
6568
plugins: {
6669
dataType: "pluginInstance",
@@ -69,7 +72,7 @@ folderPluginApp.controller('folderPluginCtrl', ['$scope', function ($scope) {
6972
};
7073
}
7174

72-
if (!$scope.data.design) {
75+
if ($scope.data && !$scope.data.design) {
7376
$scope.data.design = {
7477
backgroundImage: null,
7578
selectedLayout: 1,
@@ -107,20 +110,24 @@ folderPluginApp.controller('folderPluginCtrl', ['$scope', function ($scope) {
107110
newObj._buildfire.plugins.result = plugins.items;
108111
}
109112

113+
updateMasterItem(newObj);
114+
110115
folderPluginShared.save(newObj);
111116
};
112117

113118
/*
114119
* create an artificial delay so api isnt called on every character entered
115120
* */
116-
var saveDataWithDelay = function (newObj, oldObj) {
121+
var saveDataWithDelay = function (newObj) {
117122

118123
if (tmrDelay) clearTimeout(tmrDelay);
119-
if (angular.equals(newObj, oldObj)) return;
124+
if (isUnchanged(newObj)) {
125+
return;
126+
}
120127
if(newObj.default){
121128
newObj=folderPluginShared.getDefaultScopeBlankData();
122129
editor.loadItems([]);
123-
$scope.data.content.text=""
130+
$scope.data = newObj;
124131
}
125132
tmrDelay = setTimeout(function () {
126133
saveData(newObj);

widget/widget.controller.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ folderPluginApp.controller('folderPluginCtrl', ['$scope', '$sce','$timeout','$ro
194194
$scope.setWidth = function () {
195195
$rootScope.deviceWidth = window.innerWidth || 320;
196196
};
197-
$scope.data = folderPluginShared.getDefaultScopeData();
197+
// $scope.data = folderPluginShared.getDefaultScopeData();
198198

199199
function initDeviceSize(callback) {
200200
$scope.deviceHeight = window.innerHeight;
@@ -318,7 +318,7 @@ folderPluginApp.controller('folderPluginCtrl', ['$scope', '$sce','$timeout','$ro
318318
var searchOptions = {pageIndex:0,pageSize:10};
319319

320320
function dataLoadedHandler(result) {
321-
321+
$scope.data = result.data;
322322
searchOptions.pageIndex=0;
323323
var pluginsList = null;
324324
if (result && result.data && !angular.equals({}, result.data) && result.data.content && result.data.design) {

0 commit comments

Comments
 (0)