Skip to content

Commit

Permalink
Editor / List formats as protocols. (#5465)
Browse files Browse the repository at this point in the history
* Editor / List formats as protocols.

* Editor / List formats as protocols.

* Editor / List protocols / Don't lose existing value not in provided list.

* Editor / List formats as protocols / When editor is saved, refresh the list of values with label
  • Loading branch information
fxprunayre authored Apr 13, 2021
1 parent 8bd9b0a commit 30876ec
Showing 14 changed files with 174 additions and 119 deletions.
Original file line number Diff line number Diff line change
@@ -219,36 +219,6 @@
}
}
},
{
"group": "onlineDiscover",
"label": "onlineDiscoverKML",
"copyLabel": "name",
"sources": {
"filestore": true
},
"icon": "fa gn-icon-onlinesrc",
"process": "onlinesrc-add",
"fields": {
"url": {},
"protocol": {
"value": "WWW:LINK",
"hidden": true,
"isMultilingual": false
},
"name": {},
"desc": {},
"function": {
"value": "browsing",
"hidden": true,
"isMultilingual": false
},
"applicationProfile": {
"value": "application/vnd.google-earth.kml+xml",
"hidden": true,
"isMultilingual": false
}
}
},
{
"group": "onlineDiscover",
"label": "onlineDiscoverMap",
@@ -278,34 +248,8 @@
},
{
"group": "onlineDownload",
"label": "onlineDownloadFile",
"copyLabel": "name",
"sources": {
"filestore": true
},
"icon": "fa gn-icon-onlinesrc",
"process": "onlinesrc-add",
"fields": {
"url": {
"isMultilingual": false
},
"protocol": {
"value": "WWW:LINK",
"hidden": true,
"isMultilingual": false
},
"name": {},
"desc": {},
"function": {
"value": "download",
"hidden": true,
"isMultilingual": false
}
}
},
{
"group": "onlineDownload",
"label": "onlineDownloadKML",
"extendWithDataFormats": true,
"label": "onlineDownload",
"copyLabel": "name",
"sources": {
"filestore": true
@@ -317,7 +261,7 @@
"isMultilingual": false
},
"protocol": {
"value": "WWW:LINK",
"value": "WWW:DOWNLOAD:",
"hidden": true,
"isMultilingual": false
},
@@ -327,11 +271,6 @@
"value": "download",
"hidden": true,
"isMultilingual": false
},
"applicationProfile": {
"value": "application/vnd.google-earth.kml+xml",
"hidden": true,
"isMultilingual": false
}
}
},
Original file line number Diff line number Diff line change
@@ -15,9 +15,11 @@
xmlns:dqm="http://standards.iso.org/iso/19157/-2/dqm/1.0"
xmlns:cit="http://standards.iso.org/iso/19115/-3/cit/2.0"
xmlns:gco="http://standards.iso.org/iso/19115/-3/gco/1.0"
xmlns:gn-fn-index="http://geonetwork-opensource.org/xsl/functions/index"
xmlns:gn="http://www.fao.org/geonetwork"
xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="#all">

<xsl:import href="common/index-utils.xsl"/>
<xsl:include href="utility-tpl-multilingual.xsl"/>

<xsl:template name="get-iso19115-3.2018-is-service">
@@ -29,6 +31,17 @@
<xsl:value-of select="$metadata/mdb:identificationInfo/*/mri:citation/*/cit:title/gco:CharacterString"/>
</xsl:template>

<xsl:template mode="get-formats-as-json" match="mdb:MD_Metadata">
[
<xsl:for-each select="mdb:distributionInfo/*/mrd:distributionFormat/*/mrd:formatSpecificationCitation/*/cit:title/*/text()">{
"value": "WWW:DOWNLOAD:<xsl:value-of select="gn-fn-index:json-escape(.)"/>",
"label": "<xsl:value-of select="gn-fn-index:json-escape(.)"/>"}
<xsl:if test="position() != last()">,</xsl:if>
</xsl:for-each>
]
</xsl:template>


<xsl:template name="get-iso19115-3.2018-extents-as-json">[
<xsl:for-each select="//mdb:identificationInfo/*/mri:extent
//gex:geographicElement/gex:EX_GeographicBoundingBox[
14 changes: 13 additions & 1 deletion schemas/iso19139/src/main/plugin/iso19139/layout/utility-tpl.xsl
Original file line number Diff line number Diff line change
@@ -22,14 +22,17 @@
~ Rome - Italy. email: geonetwork@osgeo.org
-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:gmd="http://www.isotc211.org/2005/gmd"
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:gmd="http://www.isotc211.org/2005/gmd"
xmlns:gco="http://www.isotc211.org/2005/gco"
xmlns:srv="http://www.isotc211.org/2005/srv"
xmlns:gmx="http://www.isotc211.org/2005/gmx"
xmlns:gn-fn-index="http://geonetwork-opensource.org/xsl/functions/index"
xmlns:gn="http://www.fao.org/geonetwork"
version="2.0"
exclude-result-prefixes="#all">

<xsl:import href="common/index-utils.xsl"/>
<xsl:include href="utility-tpl-multilingual.xsl"/>

<xsl:template name="get-iso19139-is-service">
@@ -41,6 +44,15 @@
<xsl:value-of select="$metadata/gmd:identificationInfo/*/gmd:citation/*/gmd:title/gco:CharacterString"/>
</xsl:template>

<xsl:template mode="get-formats-as-json" match="gmd:MD_Metadata">
[
<xsl:for-each select="gmd:distributionInfo/*/gmd:distributionFormat/*/gmd:name/*/text()">{
"value": "WWW:DOWNLOAD:<xsl:value-of select="gn-fn-index:json-escape(.)"/>",
"label": "<xsl:value-of select="gn-fn-index:json-escape(.)"/>"}
<xsl:if test="position() != last()">,</xsl:if>
</xsl:for-each>
]
</xsl:template>

<xsl:template name="get-iso19139-extents-as-json">[
<xsl:for-each select="//gmd:geographicElement/gmd:EX_GeographicBoundingBox[
Original file line number Diff line number Diff line change
@@ -508,6 +508,7 @@
scope.layers = null;
scope.mapId = 'gn-thumbnail-maker-map';
scope.map = null;
scope.dataFormats = null;

scope.searchObj = {
internal: true,
@@ -713,6 +714,8 @@
getTypeConfig(linkToEdit) :
getType(linkType);

scope.dataFormats = gnCurrentEdit.dataFormats;

if (gnCurrentEdit.mdOtherLanguages) {
scope.mdOtherLanguages = gnCurrentEdit.mdOtherLanguages;
scope.mdLangs = JSON.parse(scope.mdOtherLanguages);
@@ -834,7 +837,25 @@
gnSchemaManagerService.getEditorAssociationPanelConfig(
gnCurrentEdit.schema,
gnCurrentEdit.associatedPanelConfigId).then(function (r) {
scope.config = r.config;
scope.config = angular.copy(r.config);
scope.config.types = [];
for (var i = 0; i < r.config.types.length; i ++) {
var c = r.config.types[i];
if (c.extendWithDataFormats) {
var labelPrefix = $translate.instant('recordFormatDownload');
for (var j = 0; j < scope.gnCurrentEdit.dataFormats.length; j ++) {
var f = scope.gnCurrentEdit.dataFormats[j],
option = angular.copy(c);

option.label = labelPrefix + f.label;
option.fields.protocol.value = f.value;
scope.config.types.push(option);
}
} else {
scope.config.types.push(c);
}
}


if (withInit) {
init();
@@ -1120,6 +1141,11 @@
scope.params.name = '';
scope.params.desc = '';
}
if (scope.params.function === ''
&& scope.params.protocol
&& scope.params.protocol.indexOf('DOWNLOAD') !== -1) {
scope.params.function = 'download';
}
scope.loadCurrentLink();
}
});
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@
data-schema-info-combo="codelist"
name="function"
data-init-on-load="true"
data-allow-blank="true"
data-selected-info="params.function"
data-gn-field-tooltip="{{schema}}|{{params.linkType.fields.function.tooltip}}"
data-gn-schema-info="function" lang="lang"></div>
@@ -91,7 +92,8 @@
name="protocol"
data-selected-info="params.protocol"
data-gn-field-tooltip="{{schema}}|{{params.linkType.fields.protocol.tooltip}}"
data-gn-schema-info="protocol" lang="lang"></div>
data-gn-schema-info="protocol" lang="lang"
data-extra-options="dataFormats"></div>
</div>

<div class="col-sm-1 gn-control"></div>
Original file line number Diff line number Diff line change
@@ -276,6 +276,15 @@
scope.getTitle = function(link) {
return link.title['#text'] || link.title;
};
scope.getBadgeLabel = function(mainType, r) {
if (r.protocol && r.protocol.indexOf('WWW:DOWNLOAD:') >= 0) {
return r.protocol.replace('WWW:DOWNLOAD:', '');
} else if (mainType.match(/W([MCF]|MT)S.*|ESRI:REST/)) {
return mainType.replace('SERVICE', '');
} else {
return '';
}
};
scope.hasAction = function(mainType) {
var fn = gnRelatedResources.map[mainType].action;
// If function name ends with ToMap do not display the action
Original file line number Diff line number Diff line change
@@ -387,6 +387,19 @@
} else {
return 'WMSSERVICE';
}
} else if (protocolOrType.match(/download/i)) {
var url = $filter('gnLocalized')(resource.url) || resource.url;
if (url.match(/zip/i)) {
return 'LINKDOWNLOAD-ZIP';
} else if (url.match(/pdf/i)) {
return 'LINKDOWNLOAD-PDF';
} else if (url.match(/xml/i)) {
return 'LINKDOWNLOAD-XML';
} else if (url.match(/rdf/i)) {
return 'LINKDOWNLOAD-RDF';
} else {
return 'LINKDOWNLOAD';
}
} else if (protocolOrType.match(/esri/i)) {
return 'ESRI:REST';
} else if (protocolOrType.match(/wmts/i)) {
@@ -411,19 +424,6 @@
return 'KML';
} else if (protocolOrType.match(/geojson/i)) {
return 'GEOJSON';
} else if (protocolOrType.match(/download/i)) {
var url = $filter('gnLocalized')(resource.url) || resource.url;
if (url.match(/zip/i)) {
return 'LINKDOWNLOAD-ZIP';
} else if (url.match(/pdf/i)) {
return 'LINKDOWNLOAD-PDF';
} else if (url.match(/xml/i)) {
return 'LINKDOWNLOAD-XML';
} else if (url.match(/rdf/i)) {
return 'LINKDOWNLOAD-RDF';
} else {
return 'LINKDOWNLOAD';
}
} else if (protocolOrType.match(/dataset/i)) {
return 'LINKDOWNLOAD';
} else if (protocolOrType.match(/link/i)) {
Original file line number Diff line number Diff line change
@@ -5,27 +5,25 @@ <h2>{{::title}}</h2>
<div class=""
data-ng-repeat="(type, items) in relations track by $index"
data-ng-if="type && type !== 'thumbnails'">
<div data-ng-init="mainType = config.getType(r, type);"
<div data-ng-init="mainType = config.getType(r, type);
badge = getBadgeLabel(mainType, r);
icon = config.getClassIcon(mainType);"
class="row list-group-item gn-related-item gn-related-{{type}} gn-relation-type-{{mainType}}"
data-ng-repeat="r in items track by $index">
<div class="col-xs-1 col-sm-1">
<!-- OWS have their name overlaid over the globe icon -->
<strong data-ng-if="(mainType === 'WMS') || (mainType === 'WMSSERVICE') || (mainType === 'WMTS') ||
(mainType === 'WMTSSERVICE') || (mainType === 'WFS') || (mainType === 'WCS')">
<span class="fa-stack fa-1x">
<i class="fa fa-globe fa-stack-2x" style="opacity: 0.55;"></i>
<span class="fa fa-stack-1x">
<strong style="font-size:10px;">{{mainType.replace('SERVICE', '')}}</strong>
</span>
</span>
</strong>
<strong data-ng-if="(mainType !== 'WMS') && (mainType !== 'WMSSERVICE') && (mainType !== 'WMTS') &&
(mainType !== 'WMTSSERVICE') && (mainType !== 'WFS') && (mainType !== 'WCS')">
<i class="fa"
data-ng-class="config.getClassIcon(mainType)"/>&nbsp;
<div class="gn-related-icon-col col-xs-2 col-sm-2 text-center">
<strong>
<div class="clearfix">
<i class="fa"
data-ng-class="icon"/>
</div>
<span data-ng-if="badge != ''"
class="label label-default"
data-ng-class="{
'label-primary': icon === 'fa-download' || icon === 'fa-file-pdf-o',
'label-success': icon === 'fa-globe'}">{{badge}}</span>
</strong>
</div>
<div data-ng-class="mainType === 'MDFCATS' ? 'col-xs-11' : 'col-xs-8 col-sm-8'">
<div data-ng-class="mainType === 'MDFCATS' ? 'col-xs-11' : 'col-xs-7 col-sm-7'">
<!-- Always display title if available -->
<h3 data-ng-if="::(r.title | gnLocalized: lang).length">{{::(r.title | gnLocalized: lang)}}</h3>
<!-- Display description if available -->
Original file line number Diff line number Diff line change
@@ -368,6 +368,14 @@
'Failed to parse the following extent as JSON: ' +
value);
}
var dataFormats = [], value = getInputValue('dataformats');
try {
dataFormats = angular.fromJson(value);
} catch (e) {
console.warn(
'Failed to parse the following dataformats as JSON: ' +
value);
}
angular.extend(gnCurrentEdit, {
isService: getInputValue('isService') == 'true',
isTemplate: getInputValue('template'),
@@ -389,6 +397,7 @@
geoPublisherConfig:
angular.fromJson(getInputValue('geoPublisherConfig')),
extent: extent,
dataFormats: dataFormats,
isMinor: getInputValue('minor') === 'true',
layerConfig:
angular.fromJson(getInputValue('layerConfig')),
Loading

0 comments on commit 30876ec

Please sign in to comment.