Esri / geoportal-server

Geoportal Server is a standards-based, open source product that enables discovery and use of geospatial resources including data and services.
https://gptogc.esri.com/geoportal
Apache License 2.0
244 stars 149 forks source link

Automatically update of the „Metadata Date" Field at every save #301

Closed StefanJaq closed 3 years ago

StefanJaq commented 6 years ago

Several customers request following functionality:

Automatically update of the „Metadata Date" Field with the current date at every save. The behaviour, if it updates automatically or not, can be configured e.g. at gpt.xml. Nice to have: The user can set the behaviour in the client UI for the edit session which overules the in the gpt.xml configured default behaviour. metadata_date_ui metadata_date_xml

StefanJaq commented 6 years ago

additional comment: At Geonetwork this functionality is possible and configurable.

mhogeweg commented 3 years ago

hi Stefan, we are no longer developing on Geoportal 1.x and ArcGIS for INSPIRE also has the Geoportal 2.x editor since 10.8. In the new editor, you can control this by a small modification to the DataDocumentType.js object in the INSPIRE 2 profile. There you can include 2 utility functions:


    beforeInitializeElement: function(gxeDocument, element) {
      // add specific element initializations here

      var p = element.gxePath, xDoc = gxeDocument;
      ...
    }

and

    beforeInitializeAttribute: function(gxeDocument, attribute) {
      // add specific attribute initializations here

      var p = attribute.gxePath, xDoc = gxeDocument;
      ...
    }

These functions are called when initializing the element/attribute widgets in the editor. At this point in the editor lifecycle, you can set values, change optional/mandatory settings, etc. p represents the element/attribute you want to change. To set the value of an element that is for example a gco:Date that's part of a custom element in a profile with namespace myprofile to today's date you would use:

  if (p === "/gmd:MD_Metadata/myprofile:date/gco:Date") {
    var today = new Date();
    element.value = today.toDateString();
  }