Skip to content

Commit

Permalink
Merge pull request #2371 from okauppinen/describe-layer-response
Browse files Browse the repository at this point in the history
Describe layer response
  • Loading branch information
ZakarFin authored Aug 14, 2023
2 parents 171f88a + b30333c commit aa625af
Show file tree
Hide file tree
Showing 43 changed files with 308 additions and 577 deletions.
2 changes: 1 addition & 1 deletion bundles/framework/featuredata2/Flyout.js
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ Oskari.clazz.define(
const inputlayer = this.instance.getSandbox().findMapLayerFromAllAvailable(inputid);
let message;
if (inputlayer && inputlayer.getLayerType().toUpperCase() === 'WFS') {
const noData = inputlayer.getWpsLayerParams().no_data;
const noData = inputlayer.getWpsLayerParams().noDataValue;
if (noData) {
message = this.instance.loc('gridFooter.noDataCommonMessage') + ' (' + noData + ').';
const locales = Object.values(layer.getPropertyLabels());
Expand Down
2 changes: 1 addition & 1 deletion bundles/framework/myplaces3/MyPlacesLayerControls.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const Content = styled('div')`
max-width: 500px;
`;

const getDefaultCategoryId = categories => categories.find(cat => cat.isDefault).categoryId;
const getDefaultCategoryId = categories => categories.find(cat => cat.isDefault)?.categoryId;
const DeletePlaces = ({
categories,
selectedCategoryId,
Expand Down
2 changes: 1 addition & 1 deletion bundles/framework/myplaces3/request/EditCategoryRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Oskari.clazz.define('Oskari.mapframework.bundle.myplaces3.request.EditCategoryRe
},
/**
* @method getId
* @return {Number} id of category to be edited
* @return {Number || String} id or layerId of category to be edited
*/
getId: function () {
return this._categoryId;
Expand Down
5 changes: 3 additions & 2 deletions bundles/framework/myplaces3/request/EditRequestHandler.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { getCategoryId } from '../service/LayerHelper';
/**
* @class Oskari.mapframework.bundle.myplaces3.request.EditRequestHandler
* Handles sequests for a saved "my place" or my places categorires to be opened for editing
Expand Down Expand Up @@ -59,7 +60,7 @@ Oskari.clazz.define('Oskari.mapframework.bundle.myplaces3.request.EditRequestHan
handler.deletePlace(id);
},
_handleEditCategory: function (sandbox, request) {
const id = request.getId();
const id = getCategoryId(request.getId());
this.log.debug('edit requested for category ' + id);
const handler = this.instance.getMyPlacesHandler();
if (!handler) {
Expand All @@ -72,7 +73,7 @@ Oskari.clazz.define('Oskari.mapframework.bundle.myplaces3.request.EditRequestHan
this.log.warn(`Delete requested for category: ${id}. This handler doesn't ask for move places or confirm. Skipping!`);
},
_handlePublishCategory: function (sandbox, request) {
const id = request.getId();
const id = getCategoryId(request.getId());
this.log.debug('(un/)publish requested for category ' + id);
const service = this.instance.getService();
if (!service) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Oskari.clazz.define('Oskari.mapframework.bundle.myplaces3.request.PublishCategor
},
/**
* @method getId
* @return {Number} id of category to be edited
* @return {Number || String} id or layerId to be edited
*/
isPublic: function () {
return this._isPublic;
Expand Down
2 changes: 1 addition & 1 deletion bundles/framework/myplaces3/service/LayerHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ export const layerToCategory = (layer) => {
categoryId: getCategoryId(layerId),
layerId,
name: layer.getName(),
isDefault: !!layer.getOptions().isDefault
isDefault: layer.isDefault()
};
};
6 changes: 2 additions & 4 deletions bundles/framework/myplaces3/service/MyPlacesService.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,13 @@ Oskari.clazz.define('Oskari.mapframework.bundle.myplaces3.service.MyPlacesServic
}
},
_updateLayer: function (layerJson) {
const { id, locale, options } = layerJson;
const { id } = layerJson;
const layer = this.mapLayerService.findMapLayer(id);
if (!layer) {
this.log.warn('tried to update layer which does not exist, id: ' + id);
return;
}
layer.setLocale(locale);
layer.setOptions(options);
layer.setStylesFromOptions(options);
layer.handleUpdatedLayer(layerJson);
const evt = Oskari.eventBuilder('MapLayerEvent')(id, 'update');
this.sandbox.notifyAll(evt);
if (this.sandbox.isLayerAlreadySelected(id)) {
Expand Down
10 changes: 4 additions & 6 deletions bundles/framework/myplacesimport/PersonalDataUserLayersTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Oskari.clazz.define('Oskari.mapframework.bundle.myplacesimport.PersonalDataUserL
this.loc = Oskari.getMsg.bind(null, 'MyPlacesImport');
this.layerMetaType = 'USERLAYER';
this.visibleFields = [
'name', 'description', 'source', 'edit', 'remove'
'name', 'desc', 'source', 'edit', 'remove'
];
this.grid = undefined;
this.container = undefined;
Expand Down Expand Up @@ -149,11 +149,9 @@ Oskari.clazz.define('Oskari.mapframework.bundle.myplacesimport.PersonalDataUserL
return;
}
gridModel.addData({
'id': layer.getId(),
'name': Oskari.util.sanitize(layer.getName()),
'description': Oskari.util.sanitize(layer.getDescription()),
'source': Oskari.util.sanitize(layer.getSource()),
'isBase': layer.isBaseLayer()
id: layer.getId(),
isBase: layer.isBaseLayer(),
...layer.getLocaleValues()
});
layersAdded.push(layer.getId());
});
Expand Down
11 changes: 4 additions & 7 deletions bundles/framework/myplacesimport/UserLayersList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ export const UserLayersList = ({ data = [], controller, loading }) => {
},
{
align: 'left',
title: <Message messageKey='tab.grid.description' />,
dataIndex: 'description',
title: <Message messageKey='tab.grid.desc' />,
dataIndex: 'desc',
sorter: getSorterFor('description')
},
{
Expand Down Expand Up @@ -72,12 +72,9 @@ export const UserLayersList = ({ data = [], controller, loading }) => {
<Table
columns={columnSettings}
dataSource={data.map(item => ({
...item,
key: item.getId(),
name: Oskari.util.sanitize(item.getName()),
description: Oskari.util.sanitize(item.getDescription()),
source: Oskari.util.sanitize(item.getSource()),
created: item.getCreated()
created: item.getCreated(),
...item.getLocaleValues()
}))}
pagination={false}
loading={loading}
Expand Down
2 changes: 1 addition & 1 deletion bundles/framework/myplacesimport/resources/locale/de.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Oskari.registerLocalization(
"title": "Datensatz",
"grid": {
"name": "Name",
"description": "Beschreibung",
"desc": "Beschreibung",
"source": "Datenquelle",
"remove": "Löschen",
"removeButton": "Löschen"
Expand Down
2 changes: 1 addition & 1 deletion bundles/framework/myplacesimport/resources/locale/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Oskari.registerLocalization(
"deleteLayer": "Delete map layer",
"grid": {
"name": "Name",
"description": "Description",
"desc": "Description",
"source": "Data source",
"edit": "Edit",
"editButton": "Edit",
Expand Down
2 changes: 1 addition & 1 deletion bundles/framework/myplacesimport/resources/locale/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Oskari.registerLocalization(
"title": "Conjuntos de datos",
"grid": {
"name": "Nombre",
"description": "Descripción",
"desc": "Descripción",
"source": "Fuente de datos",
"remove": "Borrar",
"removeButton": "Borrar"
Expand Down
2 changes: 1 addition & 1 deletion bundles/framework/myplacesimport/resources/locale/et.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Oskari.registerLocalization(
"title": "Andmestikud",
"grid": {
"name": "Nimi",
"description": "Kirjeldus",
"desc": "Kirjeldus",
"source": "Andmeallikas",
"remove": "Kustuta",
"removeButton": "Kustuta"
Expand Down
2 changes: 1 addition & 1 deletion bundles/framework/myplacesimport/resources/locale/fi.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Oskari.registerLocalization(
"deleteLayer": "Poista karttataso",
"grid": {
"name": "Nimi",
"description": "Kuvaus",
"desc": "Kuvaus",
"source": "Tietolähde",
"edit": "Muokkaa",
"editButton": "Muokkaa",
Expand Down
2 changes: 1 addition & 1 deletion bundles/framework/myplacesimport/resources/locale/fr.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Oskari.registerLocalization(
"deleteLayer": "Supprimer la couche cartographique",
"grid": {
"name": "Nom",
"description": "Description",
"desc": "Description",
"source": "Source des données",
"edit": "Modifier",
"editButton": "Modifier",
Expand Down
2 changes: 1 addition & 1 deletion bundles/framework/myplacesimport/resources/locale/is.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Oskari.registerLocalization(
"title": "Gagnasett",
"grid": {
"name": "Nafn",
"description": "Lýsing",
"desc": "Lýsing",
"source": "Gagnagjafi",
"remove": "Eyða",
"removeButton": "Eyða"
Expand Down
2 changes: 1 addition & 1 deletion bundles/framework/myplacesimport/resources/locale/it.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Oskari.registerLocalization(
"title": "Datasets",
"grid": {
"name": "Nome",
"description": "Descrizione",
"desc": "Descrizione",
"source": "Sorgente del dato",
"remove": "Elimina",
"removeButton": "Elimina"
Expand Down
2 changes: 1 addition & 1 deletion bundles/framework/myplacesimport/resources/locale/nb.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Oskari.registerLocalization(
"title": "Datasett",
"grid": {
"name": "Navn",
"description": "Beskrivelse",
"desc": "Beskrivelse",
"source": "Datakilde",
"remove": "Slett",
"removeButton": "Slett"
Expand Down
2 changes: 1 addition & 1 deletion bundles/framework/myplacesimport/resources/locale/nl.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Oskari.registerLocalization(
"title": "Datasets",
"grid": {
"name": "Naam",
"description": "Beschrijving",
"desc": "Beschrijving",
"source": "Gegevensbron",
"remove": "Verwijderen",
"removeButton": "Verwijderen"
Expand Down
2 changes: 1 addition & 1 deletion bundles/framework/myplacesimport/resources/locale/ru.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Oskari.registerLocalization(
"deleteLayer": "Стереть слой карты",
"grid": {
"name": "Название",
"description": "Описание",
"desc": "Описание",
"source": "Источник данных",
"edit": "Редактировать",
"editButton": "Редактировать",
Expand Down
2 changes: 1 addition & 1 deletion bundles/framework/myplacesimport/resources/locale/sk.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Oskari.registerLocalization(
"title": "Datasety",
"grid": {
"name": "Názov",
"description": "Popis",
"desc": "Popis",
"source": "Zdroj údajov",
"remove": "Vymazať",
"removeButton": "Vymazať"
Expand Down
2 changes: 1 addition & 1 deletion bundles/framework/myplacesimport/resources/locale/sl.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Oskari.registerLocalization(
"title": "Nabor podatkov",
"grid": {
"name": "Ime",
"description": "Opis",
"desc": "Opis",
"source": "Vir podatkov",
"remove": "Briši",
"removeButton": "Briši"
Expand Down
2 changes: 1 addition & 1 deletion bundles/framework/myplacesimport/resources/locale/sv.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Oskari.registerLocalization(
"deleteLayer": "Ta bort kartlagret",
"grid": {
"name": "Namn",
"description": "Beskrivning",
"desc": "Beskrivning",
"source": "Datakälla",
"edit": "Redigera",
"editButton": "Redigera",
Expand Down
12 changes: 2 additions & 10 deletions bundles/framework/myplacesimport/service/MyPlacesImportService.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,13 @@ Oskari.clazz.define('Oskari.mapframework.bundle.myplacesimport.MyPlacesImportSer
* @param {Object} updatedLayer
*/
updateLayer: function (updatedLayer) {
const { id, locale, options } = updatedLayer;
const { id } = updatedLayer;
const layer = this.instance.getMapLayerService().findMapLayer(id);
if (!layer) {
this.log.error('Could not find layer for update with id:' + id);
return;
}
layer.setLocale(locale);
layer.setOptions(options);
layer.setStylesFromOptions(options);
layer.handleUpdatedLayer(updatedLayer);
const sandbox = this.instance.getSandbox();
const evt = Oskari.eventBuilder('MapLayerEvent')(id, 'update');
sandbox.notifyAll(evt);
Expand Down Expand Up @@ -287,12 +285,6 @@ Oskari.clazz.define('Oskari.mapframework.bundle.myplacesimport.MyPlacesImportSer
// There might be other userlayer typed layers in maplayerservice from link parameters that might NOT be this users layers.
// This is used to filter out other users shared layers when listing layers on the My Data functionality.
mapLayer.markAsInternalDownloadSource();
// Add organization and groups for users own datasets (otherwise left empty/data from baselayer)
mapLayer.setOrganizationName(this.instance.loc('layer.organization'));
mapLayer.setGroups([{
id: this.groupId,
name: this.instance.loc('layer.inspire')
}]);
// Add the layer to the map layer service
mapLayerService.addLayer(mapLayer, skipEvent);
if (typeof cb === 'function') {
Expand Down
7 changes: 7 additions & 0 deletions bundles/mapping/mapmodule/domain/AbstractLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ Oskari.clazz.define(
unsupported: null // {UnsupportedLayerReason} most severe reason if unsupported
};
this._describeLayerStatus = DESCRIBE_LAYER.UNDEFINED;
this._describeLayerInfo = null;
}, {
/**
* @method setId
Expand Down Expand Up @@ -1289,6 +1290,12 @@ Oskari.clazz.define(
},
handleDescribeLayer: function (info) {
// to override in AbstarctVectorLayer
},
getDescribeLayerInfo: function () {
return this._describeLayerInfo;
},
setDescribeLayerInfo: function (info) {
this._describeLayerInfo = info;
}
}
);
33 changes: 16 additions & 17 deletions bundles/mapping/mapmodule/domain/AbstractVectorLayer.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { VectorStyle, createDefaultStyle, DEFAULT_STYLE_NAME, parseStylesFromOptions } from './VectorStyle';
import { VectorStyle, createDefaultStyle, DEFAULT_STYLE_NAME } from './VectorStyle';

const AbstractLayer = Oskari.clazz.get('Oskari.mapframework.domain.AbstractLayer');

export class AbstractVectorLayer extends AbstractLayer {
constructor () {
super(...arguments);
this.hoverOptions = null;
this._hoverOptions = null;
this._storedStyleName = null;
this._controlData = {};
}

/* override */
Expand Down Expand Up @@ -45,20 +46,26 @@ export class AbstractVectorLayer extends AbstractLayer {
return this._currentStyle;
}

/* override */
getStyleType () {
return this._controlData.styleType;
}

/* override */
getLegendImage () {
return null;
}

setHoverOptions (options) {
this.hoverOptions = options;
this._hoverOptions = options;
}

getHoverOptions () {
return this.hoverOptions;
return this._hoverOptions;
}

handleDescribeLayer (info) {
const { styles = [] } = info;
const { styles = [], controlData = {}, hover } = info;
const vs = styles.map(s => new VectorStyle(s));
if (vs.length) {
// override all styles as create map layer if there were any
Expand All @@ -68,16 +75,8 @@ export class AbstractVectorLayer extends AbstractLayer {
// request notifies change
Oskari.getSandbox().postRequestByName('ChangeMapLayerStyleRequest', [this.getId(), this._storedStyleName]);
}
}

// For user data layers
setStylesFromOptions (options) {
const styles = parseStylesFromOptions(options);
this.setStyles(styles);
// Remove styles from options to be sure that VectorStyle is used
delete options.styles;
// update current style
this.selectStyle(this.getCurrentStyle().getName());
this._controlData = controlData;
this._hoverOptions = hover;
}

removeStyle (name) {
Expand All @@ -104,7 +103,7 @@ export class AbstractVectorLayer extends AbstractLayer {
* @return {Number} Distance between features in pixels
*/
getClusteringDistance () {
return this.getOptions().clusteringDistance;
return this._controlData.clusteringDistance;
}

/**
Expand All @@ -113,7 +112,7 @@ export class AbstractVectorLayer extends AbstractLayer {
* @return {Number} Distance between features in pixels
*/
setClusteringDistance (distance) {
this.getOptions().clusteringDistance = distance;
this._controlData.clusteringDistance = distance;
}
}

Expand Down
Loading

0 comments on commit aa625af

Please sign in to comment.