diff --git a/docs/changelog.md b/docs/changelog.md index a17b2c22..10aa6e59 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -49,6 +49,10 @@ COMMIT; umap compress +## 1.0.0.rc-5 + +- Fixed user autocompletion in permissions panel (cf #635) + ## 1.0.0.rc-4 - fixed geodjango defaulting geojson parsing to SRID 3857 instead of 4326 diff --git a/umap/static/umap/js/umap.autocomplete.js b/umap/static/umap/js/umap.autocomplete.js index f3d83992..f736d22b 100644 --- a/umap/static/umap/js/umap.autocomplete.js +++ b/umap/static/umap/js/umap.autocomplete.js @@ -78,7 +78,7 @@ L.U.AutoComplete = L.Class.extend({ break; case L.U.Keys.DOWN: if(this.RESULTS.length > 0) { - if(this.CURRENT !== null && this.CURRENT < this.RESULTS.length - 1) { // what if one resutl? + if(this.CURRENT !== null && this.CURRENT < this.RESULTS.length - 1) { // what if one result? this.CURRENT++; this.highlight(); } @@ -168,7 +168,7 @@ L.U.AutoComplete = L.Class.extend({ else this.CACHE = val; this._do_search(val, function (data) { this.handleResults(data.data); - }); + }, this); }, createResult: function (item) { @@ -191,7 +191,7 @@ L.U.AutoComplete = L.Class.extend({ resultToIndex: function (result) { var out = null; this.forEach(this.RESULTS, function (item, index) { - if (item.value == result.value) { + if (item.item.value == result.item.value) { out = index; return; } @@ -215,12 +215,8 @@ L.U.AutoComplete = L.Class.extend({ highlight: function () { var self = this; this.forEach(this.RESULTS, function (result, index) { - if (index === self.CURRENT) { - L.DomUtil.addClass(result.el, 'on'); - } - else { - L.DomUtil.removeClass(result.el, 'on'); - } + if (index === self.CURRENT) L.DomUtil.addClass(result.el, 'on'); + else L.DomUtil.removeClass(result.el, 'on'); }); }, @@ -268,9 +264,9 @@ L.U.AutoComplete.Ajax = L.U.AutoComplete.extend({ }; }, - _do_search: function (val, callback) { + _do_search: function (val, callback, context) { val = val.toLowerCase(); - this.xhr.get('/agnocomplete/AutocompleteUser/?q=' + encodeURIComponent(val), {callback: callback}); + this.xhr.get('/agnocomplete/AutocompleteUser/?q=' + encodeURIComponent(val), {callback: callback, context: context || this}); } }); @@ -310,7 +306,6 @@ L.U.AutoComplete.Ajax.Select = L.U.AutoComplete.Ajax.extend({ this.input.style.display = 'none'; L.DomEvent.on(close, 'click', function () { this.selected_container.innerHTML = ''; - this.options.on_unselect(result); this.input.style.display = 'block'; }, this); this.hide(); diff --git a/umap/static/umap/js/umap.forms.js b/umap/static/umap/js/umap.forms.js index 019520ba..2c24f371 100644 --- a/umap/static/umap/js/umap.forms.js +++ b/umap/static/umap/js/umap.forms.js @@ -665,15 +665,10 @@ L.FormBuilder.Range = L.FormBuilder.Input.extend({ L.FormBuilder.ManageOwner = L.FormBuilder.Element.extend({ build: function () { - var options = {className: 'edit-owner'}; - options.on_select = function (choice) { - this._value = { - 'id': choice.item.value, - 'name': choice.item.label, - 'url': choice.item.url - }; - this.set(); - } + var options = { + className: 'edit-owner', + on_select: L.bind(this.onSelect, this) + }; this.autocomplete = new L.U.AutoComplete.Ajax.Select(this.parentNode, options); var owner = this.toHTML(); if (owner) this.autocomplete.displaySelected({'item': {'value': owner.id, 'label': owner.name}}); @@ -681,30 +676,29 @@ L.FormBuilder.ManageOwner = L.FormBuilder.Element.extend({ value: function () { return this._value; + }, + + onSelect: function (choice) { + this._value = { + 'id': choice.item.value, + 'name': choice.item.label, + 'url': choice.item.url + }; + this.set(); } + }); L.FormBuilder.ManageEditors = L.FormBuilder.Element.extend({ build: function () { - var options = {className: 'edit-editors'}; - options.on_select = function (choice) { - this._values.push({ - 'id': choice.item.value, - 'name': choice.item.label, - 'url': choice.item.url - }); - this.set(); - } - options.on_unselect = function (choice) { - var index = this._values.findIndex(function (item) {return item.id === choice.item.value}); - if (index !== -1) { - this._values.splice(index, 1); - this.set(); - } - } + var options = { + className: 'edit-editors', + on_select: L.bind(this.onSelect, this), + on_unselect: L.bind(this.onUnselect, this) + }; this.autocomplete = new L.U.AutoComplete.Ajax.SelectMultiple(this.parentNode, options); this._values = this.toHTML(); if (this._values) for (var i = 0; i < this._values.length; i++) this.autocomplete.displaySelected({'item': {'value': this._values[i].id, 'label': this._values[i].name}}); @@ -712,6 +706,23 @@ L.FormBuilder.ManageEditors = L.FormBuilder.Element.extend({ value: function () { return this._values; + }, + + onSelect: function (choice) { + this._values.push({ + 'id': choice.item.value, + 'name': choice.item.label, + 'url': choice.item.url + }); + this.set(); + }, + + onUnselect: function (choice) { + var index = this._values.findIndex(function (item) {return item.id === choice.item.value}); + if (index !== -1) { + this._values.splice(index, 1); + this.set(); + } } }); diff --git a/umap/static/umap/js/umap.layer.js b/umap/static/umap/js/umap.layer.js index c59bff04..497314e0 100644 --- a/umap/static/umap/js/umap.layer.js +++ b/umap/static/umap/js/umap.layer.js @@ -562,7 +562,7 @@ L.U.DataLayer = L.Evented.extend({ return this.geojsonToFeatures(geometry.geometries); default: - this.map.ui.alert({content: L._('Skipping unkown geometry.type: {type}', {type: geometry.type}), level: 'error'}); + this.map.ui.alert({content: L._('Skipping unknown geometry.type: {type}', {type: geometry.type || 'undefined'}), level: 'error'}); } if (layer) { this.addLayer(layer);