diff --git a/web/client/components/TOC/DefaultLayer.jsx b/web/client/components/TOC/DefaultLayer.jsx index 7ee6a2ae26..f77695f1f3 100644 --- a/web/client/components/TOC/DefaultLayer.jsx +++ b/web/client/components/TOC/DefaultLayer.jsx @@ -15,6 +15,7 @@ var WMSLegend = require('./fragments/WMSLegend'); const ConfirmButton = require('../buttons/ConfirmButton'); const LayersTool = require('./fragments/LayersTool'); const SettingsModal = require('./fragments/SettingsModal'); +const Message = require('../I18N/Message'); const {Glyphicon} = require('react-bootstrap'); var DefaultLayer = React.createClass({ @@ -37,6 +38,7 @@ var DefaultLayer = React.createClass({ opacityText: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.element]), saveText: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.element]), closeText: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.element]), + confirmDeleteText: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.element]), modalOptions: React.PropTypes.object, settingsOptions: React.PropTypes.object, visibilityCheckType: React.PropTypes.string, @@ -49,11 +51,12 @@ var DefaultLayer = React.createClass({ propertiesChangeHandler: () => {}, onToggle: () => {}, onSettings: () => {}, - activateRemoveLayer: true, + activateRemoveLayer: false, activateLegendTool: false, activateSettingsTool: false, modalOptions: {}, settingsOptions: {}, + confirmDeleteText: , visibilityCheckType: "glyph" }; }, @@ -70,7 +73,7 @@ var DefaultLayer = React.createClass({ )} style={{"float": "right", cursor: "pointer", backgroundColor: "transparent", marginRight: 3, padding: 0, outline: "none"}} - confirming={{text: "Sei sicuro", + confirming={{text: this.props.confirmDeleteText, style: {"float": "right", cursor: "pointer", marginTop: -5}}} onConfirm={() => { this.props.removeNode(this.props.node.id, "layers"); diff --git a/web/client/components/TOC/__tests__/DefaultLayer-test.jsx b/web/client/components/TOC/__tests__/DefaultLayer-test.jsx index e70c13e9d0..3e5c3fa191 100644 --- a/web/client/components/TOC/__tests__/DefaultLayer-test.jsx +++ b/web/client/components/TOC/__tests__/DefaultLayer-test.jsx @@ -9,7 +9,7 @@ var React = require('react/addons'); var ReactDOM = require('react-dom'); var Layer = require('../DefaultLayer'); - +// var ConfirmButton = require('../../buttons/ConfirmButton'); var expect = require('expect'); const TestUtils = React.addons.TestUtils; @@ -133,7 +133,33 @@ describe('test DefaultLayer module component', () => { const tool = ReactDOM.findDOMNode(TestUtils.scryRenderedDOMComponentsWithClass(comp, "glyphicon")[1]); expect(tool).toExist(); tool.click(); - expect(spy.calls.length).toBe(0); + expect(spy.calls.length).toBe(1); + }); + + it('tests removelayer tool', () => { + const l = { + name: 'layer000', + title: 'Layer001', + visibility: true, + storeIndex: 9, + type: 'wms' + }; + const actions = { + removeNode: () => {} + }; + let spy = expect.spyOn(actions, "removeNode"); + const comp = ReactDOM.render(, + document.getElementById("container")); + expect(comp).toExist(); + const domNode = ReactDOM.findDOMNode(comp); + expect(domNode).toExist(); + const tool = ReactDOM.findDOMNode(TestUtils.scryRenderedDOMComponentsWithClass(comp, "clayer_removal_button")[0]); + expect(tool).toExist(); + tool.click(); + const confirmButton = ReactDOM.findDOMNode(TestUtils.scryRenderedDOMComponentsWithClass(comp, "btn-warning")[0]); + expect(confirmButton).toExist(); + confirmButton.click(); + expect(spy.calls.length).toBe(1); }); it('tests settings tool', () => { @@ -158,11 +184,11 @@ describe('test DefaultLayer module component', () => { const tool = ReactDOM.findDOMNode(TestUtils.scryRenderedDOMComponentsWithClass(comp, "glyphicon")[1]); expect(tool).toExist(); tool.click(); - expect(spy.calls.length).toBe(0); - /* expect(spy.calls[0].arguments.length).toBe(3); + expect(spy.calls.length).toBe(1); + expect(spy.calls[0].arguments.length).toBe(3); expect(spy.calls[0].arguments[0]).toBe("layerId1"); expect(spy.calls[0].arguments[1]).toBe("layers"); - expect(spy.calls[0].arguments[2]).toEqual({opacity: 0.5});*/ + expect(spy.calls[0].arguments[2]).toEqual({opacity: 0.5}); }); it('test that settings modal is present only if all the requirements are met', () => { @@ -239,10 +265,10 @@ describe('test DefaultLayer module component', () => { expect(tool).toExist(); tool.click(); // the onSettings method must have been invoked - expect(spy.calls.length).toBe(0); - /* expect(spy.calls[0].arguments.length).toBe(3); + expect(spy.calls.length).toBe(1); + expect(spy.calls[0].arguments.length).toBe(3); expect(spy.calls[0].arguments[0]).toBe("layer1"); expect(spy.calls[0].arguments[1]).toBe("layers"); - expect(spy.calls[0].arguments[2]).toEqual({opacity: 0.0}); */ + expect(spy.calls[0].arguments[2]).toEqual({opacity: 0.0}); }); }); diff --git a/web/client/plugins/TOC.jsx b/web/client/plugins/TOC.jsx index 300645691e..d7a2087b4d 100644 --- a/web/client/plugins/TOC.jsx +++ b/web/client/plugins/TOC.jsx @@ -52,6 +52,7 @@ const LayerTree = React.createClass({ updateSettings: React.PropTypes.func, updateNode: React.PropTypes.func, removeNode: React.PropTypes.func, + activateRemoveLayer: React.PropTypes.bool, activateLegendTool: React.PropTypes.bool, activateSettingsTool: React.PropTypes.bool, visibilityCheckType: React.PropTypes.string, @@ -68,6 +69,7 @@ const LayerTree = React.createClass({ removeNode: () => {}, activateLegendTool: true, activateSettingsTool: true, + activateRemoveLayer: true, visibilityCheckType: "checkbox", settingsOptions: {} }; @@ -102,6 +104,7 @@ const LayerTree = React.createClass({ updateNode={this.props.updateNode} removeNode={this.props.removeNode} visibilityCheckType={this.props.visibilityCheckType} + activateRemoveLayer={this.props.activateRemoveLayer} activateLegendTool={this.props.activateLegendTool} activateSettingsTool={this.props.activateSettingsTool} settingsText={}