diff --git a/umap/static/umap/js/modules/data/layer.js b/umap/static/umap/js/modules/data/layer.js index 65689299..4e7ebe49 100644 --- a/umap/static/umap/js/modules/data/layer.js +++ b/umap/static/umap/js/modules/data/layer.js @@ -19,6 +19,7 @@ import { import { translate } from '../i18n.js' import { DataLayerPermissions } from '../permissions.js' import { Point, LineString, Polygon } from './features.js' +import TableEditor from '../tableeditor.js' export const LAYER_TYPES = [DefaultLayer, Cluster, Heat, Choropleth, Categorized] @@ -1090,7 +1091,7 @@ export class DataLayer { tableEdit() { if (!this.isVisible()) return - const editor = new U.TableEditor(this) + const editor = new TableEditor(this) editor.open() } diff --git a/umap/static/umap/js/modules/global.js b/umap/static/umap/js/modules/global.js index ca9fe1c1..a6c2b341 100644 --- a/umap/static/umap/js/modules/global.js +++ b/umap/static/umap/js/modules/global.js @@ -22,7 +22,6 @@ import Slideshow from './slideshow.js' import { SyncEngine } from './sync/engine.js' import Dialog from './ui/dialog.js' import { EditPanel, FullPanel, Panel } from './ui/panel.js' -import TableEditor from './tableeditor.js' import Tooltip from './ui/tooltip.js' import URLs from './urls.js' import * as Utils from './utils.js' @@ -72,7 +71,6 @@ window.U = { Share, Slideshow, SyncEngine, - TableEditor, Tooltip, URLs, Utils, diff --git a/umap/static/umap/test/TableEditor.js b/umap/static/umap/test/TableEditor.js deleted file mode 100644 index ef53362b..00000000 --- a/umap/static/umap/test/TableEditor.js +++ /dev/null @@ -1,104 +0,0 @@ -describe('L.TableEditor', () => { - let path = '/map/99/datalayer/edit/62/', - datalayer - - before(async () => { - await fetchMock.mock( - /\/datalayer\/62\/\?.*/, - JSON.stringify(RESPONSES.datalayer62_GET) - ) - this.options = { - umap_id: 99, - } - map = initMap({ umap_id: 99 }) - const datalayer_options = defaultDatalayerData() - await map.initDataLayers([datalayer_options]) - datalayer = map.getDataLayerByUmapId(62) - enableEdit() - }) - after(() => { - fetchMock.restore() - clickCancel() - resetMap() - }) - - describe('#open()', () => { - var button - - it('should exist table click on edit mode', () => { - button = qs( - '#browse_data_toggle_' + L.stamp(datalayer) + ' .icon-table' - ) - expect(button).to.be.ok - }) - - it('should open table button click', () => { - happen.click(button) - expect(qs('.panel.full.on div.table')).to.be.ok - expect(qsa('.panel.full.on div.table form').length).to.eql(3) // One per feature. - expect(qsa('.panel.full.on div.table input').length).to.eql(3) // One per feature and per property. - }) - }) - describe('#properties()', () => { - var feature - - before(() => { - var firstIndex = datalayer._index[0] - feature = datalayer._layers[firstIndex] - }) - - it('should create new property column', () => { - var newPrompt = () => { - return 'newprop' - } - var oldPrompt = window.prompt - window.prompt = newPrompt - var button = qs('.panel.full.on .add-property') - expect(button).to.be.ok - happen.click(button) - expect(qsa('.panel.full.on div.table input').length).to.eql(6) // One per feature and per property. - window.prompt = oldPrompt - }) - - it('should populate feature property on fill', () => { - var input = qs( - 'form#umap-feature-properties_' + L.stamp(feature) + ' input[name=newprop]' - ) - changeInputValue(input, 'the value') - expect(feature.properties.newprop).to.eql('the value') - }) - - it('should update property name on update click', () => { - var newPrompt = () => { - return 'newname' - } - var oldPrompt = window.prompt - window.prompt = newPrompt - var button = qs('.panel.full.on div.thead div.tcell:last-of-type .umap-edit') - expect(button).to.be.ok - happen.click(button) - expect(qsa('.panel.full.on div.table input').length).to.eql(6) - expect(feature.properties.newprop).to.be.undefined - expect(feature.properties.newname).to.eql('the value') - window.prompt = oldPrompt - }) - - it('should update property on delete click', () => { - var oldConfirm, - newConfirm = () => { - return true - } - oldConfirm = window.confirm - window.confirm = newConfirm - var button = qs( - '.panel.full.on div.thead div.tcell:last-of-type .umap-delete' - ) - expect(button).to.be.ok - happen.click(button) - FEATURE = feature - expect(qsa('.panel.full.on div.table input').length).to.eql(3) - expect(feature.properties.newname).to.be.undefined - window.confirm = oldConfirm - }) - }) -})