diff --git a/static/js/pandora/filterDialog.js b/static/js/pandora/filterDialog.js index 0b125dc7..c68e229d 100644 --- a/static/js/pandora/filterDialog.js +++ b/static/js/pandora/filterDialog.js @@ -3,24 +3,13 @@ pandora.ui.filterDialog = function(list) { var that = Ox.Dialog({ buttons: [ - /* - Ox.Button({ - id: 'cancel', - title: 'Cancel' - }) - .bindEvent({ - click: function() { - pandora.$ui.filterDialog.close(); - } - }), - */ Ox.Button({ id: 'done', title: 'Done' }) .bindEvent({ click: function() { - pandora.$ui.filterDialog.close(); + that.close(); } }) ], @@ -30,6 +19,7 @@ pandora.ui.filterDialog = function(list) { minWidth: 648 + Ox.UI.SCROLLBAR_SIZE, height: 264, // keys: {enter: 'save', escape: 'cancel'}, + removeOnClose: true, title: list ? 'Smart List - ' + list.name : 'Advanced Find', width: 648 + Ox.UI.SCROLLBAR_SIZE }); diff --git a/static/js/pandora/filterForm.js b/static/js/pandora/filterForm.js index 8fb41ee5..1475aad9 100644 --- a/static/js/pandora/filterForm.js +++ b/static/js/pandora/filterForm.js @@ -3,54 +3,70 @@ 'use strict'; pandora.ui.filterForm = function(list) { - var that = Ox.Filter({ - findKeys: Ox.merge(Ox.map(pandora.site.itemKeys, function(itemKey) { - var key = Ox.clone(itemKey); - key.type = key.type == 'layer' - ? Ox.getObjectById(pandora.site.layers, key.id).type - : key.type; - return key; - }), { - id: 'list', - title: 'List', - type: 'string' - }), - list: list ? null : { - sort: pandora.user.ui.listSort, - view: pandora.user.ui.listView - }, - query: Ox.clone(list ? list.query : pandora.user.ui.find, true), - sortKeys: pandora.site.sortKeys, - viewKeys: pandora.site.listViews - }) - .css({padding: '16px'}) - .bindEvent({ - change: function(data) { - if (list) { - pandora.api.editList({ - id: list.id, - query: data.query - }, function(result) { - Ox.Request.clearCache(list.id); - pandora.$ui.list - .bindEventOnce({ - init: function(data) { - pandora.$ui.folderList[ - pandora.getListData().folder - ].value(list.id, 'items', data.items); - } - }) - .reloadList(); - pandora.$ui.filters.forEach(function($filter) { - $filter.reloadList(); + var that = Ox.Element(); + pandora.api.findLists({ + query: { + conditions: [{key: 'type', value: 'static', operator: '='}], + operator: '&' + }, + keys: ['id'], + range: [0, 1000], + sort: [{key: 'user', operator: '+'}, {key: 'name', operator: '+'}] + }, function(result) { + that.append( + Ox.Filter({ + findKeys: Ox.merge(Ox.map(pandora.site.itemKeys, function(itemKey) { + var key = Ox.clone(itemKey); + key.type = key.type == 'layer' + ? Ox.getObjectById(pandora.site.layers, key.id).type + : key.type; + return key; + }), { + id: 'list', + title: 'List', + type: 'list', + values: result.data.items.map(function(item) { + return item.id; + }) + }), + list: list ? null : { + sort: pandora.user.ui.listSort, + view: pandora.user.ui.listView + }, + query: Ox.clone(list ? list.query : pandora.user.ui.find, true), + sortKeys: pandora.site.sortKeys, + viewKeys: pandora.site.listViews + }) + .css({padding: '16px'}) + .bindEvent({ + change: function(data) { + if (list) { + pandora.api.editList({ + id: list.id, + query: data.query + }, function(result) { + Ox.Request.clearCache(list.id); + pandora.$ui.list + .bindEventOnce({ + init: function(data) { + pandora.$ui.folderList[ + pandora.getListData().folder + ].value(list.id, 'items', data.items); + } + }) + .reloadList(); + pandora.$ui.filters.forEach(function($filter) { + $filter.reloadList(); + }); }); - }); - } else { - Ox.Log('FIND', 'change form', data.query, pandora.user.ui.find) - pandora.UI.set({find: Ox.clone(data.query, true)}); + } else { + Ox.Log('FIND', 'change form', data.query, pandora.user.ui.find) + pandora.UI.set({find: Ox.clone(data.query, true)}); + } } - } - }); + }) + ); + }); return that; }; diff --git a/static/js/pandora/findElement.js b/static/js/pandora/findElement.js index 3a67fec8..e27e9648 100644 --- a/static/js/pandora/findElement.js +++ b/static/js/pandora/findElement.js @@ -52,9 +52,7 @@ pandora.ui.findElement = function() { placeholder: 'Edit Query...', value: '' }); - (pandora.$ui.filterDialog || ( - pandora.$ui.filterDialog = pandora.ui.filterDialog() - )).open(); + pandora.$ui.filterDialog = pandora.ui.filterDialog().open(); } else { Ox.Log('FIND', pandora.$ui.findInput.value()) pandora.$ui.findInput.options({ @@ -80,9 +78,7 @@ pandora.ui.findElement = function() { focus: function(data) { if (pandora.$ui.findSelect.value() == 'advanced') { pandora.$ui.findInput.blurInput(); - (pandora.$ui.filterDialog || ( - pandora.$ui.filterDialog = pandora.ui.filterDialog() - )).open(); + pandora.$ui.filterDialog = pandora.ui.filterDialog().open(); } }, submit: function(data) {