Fix user autocompletion in permissions panel (fix #635)
This commit is contained in:
parent
b54f4efce5
commit
b72650fafe
4 changed files with 48 additions and 38 deletions
|
@ -49,6 +49,10 @@ COMMIT;
|
||||||
umap compress
|
umap compress
|
||||||
|
|
||||||
|
|
||||||
|
## 1.0.0.rc-5
|
||||||
|
|
||||||
|
- Fixed user autocompletion in permissions panel (cf #635)
|
||||||
|
|
||||||
## 1.0.0.rc-4
|
## 1.0.0.rc-4
|
||||||
|
|
||||||
- fixed geodjango defaulting geojson parsing to SRID 3857 instead of 4326
|
- fixed geodjango defaulting geojson parsing to SRID 3857 instead of 4326
|
||||||
|
|
|
@ -78,7 +78,7 @@ L.U.AutoComplete = L.Class.extend({
|
||||||
break;
|
break;
|
||||||
case L.U.Keys.DOWN:
|
case L.U.Keys.DOWN:
|
||||||
if(this.RESULTS.length > 0) {
|
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.CURRENT++;
|
||||||
this.highlight();
|
this.highlight();
|
||||||
}
|
}
|
||||||
|
@ -168,7 +168,7 @@ L.U.AutoComplete = L.Class.extend({
|
||||||
else this.CACHE = val;
|
else this.CACHE = val;
|
||||||
this._do_search(val, function (data) {
|
this._do_search(val, function (data) {
|
||||||
this.handleResults(data.data);
|
this.handleResults(data.data);
|
||||||
});
|
}, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
createResult: function (item) {
|
createResult: function (item) {
|
||||||
|
@ -191,7 +191,7 @@ L.U.AutoComplete = L.Class.extend({
|
||||||
resultToIndex: function (result) {
|
resultToIndex: function (result) {
|
||||||
var out = null;
|
var out = null;
|
||||||
this.forEach(this.RESULTS, function (item, index) {
|
this.forEach(this.RESULTS, function (item, index) {
|
||||||
if (item.value == result.value) {
|
if (item.item.value == result.item.value) {
|
||||||
out = index;
|
out = index;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -215,12 +215,8 @@ L.U.AutoComplete = L.Class.extend({
|
||||||
highlight: function () {
|
highlight: function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.forEach(this.RESULTS, function (result, index) {
|
this.forEach(this.RESULTS, function (result, index) {
|
||||||
if (index === self.CURRENT) {
|
if (index === self.CURRENT) L.DomUtil.addClass(result.el, 'on');
|
||||||
L.DomUtil.addClass(result.el, 'on');
|
else L.DomUtil.removeClass(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();
|
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';
|
this.input.style.display = 'none';
|
||||||
L.DomEvent.on(close, 'click', function () {
|
L.DomEvent.on(close, 'click', function () {
|
||||||
this.selected_container.innerHTML = '';
|
this.selected_container.innerHTML = '';
|
||||||
this.options.on_unselect(result);
|
|
||||||
this.input.style.display = 'block';
|
this.input.style.display = 'block';
|
||||||
}, this);
|
}, this);
|
||||||
this.hide();
|
this.hide();
|
||||||
|
|
|
@ -665,15 +665,10 @@ L.FormBuilder.Range = L.FormBuilder.Input.extend({
|
||||||
L.FormBuilder.ManageOwner = L.FormBuilder.Element.extend({
|
L.FormBuilder.ManageOwner = L.FormBuilder.Element.extend({
|
||||||
|
|
||||||
build: function () {
|
build: function () {
|
||||||
var options = {className: 'edit-owner'};
|
var options = {
|
||||||
options.on_select = function (choice) {
|
className: 'edit-owner',
|
||||||
this._value = {
|
on_select: L.bind(this.onSelect, this)
|
||||||
'id': choice.item.value,
|
|
||||||
'name': choice.item.label,
|
|
||||||
'url': choice.item.url
|
|
||||||
};
|
};
|
||||||
this.set();
|
|
||||||
}
|
|
||||||
this.autocomplete = new L.U.AutoComplete.Ajax.Select(this.parentNode, options);
|
this.autocomplete = new L.U.AutoComplete.Ajax.Select(this.parentNode, options);
|
||||||
var owner = this.toHTML();
|
var owner = this.toHTML();
|
||||||
if (owner) this.autocomplete.displaySelected({'item': {'value': owner.id, 'label': owner.name}});
|
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 () {
|
value: function () {
|
||||||
return this._value;
|
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({
|
L.FormBuilder.ManageEditors = L.FormBuilder.Element.extend({
|
||||||
|
|
||||||
build: function () {
|
build: function () {
|
||||||
var options = {className: 'edit-editors'};
|
var options = {
|
||||||
options.on_select = function (choice) {
|
className: 'edit-editors',
|
||||||
this._values.push({
|
on_select: L.bind(this.onSelect, this),
|
||||||
'id': choice.item.value,
|
on_unselect: L.bind(this.onUnselect, this)
|
||||||
'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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.autocomplete = new L.U.AutoComplete.Ajax.SelectMultiple(this.parentNode, options);
|
this.autocomplete = new L.U.AutoComplete.Ajax.SelectMultiple(this.parentNode, options);
|
||||||
this._values = this.toHTML();
|
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}});
|
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 () {
|
value: function () {
|
||||||
return this._values;
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -562,7 +562,7 @@ L.U.DataLayer = L.Evented.extend({
|
||||||
return this.geojsonToFeatures(geometry.geometries);
|
return this.geojsonToFeatures(geometry.geometries);
|
||||||
|
|
||||||
default:
|
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) {
|
if (layer) {
|
||||||
this.addLayer(layer);
|
this.addLayer(layer);
|
||||||
|
|
Loading…
Reference in a new issue