allow for editing of alternative names
This commit is contained in:
parent
7eb6f58312
commit
c99e7af1bd
4 changed files with 37 additions and 19 deletions
|
@ -180,8 +180,8 @@ Ox.load('Geo', function() {
|
||||||
})
|
})
|
||||||
.bindEvent({
|
.bindEvent({
|
||||||
geocode: function(event, data) {
|
geocode: function(event, data) {
|
||||||
Ox.print(event)
|
//Ox.print(data);
|
||||||
Ox.print(JSON.stringify(data))
|
Ox.print(JSON.stringify(data.results))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.appendTo(Ox.UI.$body);
|
.appendTo(Ox.UI.$body);
|
||||||
|
|
|
@ -337,7 +337,10 @@ Ox.Element = function() {
|
||||||
].indexOf(event) == -1) {
|
].indexOf(event) == -1) {
|
||||||
Ox.print(that.id, self.options.id, 'trigger', event, data);
|
Ox.print(that.id, self.options.id, 'trigger', event, data);
|
||||||
}
|
}
|
||||||
self.$eventHandler.trigger('ox_' + event, data);
|
// it is necessary to check if self.$eventHandler exists,
|
||||||
|
// since, for example, when removing the element on click,
|
||||||
|
// singleclick will fire after the removal of the event handler
|
||||||
|
self.$eventHandler && self.$eventHandler.trigger('ox_' + event, data);
|
||||||
});
|
});
|
||||||
return that;
|
return that;
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,7 +5,7 @@ Ox.ArrayInput = function(options, self) {
|
||||||
.defaults({
|
.defaults({
|
||||||
label: '',
|
label: '',
|
||||||
max: 0,
|
max: 0,
|
||||||
sort: false,
|
sort: false, // fixme: this should probably be removed
|
||||||
value: [],
|
value: [],
|
||||||
width: 256
|
width: 256
|
||||||
})
|
})
|
||||||
|
@ -50,6 +50,7 @@ Ox.ArrayInput = function(options, self) {
|
||||||
.bindEvent({
|
.bindEvent({
|
||||||
change: function(data) {
|
change: function(data) {
|
||||||
self.options.sort && data.value !== '' && sortInputs();
|
self.options.sort && data.value !== '' && sortInputs();
|
||||||
|
that.triggerEvent('change', {value: that.value()});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.appendTo(self.$element[i]));
|
.appendTo(self.$element[i]));
|
||||||
|
@ -62,7 +63,12 @@ Ox.ArrayInput = function(options, self) {
|
||||||
.css({float: 'left', marginLeft: '8px'})
|
.css({float: 'left', marginLeft: '8px'})
|
||||||
.bind({
|
.bind({
|
||||||
click: function() {
|
click: function() {
|
||||||
removeInput($(this).parent().data('index'));
|
var index = $(this).parent().data('index');
|
||||||
|
if (self.$input[index].value() !== '') {
|
||||||
|
self.$input[index].options({value: ''});
|
||||||
|
that.triggerEvent('change', {value: that.value()});
|
||||||
|
}
|
||||||
|
removeInput(index);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.appendTo(self.$element[i]));
|
.appendTo(self.$element[i]));
|
||||||
|
@ -132,12 +138,13 @@ Ox.ArrayInput = function(options, self) {
|
||||||
|
|
||||||
self.setOption = function(key, value) {
|
self.setOption = function(key, value) {
|
||||||
if (key == 'value') {
|
if (key == 'value') {
|
||||||
|
Ox.print('--value--', value, self.$input)
|
||||||
if (self.options.value.length == 0) {
|
if (self.options.value.length == 0) {
|
||||||
self.options.value = [''];
|
self.options.value = [''];
|
||||||
}
|
}
|
||||||
self.$input && self.$input.forEach(function($input, i) {
|
while (self.$input.length) {
|
||||||
removeInput(i);
|
removeInput(0);
|
||||||
});
|
}
|
||||||
self.options.value.forEach(function(value, i) {
|
self.options.value.forEach(function(value, i) {
|
||||||
addInput(i, value);
|
addInput(i, value);
|
||||||
});
|
});
|
||||||
|
|
|
@ -362,22 +362,27 @@ Ox.ListMap = function(options, self) {
|
||||||
country = Ox.getCountryByGeoname(geoname),
|
country = Ox.getCountryByGeoname(geoname),
|
||||||
countryCode = country ? country.code : '',
|
countryCode = country ? country.code : '',
|
||||||
isResult = self.selectedPlace[0] == '_';
|
isResult = self.selectedPlace[0] == '_';
|
||||||
if (!isResult) {
|
|
||||||
self.$list.value(self.selectedPlace, 'geoname', geoname);
|
|
||||||
self.$list.value(self.selectedPlace, 'countryCode', countryCode);
|
|
||||||
}
|
|
||||||
//self.$map.value(self.selectedPlace, 'geoname', geoname);
|
//self.$map.value(self.selectedPlace, 'geoname', geoname);
|
||||||
self.$placeTitleFlag.attr({
|
self.$placeTitleFlag.attr({
|
||||||
src: Ox.getImageByGeoname('icon', 16, geoname)
|
src: Ox.getImageByGeoname('icon', 16, geoname)
|
||||||
});
|
});
|
||||||
self.$placeTitleName.options({title: geoname});
|
self.$placeTitleName.options({title: geoname});
|
||||||
|
self.$placeForm.values({countryCode: countryCode});
|
||||||
if (!self.isAsync) {
|
if (!self.isAsync) {
|
||||||
|
if (!isResult) {
|
||||||
} else {
|
self.$list.value(self.selectedPlace, 'geoname', geoname);
|
||||||
editPlace(['geoname']);
|
self.$list.value(self.selectedPlace, 'countryCode', countryCode);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
editPlace(['countryCode', 'geoname']);
|
||||||
|
}
|
||||||
|
self.$map.value(self.selectedPlace, 'countryCode', countryCode);
|
||||||
|
self.$map.value(self.selectedPlace, 'geoname', geoname);
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
Ox.Input({
|
||||||
|
id: 'countryCode'
|
||||||
|
}).hide(),
|
||||||
Ox.ArrayInput({
|
Ox.ArrayInput({
|
||||||
id: 'alternativeNames',
|
id: 'alternativeNames',
|
||||||
label: 'Alternative Names',
|
label: 'Alternative Names',
|
||||||
|
@ -387,7 +392,12 @@ Ox.ListMap = function(options, self) {
|
||||||
width: 240
|
width: 240
|
||||||
}).bindEvent({
|
}).bindEvent({
|
||||||
change: function(data) {
|
change: function(data) {
|
||||||
Ox.print('CHANGE........', data)
|
if (!self.isAsync) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
editPlace(['alternativeNames'])
|
||||||
|
}
|
||||||
|
self.$map.value(self.selectedPlace, 'alternativeNames', data.value);
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
], ['South', 'West', 'North', 'East', 'Latitude', 'Longitude'].map(function(v) {
|
], ['South', 'West', 'North', 'East', 'Latitude', 'Longitude'].map(function(v) {
|
||||||
|
@ -397,7 +407,7 @@ Ox.ListMap = function(options, self) {
|
||||||
max = ['Latitude', 'South', 'North'].indexOf(v) > -1 ? Ox.MAX_LATITUDE : 180;
|
max = ['Latitude', 'South', 'North'].indexOf(v) > -1 ? Ox.MAX_LATITUDE : 180;
|
||||||
return Ox.Input({
|
return Ox.Input({
|
||||||
decimals: 8,
|
decimals: 8,
|
||||||
disabled: ['Latitude', 'Longitude'].indexOf(v) > -1,
|
disabled: true, // ['Latitude', 'Longitude'].indexOf(v) > -1,
|
||||||
id: id,
|
id: id,
|
||||||
label: v,
|
label: v,
|
||||||
labelWidth: 80,
|
labelWidth: 80,
|
||||||
|
@ -648,9 +658,7 @@ Ox.ListMap = function(options, self) {
|
||||||
});
|
});
|
||||||
self.$placeTitleName.options({title: place.geoname || ''});
|
self.$placeTitleName.options({title: place.geoname || ''});
|
||||||
self.$placeTitle.show();
|
self.$placeTitle.show();
|
||||||
self.$placeForm.values(Ox.map(place, function(val, key) {
|
self.$placeForm.values(place).show();
|
||||||
return key == 'size' ? Ox.formatArea(val) : val;
|
|
||||||
})).show();
|
|
||||||
self.$placeButton.options({title: isResult ? 'Add Place' : 'Remove Place'});
|
self.$placeButton.options({title: isResult ? 'Add Place' : 'Remove Place'});
|
||||||
self.$revertButton.options({disabled: true}).show();
|
self.$revertButton.options({disabled: true}).show();
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue