in manage places, reset form errors (fixes #576)
This commit is contained in:
parent
3ff120873b
commit
33ddaf8d9a
2 changed files with 22 additions and 27 deletions
|
@ -31,8 +31,6 @@ Ox.ListCalendar = function(options, self) {
|
||||||
height: self.options.height + 'px'
|
height: self.options.height + 'px'
|
||||||
});
|
});
|
||||||
|
|
||||||
Ox.print('LCO', self.options)
|
|
||||||
|
|
||||||
self.durationCache = {};
|
self.durationCache = {};
|
||||||
self.durationSize = {
|
self.durationSize = {
|
||||||
86400: 10,
|
86400: 10,
|
||||||
|
@ -73,7 +71,6 @@ Ox.ListCalendar = function(options, self) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
format: function(value, data) {
|
format: function(value, data) {
|
||||||
Ox.print('format', value, data)
|
|
||||||
return data.type
|
return data.type
|
||||||
? value
|
? value
|
||||||
: $('<span>').addClass('OxWarning').html(value);
|
: $('<span>').addClass('OxWarning').html(value);
|
||||||
|
@ -621,7 +618,6 @@ Ox.ListCalendar = function(options, self) {
|
||||||
data = {id: id};
|
data = {id: id};
|
||||||
data[key] = value;
|
data[key] = value;
|
||||||
self.options.editEvent(data, function(result) {
|
self.options.editEvent(data, function(result) {
|
||||||
Ox.print('EDIT EVENT::', result.data)
|
|
||||||
if (result.status.code == 200) {
|
if (result.status.code == 200) {
|
||||||
self.options.events[index][key] = value;
|
self.options.events[index][key] = value;
|
||||||
self.$list.value(id, key, value);
|
self.$list.value(id, key, value);
|
||||||
|
@ -713,7 +709,6 @@ Ox.ListCalendar = function(options, self) {
|
||||||
|
|
||||||
function selectItem(data) {
|
function selectItem(data) {
|
||||||
// Select item in list
|
// Select item in list
|
||||||
Ox.print('selectItem', data);
|
|
||||||
var event, isUndefined, selectedEvent;
|
var event, isUndefined, selectedEvent;
|
||||||
self.options.selected = data.ids.length ? data.ids[0] : '';
|
self.options.selected = data.ids.length ? data.ids[0] : '';
|
||||||
event = self.options.selected
|
event = self.options.selected
|
||||||
|
@ -724,7 +719,6 @@ Ox.ListCalendar = function(options, self) {
|
||||||
? self.options.selected : '';
|
? self.options.selected : '';
|
||||||
self.$calendar.options({selected: selectedEvent});
|
self.$calendar.options({selected: selectedEvent});
|
||||||
selectedEvent && self.$calendar.panToEvent();
|
selectedEvent && self.$calendar.panToEvent();
|
||||||
Ox.print('EVENT', event, self.options.hasMatches)
|
|
||||||
if (self.options.selected) {
|
if (self.options.selected) {
|
||||||
self.$eventName.options({title: event.name || ''});
|
self.$eventName.options({title: event.name || ''});
|
||||||
self.$eventTitle.show();
|
self.$eventTitle.show();
|
||||||
|
|
|
@ -817,8 +817,7 @@ Ox.ListMap = function(options, self) {
|
||||||
self.$map.removePlace().options({selected: ''});
|
self.$map.removePlace().options({selected: ''});
|
||||||
self.$findPlaceButton.show();
|
self.$findPlaceButton.show();
|
||||||
self.$placeFlag.hide();
|
self.$placeFlag.hide();
|
||||||
self.$placeForm.hide();
|
hideForm();
|
||||||
self.$areaKmInput.hide();
|
|
||||||
self.$definePlaceButton.options({disabled: false, title: 'Define Place'})
|
self.$definePlaceButton.options({disabled: false, title: 'Define Place'})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -829,13 +828,13 @@ Ox.ListMap = function(options, self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function editPlace(keys) {
|
function editPlace(keys) {
|
||||||
Ox.print('EDIT PLACE', keys, self.$placeForm.values())
|
Ox.Log('Map', 'EDIT PLACE', keys, self.$placeForm.values())
|
||||||
var values = Ox.filter(self.$placeForm.values(), function(values, key) {
|
var values = Ox.filter(self.$placeForm.values(), function(values, key) {
|
||||||
return keys.indexOf(key) > -1;
|
return keys.indexOf(key) > -1;
|
||||||
});
|
});
|
||||||
values.id = self.selectedPlace;
|
values.id = self.selectedPlace;
|
||||||
self.options.editPlace(values, function(result) {
|
self.options.editPlace(values, function(result) {
|
||||||
Ox.print('EDIT PLACE::', result)
|
Ox.Log('Map', 'EDIT PLACE::', result)
|
||||||
if (result.status.code == 200) {
|
if (result.status.code == 200) {
|
||||||
if (
|
if (
|
||||||
keys.indexOf(self.$list.options('sort')[0].key) > -1
|
keys.indexOf(self.$list.options('sort')[0].key) > -1
|
||||||
|
@ -886,6 +885,11 @@ Ox.ListMap = function(options, self) {
|
||||||
.options({find: self.$list.value(self.options.selected, 'name')});
|
.options({find: self.$list.value(self.options.selected, 'name')});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function hideForm() {
|
||||||
|
self.$placeForm.hide();
|
||||||
|
self.$areaKmInput.hide();
|
||||||
|
}
|
||||||
|
|
||||||
function initList(data) {
|
function initList(data) {
|
||||||
self.$status.html(
|
self.$status.html(
|
||||||
Ox.formatNumber(data.items) + ' Place' + (
|
Ox.formatNumber(data.items) + ' Place' + (
|
||||||
|
@ -935,7 +939,7 @@ Ox.ListMap = function(options, self) {
|
||||||
|
|
||||||
function selectItem(data, place) {
|
function selectItem(data, place) {
|
||||||
// Select item in list
|
// Select item in list
|
||||||
Ox.print('selectItem', data, place);
|
Ox.Log('Map', 'selectItem', data, place);
|
||||||
var isUndefined, selectedPlace;
|
var isUndefined, selectedPlace;
|
||||||
self.options.selected = data.ids.length ? data.ids[0] : '';
|
self.options.selected = data.ids.length ? data.ids[0] : '';
|
||||||
place = place || (
|
place = place || (
|
||||||
|
@ -955,13 +959,7 @@ Ox.ListMap = function(options, self) {
|
||||||
})[isUndefined ? 'hide' : 'show']();
|
})[isUndefined ? 'hide' : 'show']();
|
||||||
self.$placeName.options({title: place.name || ''});
|
self.$placeName.options({title: place.name || ''});
|
||||||
self.$placeTitle.show();
|
self.$placeTitle.show();
|
||||||
if (!isUndefined) {
|
!isUndefined ? showForm(place) : hideForm();
|
||||||
self.$placeForm.values(place).show();
|
|
||||||
self.$areaKmInput.value(Ox.formatArea(place.area)).show();
|
|
||||||
} else {
|
|
||||||
self.$placeForm.hide();
|
|
||||||
self.$areaKmInput.hide();
|
|
||||||
}
|
|
||||||
self.options.hasMatches && self.$matchesInput.value(place.matches || 0).show();
|
self.options.hasMatches && self.$matchesInput.value(place.matches || 0).show();
|
||||||
self.options.mode == 'define' && self.$definePlaceButton.options({
|
self.options.mode == 'define' && self.$definePlaceButton.options({
|
||||||
disabled: !isUndefined && !place.matches,
|
disabled: !isUndefined && !place.matches,
|
||||||
|
@ -973,8 +971,7 @@ Ox.ListMap = function(options, self) {
|
||||||
}).show();
|
}).show();
|
||||||
} else {
|
} else {
|
||||||
self.$placeTitle.hide();
|
self.$placeTitle.hide();
|
||||||
self.$placeForm.hide();
|
hideForm();
|
||||||
self.$areaKmInput.hide();
|
|
||||||
self.options.hasMatches && self.$matchesInput.hide();
|
self.options.hasMatches && self.$matchesInput.hide();
|
||||||
self.options.mode == 'define' && self.$definePlaceButton.hide();
|
self.options.mode == 'define' && self.$definePlaceButton.hide();
|
||||||
self.$addPlaceButton.hide();
|
self.$addPlaceButton.hide();
|
||||||
|
@ -983,7 +980,7 @@ Ox.ListMap = function(options, self) {
|
||||||
|
|
||||||
function selectPlace(place) {
|
function selectPlace(place) {
|
||||||
// Select place on map
|
// Select place on map
|
||||||
Ox.print('selectPlace', place)
|
Ox.Log('Map', 'selectPlace', place)
|
||||||
var isResult = !!place.id && place.id[0] == '_',
|
var isResult = !!place.id && place.id[0] == '_',
|
||||||
isUndefined = !!self.options.selected
|
isUndefined = !!self.options.selected
|
||||||
&& !self.$list.value(self.options.selected, 'type'),
|
&& !self.$list.value(self.options.selected, 'type'),
|
||||||
|
@ -999,8 +996,7 @@ Ox.ListMap = function(options, self) {
|
||||||
self.$placeFlag.attr({
|
self.$placeFlag.attr({
|
||||||
src: Ox.getFlagByGeoname(place.geoname || '', 16)
|
src: Ox.getFlagByGeoname(place.geoname || '', 16)
|
||||||
}).show();
|
}).show();
|
||||||
self.$placeForm.values(place).show();
|
showForm(place);
|
||||||
self.$areaKmInput.value(Ox.formatArea(place.area)).show();
|
|
||||||
editPlace([
|
editPlace([
|
||||||
'geoname', 'type',
|
'geoname', 'type',
|
||||||
'lat', 'lng',
|
'lat', 'lng',
|
||||||
|
@ -1014,8 +1010,7 @@ Ox.ListMap = function(options, self) {
|
||||||
}).show();
|
}).show();
|
||||||
self.$placeName.options({title: place.name || ''});
|
self.$placeName.options({title: place.name || ''});
|
||||||
self.$placeTitle.show();
|
self.$placeTitle.show();
|
||||||
self.$placeForm.values(place).show();
|
showForm(place);
|
||||||
self.$areaKmInput.value(Ox.formatArea(place.area)).show();
|
|
||||||
if (self.options.hasMatches) {
|
if (self.options.hasMatches) {
|
||||||
self.$matchesInput.value('').show();
|
self.$matchesInput.value('').show();
|
||||||
names = Ox.filter(Ox.merge([place.name], place.alternativeNames), function(name) {
|
names = Ox.filter(Ox.merge([place.name], place.alternativeNames), function(name) {
|
||||||
|
@ -1031,8 +1026,7 @@ Ox.ListMap = function(options, self) {
|
||||||
// deselect result place
|
// deselect result place
|
||||||
self.$placeFlag.hide();
|
self.$placeFlag.hide();
|
||||||
self.$placeTitle.hide();
|
self.$placeTitle.hide();
|
||||||
self.$placeForm.hide();
|
hideForm();
|
||||||
self.$areaKmInput.hide();
|
|
||||||
self.options.hasMatches && self.$matchesInput.hide();
|
self.options.hasMatches && self.$matchesInput.hide();
|
||||||
} else if (!self.selectedPlace && isUndefined) {
|
} else if (!self.selectedPlace && isUndefined) {
|
||||||
// deselect triggered by selecting an undefined item,
|
// deselect triggered by selecting an undefined item,
|
||||||
|
@ -1048,6 +1042,13 @@ Ox.ListMap = function(options, self) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function showForm(place) {
|
||||||
|
self.$nameInput.removeClass('OxError');
|
||||||
|
self.$alternativeNamesInput.setErrors([]);
|
||||||
|
self.$placeForm.values(place).show();
|
||||||
|
self.$areaKmInput.value(Ox.formatArea(place.area)).show();
|
||||||
|
}
|
||||||
|
|
||||||
function toFixed(val) {
|
function toFixed(val) {
|
||||||
return Ox.isNumber(val) ? val.toFixed(3) : '';
|
return Ox.isNumber(val) ? val.toFixed(3) : '';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue