Skip to content

Commit

Permalink
Metadata editor / link to remote dataset improvements:
Browse files Browse the repository at this point in the history
- Improve the title extraction For HTML links, to support title elements with attributes.
- Allow to define a custom title for the remote dataset link
  • Loading branch information
josegar74 committed Sep 7, 2023
1 parent 79865d1 commit d88fc5c
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -270,14 +270,12 @@
// No UUID can be easily extracted.
try {
scope.remoteRecord.title = doc.replace(
/(.|[\r\n])*<title>(.*)<\/title>(.|[\r\n])*/,
"$2"
/(.|[\r\n])*<title(.*)>(.*)<\/title>(.|[\r\n])*/,
"$3"
);

scope.remoteRecord.uuid = scope.remoteRecord.remoteUrl;

if (scope.remoteRecord.title === "") {
return false;
}
// Looking for schema.org tags or json+ld format could also be an option.
} catch (e) {
console.warn(e);
Expand Down Expand Up @@ -1939,6 +1937,24 @@
scope.searchObj.params.any = scope.searchObj.any;
};

/**
* Checks if there are selected records and the selected records have a title.
*
* @param selectRecords
* @returns {boolean}
*/
scope.canEnableLinkButton = function (selectRecords) {
if (selectRecords.length < 1) return false;

// Check if the metadata titles are defined
for (var i = 0; i < selectRecords.length; i++) {
if (!selectRecords[i].title && !selectRecords[i].resourceTitle)
return false;
}

return true;
};

/**
* Register a method on popup open to reset
* the search form and trigger a search.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,8 @@
/>
</div>
</div>
<div class="col-sm-9 col-xs-9 "
<div
class="col-sm-9 col-xs-9"
data-ng-if="params.linkType.fields.desc.directive === 'gn-multientry-combiner-online-resources-description'"
>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
type="button"
class="btn navbar-btn btn-success"
data-gn-click-and-spin="gnOnlinesrc.linkToMd(mode, selectRecords[0], popupid)"
ng-disabled="(selectRecords.length < 1)"
ng-disabled="!canEnableLinkButton(selectRecords)"
>
<i class="fa gn-icon-{{mode}}" />
<i class="icon-external-link"></i>&nbsp; {{btn.label}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div data-ng-if="allowRemoteRecordLink">
<div data-ng-if="allowRemoteRecordLink" xmlns="http://www.w3.org/1999/html">
<form class="form-horizontal">
<div class="form-group">
<label for="gnRemoteRecordUrl" class="control-label col-sm-2" data-translate=""
Expand Down Expand Up @@ -28,13 +28,18 @@
</div>
</form>

<div class="list-group" data-ng-if="remoteRecord.title">
<div class="list-group" data-ng-if="remoteRecord.uuid">
<li
class="list-group-item"
data-ng-click="updateSelection();triggerSearch();"
data-ng-class="{'active' : selectionList[0].uuid === remoteRecord.uuid}"
>
{{remoteRecord.title}} ({{remoteRecord.uuid}})
<input
type="text"
class="form-control"
data-ng-model="remoteRecord.title"
placeholder="{{'remoteAssociatedMetadataTitlePlaceholder' | translate}}"
/>
</li>
</div>

Expand Down
3 changes: 2 additions & 1 deletion web-ui/src/main/resources/catalog/locales/en-editor.json
Original file line number Diff line number Diff line change
Expand Up @@ -428,5 +428,6 @@
"confirmCancelEdit": "Do you want to cancel all changes and close the editor?",
"allowEditGroupMembers": "Allow group editors to edit",
"wmsSelectedLayers": "Selected layers",
"wmsSelectedLayersNone": "No layers selected"
"wmsSelectedLayersNone": "No layers selected",
"remoteAssociatedMetadataTitlePlaceholder": "Remote associated metadata title"
}

0 comments on commit d88fc5c

Please sign in to comment.