undefined places/events

This commit is contained in:
j 2012-02-01 17:21:10 +00:00
parent 8bab6a9c0c
commit 2ce6b0af9a

View file

@ -169,7 +169,7 @@ Ox.AnnotationFolder = function(options, self) {
.bindEvent({
// FIXME: should be select, not selectplace
selectplace: function(data) {
if (!data.id && self.options.selected && Ox.getObjectById(self.options.items, self.options.selected).place) {
if (!data.id && self.options.selected && Ox.getObjectById(self.options.items, self.options.selected).place.defined) {
// only deselect annotation if the place deselect was not
// caused by switching to an annotation without place
self.$annotations.options({selected: ''});
@ -335,7 +335,7 @@ Ox.AnnotationFolder = function(options, self) {
function getEvents() {
var events = [];
self.annotations.filter(function(item) {
return !!(item.event && item.event.defined);
return !!item.event.defined;
}).forEach(function(item) {
var index = Ox.getIndexById(events, item.event.id);
if (index == -1) {
@ -352,7 +352,7 @@ Ox.AnnotationFolder = function(options, self) {
function getPlaces() {
var places = [];
self.annotations.filter(function(item) {
return !!(item.place && item.place.defined);
return !!item.place.defined;
}).forEach(function(item) {
var index = Ox.getIndexById(places, item.place.id);
if (index == -1) {
@ -379,7 +379,7 @@ Ox.AnnotationFolder = function(options, self) {
self.editing = false;
if (self.widget) {
item = Ox.getObjectById(self.options.items, data.id);
if (item[self.options.type]) {
if (item[self.options.type].defined) {
if (self.options.type == 'event') {
self.$calendar.removeEvent(data.id);
} else {
@ -398,12 +398,12 @@ Ox.AnnotationFolder = function(options, self) {
if (self.widget) {
if (self.options.type == 'event') {
self.$calendar.options({
selected: item && item.event ? item.event.id : ''
selected: item && item.event.defined ? item.event.id : ''
})
.panToEvent();
} else {
self.$map.options({
selected: item && item.place ? item.place.id : ''
selected: item && item.place.defined ? item.place.id : ''
})
.panToPlace();
}
@ -423,9 +423,9 @@ Ox.AnnotationFolder = function(options, self) {
// which is an EditableElement without .data('id')
if (
$element.data('id')
&& !(Ox.getObjectById(
&& !Ox.getObjectById(
self.options.items, $element.data('id')
)[self.options.type] || {}).defined
)[self.options.type].defined
) {
$element.addClass('OxWarning');
}
@ -578,7 +578,7 @@ Ox.AnnotationFolder = function(options, self) {
});
self.options.selected = item.id;
self.$annotations.options({selected: self.options.selected});
if (self.widget && item[self.options.type]) {
if (self.widget && item[self.options.type].defined) {
// if updating has made the item match
// an event or place, then select it
self.$widget.options({selected: item[self.options.type].id});