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

Fix service metadata before saving the layer #2642

Merged
merged 2 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const MetadataId = ({ layer, controller }) => {
<StyledFormField>
<Message messageKey='metadata.overridden'/>
{renderButton &&
<MetadataButton onClick={() => controller.showLayerMetadata(layer.id)}/>
<MetadataButton onClick={() => controller.showLayerMetadata(layer.isNew ? layer.metadataid : layer.id)}/>
}
<TextInput
value={layer.metadataid}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const ServiceMetadata = ({ capabilities, controller, hasHandler, layerId
<Tooltip title={metadataUuid}>
<Message messageKey='metadata.service' />
{hasHandler &&
<MetadataButton onClick={() => controller.showLayerMetadata(layerId)}/>
<MetadataButton onClick={() => controller.showLayerMetadata(layerId || metadataUuid)}/>
}
</Tooltip>
);
Expand All @@ -36,5 +36,5 @@ ServiceMetadata.propTypes = {
hasHandler: PropTypes.bool.isRequired,
capabilities: PropTypes.object.isRequired,
controller: PropTypes.instanceOf(Controller).isRequired,
layerId: PropTypes.number.isRequired
layerId: PropTypes.number
};
Original file line number Diff line number Diff line change
Expand Up @@ -1178,8 +1178,15 @@ class UIHandler extends StateHandler {
}

showLayerMetadata (layerId) {
// this works even when the layer hasn't been saved yet
let payload = { uuid: layerId };
if (typeof layerId === 'number') {
// this works only when layer has been saved
// (and supports the attributes override for metadata service url)
payload = { layerId };
}
Oskari.getSandbox().postRequestByName('catalogue.ShowMetadataRequest', [
{ layerId: layerId }
payload
]);
}

Expand Down
Loading