diff --git a/source/Ox.UI/js/Calendar/CalendarEditor.js b/source/Ox.UI/js/Calendar/CalendarEditor.js index cc745440..b18ab53e 100644 --- a/source/Ox.UI/js/Calendar/CalendarEditor.js +++ b/source/Ox.UI/js/Calendar/CalendarEditor.js @@ -259,7 +259,9 @@ Ox.CalendarEditor = function(options, self) { that.triggerEvent('loadlist'); }, open: openItem, - select: selectItem + select: function(data) { + selectItem(data); + } }); self.$listStatusbar = Ox.Bar({ @@ -577,16 +579,23 @@ Ox.CalendarEditor = function(options, self) { event.start = Ox.formatDate(startTime, '%Y-%m-%d %H:%M:%S', true); event.end = Ox.formatDate(endTime, '%Y-%m-%d %H:%M:%S', true); Ox.Log('Calendar', event); + self.$newEventButton.options({disabled: true}); + self.$removeEventButton.options({disabled: true}); self.options.addEvent(encodeValues(event), function(result) { if (result.status.code == '200') { event.id = result.data.id; + if (self.options.hasMatches) { + event.matches = result.data.matches; + } self.options.events.push(event); - var time0 = +new Date() + // var time0 = +new Date() self.$list.options({items: Ox.clone(self.options.events, true)}); - Ox.Log('Calendar', 'TIME TO SET LIST OPTIONS:', +new Date() - time0); + // Ox.Log('Calendar', 'TIME TO SET LIST OPTIONS:', +new Date() - time0); self.$calendar.addEvent(event); selectEvent(event); self.$nameInput.focusInput(true); + self.$newEventButton.options({disabled: false}); + self.$removeEventButton.options({disabled: false}); } else { // FIXME // alert(result.status.text); @@ -714,14 +723,18 @@ Ox.CalendarEditor = function(options, self) { function removeEvent() { var id = self.selectedEvent, index = Ox.getIndexById(self.options.events, id); + self.$newEventButton.options({disabled: true}); + self.$removeEventButton.options({disabled: true}); self.options.removeEvent({id: id}, function(result) { if (result.status.code == '200') { + selectEvent({}); self.options.events.splice(index, 1); var time0 = +new Date(); self.$list.options({items: Ox.clone(self.options.events, true)}); Ox.Log('Calendar', 'TIME TO SET LIST OPTIONS:', +new Date() - time0); self.$calendar.removeEvent(); - selectEvent({}); + self.$newEventButton.options({disabled: false}); + self.$removeEventButton.options({disabled: false}); } else { // FIXME // alert(result.status.text); @@ -754,7 +767,7 @@ Ox.CalendarEditor = function(options, self) { self.options.selected ? self.$list.value(self.options.selected) : {} - ) + ); isUndefined = !fromCalendar && !!self.options.selected && !self.$list.value(self.options.selected, 'type'); if (!fromCalendar) { @@ -794,7 +807,6 @@ Ox.CalendarEditor = function(options, self) { self.options.mode == 'define' && self.$defineEventButton.hide(); self.$removeEventButton.hide(); } - return; } function updateList(key, value) {