Skip to content

Commit

Permalink
Improve the add GeoJSONSource and addVectorLayer dialogs
Browse files Browse the repository at this point in the history
  • Loading branch information
brichet committed Jul 9, 2024
1 parent 2452b91 commit ad3eb2f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 15 deletions.
16 changes: 4 additions & 12 deletions packages/base/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,6 @@ namespace Private {
current.context.model
.readGeoJSON(filepath)
.then(async geoJSONData => {
if (geoJSONData === undefined) {
showErrorMessage(
'Error reading GeoJSON',
'An error occurred while reading the GeoJSON file'
);
}
const name = PathExt.basename(filepath, '.json');
const valid = validate(geoJSONData);
if (!valid) {
Expand Down Expand Up @@ -345,13 +339,15 @@ namespace Private {
default: (model: IJupyterGISModel) => {
return {
name: 'VectorSource',
source: sources[Object.keys(sources)[0]] ?? null
source: Object.keys(sources)[0] ?? null
};
}
};

current.context.model.syncFormData(form);

FORM_SCHEMA['VectorLayer'].properties.source.enumNames = Object.values(sources);
FORM_SCHEMA['VectorLayer'].properties.source.enum = Object.keys(sources);
const dialog = new FormDialog({
context: current.context,
title: form.title,
Expand All @@ -365,14 +361,10 @@ namespace Private {

const { name, ...parameters } = props;

const source = Object.keys(sources).find(
key => sources[key] === parameters.source
);

const layerModel: IJGISLayer = {
type: 'VectorLayer',
parameters: {
source,
source: parameters.source,
type: parameters.type,
color: parameters.color,
opacity: parameters.opacity
Expand Down
1 change: 1 addition & 0 deletions packages/base/src/formdialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class FormDialog extends Dialog<IDict> {
this.resolve(0);
};
}

const filePath = options.context.path;
const jGISModel = options.context.model;
const body = (
Expand Down
4 changes: 4 additions & 0 deletions packages/base/style/dialog.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
| Distributed under the terms of the Modified BSD License.
|---------------------------------------------------------------------------- */

.jp-SchemaForm .jp-select-wrapper select {
background-image: unset;
}

.jp-gis-addDataSourceBody > :not(:first-child) {
margin-top: 1em;
}
Expand Down
4 changes: 1 addition & 3 deletions packages/schema/src/model.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ICollaborativeDrive } from '@jupyter/docprovider';
import { MapChange } from '@jupyter/ydoc';
import { showErrorMessage } from '@jupyterlab/apputils';
import { IChangedArgs } from '@jupyterlab/coreutils';
import { DocumentRegistry } from '@jupyterlab/docregistry';
import { PartialJSONObject } from '@lumino/coreutils';
Expand Down Expand Up @@ -253,8 +252,7 @@ export class JupyterGISModel implements IJupyterGISModel {
return JSON.parse(contentModel.content);
})
.catch(e => {
showErrorMessage('Error opening GeoJSON file', e);
return;
throw(e);
});
}

Expand Down

0 comments on commit ad3eb2f

Please sign in to comment.