Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metadata editor / Fix javascript error in the add thumbnail option when the metadata has 1 WMS layer #7646

Merged
merged 2 commits into from
Feb 1, 2024

Conversation

josegar74
Copy link
Member

@josegar74 josegar74 commented Jan 22, 2024

Test case:

  1. Create an iso19139 dataset metadata
  2. Add an online resource with a WMS layer
  3. Add an online resource and select the option Add a thumbnail in the dialog. Check the Javascript console:
  • Without the fix:
Error: [orderBy:notarray] http://errors.angularjs.org/1.8.2/orderBy/notarray\?p0\=%7B%22resource%22%3A%7B%22ref%22%3A%22172%22%2C%22refParent%22%3A%22171%22%2C%22name%22%3A%222%22%2C%22url%22%3A%22https%3A%2F%2Fmaps-cartes.ec.gc.ca%2Farcgis%2Fservices%2FDMS%2FStressCumulatifLittorales%2FMapServer%2FWMSServer%3Frequest%3DGetCapabilities%26service%3DWMS%22%2C%22title%22%3A%22Metadata%20WMS%20layer%22%2C%22abstract%22%3A%22The%20ISO19115%20metadata%20standard%20is%20the%20preferred%20metadata%20standard%20to%20use.%20If%20unsure%20what%20templates%20to%20start%20with%2C%20use%20this%20one.%22%2C%22protocol%22%3A%22OGC%3AWMS%22%7D%7D
    at lib.js?v=65b94734a63ca8491dba95d7439baf1be02c2450:21:168
  • With the fix: no javascript error is displayed

@fxprunayre not really related to this change, but to the Add thumbnails from map feature. Is this to hide the add thumbnails from map panel if the metadata doesn't have any WMS layer?

<div
id="gn-addonlinesrc-thumbnail-warning"
class="alert alert-warning"
data-ng-show="layers == undefined"
data-translate=""
>
noLayersForThumbnail
</div>

This doesn't really work, independently of the value of scope.layers in

(no matter if in that line it is undefined or has a value), if you print that value in the HTML it is always prints [].

Debugging the code, scope.layers are reset in

after executing

I don't know that much this code, but seems like an unwanted side-effect?


Should not be this set to undefined to be consistent with the HTML check?

If the purpose is to hide the panel if no WMS layers, I think we should unify the check either to undefined or empty array and check the side effect for reset protocol.

Doing some additional research, it seems scope.layers are used both in the WMS directive to select a WMS layer and also in the Add Thumbnail from map feature, that doesn't look good. I've changed

<div
id="gn-addonlinesrc-thumbnail-warning"
class="alert alert-warning"
data-ng-show="layers == undefined"
data-translate=""
>
noLayersForThumbnail
</div>

To

data-ng-show="gnCurrentEdit.layerConfig == undefined"

And looks working fine like this:

  1. If the metadata has WMS layers, are loaded in the map viewer to create the thumbnail

  2. If the metadata has no WMS layers, a message No layer defined in record to generate thumbnail from is displayed (although needs some styling).

I think the assignment changed in this PR can be also completely removed, scope.layers should be used only to select layers from a WMS service.

Checklist

  • I have read the contribution guidelines
  • Pull request provided for main branch, backports managed with label
  • Good housekeeping of code, cleaning up comments, tests, and documentation
  • Clean commit history broken into understandable chucks, avoiding big commits with hundreds of files, cautious of reformatting and whitespace changes
  • Clean commit messages, longer verbose messages are encouraged
  • API Changes are identified in commit messages
  • Testing provided for features or enhancements using automatic tests
  • User documentation provided for new features or enhancements in manual
  • Build documentation provided for development instructions in README.md files
  • Library management using pom.xml dependency management. Update build documentation with intended library use and library tutorials or documentation

@josegar74 josegar74 added this to the 4.4.3 milestone Jan 22, 2024
fxprunayre added a commit to fxprunayre/core-geonetwork that referenced this pull request Feb 1, 2024
* Metadata editor / Improve layer configuration init.

Related to geonetwork#7646.

* Metadata editor / Improve layer configuration init.

* Metadata editor / Remove log.
@josegar74 josegar74 merged commit a76374c into geonetwork:main Feb 1, 2024
6 checks passed
geonetworkbuild pushed a commit that referenced this pull request Feb 1, 2024
* Metadata editor / Improve layer configuration init.

Related to #7646.

* Metadata editor / Improve layer configuration init.

* Metadata editor / Remove log.
josegar74 added a commit that referenced this pull request Feb 1, 2024
…umbnail option when the metadata has 1 WMS layer (#7684)

* Metadata editor / Fix javascript error in the add thumbnail option when the metadata has 1 WMS layer:

Error: [orderBy:notarray] http://errors.angularjs.org/1.8.2/orderBy/notarray\?p0\=%7B%22resource%22%3A%7B%22ref%22%3A%22172%22%2C%22refParent%22%3A%22171%22%2C%22name%22%3A%222%22%2C%22url%22%3A%22https%3A%2F%2Fmaps-cartes.ec.gc.ca%2Farcgis%2Fservices%2FDMS%2FStressCumulatifLittorales%2FMapServer%2FWMSServer%3Frequest%3DGetCapabilities%26service%3DWMS%22%2C%22title%22%3A%22Metadata%20WMS%20layer%22%2C%22abstract%22%3A%22The%20ISO19115%20metadata%20standard%20is%20the%20preferred%20metadata%20standard%20to%20use.%20If%20unsure%20what%20templates%20to%20start%20with%2C%20use%20this%20one.%22%2C%22protocol%22%3A%22OGC%3AWMS%22%7D%7D
    at lib.js?v=65b94734a63ca8491dba95d7439baf1be02c2450:21:168

* Metadata editor / Improve layer configuration init. (#96)

* Metadata editor / Improve layer configuration init.

Related to #7646.

* Metadata editor / Improve layer configuration init.

* Metadata editor / Remove log.

---------

Co-authored-by: Jose García <[email protected]>
Co-authored-by: François Prunayre <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants