Skip to content

Commit

Permalink
Metadata editor / link to remote dataset improvements (#7324)
Browse files Browse the repository at this point in the history
* Metadata editor / link to remote dataset improvements:
- Improve the title extraction For HTML links, to support title elements with attributes.
- Allow to define a custom title for the remote dataset link



Co-authored-by: François Prunayre <fx.prunayre@gmail.com>
  • Loading branch information
josegar74 and fxprunayre committed Sep 21, 2023
1 parent 51c6fa4 commit 3609c5d
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 9 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 @@ -1937,6 +1935,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 @@ -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
Expand Up @@ -28,13 +28,18 @@
</div>
</form>

<div class="list-group" data-ng-if="remoteRecord.title">
<div class="col-md-offset-2 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}}"
/> ({{remoteRecord.uuid}})
</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 3609c5d

Please sign in to comment.