Skip to content

Commit

Permalink
Merge branch 'remove_gridhelper' into remove_gridhelper_001
Browse files Browse the repository at this point in the history
  • Loading branch information
guerler committed Dec 14, 2017
2 parents 52cee72 + d0a5a35 commit 5ed7b14
Show file tree
Hide file tree
Showing 57 changed files with 974 additions and 291 deletions.
21 changes: 7 additions & 14 deletions client/galaxy/scripts/apps/admin.js
Expand Up @@ -39,8 +39,7 @@ window.app = function app(options, bootstrapped) {
this.page.display(
new GridView({
url_base: `${Galaxy.root}admin/users_list`,
url_data: Galaxy.params,
dict_format: true
url_data: Galaxy.params
})
);
},
Expand All @@ -49,8 +48,7 @@ window.app = function app(options, bootstrapped) {
this.page.display(
new GridView({
url_base: `${Galaxy.root}admin/roles_list`,
url_data: Galaxy.params,
dict_format: true
url_data: Galaxy.params
})
);
},
Expand All @@ -59,8 +57,7 @@ window.app = function app(options, bootstrapped) {
this.page.display(
new GridView({
url_base: `${Galaxy.root}admin/groups_list`,
url_data: Galaxy.params,
dict_format: true
url_data: Galaxy.params
})
);
},
Expand All @@ -69,8 +66,7 @@ window.app = function app(options, bootstrapped) {
this.page.display(
new GridView({
url_base: `${Galaxy.root}admin_toolshed/browse_repositories`,
url_data: Galaxy.params,
dict_format: true
url_data: Galaxy.params
})
);
},
Expand All @@ -79,8 +75,7 @@ window.app = function app(options, bootstrapped) {
this.page.display(
new GridView({
url_base: `${Galaxy.root}admin/tool_versions_list`,
url_data: Galaxy.params,
dict_format: true
url_data: Galaxy.params
})
);
},
Expand All @@ -89,8 +84,7 @@ window.app = function app(options, bootstrapped) {
this.page.display(
new GridView({
url_base: `${Galaxy.root}admin/quotas_list`,
url_data: Galaxy.params,
dict_format: true
url_data: Galaxy.params
})
);
},
Expand All @@ -105,8 +99,7 @@ window.app = function app(options, bootstrapped) {
this.page.display(
new GridView({
url_base: `${Galaxy.root}forms/forms_list`,
url_data: Galaxy.params,
dict_format: true
url_data: Galaxy.params
})
);
},
Expand Down
15 changes: 11 additions & 4 deletions client/galaxy/scripts/apps/analysis.js
Expand Up @@ -47,6 +47,7 @@ window.app = function app(options, bootstrapped) {
"(/)tours(/)(:tour_id)": "show_tours",
"(/)user(/)": "show_user",
"(/)user(/)(:form_id)": "show_user_form",
"(/)openids(/)list": "show_openids",
"(/)pages(/)create(/)": "show_pages_create",
"(/)pages(/)edit(/)": "show_pages_edit",
"(/)pages(/)(:action_id)": "show_pages",
Expand Down Expand Up @@ -115,8 +116,7 @@ window.app = function app(options, bootstrapped) {
show_workflows_published: function() {
this.page.display(
new GridView({
url_base: `${Galaxy.root}workflow/list_published`,
dict_format: true
url_base: `${Galaxy.root}workflow/list_published`
})
);
},
Expand Down Expand Up @@ -157,11 +157,18 @@ window.app = function app(options, bootstrapped) {
);
},

show_openids: function() {
this.page.display(
new GridView({
url_base: `${Galaxy.root}user/openids_list`
})
);
},

show_datasets: function() {
this.page.display(
new GridView({
url_base: `${Galaxy.root}dataset/list`,
dict_format: true
url_base: `${Galaxy.root}dataset/list`
})
);
},
Expand Down
2 changes: 0 additions & 2 deletions client/galaxy/scripts/galaxy.pages.js
Expand Up @@ -332,7 +332,6 @@ WYMeditor.editor.prototype.dialog = function(dialogType, dialogFeatures, bodyHtm

var grid = new GridView({
url_base: item_info.list_ajax_url,
dict_format: true,
embedded: true
});
Galaxy.modal.show({
Expand Down Expand Up @@ -426,7 +425,6 @@ WYMeditor.editor.prototype.dialog = function(dialogType, dialogFeatures, bodyHtm

var grid = new GridView({
url_base: item_info.list_ajax_url,
dict_format: true,
embedded: true
});
Galaxy.modal.show({
Expand Down
1 change: 0 additions & 1 deletion client/galaxy/scripts/mvc/history/history-list.js
Expand Up @@ -60,7 +60,6 @@ var View = Backbone.View.extend({
Utils.get({
url: `${Galaxy.root}history/${options.action_id}?${$.param(Galaxy.params)}`,
success: function(response) {
response.dict_format = true;
self.model.set(response);
self.render();
}
Expand Down
2 changes: 1 addition & 1 deletion client/galaxy/scripts/mvc/user/user-preferences.js
Expand Up @@ -62,7 +62,7 @@ var Model = Backbone.Model.extend({
description: _l("Associate OpenIDs with your account."),
icon: "fa-openid",
onclick: function() {
window.location.href = `${Galaxy.root}user/openid_manage?cntrller=user&use_panels=True`;
window.location.href = `${Galaxy.root}openids/list`;
}
},
custom_builds: {
Expand Down
1 change: 0 additions & 1 deletion client/galaxy/scripts/reports/grid/grid-shared.js
Expand Up @@ -10,7 +10,6 @@ var View = Backbone.View.extend({
$.ajax({
url: `${Galaxy.root + this.item}/${this.model.get("action_id")}?${$.param(Galaxy.params)}`,
success: function(response) {
response["dict_format"] = true;
self.model.set(response);
self.render();
}
Expand Down
1 change: 0 additions & 1 deletion client/galaxy/scripts/viz/trackster.js
Expand Up @@ -459,7 +459,6 @@ var TracksterView = Backbone.View.extend({
view_in_saved: function(dataset_params) {
var tracks_grid = new GridView({
url_base: `${Galaxy.root}visualization/list_tracks`,
dict_format: true,
embedded: true
});
Galaxy.modal.show({
Expand Down
2 changes: 0 additions & 2 deletions client/galaxy/scripts/viz/visualization.js
Expand Up @@ -46,14 +46,12 @@ var select_datasets = (filters, success_fn) => {
var history_grid = new GridView({
url_base: `${Galaxy.root}visualization/list_history_datasets`,
filters: filters,
dict_format: true,
embedded: true
});

// library dataset selection tab
var library_grid = new GridView({
url_base: `${Galaxy.root}visualization/list_library_datasets`,
dict_format: true,
embedded: true
});

Expand Down
15 changes: 0 additions & 15 deletions lib/galaxy/web/base/controller.py
Expand Up @@ -1289,21 +1289,6 @@ def get_all_forms(self, trans, all_versions=False, filter=None, form_type='All')
else:
return [fdc.latest_form for fdc in fdc_list if fdc.latest_form.type == form_type]

def field_param_values_ok(self, widget_name, widget_type, **kwd):
# Make sure required fields have contents, etc
params = util.Params(kwd)
if widget_type == 'AddressField':
if not util.restore_text(params.get('%s_short_desc' % widget_name, '')) \
or not util.restore_text(params.get('%s_name' % widget_name, '')) \
or not util.restore_text(params.get('%s_institution' % widget_name, '')) \
or not util.restore_text(params.get('%s_address' % widget_name, '')) \
or not util.restore_text(params.get('%s_city' % widget_name, '')) \
or not util.restore_text(params.get('%s_state' % widget_name, '')) \
or not util.restore_text(params.get('%s_postal_code' % widget_name, '')) \
or not util.restore_text(params.get('%s_country' % widget_name, '')):
return False
return True

def save_widget_field(self, trans, field_obj, widget_name, **kwd):
# Save a form_builder field object
params = util.Params(kwd)
Expand Down
62 changes: 1 addition & 61 deletions lib/galaxy/web/framework/helpers/grids.py
Expand Up @@ -10,7 +10,6 @@
from galaxy.util import restore_text, sanitize_text, unicodify
from galaxy.util.odict import odict
from galaxy.web.framework import decorators, url_for
from galaxy.web.framework.helpers import iff


log = logging.getLogger(__name__)
Expand All @@ -21,12 +20,8 @@ class Grid(object):
Specifies the content and format of a grid (data table).
"""
title = ""
exposed = True
model_class = None
show_item_checkboxes = False
template = "grid_base.mako"
async_template = "grid_base_async.mako"
use_async = False
use_hide_message = True
global_actions = []
columns = []
Expand All @@ -35,14 +30,12 @@ class Grid(object):
# Any columns that are filterable (either standard or advanced) should have a default value set in the default filter.
default_filter = {}
default_sort_key = None
preserve_state = False
use_paging = False
num_rows_per_page = 25
num_page_links = 10
# Set preference names.
cur_filter_pref_name = ".filter"
cur_sort_key_pref_name = ".sort_key"
pass_through_operations = {}
legend = None
info_text = None

Expand All @@ -65,22 +58,13 @@ def __call__(self, trans, **kwargs):
# FIXME: pretty sure this is only here to pass along, can likely be eliminated
status = kwargs.get('status', None)
message = kwargs.get('message', None)
dict_format = kwargs.get('dict_format', False)
# Build a base filter and sort key that is the combination of the saved state and defaults.
# Saved state takes preference over defaults.
base_filter = {}
if self.default_filter:
# default_filter is a dictionary that provides a default set of filters based on the grid's columns.
base_filter = self.default_filter.copy()
base_sort_key = self.default_sort_key
if self.preserve_state:
pref_name = text_type(self.__class__.__name__ + self.cur_filter_pref_name)
if pref_name in trans.get_user().preferences:
saved_filter = loads(trans.get_user().preferences[pref_name])
base_filter.update(saved_filter)
pref_name = text_type(self.__class__.__name__ + self.cur_sort_key_pref_name)
if pref_name in trans.get_user().preferences:
base_sort_key = loads(trans.get_user().preferences[pref_name])
# Build initial query
query = self.build_initial_query(trans, **kwargs)
query = self.apply_query_filter(trans, query, **kwargs)
Expand Down Expand Up @@ -228,26 +212,11 @@ def loads_recurse(item):
# There are some places in grid templates where it's useful for a grid
# to have its current filter.
self.cur_filter_dict = cur_filter_dict
# Preserve grid state: save current filter and sort key.
if self.preserve_state:
pref_name = text_type(self.__class__.__name__ + self.cur_filter_pref_name)
trans.get_user().preferences[pref_name] = text_type(dumps(cur_filter_dict))
if sort_key:
pref_name = text_type(self.__class__.__name__ + self.cur_sort_key_pref_name)
trans.get_user().preferences[pref_name] = text_type(dumps(sort_key))
trans.sa_session.flush()

# Log grid view.
context = text_type(self.__class__.__name__)
params = cur_filter_dict.copy()
params['sort'] = sort_key
params['async'] = ('async' in kwargs)

# TODO:??
# commenting this out; when this fn calls session.add( action ) and session.flush the query from this fn
# is effectively 'wiped' out. Nate believes it has something to do with our use of session( autocommit=True )
# in mapping.py. If you change that to False, the log_action doesn't affect the query
# Below, I'm rendering the template first (that uses query), then calling log_action, then returning the page
# trans.log_action( trans.get_user(), text_type( "grid.view" ), context, params )

# Render grid.
def url(*args, **kwargs):
Expand Down Expand Up @@ -280,43 +249,14 @@ def url(*args, **kwargs):

self.use_panels = (kwargs.get('use_panels', False) in [True, 'True', 'true'])
self.advanced_search = (kwargs.get('advanced_search', False) in [True, 'True', 'true'])
async_request = ((self.use_async) and (kwargs.get('async', False) in [True, 'True', 'true']))
# Currently, filling the template returns a str object; this requires decoding the string into a
# unicode object within mako templates. What probably should be done is to return the template as
# utf-8 unicode; however, this would require encoding the object as utf-8 before returning the grid
# results via a controller method, which is require substantial changes. Hence, for now, return grid
# as str.
if not dict_format:
page = trans.fill_template(iff(async_request, self.async_template, self.template),
grid=self,
query=query,
cur_page_num=page_num,
num_pages=num_pages,
num_page_links=self.num_page_links,
default_filter_dict=self.default_filter,
cur_filter_dict=cur_filter_dict,
sort_key=sort_key,
current_item=current_item,
ids=kwargs.get('id', []),
url=url,
status=status,
message=message,
info_text=self.info_text,
use_panels=self.use_panels,
use_hide_message=self.use_hide_message,
advanced_search=self.advanced_search,
show_item_checkboxes=(self.show_item_checkboxes or
kwargs.get('show_item_checkboxes', '') in ['True', 'true']),
# Pass back kwargs so that grid template can set and use args without
# grid explicitly having to pass them.
kwargs=kwargs)
trans.log_action(trans.get_user(), text_type("grid.view"), context, params)
return page

grid_config = {
'title' : self.title,
'url_base' : trans.request.path_url,
'async' : self.use_async,
'async_ops' : [],
'categorical_filters' : {},
'filters' : cur_filter_dict,
Expand Down
1 change: 1 addition & 0 deletions lib/galaxy/webapps/galaxy/buildapp.py
Expand Up @@ -106,6 +106,7 @@ def app_factory(global_conf, load_app_kwds={}, **kwargs):
webapp.add_client_route('/tours/{tour_id}')
webapp.add_client_route('/user')
webapp.add_client_route('/user/{form_id}')
webapp.add_client_route('/openids/list')
webapp.add_client_route('/visualizations/list_published')
webapp.add_client_route('/visualizations/list')
webapp.add_client_route('/visualizations/edit')
Expand Down

0 comments on commit 5ed7b14

Please sign in to comment.