fix bugs in list calendar, related to selecting an event on the calendar, just after load, which is not yet in the scope of the list
This commit is contained in:
parent
244312aede
commit
14102508e1
2 changed files with 21 additions and 14 deletions
|
@ -365,7 +365,7 @@ Ox.ListCalendar = function(options, self) {
|
||||||
}),
|
}),
|
||||||
self.$durationInput = Ox.Input({
|
self.$durationInput = Ox.Input({
|
||||||
disabled: true,
|
disabled: true,
|
||||||
id: 'duration',
|
id: 'durationText',
|
||||||
label: 'Duration',
|
label: 'Duration',
|
||||||
labelWidth: 64,
|
labelWidth: 64,
|
||||||
width: 240
|
width: 240
|
||||||
|
@ -724,7 +724,7 @@ Ox.ListCalendar = function(options, self) {
|
||||||
var isUndefined = !!self.options.selected
|
var isUndefined = !!self.options.selected
|
||||||
&& !self.$list.value(self.options.selected, 'type');
|
&& !self.$list.value(self.options.selected, 'type');
|
||||||
self.selectedEvent = event.id || '';
|
self.selectedEvent = event.id || '';
|
||||||
if (!self.selectedPlace && isUndefined) {
|
if (!self.selectedEvent && isUndefined) {
|
||||||
// deselect triggered by selecting an undefined item,
|
// deselect triggered by selecting an undefined item,
|
||||||
// so do nothing
|
// so do nothing
|
||||||
} else {
|
} else {
|
||||||
|
@ -732,22 +732,28 @@ Ox.ListCalendar = function(options, self) {
|
||||||
self.$list.options({
|
self.$list.options({
|
||||||
selected: self.options.selected ? [self.options.selected] : []
|
selected: self.options.selected ? [self.options.selected] : []
|
||||||
});
|
});
|
||||||
selectItem({ids: self.$list.options('selected')});
|
selectItem({ids: self.$list.options('selected')}, event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectItem(data) {
|
function selectItem(data, event) {
|
||||||
// Select item in list
|
// Select item in list
|
||||||
var event, isUndefined, selectedEvent;
|
var fromCalendar = !!event, isUndefined, selectedEvent;
|
||||||
self.options.selected = data.ids.length ? data.ids[0] : '';
|
self.options.selected = data.ids.length ? data.ids[0] : '';
|
||||||
event = self.options.selected
|
event = event || (
|
||||||
? self.$list.value(self.options.selected) : {};
|
self.options.selected
|
||||||
isUndefined = !!self.options.selected
|
? self.$list.value(self.options.selected)
|
||||||
|
: {}
|
||||||
|
)
|
||||||
|
isUndefined = !fromCalendar && !!self.options.selected
|
||||||
&& !self.$list.value(self.options.selected, 'type');
|
&& !self.$list.value(self.options.selected, 'type');
|
||||||
|
if (!fromCalendar) {
|
||||||
selectedEvent = self.options.selected && !isUndefined
|
selectedEvent = self.options.selected && !isUndefined
|
||||||
? self.options.selected : '';
|
? self.options.selected
|
||||||
|
: '';
|
||||||
self.$calendar.options({selected: selectedEvent});
|
self.$calendar.options({selected: selectedEvent});
|
||||||
selectedEvent && self.$calendar.panToEvent();
|
selectedEvent && self.$calendar.panToEvent();
|
||||||
|
}
|
||||||
if (self.options.selected) {
|
if (self.options.selected) {
|
||||||
self.$eventName.options({title: event.name || ''});
|
self.$eventName.options({title: event.name || ''});
|
||||||
self.$eventTitle.show();
|
self.$eventTitle.show();
|
||||||
|
@ -755,7 +761,7 @@ Ox.ListCalendar = function(options, self) {
|
||||||
self.$eventForm.values(
|
self.$eventForm.values(
|
||||||
decodeValues(Ox.extend({}, event, {
|
decodeValues(Ox.extend({}, event, {
|
||||||
end: event.current ? '' : event.end,
|
end: event.current ? '' : event.end,
|
||||||
duration: Ox.formatDateRangeDuration(
|
durationText: Ox.formatDateRangeDuration(
|
||||||
event.start, event.end, true
|
event.start, event.end, true
|
||||||
)
|
)
|
||||||
}))
|
}))
|
||||||
|
|
|
@ -1673,6 +1673,7 @@ Ox.List = function(options, self) {
|
||||||
var pos = Ox.isNumber(id) ? id : getPositionById(id),
|
var pos = Ox.isNumber(id) ? id : getPositionById(id),
|
||||||
$item = self.$items[pos],
|
$item = self.$items[pos],
|
||||||
data = $item ? $item.options('data') : {};
|
data = $item ? $item.options('data') : {};
|
||||||
|
//Ox.print('List', 'that.value id key value pos', id, key, value, pos)
|
||||||
if (arguments.length == 1) {
|
if (arguments.length == 1) {
|
||||||
return data;
|
return data;
|
||||||
} else if (arguments.length == 2) {
|
} else if (arguments.length == 2) {
|
||||||
|
|
Loading…
Reference in a new issue