when updating a value in a list with an items array, pass new items array (fixes #829)

This commit is contained in:
rlx 2012-06-13 08:00:02 +00:00
parent fbbe1e256a
commit 79bb322112

View file

@ -394,13 +394,10 @@ Ox.CalendarEditor = function(options, self) {
values = data.id == 'name' ? [data.data.value] : data.data.value;
Ox.forEach(self.options.events, function(event) {
Ox.forEach(values, function(value) {
if (
event.type
&& (
event.name == data.data.value
|| event.alternativeNames.indexOf(data.data.value) > -1
)
) {
if (event.type && (
event.name == data.data.value
|| event.alternativeNames.indexOf(data.data.value) > -1
)) {
exists = value;
Ox.Break();
}
@ -649,17 +646,6 @@ Ox.CalendarEditor = function(options, self) {
self.$defineEventButton.options({title: 'Clear Event'});
}
function encodeValues(place) {
return Ox.map(place, function(value) {
var type = Ox.typeOf(value);
return type == 'string' ? Ox.encodeHTMLEntities(value)
: type == 'array' ? Ox.map(value, function(value) {
return encodeValues(value);
})
: value;
});
}
function editEvent(key, value) {
var id = self.selectedEvent,
index = Ox.getIndexById(self.options.events, id),
@ -668,7 +654,10 @@ Ox.CalendarEditor = function(options, self) {
self.options.editEvent(encodeValues(data), function(result) {
if (result.status.code == 200) {
self.options.events[index][key] = value;
self.$list.value(id, key, value);
if (self.options.hasMatches) {
self.options.events[index].matches = result.data.matches;
}
self.$list.options({items: Ox.clone(self.options.events, true)});
self.$calendar.editEvent(id, key, value);
if (key == 'name') {
self.$eventName.options({title: value});
@ -682,8 +671,7 @@ Ox.CalendarEditor = function(options, self) {
)
);
}
self.$list.value(id, 'matches', result.data.matches);
self.$matchesInput.value(result.data.matches);
self.options.hasMatches && self.$matchesInput.value(result.data.matches);
self.options.mode == 'define' && self.$removeEventButton.options({
disabled: !!result.data.matches
});
@ -693,6 +681,17 @@ Ox.CalendarEditor = function(options, self) {
});
}
function encodeValues(place) {
return Ox.map(place, function(value) {
var type = Ox.typeOf(value);
return type == 'string' ? Ox.encodeHTMLEntities(value)
: type == 'array' ? Ox.map(value, function(value) {
return encodeValues(value);
})
: value;
});
}
function initList(data) {
self.$status.html(
Ox.formatNumber(data.items) + ' Event' + (