Skip to content

Commit cdb3a7f

Browse files
authored
Fix record view custom menus (geonetwork#9171)
* Add context handling for static page menu * Refactor static page menus to work properly with the record view page
1 parent 43bf606 commit cdb3a7f

File tree

4 files changed

+32
-20
lines changed

4 files changed

+32
-20
lines changed

web-ui/src/main/resources/catalog/components/pages/GnStaticPagesDirective.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@
123123
scope: {
124124
pageId: "=gnStaticPageMenu",
125125
language: "@language",
126-
section: "@section"
126+
section: "@section",
127+
renderAsButton: "@?",
128+
context: "=?"
127129
},
128130
templateUrl: function (elem, attr) {
129131
return "../../catalog/components/pages/partials/menu-page.html";
@@ -135,6 +137,9 @@
135137
? $scope.pageId
136138
: [$scope.pageId];
137139

140+
// Set button style based on explicit parameter (defaults to false)
141+
$scope.renderAsButton = $scope.renderAsButton === "true";
142+
138143
if ($scope.pagesConfig.length > 0) {
139144
gnStaticPagesService.loadPages($scope.language, $scope.section).then(
140145
function (response) {

web-ui/src/main/resources/catalog/components/pages/partials/menu-page.html

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
<li
2-
data-ng-class="{'dropdown': isSubmenu}"
2+
data-ng-class="{'dropdown': isSubmenu, 'btn-group': renderAsButton}"
33
role="menuitem"
44
data-ng-hide="isSubmenu && page.pages.length < 1"
55
>
6+
<!-- Submenu dropdown toggle -->
67
<a
7-
data-ng-if="isSubmenu && section!='record_view_menu'"
8+
data-ng-if="isSubmenu"
9+
data-ng-class="{'btn btn-default': renderAsButton}"
810
class="dropdown-toggle gn-menuheader-xs"
911
role="button"
1012
data-toggle="dropdown"
@@ -19,17 +21,7 @@
1921
<span class="caret hidden-xs"></span>
2022
</a>
2123

22-
<button
23-
data-ng-if="section=='record_view_menu'"
24-
type="button"
25-
class="btn btn-default dropdown-toggle"
26-
data-toggle="dropdown"
27-
aria-label="{{'additionalLinks' | translate}}"
28-
aria-expanded="false"
29-
>
30-
<span data-translate="" class="hidden-sm hidden-xs">{{page.label}}</span>
31-
<span class="caret"></span>
32-
</button>
24+
<!-- Submenu dropdown items -->
3325
<ul data-ng-if="isSubmenu" class="dropdown-menu gn-menu-xs clearfix">
3426
<li
3527
data-ng-repeat="page in page.pages"
@@ -40,7 +32,7 @@
4032
<a
4133
data-ng-show="submenuExternalLink"
4234
title="{{page.label}}"
43-
href="{{page.link}}"
35+
href="{{page.link | replaceLinkPlaceholders:context}}"
4436
target="{{page.link.indexOf('http') === 0 ? '_blank' : '_self'}}"
4537
>
4638
<span
@@ -63,11 +55,13 @@
6355
</a>
6456
</li>
6557
</ul>
58+
59+
<!-- Single page external link -->
6660
<a
67-
data-ng-if="!isSubmenu && page"
68-
data-ng-show="isExternalLink"
61+
data-ng-if="!isSubmenu && page && isExternalLink"
62+
data-ng-class="{'btn btn-default': renderAsButton}"
6963
title="{{page.label}}"
70-
href="{{page.link}}"
64+
href="{{page.link | replaceLinkPlaceholders:context}}"
7165
target="_blank"
7266
>
7367
<span
@@ -76,9 +70,11 @@
7670
></span>
7771
<span>{{page.label}}</span>
7872
</a>
73+
74+
<!-- Single page internal link -->
7975
<a
80-
data-ng-if="!isSubmenu && page"
81-
data-ng-show="!isExternalLink"
76+
data-ng-if="!isSubmenu && page && !isExternalLink"
77+
data-ng-class="{'btn btn-default': renderAsButton}"
8278
data-gn-active-tb-item="{{gnCfg.mods.page.appUrl + '/' + page.pageId}}?page={{page.pageId}}"
8379
title="{{page.pageId}}"
8480
data-ng-click="changePage($event)"

web-ui/src/main/resources/catalog/components/utility/UtilityDirective.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2523,6 +2523,15 @@
25232523
};
25242524
}
25252525
]);
2526+
module.filter("replaceLinkPlaceholders", [
2527+
function () {
2528+
return function (url, context) {
2529+
return url
2530+
.replace(/{uuid}/g, (context && context.uuid) || "")
2531+
.replace(/{id}/g, (context && context.id) || "");
2532+
};
2533+
}
2534+
]);
25262535
module.filter("signInLink", [
25272536
"$location",
25282537
"$filter",

web-ui/src/main/resources/catalog/views/default/templates/recordView/recordView.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@
9999
gn-static-page-menu="menu"
100100
language="{{lang}}"
101101
section="record_view_menu"
102+
render-as-button="true"
103+
context="{uuid: mdView.current.record.uuid, id: mdView.current.record.id}"
102104
></div>
103105

104106
<!-- edit -->

0 commit comments

Comments
 (0)