Skip to content
This repository has been archived by the owner on May 4, 2022. It is now read-only.

Commit

Permalink
Merge pull request #932 from nogalpaulina/check-for-duplicates-in-layout
Browse files Browse the repository at this point in the history
Ensure there are no duplicate fnames in dataLayout
  • Loading branch information
apetro authored Sep 27, 2021
2 parents 9ecce98 + c1c5a21 commit 71ae118
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Versions in this document should match those
## 14.0.0 - 2021-09-09

+ Automate migrating layout from old layout backend to new layout backend.
+ Ensure there are no duplicate fnames in layout

## 13.0.0 - 2021-04-23

Expand Down
12 changes: 8 additions & 4 deletions web/src/main/webapp/my-app/layout/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ define(['angular', 'jquery'], function(angular, $) {
var successFn;
var errorFn;
var defer;

// first, check the local storage...
if (data) {
$log.log('getLayout (new version): found layout in cache: ' + data);
Expand Down Expand Up @@ -343,10 +342,15 @@ define(['angular', 'jquery'], function(angular, $) {
var result = {
'layout': [],
};
// Check if there are duplicate fnames in data.layout
var filteredDataLayout = data.layout.filter(function (item, ind) {
return data.layout.indexOf(item) == ind;
});

// layout will map to an array of objects each with an fname field.
// those fnames represent, in order,
// the home page content for the user
if ($.isPlainObject(data.layout) &&
if ($.isPlainObject(filteredDataLayout) &&
$.isArray(data.layout.folders)) { // layout.json v1
var folders = data.layout.folders.filter(function(el) {
var result = false;
Expand Down Expand Up @@ -380,8 +384,8 @@ define(['angular', 'jquery'], function(angular, $) {
}
result.layout = portlets;
}
} else if ($.isArray(data.layout)) { // layoutDoc
result.layout = data.layout;
} else if ($.isArray(filteredDataLayout)) { // layoutDoc
result.layout = filteredDataLayout;
}

return result;
Expand Down

0 comments on commit 71ae118

Please sign in to comment.