Fix inheritable select not properly reset (fix #551)

This commit is contained in:
Yohan Boniface 2018-06-19 12:41:37 +02:00
parent 67d7ab962c
commit fded9d6201
9 changed files with 51 additions and 5 deletions

View file

@ -62,6 +62,9 @@ COMMIT;
- local settings are now loaded from `/etc/umap/umap.conf` if available
- fixed an issue where it was not possible to change the tilelayer if the
tilelayer control was not added to the map (#587)
- `showLabel` is now a ternary value (instead of having this plus `labelHover`)
(#553)
- fixed resetting a select to undefined for inheritable fields (#551)

View file

@ -8,6 +8,7 @@ L.FormBuilder.Element.include({
if (this.options.inheritable) {
className += this.get(true) === undefined ? ' inheritable undefined' : ' inheritable ';
}
className += ' umap-field-' + this.name;
this.wrapper = L.DomUtil.create('div', className, this.form);
this.header = L.DomUtil.create('div', 'header', this.wrapper);
if (this.options.inheritable) {
@ -66,6 +67,11 @@ L.FormBuilder.Select.include({
clear: function () {
this.select.value = '';
},
getDefault: function () {
if (this.options.inheritable) return undefined
else return L.FormBuilder.Select.prototype.getDefault.call(this)
}
});

View file

@ -55,7 +55,6 @@ L.U.Xhr = L.Evented.extend({
xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
console.log(xhr.status)
if (xhr.status == 200) {
settings.callback.call(settings.context || xhr, xhr.responseText, xhr);
}

View file

@ -1,4 +1,4 @@
describe('L.DataLayer', function () {
describe('L.U.DataLayer', function () {
var path = '/map/99/datalayer/edit/62/';
before(function () {
@ -202,6 +202,9 @@ describe('L.DataLayer', function () {
changeSelectValue(qs('form#datalayer-advanced-properties select[name=iconClass]'), 'Circle');
assert.notOk(qs('div.umap-div-icon'));
assert.ok(qs('div.umap-circle-icon'));
happen.click(qs('form#datalayer-advanced-properties .umap-field-iconClass .undefine'));
assert.notOk(qs('div.umap-circle-icon'));
assert.ok(qs('div.umap-div-icon'));
clickCancel();
});

View file

@ -1,4 +1,4 @@
describe('L.Utorage.FeatureMixin', function () {
describe('L.U.FeatureMixin', function () {
before(function () {
this.server = sinon.fakeServer.create();

View file

@ -1,4 +1,4 @@
describe('L.Umap.Map', function(){
describe('L.U.Map', function(){
before(function () {
this.server = sinon.fakeServer.create();

View file

@ -0,0 +1,34 @@
describe('L.U.Marker', function () {
before(function () {
this.server = sinon.fakeServer.create();
var datalayer_response = JSON.parse(JSON.stringify(RESPONSES.datalayer62_GET)); // Copy.
datalayer_response._umap_options.iconClass = 'Drop';
this.server.respondWith('GET', '/datalayer/62/', JSON.stringify(datalayer_response));
this.map = initMap({umap_id: 99});
this.datalayer = this.map.getDataLayerByUmapId(62);
this.server.respond();
});
after(function () {
this.server.restore();
resetMap();
});
describe('#iconClassChange()', function () {
it('should change icon class', function () {
enableEdit();
happen.click(qs('div.umap-drop-icon'));
happen.click(qs('ul.leaflet-inplace-toolbar a.umap-toggle-edit'));
changeSelectValue(qs('form#umap-feature-shape-properties .umap-field-iconClass select[name=iconClass]'), 'Circle');
assert.notOk(qs('div.umap-drop-icon'));
assert.ok(qs('div.umap-circle-icon'));
happen.click(qs('form#umap-feature-shape-properties .umap-field-iconClass .undefine'));
assert.notOk(qs('div.umap-circle-icon'));
assert.ok(qs('div.umap-drop-icon'));
clickCancel();
});
});
});

View file

@ -65,7 +65,7 @@ var cleanAlert = function () {
};
var defaultDatalayerData = function (custom) {
var _default = {
icon_class: 'Default',
iconClass: 'Default',
name: 'Elephants',
displayOnLoad: true,
id: 62,

View file

@ -70,6 +70,7 @@
<script src="./DataLayer.js"></script>
<script src="./TableEditor.js"></script>
<script src="./Feature.js"></script>
<script src="./Marker.js"></script>
<script src="./Polyline.js"></script>
<script src="./Polygon.js"></script>
<script src="./Util.js"></script>