fix a bug where edited places would not be updated correctly

This commit is contained in:
rlx 2011-10-11 09:48:24 +00:00
parent 9fb30bf1af
commit db25eec98b
2 changed files with 13 additions and 8 deletions

View file

@ -474,6 +474,7 @@ Ox.ListCalendar = function(options, self) {
event.end = Ox.formatDate(endTime, '%Y-%m-%d %H:%M:%S', true); event.end = Ox.formatDate(endTime, '%Y-%m-%d %H:%M:%S', true);
Ox.print(event); Ox.print(event);
self.options.addEvent(event, function(result) { self.options.addEvent(event, function(result) {
if (result.status.code == '200') {
event.id = result.data.id; event.id = result.data.id;
self.options.events.push(event); self.options.events.push(event);
var time0 = +new Date() var time0 = +new Date()
@ -481,6 +482,9 @@ Ox.ListCalendar = function(options, self) {
Ox.print('TIME TO SET LIST OPTIONS:', +new Date() - time0); Ox.print('TIME TO SET LIST OPTIONS:', +new Date() - time0);
self.$calendar.addEvent(event); self.$calendar.addEvent(event);
selectEvent(event); selectEvent(event);
} else {
alert(result.status.code)
}
}); });
} }
@ -488,9 +492,9 @@ Ox.ListCalendar = function(options, self) {
var id = self.selectedEvent, var id = self.selectedEvent,
index = Ox.getPositionById(self.options.events, id), index = Ox.getPositionById(self.options.events, id),
data = {id: id}; data = {id: id};
data[key] = value;
self.options.editEvent(data, function(result) { self.options.editEvent(data, function(result) {
self.options.events[index][key] = value; self.options.events[index][key] = value;
data[key] = value;
self.$list.value(id, key, value); self.$list.value(id, key, value);
if (['name', 'type', 'start', 'end'].indexOf(key) > -1) { if (['name', 'type', 'start', 'end'].indexOf(key) > -1) {
self.$calendar.editEvent(id, key, value); self.$calendar.editEvent(id, key, value);

View file

@ -1178,6 +1178,7 @@ Ox.List = function(options, self) {
// fixme: no case where callback is set // fixme: no case where callback is set
// note: can't use selectNone here, // note: can't use selectNone here,
// since it'd trigger a select event // since it'd trigger a select event
Ox.print('SET SELECTED', ids)
var counter = 0; var counter = 0;
self.$items.forEach(function($item, pos) { self.$items.forEach(function($item, pos) {
if (isSelected(pos)) { if (isSelected(pos)) {