diff --git a/packages/base/src/commands.ts b/packages/base/src/commands.ts index 87b38d31..f76e4577 100644 --- a/packages/base/src/commands.ts +++ b/packages/base/src/commands.ts @@ -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) { @@ -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, @@ -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 diff --git a/packages/base/src/formdialog.tsx b/packages/base/src/formdialog.tsx index dd057552..9755a946 100644 --- a/packages/base/src/formdialog.tsx +++ b/packages/base/src/formdialog.tsx @@ -28,6 +28,7 @@ export class FormDialog extends Dialog { this.resolve(0); }; } + const filePath = options.context.path; const jGISModel = options.context.model; const body = ( diff --git a/packages/base/style/dialog.css b/packages/base/style/dialog.css index aa4aea06..13e375b7 100644 --- a/packages/base/style/dialog.css +++ b/packages/base/style/dialog.css @@ -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; } diff --git a/packages/schema/src/model.ts b/packages/schema/src/model.ts index 361d324f..282583a1 100644 --- a/packages/schema/src/model.ts +++ b/packages/schema/src/model.ts @@ -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'; @@ -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); }); }