2014-05-14 09:57:11 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
oml.ui.findForm = function(list) {
|
|
|
|
|
|
|
|
var ui = oml.user.ui,
|
|
|
|
|
|
|
|
that = Ox.Element(),
|
|
|
|
|
|
|
|
$filter = Ox.Filter({
|
|
|
|
findKeys: oml.config.itemKeys.map(function(key) {
|
|
|
|
return Ox.extend({}, key, {
|
|
|
|
title: Ox._(key.title),
|
2014-05-26 11:46:04 +00:00
|
|
|
type: key.id == 'mediastate' ? 'item' : key.type,
|
|
|
|
format: key.format && key.format.type == 'upper' ? void 0 : key.format
|
2014-05-14 09:57:11 +00:00
|
|
|
});
|
|
|
|
}).concat([{
|
|
|
|
id: 'list',
|
|
|
|
title: Ox._('List'),
|
|
|
|
type: 'item',
|
|
|
|
values: ui._lists.filter(function(list) {
|
2014-05-18 23:24:04 +00:00
|
|
|
return Ox.contains(['library', 'static'], list.type);
|
2014-05-14 09:57:11 +00:00
|
|
|
}).map(function(list) {
|
2016-01-12 04:46:32 +00:00
|
|
|
return {
|
|
|
|
id: list.id,
|
|
|
|
title: Ox.encodeHTMLEntities(list.title)
|
|
|
|
};
|
2014-05-14 09:57:11 +00:00
|
|
|
})
|
|
|
|
}]),
|
|
|
|
list: list ? null : {
|
|
|
|
sort: ui.listSort,
|
|
|
|
view: ui.listView
|
|
|
|
},
|
|
|
|
sortKeys: oml.config.sortKeys,
|
|
|
|
value: Ox.clone(list ? list.query : ui.find, true),
|
|
|
|
viewKeys: oml.config.listViews
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
change: function(data) {
|
|
|
|
(list ? oml.api.editList : Ox.noop)(list ? {
|
|
|
|
id: list.id,
|
|
|
|
query: data.value
|
|
|
|
} : {}, function(result) {
|
2016-01-12 04:46:32 +00:00
|
|
|
if (list || ui.updateResults) {
|
2016-01-14 08:41:52 +00:00
|
|
|
if (!list) {
|
|
|
|
oml.UI.set({find: Ox.clone(data.value, true)});
|
|
|
|
oml.$ui.findElement.updateElement();
|
|
|
|
}
|
|
|
|
oml.reloadLists();
|
2014-05-14 09:57:11 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.appendTo(that);
|
|
|
|
|
|
|
|
that.getList = $filter.getList;
|
|
|
|
that.value = $filter.value;
|
|
|
|
|
|
|
|
return that;
|
|
|
|
|
2014-05-22 12:17:23 +00:00
|
|
|
};
|