From 79bb3221123858c60d202991d6c89ef02ddd8ab9 Mon Sep 17 00:00:00 2001 From: rlx <0x0073@0x2620.org> Date: Wed, 13 Jun 2012 08:00:02 +0000 Subject: [PATCH] when updating a value in a list with an items array, pass new items array (fixes #829) --- source/Ox.UI/js/Calendar/CalendarEditor.js | 41 +++++++++++----------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/source/Ox.UI/js/Calendar/CalendarEditor.js b/source/Ox.UI/js/Calendar/CalendarEditor.js index b18ab53e..31b35e25 100644 --- a/source/Ox.UI/js/Calendar/CalendarEditor.js +++ b/source/Ox.UI/js/Calendar/CalendarEditor.js @@ -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' + (