From 4486117744ed92138e5ae1fd404d8582aec858e9 Mon Sep 17 00:00:00 2001 From: Dannon Baker Date: Thu, 4 Dec 2014 11:38:16 -0500 Subject: [PATCH 01/20] Sanitize all user fields in cloud/index.mako --- templates/webapps/galaxy/cloud/index.mako | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/webapps/galaxy/cloud/index.mako b/templates/webapps/galaxy/cloud/index.mako index 309526fd651..3dbb0fa22e5 100644 --- a/templates/webapps/galaxy/cloud/index.mako +++ b/templates/webapps/galaxy/cloud/index.mako @@ -218,7 +218,7 @@ Credentials section of the AWS Console. %if share_string: - + %else: %endif %if ami: - + %endif %if bucket_default: - + %endif
From ccaa6334d7850212800a30e32755c2df635adce0 Mon Sep 17 00:00:00 2001 From: Dannon Baker Date: Thu, 4 Dec 2014 11:51:46 -0500 Subject: [PATCH 02/20] Remove unused cloud/run.mako; all functionality is rolled into cloud/index. --- templates/webapps/galaxy/cloud/run.mako | 41 ------------------------- 1 file changed, 41 deletions(-) delete mode 100644 templates/webapps/galaxy/cloud/run.mako diff --git a/templates/webapps/galaxy/cloud/run.mako b/templates/webapps/galaxy/cloud/run.mako deleted file mode 100644 index 98d1424a716..00000000000 --- a/templates/webapps/galaxy/cloud/run.mako +++ /dev/null @@ -1,41 +0,0 @@ -<%inherit file="/webapps/galaxy/base_panels.mako"/> - -<%def name="init()"> -<% - self.has_left_panel=False - self.has_right_panel=False - self.active_view="shared" - self.message_box_visible=False -%> - - - -<%def name="center_panel()"> -
-
-

Launching a Galaxy Cloud Instance

-%if error: -

${error}

-%elif instance: - %if kp_material: -

Very Important Key Pair Information

-

A new key pair named '${kp_name}' has been created in your AWS - account and will be used to access this instance via ssh. It is - very important that you save the following private key - as it is not saved on this Galaxy instance and will be permanently lost - once you leave this page. To do this, save the following key block as - a plain text file named '${kp_name}'.

-
${kp_material}
- %endif -

The instance '${instance.id} has been successfully launched using the - '${instance.image_id}' AMI.
Access it at http://${instance.public_dns_name}

-

SSH access is available using your private key '${kp_name}'.

-%else: -

Unknown failure, no instance. Please refer to your AWS console at https://console.aws.amazon.com

-%endif -
-
- - From d28c58d0dd645325738ce3cbfd073e6f41818b64 Mon Sep 17 00:00:00 2001 From: Dannon Baker Date: Thu, 4 Dec 2014 12:05:07 -0500 Subject: [PATCH 03/20] Don't trust user email rendered into page unescaped for Raven. --- templates/base/base_panels.mako | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/base/base_panels.mako b/templates/base/base_panels.mako index 64e1fd0d598..2f32a37b943 100644 --- a/templates/base/base_panels.mako +++ b/templates/base/base_panels.mako @@ -45,7 +45,7 @@ %endif From 51315a080cbe00c3856169a06d296f682ec23314 Mon Sep 17 00:00:00 2001 From: Dannon Baker Date: Thu, 4 Dec 2014 12:05:23 -0500 Subject: [PATCH 04/20] Trim trailing whitespace. --- templates/base/base_panels.mako | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/templates/base/base_panels.mako b/templates/base/base_panels.mako index 2f32a37b943..2e735c391ae 100644 --- a/templates/base/base_panels.mako +++ b/templates/base/base_panels.mako @@ -13,7 +13,7 @@ self.body_class="" self.require_javascript=False %> - + <%def name="init()"> ## Override @@ -62,7 +62,7 @@ 'libs/require', "mvc/ui" )} - + ## Handle AJAX (actually hidden iframe) upload tool diff --git a/templates/search/search.mako b/templates/search/search.mako index 01cf4981ca2..badfc49ff4c 100644 --- a/templates/search/search.mako +++ b/templates/search/search.mako @@ -2,7 +2,7 @@ <%def name="search_init()"> ${h.js( - 'libs/jquery/jquery', + 'libs/jquery/jquery', )} @@ -12,54 +12,54 @@
- +
From 5909dfbc6e8db34ec858bf6ba94b8a366ab6cb6f Mon Sep 17 00:00:00 2001 From: Dannon Baker Date: Thu, 4 Dec 2014 15:23:35 -0500 Subject: [PATCH 08/20] Fix search to work for at least datasets, hdas, etc. --- templates/search/index.mako | 138 +++++++++++++++++++++++++---------- templates/search/search.mako | 68 ----------------- 2 files changed, 99 insertions(+), 107 deletions(-) delete mode 100644 templates/search/search.mako diff --git a/templates/search/index.mako b/templates/search/index.mako index 78c3c8353f3..353943c74fa 100644 --- a/templates/search/index.mako +++ b/templates/search/index.mako @@ -1,52 +1,112 @@ - <%inherit file="/webapps/galaxy/base_panels.mako"/> -<%namespace file="/search/search.mako" import="search_init" /> -<%namespace file="/search/search.mako" import="search_dialog" /> <%def name="init()"> -<% - self.has_left_panel=False - self.has_right_panel=False - self.message_box_visible=False - self.active_view="shared" - self.overlay_visible=False -%> + <% + self.has_left_panel=False + self.has_right_panel=False + self.message_box_visible=False + self.active_view="shared" + self.overlay_visible=False + %> <%def name="stylesheets()"> -${parent.stylesheets()} - + ${parent.stylesheets()} + + + + +<%def name="javascripts()"> + ${parent.javascripts()} + ${h.js( + "libs/jquery/jquery", + )} + + <%def name="center_panel()"> -${search_init()} - -
-${search_dialog("search_format_output")} -
- - diff --git a/templates/search/search.mako b/templates/search/search.mako deleted file mode 100644 index badfc49ff4c..00000000000 --- a/templates/search/search.mako +++ /dev/null @@ -1,68 +0,0 @@ - -<%def name="search_init()"> - - ${h.js( - 'libs/jquery/jquery', -)} - - - -<%def name="search_dialog(output_format)"> - - - - -
- -
- -
- - - From 09046f869b46b651aa1410762ac15c3d943c8ee0 Mon Sep 17 00:00:00 2001 From: Dannon Baker Date: Thu, 4 Dec 2014 15:27:19 -0500 Subject: [PATCH 09/20] Disable search interface for right now -- I made it not broken in the previous commit, but nobody should be using this yet. --- lib/galaxy/webapps/galaxy/controllers/search.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/galaxy/webapps/galaxy/controllers/search.py b/lib/galaxy/webapps/galaxy/controllers/search.py index 1472a911a5c..79e6e8780fd 100644 --- a/lib/galaxy/webapps/galaxy/controllers/search.py +++ b/lib/galaxy/webapps/galaxy/controllers/search.py @@ -9,6 +9,11 @@ log = logging.getLogger( __name__ ) class SearchController( BaseUIController ): + @web.expose def index(self, trans): - return trans.fill_template( "search/index.mako" ) + """ + Not ready for human consumption, yet. Power users can still use the + search API. + """ + return trans.show_message("Sorry, the search interface isn't quite ready for use, yet.") From 14b2d98357f0241901f15a0ce373391884c19244 Mon Sep 17 00:00:00 2001 From: Dannon Baker Date: Thu, 4 Dec 2014 15:29:06 -0500 Subject: [PATCH 10/20] Tweak message and commentary for search controller. --- lib/galaxy/webapps/galaxy/controllers/search.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/galaxy/webapps/galaxy/controllers/search.py b/lib/galaxy/webapps/galaxy/controllers/search.py index 79e6e8780fd..4b33deb74e1 100644 --- a/lib/galaxy/webapps/galaxy/controllers/search.py +++ b/lib/galaxy/webapps/galaxy/controllers/search.py @@ -13,7 +13,7 @@ class SearchController( BaseUIController ): @web.expose def index(self, trans): """ - Not ready for human consumption, yet. Power users can still use the - search API. + Per the message, this is not ready for human consumption, yet. Power + users can still use the search API. """ - return trans.show_message("Sorry, the search interface isn't quite ready for use, yet.") + return trans.show_message("Sorry, the search interface isn't quite ready for use, yet. Watch the release notes and check back later!") From 61bf387a5cacde502c6061a08cb679cecf58570e Mon Sep 17 00:00:00 2001 From: Daniel Blankenberg Date: Thu, 4 Dec 2014 16:14:28 -0500 Subject: [PATCH 11/20] Some web sanitization for Data Managers and Biostar redirect. --- .../galaxy/controllers/data_manager.py | 20 ++++++++++--------- .../webapps/galaxy/biostar/post_redirect.mako | 2 +- .../data_manager/manage_data_table.mako | 4 ++-- .../webapps/galaxy/data_manager/view_job.mako | 6 +++--- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/lib/galaxy/webapps/galaxy/controllers/data_manager.py b/lib/galaxy/webapps/galaxy/controllers/data_manager.py index 703d1c01247..9310fc033d7 100644 --- a/lib/galaxy/webapps/galaxy/controllers/data_manager.py +++ b/lib/galaxy/webapps/galaxy/controllers/data_manager.py @@ -7,6 +7,8 @@ import pkg_resources; pkg_resources.require( "Paste" ) import paste.httpexceptions +from galaxy.web.framework.helpers import escape + #set up logger import logging log = logging.getLogger( __name__ ) @@ -18,8 +20,8 @@ class DataManager( BaseUIController ): not_is_admin = not trans.user_is_admin() if not_is_admin and not trans.app.config.enable_data_manager_user_view: raise paste.httpexceptions.HTTPUnauthorized( "This Galaxy instance is not configured to allow non-admins to view the data manager." ) - message = kwd.get( 'message' ) - status = kwd.get( 'status', 'info' ) + message = escape( kwd.get( 'message', '' ) ) + status = escape( kwd.get( 'status', 'info' ) ) return trans.fill_template( "data_manager/index.mako", data_managers=trans.app.data_managers, tool_data_tables=trans.app.tool_data_tables, view_only=not_is_admin, message=message, status=status ) @web.expose @@ -27,8 +29,8 @@ class DataManager( BaseUIController ): not_is_admin = not trans.user_is_admin() if not_is_admin and not trans.app.config.enable_data_manager_user_view: raise paste.httpexceptions.HTTPUnauthorized( "This Galaxy instance is not configured to allow non-admins to view the data manager." ) - message = kwd.get( 'message' ) - status = kwd.get( 'status', 'info' ) + message = escape( kwd.get( 'message', '' ) ) + status = escape( kwd.get( 'status', 'info' ) ) data_manager_id = kwd.get( 'id', None ) data_manager = trans.app.data_managers.get_manager( data_manager_id ) if data_manager is None: @@ -41,8 +43,8 @@ class DataManager( BaseUIController ): not_is_admin = not trans.user_is_admin() if not_is_admin and not trans.app.config.enable_data_manager_user_view: raise paste.httpexceptions.HTTPUnauthorized( "This Galaxy instance is not configured to allow non-admins to view the data manager." ) - message = kwd.get( 'message' ) - status = kwd.get( 'status', 'info' ) + message = escape( kwd.get( 'message', '' ) ) + status = escape( kwd.get( 'status', 'info' ) ) job_id = kwd.get( 'id', None ) try: job_id = trans.security.decode_id( job_id ) @@ -62,7 +64,7 @@ class DataManager( BaseUIController ): data_manager_json = loads( open( hda.get_file_name() ).read() ) except Exception, e: data_manager_json = {} - error_messages.append( "Unable to obtain data_table info for hda (%s): %s" % ( hda.id, e ) ) + error_messages.append( escape( "Unable to obtain data_table info for hda (%s): %s" % ( hda.id, e ) ) ) values = [] for key, value in data_manager_json.get( 'data_tables', {} ).iteritems(): values.append( ( key, value ) ) @@ -74,8 +76,8 @@ class DataManager( BaseUIController ): not_is_admin = not trans.user_is_admin() if not_is_admin and not trans.app.config.enable_data_manager_user_view: raise paste.httpexceptions.HTTPUnauthorized( "This Galaxy instance is not configured to allow non-admins to view the data manager." ) - message = kwd.get( 'message' ) - status = kwd.get( 'status', 'info' ) + message = escape( kwd.get( 'message', '' ) ) + status = escape( kwd.get( 'status', 'info' ) ) data_table_name = kwd.get( 'table_name', None ) if not data_table_name: return trans.response.send_redirect( web.url_for( controller="data_manager", action="index" ) ) diff --git a/templates/webapps/galaxy/biostar/post_redirect.mako b/templates/webapps/galaxy/biostar/post_redirect.mako index 839c61edb29..d2c40156ba1 100644 --- a/templates/webapps/galaxy/biostar/post_redirect.mako +++ b/templates/webapps/galaxy/biostar/post_redirect.mako @@ -18,7 +18,7 @@

If you are not automatically forwarded, click the button below:

%for input_name, input_value in form_inputs.items(): - + %endfor
diff --git a/templates/webapps/galaxy/data_manager/manage_data_table.mako b/templates/webapps/galaxy/data_manager/manage_data_table.mako index ca88380bac3..d6f642aeec9 100644 --- a/templates/webapps/galaxy/data_manager/manage_data_table.mako +++ b/templates/webapps/galaxy/data_manager/manage_data_table.mako @@ -14,9 +14,9 @@ <% column_name_list = data_table.get_column_name_list() %> - diff --git a/templates/webapps/galaxy/data_manager/view_job.mako b/templates/webapps/galaxy/data_manager/view_job.mako index 6487087beba..a005ba47b4a 100644 --- a/templates/webapps/galaxy/data_manager/view_job.mako +++ b/templates/webapps/galaxy/data_manager/view_job.mako @@ -26,8 +26,8 @@ - - + + @@ -47,7 +47,7 @@ %for j, table_row in enumerate( json_table ): %if len_json_table > 1: - + %endif %for name, value in table_row.iteritems(): From c14342b2cc04e16a55a1554e877de04aa04d94df Mon Sep 17 00:00:00 2001 From: Martin Cech Date: Fri, 5 Dec 2014 15:11:16 -0500 Subject: [PATCH 12/20] add API endpoint to un/mark library folder as deleted --- lib/galaxy/managers/folders.py | 49 ++++++++++++++++-------- lib/galaxy/model/__init__.py | 2 +- lib/galaxy/webapps/galaxy/api/folders.py | 28 +++++++++++++- 3 files changed, 62 insertions(+), 17 deletions(-) diff --git a/lib/galaxy/managers/folders.py b/lib/galaxy/managers/folders.py index 8093d38d177..1a21fd029b1 100644 --- a/lib/galaxy/managers/folders.py +++ b/lib/galaxy/managers/folders.py @@ -16,14 +16,14 @@ class FolderManager( object ): Interface/service object for interacting with folders. """ - def get( self, trans, decoded_folder_id, check_ownership=False, check_accessible=True): + def get( self, trans, decoded_folder_id, check_manageable=False, check_accessible=True): """ Get the folder from the DB. :param decoded_folder_id: decoded folder id :type decoded_folder_id: int - :param check_ownership: flag whether the check that user is owner - :type check_ownership: bool + :param check_manageable: flag whether the check that user can manage item + :type check_manageable: bool :param check_accessible: flag whether to check that user can access item :type check_accessible: bool @@ -38,17 +38,17 @@ class FolderManager( object ): raise exceptions.RequestParameterInvalidException( 'No folder found with the id provided.' ) except Exception, e: raise exceptions.InternalServerError( 'Error loading from the database.' + str( e ) ) - folder = self.secure( trans, folder, check_ownership, check_accessible ) + folder = self.secure( trans, folder, check_manageable, check_accessible ) return folder - def secure( self, trans, folder, check_ownership=True, check_accessible=True ): + def secure( self, trans, folder, check_manageable=True, check_accessible=True ): """ - Check if (a) user owns folder or (b) folder is accessible to user. + Check if (a) user can manage folder or (b) folder is accessible to user. :param folder: folder item :type folder: LibraryFolder - :param check_ownership: flag whether the check that user is owner - :type check_ownership: bool + :param check_manageable: flag whether to check that user can manage item + :type check_manageable: bool :param check_accessible: flag whether to check that user can access item :type check_accessible: bool @@ -58,23 +58,26 @@ class FolderManager( object ): # all folders are accessible to an admin if trans.user_is_admin(): return folder - if check_ownership: - folder = self.check_ownership( trans, folder ) + if check_manageable: + folder = self.check_manageable( trans, folder ) if check_accessible: folder = self.check_accessible( trans, folder ) return folder - def check_ownership( self, trans, folder ): + def check_manageable( self, trans, folder ): """ - Check whether the user is owner of the folder. + Check whether the user can manage the folder. :returns: the original folder :rtype: LibraryFolder + + :raises: AuthenticationRequired, InsufficientPermissionsException """ if not trans.user: - raise exceptions.AuthenticationRequired( "Must be logged in to manage Galaxy items", type='error' ) - if folder.user != trans.user: - raise exceptions.ItemOwnershipException( "Folder is not owned by the current user", type='error' ) + raise exceptions.AuthenticationRequired( "Must be logged in to manage Galaxy items.", type='error' ) + current_user_roles = trans.get_current_user_roles() + if not trans.app.security_agent.can_manage_library_item( current_user_roles, folder ): + raise exceptions.InsufficientPermissionsException( "You don't have permissions to manage this folder.", type='error' ) else: return folder @@ -135,6 +138,22 @@ class FolderManager( object ): trans.app.security_agent.copy_library_permissions( trans, parent_folder, new_folder ) return new_folder + def delete( self, trans, folder, undelete=False ): + """ + Mark given folder deleted/undeleted based on the flag. + + :raises: ItemAccessibilityException + """ + if not trans.user_is_admin(): + folder = self.check_manageable( trans, folder ) + if undelete: + folder.deleted = False + else: + folder.deleted = True + trans.sa_session.add( folder ) + trans.sa_session.flush() + return folder + def get_current_roles( self, trans, folder ): """ Find all roles currently connected to relevant permissions diff --git a/lib/galaxy/model/__init__.py b/lib/galaxy/model/__init__.py index e0984d8288a..c4bfd5523ef 100644 --- a/lib/galaxy/model/__init__.py +++ b/lib/galaxy/model/__init__.py @@ -2192,7 +2192,7 @@ class Library( object, Dictifiable, HasName ): return roles class LibraryFolder( object, Dictifiable, HasName ): - dict_element_visible_keys = ( 'id', 'parent_id', 'name', 'description', 'item_count', 'genome_build', 'update_time' ) + dict_element_visible_keys = ( 'id', 'parent_id', 'name', 'description', 'item_count', 'genome_build', 'update_time', 'deleted' ) def __init__( self, name=None, description=None, item_count=0, order_id=None ): self.name = name or "Unnamed folder" self.description = description diff --git a/lib/galaxy/webapps/galaxy/api/folders.py b/lib/galaxy/webapps/galaxy/api/folders.py index 283c7dc98ff..89c79c35888 100644 --- a/lib/galaxy/webapps/galaxy/api/folders.py +++ b/lib/galaxy/webapps/galaxy/api/folders.py @@ -44,7 +44,7 @@ class FoldersController( BaseAPIController, UsesLibraryMixin, UsesLibraryMixinIt :rtype: dict """ folder_id = self.folder_manager.cut_and_decode( trans, id ) - folder = self.folder_manager.get( trans, folder_id, check_ownership=False, check_accessible=True ) + folder = self.folder_manager.get( trans, folder_id, check_manageable=False, check_accessible=True ) return_dict = self.folder_manager.get_folder_dict( trans, folder ) return return_dict @@ -229,6 +229,32 @@ class FoldersController( BaseAPIController, UsesLibraryMixin, UsesLibraryMixinIt 'Allowed values are: "set_permissions"' ) return self.folder_manager.get_current_roles( trans, folder ) + @expose_api + def delete( self, trans, id, **kwd ): + """ + delete( self, trans, id, **kwd ) + * DELETE /api/folders/{id} + marks the folder with the given ``id`` as `deleted` (or removes the `deleted` mark if the `undelete` param is true) + + .. note:: Currently, only admin users can un/delete folders. + + :param id: the encoded id of the folder to un/delete + :type id: an encoded id string + + :param undelete: (optional) flag specifying whether the item should be deleted or undeleted, defaults to false: + :type undelete: bool + + :returns: detailed folder information + :rtype: dictionary + + :raises: ItemAccessibilityException, MalformedId, ObjectNotFound + """ + folder = self.folder_manager.get( trans, self.folder_manager.cut_and_decode( trans, id ), True ) + undelete = util.string_as_bool( kwd.get( 'undelete', False ) ) + folder = self.folder_manager.delete( trans, folder, undelete ) + folder_dict = self.folder_manager.get_folder_dict( trans, folder ) + return folder_dict + @web.expose_api def update( self, trans, id, library_id, payload, **kwd ): """ From 4833e183fd3e8460cb9f383977c9ba3516799448 Mon Sep 17 00:00:00 2001 From: Aysam Guerler Date: Wed, 3 Dec 2014 17:29:34 -0500 Subject: [PATCH 13/20] ToolForm: Add data collection parameter --- .../galaxy/scripts/mvc/tools/tools-section.js | 6 ++ .../scripts/mvc/tools/tools-select-content.js | 80 +++++++++++-------- lib/galaxy/tools/parameters/basic.py | 41 ++++++++++ static/scripts/mvc/tools/tools-section.js | 6 ++ .../scripts/mvc/tools/tools-select-content.js | 80 +++++++++++-------- .../scripts/packed/mvc/tools/tools-section.js | 2 +- .../packed/mvc/tools/tools-select-content.js | 2 +- 7 files changed, 149 insertions(+), 68 deletions(-) diff --git a/client/galaxy/scripts/mvc/tools/tools-section.js b/client/galaxy/scripts/mvc/tools/tools-section.js index 4c9f80303f9..c3406505bec 100644 --- a/client/galaxy/scripts/mvc/tools/tools-section.js +++ b/client/galaxy/scripts/mvc/tools/tools-section.js @@ -307,6 +307,11 @@ define(['utils/utils', 'mvc/ui/ui-table', 'mvc/ui/ui-misc', 'mvc/tools/tools-rep field = this._fieldData(input_def); break; + // collection selector + //case 'data_collection': + // field = this._fieldData(input_def); + // break; + // data column case 'data_column': field = this._fieldSelect(input_def); @@ -383,6 +388,7 @@ define(['utils/utils', 'mvc/ui/ui-table', 'mvc/ui/ui-misc', 'mvc/tools/tools-rep id : 'field-' + input_def.id, extensions : input_def.extensions, multiple : input_def.multiple, + type : input_def.type, data : input_def.options, onchange : function() { self.app.refresh(); diff --git a/client/galaxy/scripts/mvc/tools/tools-select-content.js b/client/galaxy/scripts/mvc/tools/tools-select-content.js index 3c3b3b5000b..23d673461c5 100644 --- a/client/galaxy/scripts/mvc/tools/tools-select-content.js +++ b/client/galaxy/scripts/mvc/tools/tools-select-content.js @@ -20,15 +20,23 @@ var View = Backbone.View.extend({ // radio button options var radio_buttons = []; - // set initial state - if (!options.multiple) { - this.current = 'single'; + // identify selector type + if (options.type == 'data_collection') { + this.mode = 'collection'; } else { - this.current = 'multiple'; + if (options.multiple) { + this.mode = 'multiple'; + } else { + this.mode = 'single'; + } } - + + // set initial state + this.current = this.mode; + this.list = {}; + // add single dataset selector - if (!options.multiple) { + if (this.mode == 'single') { radio_buttons.push({icon: 'fa-file-o', label : 'Single dataset', value : 'single'}); this.select_single = new Ui.Select.View({ onchange : function() { @@ -42,29 +50,33 @@ var View = Backbone.View.extend({ } // add multiple dataset selector - radio_buttons.push({icon: 'fa-files-o', label : 'Multiple datasets', value : 'multiple' }); - this.select_multiple = new Ui.Select.View({ - multiple : true, - onchange : function() { - self.trigger('change'); - } - }); - this.list['multiple'] = { - field: this.select_multiple, - type : 'hda' - }; + if (this.mode == 'single' || this.mode == 'multiple') { + radio_buttons.push({icon: 'fa-files-o', label : 'Multiple datasets', value : 'multiple' }); + this.select_multiple = new Ui.Select.View({ + multiple : true, + onchange : function() { + self.trigger('change'); + } + }); + this.list['multiple'] = { + field: this.select_multiple, + type : 'hda' + }; + } // add collection selector - radio_buttons.push({icon: 'fa-folder-o', label : 'List of datasets', value : 'collection' }); - this.select_collection = new Ui.Select.View({ - onchange : function() { - self.trigger('change'); - } - }); - this.list['collection'] = { - field: this.select_collection, - type : 'hdca' - }; + if (this.mode == 'single' || this.mode == 'collection') { + radio_buttons.push({icon: 'fa-folder-o', label : 'List of datasets', value : 'collection' }); + this.select_collection = new Ui.Select.View({ + onchange : function() { + self.trigger('change'); + } + }); + this.list['collection'] = { + field: this.select_collection, + type : 'hdca' + }; + } // create button this.button_type = new Ui.RadioButton.View({ @@ -81,7 +93,9 @@ var View = Backbone.View.extend({ this.$batch = $(ToolTemplate.batchMode()); // add elements to dom - this.$el.append(Utils.wrap(this.button_type.$el)); + if (_.size(this.list) > 1) { + this.$el.append(Utils.wrap(this.button_type.$el)); + } for (var i in this.list) { this.$el.append(this.list[i].field.$el); } @@ -144,8 +158,8 @@ var View = Backbone.View.extend({ // update selection fields this.select_single && this.select_single.update(dataset_options); - this.select_multiple.update(dataset_options); - this.select_collection.update(collection_options); + this.select_multiple && this.select_multiple.update(dataset_options); + this.select_collection && this.select_collection.update(collection_options); // add to content list this.app.content.add(options); @@ -167,7 +181,7 @@ var View = Backbone.View.extend({ this.current = 'collection'; this.select_collection.value(list[0]); } else { - if (list.length > 1 || this.options.multiple) { + if (this.mode == 'multiple') { this.current = 'multiple'; this.select_multiple.value(list); } else { @@ -195,7 +209,7 @@ var View = Backbone.View.extend({ // prepare result dict var result = { - batch : !this.options.multiple && this.current != 'single', + batch : this.mode == 'single' && this.current != 'single', values : [] } @@ -227,7 +241,7 @@ var View = Backbone.View.extend({ $el.hide(); } } - if (this.current != 'single' && !this.options.multiple) { + if (this.mode == 'single' && this.current != 'single') { this.$batch.show(); } else { this.$batch.hide(); diff --git a/lib/galaxy/tools/parameters/basic.py b/lib/galaxy/tools/parameters/basic.py index 5225c8e328c..498d2a9f37f 100644 --- a/lib/galaxy/tools/parameters/basic.py +++ b/lib/galaxy/tools/parameters/basic.py @@ -2310,6 +2310,47 @@ class DataCollectionToolParameter( BaseDataToolParameter ): return d + def to_dict( self, trans, view='collection', value_mapper=None, other_values=None ): + # create dictionary and fill default parameters + d = super( DataCollectionToolParameter, self ).to_dict( trans ) + d['multiple'] = self.multiple + d['is_dynamic'] = False + d['options'] = {'hda': [], 'hdca': []} + + # return default content if context is not available + if other_values is None: + return d + + # prepare dataset/collection matching + dataset_matcher = DatasetMatcher( trans, self, None, other_values ) + history = trans.history + + # append directly matched collections + for hdca in self.match_collections( trans, history, dataset_matcher ): + d['options']['hdca'].append({ + 'id' : trans.security.encode_id( hdca.id ), + 'id_uncoded' : hdca.id, + 'hid' : hdca.hid, + 'name' : hdca.name, + 'src' : 'hdca' + }) + + # append matching subcollections + for hdca in self.match_multirun_collections( trans, history, dataset_matcher ): + subcollection_type = self._history_query( trans ).collection_type_description.collection_type + d['options']['hdca'].append({ + 'id' : trans.security.encode_id( hdca.id ), + 'id_uncoded' : hdca.id, + 'hid' : hdca.hid, + 'name' : hdca.name, + 'src' : 'hdca' + }) + + # sort both lists + d['options']['hdca'] = sorted(d['options']['hdca'], key=lambda k: k['hid'], reverse=True) + + # return final dictionary + return d class HiddenDataToolParameter( HiddenToolParameter, DataToolParameter ): """ diff --git a/static/scripts/mvc/tools/tools-section.js b/static/scripts/mvc/tools/tools-section.js index 4c9f80303f9..c3406505bec 100644 --- a/static/scripts/mvc/tools/tools-section.js +++ b/static/scripts/mvc/tools/tools-section.js @@ -307,6 +307,11 @@ define(['utils/utils', 'mvc/ui/ui-table', 'mvc/ui/ui-misc', 'mvc/tools/tools-rep field = this._fieldData(input_def); break; + // collection selector + //case 'data_collection': + // field = this._fieldData(input_def); + // break; + // data column case 'data_column': field = this._fieldSelect(input_def); @@ -383,6 +388,7 @@ define(['utils/utils', 'mvc/ui/ui-table', 'mvc/ui/ui-misc', 'mvc/tools/tools-rep id : 'field-' + input_def.id, extensions : input_def.extensions, multiple : input_def.multiple, + type : input_def.type, data : input_def.options, onchange : function() { self.app.refresh(); diff --git a/static/scripts/mvc/tools/tools-select-content.js b/static/scripts/mvc/tools/tools-select-content.js index 3c3b3b5000b..23d673461c5 100644 --- a/static/scripts/mvc/tools/tools-select-content.js +++ b/static/scripts/mvc/tools/tools-select-content.js @@ -20,15 +20,23 @@ var View = Backbone.View.extend({ // radio button options var radio_buttons = []; - // set initial state - if (!options.multiple) { - this.current = 'single'; + // identify selector type + if (options.type == 'data_collection') { + this.mode = 'collection'; } else { - this.current = 'multiple'; + if (options.multiple) { + this.mode = 'multiple'; + } else { + this.mode = 'single'; + } } - + + // set initial state + this.current = this.mode; + this.list = {}; + // add single dataset selector - if (!options.multiple) { + if (this.mode == 'single') { radio_buttons.push({icon: 'fa-file-o', label : 'Single dataset', value : 'single'}); this.select_single = new Ui.Select.View({ onchange : function() { @@ -42,29 +50,33 @@ var View = Backbone.View.extend({ } // add multiple dataset selector - radio_buttons.push({icon: 'fa-files-o', label : 'Multiple datasets', value : 'multiple' }); - this.select_multiple = new Ui.Select.View({ - multiple : true, - onchange : function() { - self.trigger('change'); - } - }); - this.list['multiple'] = { - field: this.select_multiple, - type : 'hda' - }; + if (this.mode == 'single' || this.mode == 'multiple') { + radio_buttons.push({icon: 'fa-files-o', label : 'Multiple datasets', value : 'multiple' }); + this.select_multiple = new Ui.Select.View({ + multiple : true, + onchange : function() { + self.trigger('change'); + } + }); + this.list['multiple'] = { + field: this.select_multiple, + type : 'hda' + }; + } // add collection selector - radio_buttons.push({icon: 'fa-folder-o', label : 'List of datasets', value : 'collection' }); - this.select_collection = new Ui.Select.View({ - onchange : function() { - self.trigger('change'); - } - }); - this.list['collection'] = { - field: this.select_collection, - type : 'hdca' - }; + if (this.mode == 'single' || this.mode == 'collection') { + radio_buttons.push({icon: 'fa-folder-o', label : 'List of datasets', value : 'collection' }); + this.select_collection = new Ui.Select.View({ + onchange : function() { + self.trigger('change'); + } + }); + this.list['collection'] = { + field: this.select_collection, + type : 'hdca' + }; + } // create button this.button_type = new Ui.RadioButton.View({ @@ -81,7 +93,9 @@ var View = Backbone.View.extend({ this.$batch = $(ToolTemplate.batchMode()); // add elements to dom - this.$el.append(Utils.wrap(this.button_type.$el)); + if (_.size(this.list) > 1) { + this.$el.append(Utils.wrap(this.button_type.$el)); + } for (var i in this.list) { this.$el.append(this.list[i].field.$el); } @@ -144,8 +158,8 @@ var View = Backbone.View.extend({ // update selection fields this.select_single && this.select_single.update(dataset_options); - this.select_multiple.update(dataset_options); - this.select_collection.update(collection_options); + this.select_multiple && this.select_multiple.update(dataset_options); + this.select_collection && this.select_collection.update(collection_options); // add to content list this.app.content.add(options); @@ -167,7 +181,7 @@ var View = Backbone.View.extend({ this.current = 'collection'; this.select_collection.value(list[0]); } else { - if (list.length > 1 || this.options.multiple) { + if (this.mode == 'multiple') { this.current = 'multiple'; this.select_multiple.value(list); } else { @@ -195,7 +209,7 @@ var View = Backbone.View.extend({ // prepare result dict var result = { - batch : !this.options.multiple && this.current != 'single', + batch : this.mode == 'single' && this.current != 'single', values : [] } @@ -227,7 +241,7 @@ var View = Backbone.View.extend({ $el.hide(); } } - if (this.current != 'single' && !this.options.multiple) { + if (this.mode == 'single' && this.current != 'single') { this.$batch.show(); } else { this.$batch.hide(); diff --git a/static/scripts/packed/mvc/tools/tools-section.js b/static/scripts/packed/mvc/tools/tools-section.js index 5ab2a6d9526..4d26e071db6 100644 --- a/static/scripts/packed/mvc/tools/tools-section.js +++ b/static/scripts/packed/mvc/tools/tools-section.js @@ -1 +1 @@ -define(["utils/utils","mvc/ui/ui-table","mvc/ui/ui-misc","mvc/tools/tools-repeat","mvc/tools/tools-select-content","mvc/tools/tools-input"],function(d,b,g,c,a,e){var f=Backbone.View.extend({initialize:function(i,h){this.app=i;this.inputs=h.inputs;h.cls_tr="section-row";this.table=new b.View(h);this.setElement(this.table.$el);this.render()},render:function(){this.table.delAll();for(var h in this.inputs){this._add(this.inputs[h])}},_add:function(j){var i=this;var h=jQuery.extend(true,{},j);h.id=j.id=d.uuid();this.app.input_list[h.id]=h;var k=h.type;switch(k){case"conditional":this._addConditional(h);break;case"repeat":this._addRepeat(h);break;default:this._addRow(h)}},_addConditional:function(h){var j=this;h.test_param.id=h.id;var m=this._addRow(h.test_param);m.options.onchange=function(t){var p=j.app.tree.matchCase(h,t);for(var r in h.cases){var w=h.cases[r];var u=h.id+"-section-"+r;var o=j.table.get(u);var v=false;for(var q in w.inputs){var s=w.inputs[q].type;if(s&&s!=="hidden"){v=true;break}}if(r==p&&v){o.fadeIn("fast")}else{o.hide()}}j.app.refresh()};for(var l in h.cases){var k=h.id+"-section-"+l;var n=new f(this.app,{inputs:h.cases[l].inputs,cls:"ui-table-plain"});n.$el.addClass("ui-table-form-section");this.table.add(n.$el);this.table.append(k)}m.trigger("change")},_addRepeat:function(o){var r=this;var p=0;function m(i,t){var s=o.id+"-section-"+(p++);var u=null;if(t){u=function(){k.del(s);k.retitle(o.title);r.app.rebuild();r.app.refresh()}}var v=new f(r.app,{inputs:i,cls:"ui-table-plain"});k.add({id:s,title:o.title,$el:v.$el,ondel:u});k.retitle(o.title)}var k=new c.View({title_new:o.title,max:o.max,onnew:function(){m(o.inputs,true);r.app.rebuild();r.app.refresh()}});var h=o.min;var q=_.size(o.cache);for(var l=0;l=h)}var j=new e(this.app,{label:o.title,help:o.help,field:k});j.$el.addClass("ui-table-form-section");this.table.add(j.$el);this.table.append(o.id)},_addRow:function(h){var k=h.id;var i=this._createField(h);if(h.is_dynamic){this.app.is_dynamic=true}this.app.field_list[k]=i;var j=new e(this.app,{label:h.label,optional:h.optional,help:h.help,field:i});this.app.element_list[k]=j;this.table.add(j.$el);this.table.append(k);return i},_createField:function(h){var i=null;switch(h.type){case"text":i=this._fieldText(h);break;case"select":i=this._fieldSelect(h);break;case"data":i=this._fieldData(h);break;case"data_column":i=this._fieldSelect(h);break;case"hidden":i=this._fieldHidden(h);break;case"integer":i=this._fieldSlider(h);break;case"float":i=this._fieldSlider(h);break;case"boolean":i=this._fieldBoolean(h);break;case"genomebuild":h.searchable=true;i=this._fieldSelect(h);break;case"drill_down":i=this._fieldDrilldown(h);break;case"baseurl":i=this._fieldHidden(h);break;default:this.app.incompatible=true;if(h.options){i=this._fieldSelect(h)}else{i=this._fieldText(h)}console.debug("tools-form::_addRow() : Auto matched field type ("+h.type+").")}if(h.value!==undefined){i.value(h.value)}return i},_fieldData:function(h){var i=this;return new a.View(this.app,{id:"field-"+h.id,extensions:h.extensions,multiple:h.multiple,data:h.options,onchange:function(){i.app.refresh()}})},_fieldSelect:function(h){var k=[];for(var l in h.options){var m=h.options[l];k.push({label:m[0],value:m[1]})}var n=g.Select;switch(h.display){case"checkboxes":n=g.Checkbox;break;case"radio":n=g.Radio;break}var j=this;return new n.View({id:"field-"+h.id,data:k,multiple:h.multiple,searchable:h.searchable,onchange:function(){j.app.refresh()}})},_fieldDrilldown:function(h){var i=this;return new g.Drilldown.View({id:"field-"+h.id,data:h.options,display:h.display,onchange:function(){i.app.refresh()}})},_fieldText:function(h){var i=this;return new g.Input({id:"field-"+h.id,area:h.area,onchange:function(){i.app.refresh()}})},_fieldSlider:function(h){return new g.Slider.View({id:"field-"+h.id,precise:h.type=="float",min:h.min,max:h.max})},_fieldHidden:function(h){return new g.Hidden({id:"field-"+h.id})},_fieldBoolean:function(h){return new g.RadioButton.View({id:"field-"+h.id,data:[{label:"Yes",value:"true"},{label:"No",value:"false"}]})}});return{View:f}}); \ No newline at end of file +define(["utils/utils","mvc/ui/ui-table","mvc/ui/ui-misc","mvc/tools/tools-repeat","mvc/tools/tools-select-content","mvc/tools/tools-input"],function(d,b,g,c,a,e){var f=Backbone.View.extend({initialize:function(i,h){this.app=i;this.inputs=h.inputs;h.cls_tr="section-row";this.table=new b.View(h);this.setElement(this.table.$el);this.render()},render:function(){this.table.delAll();for(var h in this.inputs){this._add(this.inputs[h])}},_add:function(j){var i=this;var h=jQuery.extend(true,{},j);h.id=j.id=d.uuid();this.app.input_list[h.id]=h;var k=h.type;switch(k){case"conditional":this._addConditional(h);break;case"repeat":this._addRepeat(h);break;default:this._addRow(h)}},_addConditional:function(h){var j=this;h.test_param.id=h.id;var m=this._addRow(h.test_param);m.options.onchange=function(t){var p=j.app.tree.matchCase(h,t);for(var r in h.cases){var w=h.cases[r];var u=h.id+"-section-"+r;var o=j.table.get(u);var v=false;for(var q in w.inputs){var s=w.inputs[q].type;if(s&&s!=="hidden"){v=true;break}}if(r==p&&v){o.fadeIn("fast")}else{o.hide()}}j.app.refresh()};for(var l in h.cases){var k=h.id+"-section-"+l;var n=new f(this.app,{inputs:h.cases[l].inputs,cls:"ui-table-plain"});n.$el.addClass("ui-table-form-section");this.table.add(n.$el);this.table.append(k)}m.trigger("change")},_addRepeat:function(o){var r=this;var p=0;function m(i,t){var s=o.id+"-section-"+(p++);var u=null;if(t){u=function(){k.del(s);k.retitle(o.title);r.app.rebuild();r.app.refresh()}}var v=new f(r.app,{inputs:i,cls:"ui-table-plain"});k.add({id:s,title:o.title,$el:v.$el,ondel:u});k.retitle(o.title)}var k=new c.View({title_new:o.title,max:o.max,onnew:function(){m(o.inputs,true);r.app.rebuild();r.app.refresh()}});var h=o.min;var q=_.size(o.cache);for(var l=0;l=h)}var j=new e(this.app,{label:o.title,help:o.help,field:k});j.$el.addClass("ui-table-form-section");this.table.add(j.$el);this.table.append(o.id)},_addRow:function(h){var k=h.id;var i=this._createField(h);if(h.is_dynamic){this.app.is_dynamic=true}this.app.field_list[k]=i;var j=new e(this.app,{label:h.label,optional:h.optional,help:h.help,field:i});this.app.element_list[k]=j;this.table.add(j.$el);this.table.append(k);return i},_createField:function(h){var i=null;switch(h.type){case"text":i=this._fieldText(h);break;case"select":i=this._fieldSelect(h);break;case"data":i=this._fieldData(h);break;case"data_column":i=this._fieldSelect(h);break;case"hidden":i=this._fieldHidden(h);break;case"integer":i=this._fieldSlider(h);break;case"float":i=this._fieldSlider(h);break;case"boolean":i=this._fieldBoolean(h);break;case"genomebuild":h.searchable=true;i=this._fieldSelect(h);break;case"drill_down":i=this._fieldDrilldown(h);break;case"baseurl":i=this._fieldHidden(h);break;default:this.app.incompatible=true;if(h.options){i=this._fieldSelect(h)}else{i=this._fieldText(h)}console.debug("tools-form::_addRow() : Auto matched field type ("+h.type+").")}if(h.value!==undefined){i.value(h.value)}return i},_fieldData:function(h){var i=this;return new a.View(this.app,{id:"field-"+h.id,extensions:h.extensions,multiple:h.multiple,type:h.type,data:h.options,onchange:function(){i.app.refresh()}})},_fieldSelect:function(h){var k=[];for(var l in h.options){var m=h.options[l];k.push({label:m[0],value:m[1]})}var n=g.Select;switch(h.display){case"checkboxes":n=g.Checkbox;break;case"radio":n=g.Radio;break}var j=this;return new n.View({id:"field-"+h.id,data:k,multiple:h.multiple,searchable:h.searchable,onchange:function(){j.app.refresh()}})},_fieldDrilldown:function(h){var i=this;return new g.Drilldown.View({id:"field-"+h.id,data:h.options,display:h.display,onchange:function(){i.app.refresh()}})},_fieldText:function(h){var i=this;return new g.Input({id:"field-"+h.id,area:h.area,onchange:function(){i.app.refresh()}})},_fieldSlider:function(h){return new g.Slider.View({id:"field-"+h.id,precise:h.type=="float",min:h.min,max:h.max})},_fieldHidden:function(h){return new g.Hidden({id:"field-"+h.id})},_fieldBoolean:function(h){return new g.RadioButton.View({id:"field-"+h.id,data:[{label:"Yes",value:"true"},{label:"No",value:"false"}]})}});return{View:f}}); \ No newline at end of file diff --git a/static/scripts/packed/mvc/tools/tools-select-content.js b/static/scripts/packed/mvc/tools/tools-select-content.js index f2b5c858896..0b69cedb6ee 100644 --- a/static/scripts/packed/mvc/tools/tools-select-content.js +++ b/static/scripts/packed/mvc/tools/tools-select-content.js @@ -1 +1 @@ -define(["utils/utils","mvc/ui/ui-misc","mvc/ui/ui-tabs","mvc/tools/tools-template"],function(c,e,b,a){var d=Backbone.View.extend({initialize:function(k,g){this.app=k;this.options=g;var f=this;this.setElement("
");this.list={};var j=[];if(!g.multiple){this.current="single"}else{this.current="multiple"}if(!g.multiple){j.push({icon:"fa-file-o",label:"Single dataset",value:"single"});this.select_single=new e.Select.View({onchange:function(){f.trigger("change")}});this.list.single={field:this.select_single,type:"hda"}}j.push({icon:"fa-files-o",label:"Multiple datasets",value:"multiple"});this.select_multiple=new e.Select.View({multiple:true,onchange:function(){f.trigger("change")}});this.list.multiple={field:this.select_multiple,type:"hda"};j.push({icon:"fa-folder-o",label:"List of datasets",value:"collection"});this.select_collection=new e.Select.View({onchange:function(){f.trigger("change")}});this.list.collection={field:this.select_collection,type:"hdca"};this.button_type=new e.RadioButton.View({value:this.current,data:j,onchange:function(i){f.current=i;f.refresh();f.trigger("change")}});this.$batch=$(a.batchMode());this.$el.append(c.wrap(this.button_type.$el));for(var h in this.list){this.$el.append(this.list[h].field.$el)}this.$el.append(this.$batch);this.update(g.data);if(this.options.value!==undefined){this.value(this.options.value)}this.refresh();this.on("change",function(){if(g.onchange){g.onchange(f.value())}})},wait:function(){for(var f in this.list){this.list[f].field.wait()}},unwait:function(){for(var f in this.list){this.list[f].field.unwait()}},update:function(g){var l=[];for(var j in g.hda){var k=g.hda[j];l.push({label:k.hid+": "+k.name,value:k.id})}var f=[];for(var j in g.hdca){var h=g.hdca[j];f.push({label:h.hid+": "+h.name,value:h.id})}this.select_single&&this.select_single.update(l);this.select_multiple.update(l);this.select_collection.update(f);this.app.content.add(g)},value:function(m){if(m&&m.values){try{var l=[];for(var h in m.values){l.push(m.values[h].id)}if(m&&m.values.length>0&&m.values[0].src=="hcda"){this.current="collection";this.select_collection.value(l[0])}else{if(l.length>1||this.options.multiple){this.current="multiple";this.select_multiple.value(l)}else{this.current="single";this.select_single.value(l[0])}}this.refresh();var g=this._select();if(!g.validate()){g.value(g.first())}}catch(k){console.debug("tools-select-content::value() - Skipped.")}}var j=this._select().value();if(!(j instanceof Array)){j=[j]}var f={batch:!this.options.multiple&&this.current!="single",values:[]};for(var h in j){f.values.push({id:j[h],src:this.list[this.current].type})}return f},validate:function(){return this._select().validate()},refresh:function(){for(var g in this.list){var f=this.list[g].field.$el;if(this.current==g){f.show()}else{f.hide()}}if(this.current!="single"&&!this.options.multiple){this.$batch.show()}else{this.$batch.hide()}},_select:function(){return this.list[this.current].field}});return{View:d}}); \ No newline at end of file +define(["utils/utils","mvc/ui/ui-misc","mvc/ui/ui-tabs","mvc/tools/tools-template"],function(c,e,b,a){var d=Backbone.View.extend({initialize:function(k,g){this.app=k;this.options=g;var f=this;this.setElement("
");this.list={};var j=[];if(g.type=="data_collection"){this.mode="collection"}else{if(g.multiple){this.mode="multiple"}else{this.mode="single"}}this.current=this.mode;this.list={};if(this.mode=="single"){j.push({icon:"fa-file-o",label:"Single dataset",value:"single"});this.select_single=new e.Select.View({onchange:function(){f.trigger("change")}});this.list.single={field:this.select_single,type:"hda"}}if(this.mode=="single"||this.mode=="multiple"){j.push({icon:"fa-files-o",label:"Multiple datasets",value:"multiple"});this.select_multiple=new e.Select.View({multiple:true,onchange:function(){f.trigger("change")}});this.list.multiple={field:this.select_multiple,type:"hda"}}if(this.mode=="single"||this.mode=="collection"){j.push({icon:"fa-folder-o",label:"List of datasets",value:"collection"});this.select_collection=new e.Select.View({onchange:function(){f.trigger("change")}});this.list.collection={field:this.select_collection,type:"hdca"}}this.button_type=new e.RadioButton.View({value:this.current,data:j,onchange:function(i){f.current=i;f.refresh();f.trigger("change")}});this.$batch=$(a.batchMode());if(_.size(this.list)>1){this.$el.append(c.wrap(this.button_type.$el))}for(var h in this.list){this.$el.append(this.list[h].field.$el)}this.$el.append(this.$batch);this.update(g.data);if(this.options.value!==undefined){this.value(this.options.value)}this.refresh();this.on("change",function(){if(g.onchange){g.onchange(f.value())}})},wait:function(){for(var f in this.list){this.list[f].field.wait()}},unwait:function(){for(var f in this.list){this.list[f].field.unwait()}},update:function(g){var l=[];for(var j in g.hda){var k=g.hda[j];l.push({label:k.hid+": "+k.name,value:k.id})}var f=[];for(var j in g.hdca){var h=g.hdca[j];f.push({label:h.hid+": "+h.name,value:h.id})}this.select_single&&this.select_single.update(l);this.select_multiple&&this.select_multiple.update(l);this.select_collection&&this.select_collection.update(f);this.app.content.add(g)},value:function(m){if(m&&m.values){try{var l=[];for(var h in m.values){l.push(m.values[h].id)}if(m&&m.values.length>0&&m.values[0].src=="hcda"){this.current="collection";this.select_collection.value(l[0])}else{if(this.mode=="multiple"){this.current="multiple";this.select_multiple.value(l)}else{this.current="single";this.select_single.value(l[0])}}this.refresh();var g=this._select();if(!g.validate()){g.value(g.first())}}catch(k){console.debug("tools-select-content::value() - Skipped.")}}var j=this._select().value();if(!(j instanceof Array)){j=[j]}var f={batch:this.mode=="single"&&this.current!="single",values:[]};for(var h in j){f.values.push({id:j[h],src:this.list[this.current].type})}return f},validate:function(){return this._select().validate()},refresh:function(){for(var g in this.list){var f=this.list[g].field.$el;if(this.current==g){f.show()}else{f.hide()}}if(this.mode=="single"&&this.current!="single"){this.$batch.show()}else{this.$batch.hide()}},_select:function(){return this.list[this.current].field}});return{View:d}}); \ No newline at end of file From 7b8c3a1e1db7b6a6b3eed1ad716ff7905f2b3331 Mon Sep 17 00:00:00 2001 From: Aysam Guerler Date: Thu, 4 Dec 2014 11:45:18 -0500 Subject: [PATCH 14/20] ToolForm: Add dataset types to error message --- client/galaxy/scripts/mvc/tools/tools-form.js | 2 +- .../galaxy/scripts/mvc/tools/tools-section.js | 2 ++ .../scripts/mvc/tools/tools-select-content.js | 21 +++++++++++++++++++ client/galaxy/scripts/mvc/ui/ui-options.js | 8 +++---- .../scripts/mvc/ui/ui-select-default.js | 4 ++-- static/scripts/mvc/tools/tools-form.js | 2 +- static/scripts/mvc/tools/tools-section.js | 2 ++ .../scripts/mvc/tools/tools-select-content.js | 21 +++++++++++++++++++ static/scripts/mvc/ui/ui-options.js | 8 +++---- static/scripts/mvc/ui/ui-select-default.js | 4 ++-- static/scripts/packed/mvc/tools/tools-form.js | 2 +- .../scripts/packed/mvc/tools/tools-section.js | 2 +- .../packed/mvc/tools/tools-select-content.js | 2 +- static/scripts/packed/mvc/ui/ui-options.js | 2 +- .../packed/mvc/ui/ui-select-default.js | 2 +- 15 files changed, 65 insertions(+), 19 deletions(-) diff --git a/client/galaxy/scripts/mvc/tools/tools-form.js b/client/galaxy/scripts/mvc/tools/tools-form.js index f6f772abcf0..19d039aba41 100644 --- a/client/galaxy/scripts/mvc/tools/tools-form.js +++ b/client/galaxy/scripts/mvc/tools/tools-form.js @@ -340,7 +340,7 @@ define(['utils/utils', 'utils/deferred', 'mvc/ui/ui-portlet', 'mvc/ui/ui-misc', buttons: { execute : new Ui.Button({ icon : 'fa-check', - tooltip : 'Execute the tool', + tooltip : 'Execute: ' + self.model.name, title : 'Execute', cls : 'btn btn-primary', floating : 'clear', diff --git a/client/galaxy/scripts/mvc/tools/tools-section.js b/client/galaxy/scripts/mvc/tools/tools-section.js index c3406505bec..d18525676ff 100644 --- a/client/galaxy/scripts/mvc/tools/tools-section.js +++ b/client/galaxy/scripts/mvc/tools/tools-section.js @@ -314,6 +314,7 @@ define(['utils/utils', 'mvc/ui/ui-table', 'mvc/ui/ui-misc', 'mvc/tools/tools-rep // data column case 'data_column': + input_def.error_text = 'Referenced dataset contains no suitable columns'; field = this._fieldSelect(input_def); break; @@ -425,6 +426,7 @@ define(['utils/utils', 'mvc/ui/ui-table', 'mvc/ui/ui-misc', 'mvc/tools/tools-rep return new SelectClass.View({ id : 'field-' + input_def.id, data : options, + error_text : input_def.error_text || 'No options available', multiple : input_def.multiple, searchable : input_def.searchable, onchange : function() { diff --git a/client/galaxy/scripts/mvc/tools/tools-select-content.js b/client/galaxy/scripts/mvc/tools/tools-select-content.js index 23d673461c5..ae94518d081 100644 --- a/client/galaxy/scripts/mvc/tools/tools-select-content.js +++ b/client/galaxy/scripts/mvc/tools/tools-select-content.js @@ -35,10 +35,29 @@ var View = Backbone.View.extend({ this.current = this.mode; this.list = {}; + // error messages + var extensions = options.extensions.toString(); + if (extensions) { + extensions = extensions.replace(',', ', '); + var pos = extensions.lastIndexOf(', '); + if (pos != -1) { + extensions = extensions.substr(0, pos) + " or " + extensions.substr(pos+1); + } + } + var hda_error = 'No dataset available'; + if (extensions) { + hda_error = 'No dataset of type ' + extensions + ' available.'; + } + var hdca_error = 'No dataset list available'; + if (extensions) { + hdca_error = 'No dataset list of type ' + extensions + ' available.'; + } + // add single dataset selector if (this.mode == 'single') { radio_buttons.push({icon: 'fa-file-o', label : 'Single dataset', value : 'single'}); this.select_single = new Ui.Select.View({ + error_text : hda_error, onchange : function() { self.trigger('change'); } @@ -54,6 +73,7 @@ var View = Backbone.View.extend({ radio_buttons.push({icon: 'fa-files-o', label : 'Multiple datasets', value : 'multiple' }); this.select_multiple = new Ui.Select.View({ multiple : true, + error_text : hda_error, onchange : function() { self.trigger('change'); } @@ -68,6 +88,7 @@ var View = Backbone.View.extend({ if (this.mode == 'single' || this.mode == 'collection') { radio_buttons.push({icon: 'fa-folder-o', label : 'List of datasets', value : 'collection' }); this.select_collection = new Ui.Select.View({ + error_text : hdca_error, onchange : function() { self.trigger('change'); } diff --git a/client/galaxy/scripts/mvc/ui/ui-options.js b/client/galaxy/scripts/mvc/ui/ui-options.js index 151dd42e2fd..8d47dfe0330 100644 --- a/client/galaxy/scripts/mvc/ui/ui-options.js +++ b/client/galaxy/scripts/mvc/ui/ui-options.js @@ -10,8 +10,8 @@ var Base = Backbone.View.extend({ visible : true, data : [], id : Utils.uuid(), - errorText : 'No data available.', - waitText : 'Please wait...' + error_text : 'No data available.', + wait_text : 'Please wait...' }; // configure options @@ -153,7 +153,7 @@ var Base = Backbone.View.extend({ */ wait: function() { if (this._size() == 0) { - this._messageShow(this.options.waitText, 'info'); + this._messageShow(this.options.wait_text, 'info'); this.$options.hide(); } }, @@ -177,7 +177,7 @@ var Base = Backbone.View.extend({ */ _refresh: function() { if (this._size() == 0) { - this._messageShow(this.options.errorText, 'danger'); + this._messageShow(this.options.error_text, 'danger'); this.$options.hide(); } else { this._messageHide(); diff --git a/client/galaxy/scripts/mvc/ui/ui-select-default.js b/client/galaxy/scripts/mvc/ui/ui-select-default.js index e2918e0ca98..6171ca3043d 100644 --- a/client/galaxy/scripts/mvc/ui/ui-select-default.js +++ b/client/galaxy/scripts/mvc/ui/ui-select-default.js @@ -9,7 +9,7 @@ var View = Backbone.View.extend({ optionsDefault : { id : '', cls : '', - empty : 'No data available', + error_text : 'No data available', visible : true, wait : false, multiple : false, @@ -247,7 +247,7 @@ var View = Backbone.View.extend({ this.disable(); // append placeholder - this.$select.append(this._templateOption({value : 'null', label : this.options.empty})); + this.$select.append(this._templateOption({value : 'null', label : this.options.error_text})); } else { // enable select field this.enable(); diff --git a/static/scripts/mvc/tools/tools-form.js b/static/scripts/mvc/tools/tools-form.js index f6f772abcf0..19d039aba41 100644 --- a/static/scripts/mvc/tools/tools-form.js +++ b/static/scripts/mvc/tools/tools-form.js @@ -340,7 +340,7 @@ define(['utils/utils', 'utils/deferred', 'mvc/ui/ui-portlet', 'mvc/ui/ui-misc', buttons: { execute : new Ui.Button({ icon : 'fa-check', - tooltip : 'Execute the tool', + tooltip : 'Execute: ' + self.model.name, title : 'Execute', cls : 'btn btn-primary', floating : 'clear', diff --git a/static/scripts/mvc/tools/tools-section.js b/static/scripts/mvc/tools/tools-section.js index c3406505bec..d18525676ff 100644 --- a/static/scripts/mvc/tools/tools-section.js +++ b/static/scripts/mvc/tools/tools-section.js @@ -314,6 +314,7 @@ define(['utils/utils', 'mvc/ui/ui-table', 'mvc/ui/ui-misc', 'mvc/tools/tools-rep // data column case 'data_column': + input_def.error_text = 'Referenced dataset contains no suitable columns'; field = this._fieldSelect(input_def); break; @@ -425,6 +426,7 @@ define(['utils/utils', 'mvc/ui/ui-table', 'mvc/ui/ui-misc', 'mvc/tools/tools-rep return new SelectClass.View({ id : 'field-' + input_def.id, data : options, + error_text : input_def.error_text || 'No options available', multiple : input_def.multiple, searchable : input_def.searchable, onchange : function() { diff --git a/static/scripts/mvc/tools/tools-select-content.js b/static/scripts/mvc/tools/tools-select-content.js index 23d673461c5..ae94518d081 100644 --- a/static/scripts/mvc/tools/tools-select-content.js +++ b/static/scripts/mvc/tools/tools-select-content.js @@ -35,10 +35,29 @@ var View = Backbone.View.extend({ this.current = this.mode; this.list = {}; + // error messages + var extensions = options.extensions.toString(); + if (extensions) { + extensions = extensions.replace(',', ', '); + var pos = extensions.lastIndexOf(', '); + if (pos != -1) { + extensions = extensions.substr(0, pos) + " or " + extensions.substr(pos+1); + } + } + var hda_error = 'No dataset available'; + if (extensions) { + hda_error = 'No dataset of type ' + extensions + ' available.'; + } + var hdca_error = 'No dataset list available'; + if (extensions) { + hdca_error = 'No dataset list of type ' + extensions + ' available.'; + } + // add single dataset selector if (this.mode == 'single') { radio_buttons.push({icon: 'fa-file-o', label : 'Single dataset', value : 'single'}); this.select_single = new Ui.Select.View({ + error_text : hda_error, onchange : function() { self.trigger('change'); } @@ -54,6 +73,7 @@ var View = Backbone.View.extend({ radio_buttons.push({icon: 'fa-files-o', label : 'Multiple datasets', value : 'multiple' }); this.select_multiple = new Ui.Select.View({ multiple : true, + error_text : hda_error, onchange : function() { self.trigger('change'); } @@ -68,6 +88,7 @@ var View = Backbone.View.extend({ if (this.mode == 'single' || this.mode == 'collection') { radio_buttons.push({icon: 'fa-folder-o', label : 'List of datasets', value : 'collection' }); this.select_collection = new Ui.Select.View({ + error_text : hdca_error, onchange : function() { self.trigger('change'); } diff --git a/static/scripts/mvc/ui/ui-options.js b/static/scripts/mvc/ui/ui-options.js index 151dd42e2fd..8d47dfe0330 100644 --- a/static/scripts/mvc/ui/ui-options.js +++ b/static/scripts/mvc/ui/ui-options.js @@ -10,8 +10,8 @@ var Base = Backbone.View.extend({ visible : true, data : [], id : Utils.uuid(), - errorText : 'No data available.', - waitText : 'Please wait...' + error_text : 'No data available.', + wait_text : 'Please wait...' }; // configure options @@ -153,7 +153,7 @@ var Base = Backbone.View.extend({ */ wait: function() { if (this._size() == 0) { - this._messageShow(this.options.waitText, 'info'); + this._messageShow(this.options.wait_text, 'info'); this.$options.hide(); } }, @@ -177,7 +177,7 @@ var Base = Backbone.View.extend({ */ _refresh: function() { if (this._size() == 0) { - this._messageShow(this.options.errorText, 'danger'); + this._messageShow(this.options.error_text, 'danger'); this.$options.hide(); } else { this._messageHide(); diff --git a/static/scripts/mvc/ui/ui-select-default.js b/static/scripts/mvc/ui/ui-select-default.js index e2918e0ca98..6171ca3043d 100644 --- a/static/scripts/mvc/ui/ui-select-default.js +++ b/static/scripts/mvc/ui/ui-select-default.js @@ -9,7 +9,7 @@ var View = Backbone.View.extend({ optionsDefault : { id : '', cls : '', - empty : 'No data available', + error_text : 'No data available', visible : true, wait : false, multiple : false, @@ -247,7 +247,7 @@ var View = Backbone.View.extend({ this.disable(); // append placeholder - this.$select.append(this._templateOption({value : 'null', label : this.options.empty})); + this.$select.append(this._templateOption({value : 'null', label : this.options.error_text})); } else { // enable select field this.enable(); diff --git a/static/scripts/packed/mvc/tools/tools-form.js b/static/scripts/packed/mvc/tools/tools-form.js index 3144cdfc41d..a2da39278ea 100644 --- a/static/scripts/packed/mvc/tools/tools-form.js +++ b/static/scripts/packed/mvc/tools/tools-form.js @@ -1 +1 @@ -define(["utils/utils","utils/deferred","mvc/ui/ui-portlet","mvc/ui/ui-misc","mvc/citation/citation-model","mvc/citation/citation-view","mvc/tools","mvc/tools/tools-template","mvc/tools/tools-content","mvc/tools/tools-section","mvc/tools/tools-tree","mvc/tools/tools-jobs"],function(i,j,h,m,k,a,e,d,f,l,c,g){var b=Backbone.View.extend({container:"body",initialize:function(o){console.debug(o);var n=this;var p=parent.Galaxy;if(p&&p.modal){this.modal=p.modal}else{this.modal=new m.Modal.View()}if(p&&p.currUser){this.is_admin=p.currUser.get("is_admin")}else{this.is_admin=false}this.options=o;this.deferred=new j();this.setElement("
");$(this.container).append(this.$el);this.tree=new c(this);this.job_handler=new g(this);this.content=new f(this);this._buildForm(o)},message:function(n){$(this.container).empty();$(this.container).append(n)},reset:function(){for(var n in this.element_list){this.element_list[n].reset()}},rebuild:function(){this.tree.refresh();console.debug("tools-form::rebuild() - Rebuilding data structures.")},refresh:function(){if(this.is_dynamic){var n=this;this.deferred.reset();this.deferred.execute(function(){n._updateModel()})}},_buildModel:function(){var n=this;var o=galaxy_config.root+"api/tools/"+this.options.id+"/build?";if(this.options.job_id){o+="job_id="+this.options.job_id}else{if(this.options.dataset_id){o+="dataset_id="+this.options.dataset_id}else{var p=top.location.href;var q=p.indexOf("?");if(p.indexOf("tool_id=")!=-1&&q!==-1){o+=p.slice(q+1)}}}i.request({type:"GET",url:o,success:function(r){n.options=$.extend(n.options,r);n.model=r;n.inputs=r.inputs;console.debug("tools-form::initialize() - Initial tool model ready.");console.debug(r);n._buildForm()},error:function(r){console.debug("tools-form::initialize() - Initial tool model request failed.");console.debug(r)}})},_updateModel:function(){var n=this;var o=this.tree.finalize({data:function(r){if(r.values.length>0&&r.values[0]&&r.values[0].src==="hda"){return n.content.get({id:r.values[0].id,src:"hda"}).id_uncoded}return null}});console.debug("tools-form::_refreshForm() - Refreshing states.");console.debug(o);function q(u){for(var s in n.input_list){var t=n.field_list[s];var r=n.input_list[s];if(r.is_dynamic&&t.wait&&t.unwait){if(u){t.wait()}else{t.unwait()}}}}q(true);var p=this.deferred.register();i.request({type:"GET",url:galaxy_config.root+"api/tools/"+this.options.id+"/build",data:o,success:function(r){n._updateForm(r);q(false);n.deferred.done(p);console.debug("tools-form::_refreshForm() - States refreshed.");console.debug(r)},error:function(r){n.deferred.done(p);console.debug("tools-form::_refreshForm() - Refresh request failed.");console.debug(r)}})},_updateForm:function(n){var o=this;this.tree.matchModel(n,function(q,u){var p=o.input_list[q];if(p&&p.options){if(!_.isEqual(p.options,u.options)){p.options=u.options;var v=o.field_list[q];if(v.update){var t=[];switch(p.type){case"data":t=p.options;break;case"drill_down":t=p.options;break;default:for(var s in u.options){var r=u.options[s];if(r.length>2){t.push({label:r[0],value:r[1]})}}}v.update(t);v.trigger("change");console.debug("Updating options for "+q)}}}})},_buildForm:function(p){var o=this;this.field_list={};this.input_list={};this.element_list={};this.model=p;this.inputs=p.inputs;var s=new m.ButtonMenu({icon:"fa-gear",tooltip:"Click to see a list of options."});if(p.biostar_url){s.addMenu({icon:"fa-question-circle",title:"Question?",tooltip:"Ask a question about this tool (Biostar)",onclick:function(){window.open(o.options.biostar_url+"/p/new/post/")}});s.addMenu({icon:"fa-search",title:"Search",tooltip:"Search help for this tool (Biostar)",onclick:function(){window.open(o.options.biostar_url+"/t/"+o.options.id+"/")}})}s.addMenu({icon:"fa-share",title:"Share",tooltip:"Share this tool",onclick:function(){prompt("Copy to clipboard: Ctrl+C, Enter",window.location.origin+galaxy_config.root+"root?tool_id="+o.options.id)}});if(this.is_admin){s.addMenu({icon:"fa-download",title:"Download",tooltip:"Download this tool",onclick:function(){window.location.href=galaxy_config.root+"api/tools/"+o.options.id+"/download"}})}this.section=new l.View(o,{inputs:this.inputs,cls:"ui-table-plain"});if(this.incompatible){this.$el.hide();$("#tool-form-classic").show();return}this.portlet=new h.View({icon:"fa-wrench",title:""+this.model.name+" "+this.model.description,cls:"ui-portlet-slim",operations:{menu:s},buttons:{execute:new m.Button({icon:"fa-check",tooltip:"Execute the tool",title:"Execute",cls:"btn btn-primary",floating:"clear",onclick:function(){o.job_handler.submit()}})}});this.$el.empty();this.$el.append(this.portlet.$el);if(p.help!=""){this.$el.append(d.help(p.help))}if(p.citations){var r=$("
");var n=new k.ToolCitationCollection();n.tool_id=p.id;var q=new a.CitationListView({el:r,collection:n});q.render();n.fetch();this.$el.append(r)}this.portlet.append(this.section.$el);this.rebuild()}});return{View:b}}); \ No newline at end of file +define(["utils/utils","utils/deferred","mvc/ui/ui-portlet","mvc/ui/ui-misc","mvc/citation/citation-model","mvc/citation/citation-view","mvc/tools","mvc/tools/tools-template","mvc/tools/tools-content","mvc/tools/tools-section","mvc/tools/tools-tree","mvc/tools/tools-jobs"],function(i,j,h,m,k,a,e,d,f,l,c,g){var b=Backbone.View.extend({container:"body",initialize:function(o){console.debug(o);var n=this;var p=parent.Galaxy;if(p&&p.modal){this.modal=p.modal}else{this.modal=new m.Modal.View()}if(p&&p.currUser){this.is_admin=p.currUser.get("is_admin")}else{this.is_admin=false}this.options=o;this.deferred=new j();this.setElement("
");$(this.container).append(this.$el);this.tree=new c(this);this.job_handler=new g(this);this.content=new f(this);this._buildForm(o)},message:function(n){$(this.container).empty();$(this.container).append(n)},reset:function(){for(var n in this.element_list){this.element_list[n].reset()}},rebuild:function(){this.tree.refresh();console.debug("tools-form::rebuild() - Rebuilding data structures.")},refresh:function(){if(this.is_dynamic){var n=this;this.deferred.reset();this.deferred.execute(function(){n._updateModel()})}},_buildModel:function(){var n=this;var o=galaxy_config.root+"api/tools/"+this.options.id+"/build?";if(this.options.job_id){o+="job_id="+this.options.job_id}else{if(this.options.dataset_id){o+="dataset_id="+this.options.dataset_id}else{var p=top.location.href;var q=p.indexOf("?");if(p.indexOf("tool_id=")!=-1&&q!==-1){o+=p.slice(q+1)}}}i.request({type:"GET",url:o,success:function(r){n.options=$.extend(n.options,r);n.model=r;n.inputs=r.inputs;console.debug("tools-form::initialize() - Initial tool model ready.");console.debug(r);n._buildForm()},error:function(r){console.debug("tools-form::initialize() - Initial tool model request failed.");console.debug(r)}})},_updateModel:function(){var n=this;var o=this.tree.finalize({data:function(r){if(r.values.length>0&&r.values[0]&&r.values[0].src==="hda"){return n.content.get({id:r.values[0].id,src:"hda"}).id_uncoded}return null}});console.debug("tools-form::_refreshForm() - Refreshing states.");console.debug(o);function q(u){for(var s in n.input_list){var t=n.field_list[s];var r=n.input_list[s];if(r.is_dynamic&&t.wait&&t.unwait){if(u){t.wait()}else{t.unwait()}}}}q(true);var p=this.deferred.register();i.request({type:"GET",url:galaxy_config.root+"api/tools/"+this.options.id+"/build",data:o,success:function(r){n._updateForm(r);q(false);n.deferred.done(p);console.debug("tools-form::_refreshForm() - States refreshed.");console.debug(r)},error:function(r){n.deferred.done(p);console.debug("tools-form::_refreshForm() - Refresh request failed.");console.debug(r)}})},_updateForm:function(n){var o=this;this.tree.matchModel(n,function(q,u){var p=o.input_list[q];if(p&&p.options){if(!_.isEqual(p.options,u.options)){p.options=u.options;var v=o.field_list[q];if(v.update){var t=[];switch(p.type){case"data":t=p.options;break;case"drill_down":t=p.options;break;default:for(var s in u.options){var r=u.options[s];if(r.length>2){t.push({label:r[0],value:r[1]})}}}v.update(t);v.trigger("change");console.debug("Updating options for "+q)}}}})},_buildForm:function(p){var o=this;this.field_list={};this.input_list={};this.element_list={};this.model=p;this.inputs=p.inputs;var s=new m.ButtonMenu({icon:"fa-gear",tooltip:"Click to see a list of options."});if(p.biostar_url){s.addMenu({icon:"fa-question-circle",title:"Question?",tooltip:"Ask a question about this tool (Biostar)",onclick:function(){window.open(o.options.biostar_url+"/p/new/post/")}});s.addMenu({icon:"fa-search",title:"Search",tooltip:"Search help for this tool (Biostar)",onclick:function(){window.open(o.options.biostar_url+"/t/"+o.options.id+"/")}})}s.addMenu({icon:"fa-share",title:"Share",tooltip:"Share this tool",onclick:function(){prompt("Copy to clipboard: Ctrl+C, Enter",window.location.origin+galaxy_config.root+"root?tool_id="+o.options.id)}});if(this.is_admin){s.addMenu({icon:"fa-download",title:"Download",tooltip:"Download this tool",onclick:function(){window.location.href=galaxy_config.root+"api/tools/"+o.options.id+"/download"}})}this.section=new l.View(o,{inputs:this.inputs,cls:"ui-table-plain"});if(this.incompatible){this.$el.hide();$("#tool-form-classic").show();return}this.portlet=new h.View({icon:"fa-wrench",title:""+this.model.name+" "+this.model.description,cls:"ui-portlet-slim",operations:{menu:s},buttons:{execute:new m.Button({icon:"fa-check",tooltip:"Execute: "+o.model.name,title:"Execute",cls:"btn btn-primary",floating:"clear",onclick:function(){o.job_handler.submit()}})}});this.$el.empty();this.$el.append(this.portlet.$el);if(p.help!=""){this.$el.append(d.help(p.help))}if(p.citations){var r=$("
");var n=new k.ToolCitationCollection();n.tool_id=p.id;var q=new a.CitationListView({el:r,collection:n});q.render();n.fetch();this.$el.append(r)}this.portlet.append(this.section.$el);this.rebuild()}});return{View:b}}); \ No newline at end of file diff --git a/static/scripts/packed/mvc/tools/tools-section.js b/static/scripts/packed/mvc/tools/tools-section.js index 4d26e071db6..5c5623c9e6c 100644 --- a/static/scripts/packed/mvc/tools/tools-section.js +++ b/static/scripts/packed/mvc/tools/tools-section.js @@ -1 +1 @@ -define(["utils/utils","mvc/ui/ui-table","mvc/ui/ui-misc","mvc/tools/tools-repeat","mvc/tools/tools-select-content","mvc/tools/tools-input"],function(d,b,g,c,a,e){var f=Backbone.View.extend({initialize:function(i,h){this.app=i;this.inputs=h.inputs;h.cls_tr="section-row";this.table=new b.View(h);this.setElement(this.table.$el);this.render()},render:function(){this.table.delAll();for(var h in this.inputs){this._add(this.inputs[h])}},_add:function(j){var i=this;var h=jQuery.extend(true,{},j);h.id=j.id=d.uuid();this.app.input_list[h.id]=h;var k=h.type;switch(k){case"conditional":this._addConditional(h);break;case"repeat":this._addRepeat(h);break;default:this._addRow(h)}},_addConditional:function(h){var j=this;h.test_param.id=h.id;var m=this._addRow(h.test_param);m.options.onchange=function(t){var p=j.app.tree.matchCase(h,t);for(var r in h.cases){var w=h.cases[r];var u=h.id+"-section-"+r;var o=j.table.get(u);var v=false;for(var q in w.inputs){var s=w.inputs[q].type;if(s&&s!=="hidden"){v=true;break}}if(r==p&&v){o.fadeIn("fast")}else{o.hide()}}j.app.refresh()};for(var l in h.cases){var k=h.id+"-section-"+l;var n=new f(this.app,{inputs:h.cases[l].inputs,cls:"ui-table-plain"});n.$el.addClass("ui-table-form-section");this.table.add(n.$el);this.table.append(k)}m.trigger("change")},_addRepeat:function(o){var r=this;var p=0;function m(i,t){var s=o.id+"-section-"+(p++);var u=null;if(t){u=function(){k.del(s);k.retitle(o.title);r.app.rebuild();r.app.refresh()}}var v=new f(r.app,{inputs:i,cls:"ui-table-plain"});k.add({id:s,title:o.title,$el:v.$el,ondel:u});k.retitle(o.title)}var k=new c.View({title_new:o.title,max:o.max,onnew:function(){m(o.inputs,true);r.app.rebuild();r.app.refresh()}});var h=o.min;var q=_.size(o.cache);for(var l=0;l=h)}var j=new e(this.app,{label:o.title,help:o.help,field:k});j.$el.addClass("ui-table-form-section");this.table.add(j.$el);this.table.append(o.id)},_addRow:function(h){var k=h.id;var i=this._createField(h);if(h.is_dynamic){this.app.is_dynamic=true}this.app.field_list[k]=i;var j=new e(this.app,{label:h.label,optional:h.optional,help:h.help,field:i});this.app.element_list[k]=j;this.table.add(j.$el);this.table.append(k);return i},_createField:function(h){var i=null;switch(h.type){case"text":i=this._fieldText(h);break;case"select":i=this._fieldSelect(h);break;case"data":i=this._fieldData(h);break;case"data_column":i=this._fieldSelect(h);break;case"hidden":i=this._fieldHidden(h);break;case"integer":i=this._fieldSlider(h);break;case"float":i=this._fieldSlider(h);break;case"boolean":i=this._fieldBoolean(h);break;case"genomebuild":h.searchable=true;i=this._fieldSelect(h);break;case"drill_down":i=this._fieldDrilldown(h);break;case"baseurl":i=this._fieldHidden(h);break;default:this.app.incompatible=true;if(h.options){i=this._fieldSelect(h)}else{i=this._fieldText(h)}console.debug("tools-form::_addRow() : Auto matched field type ("+h.type+").")}if(h.value!==undefined){i.value(h.value)}return i},_fieldData:function(h){var i=this;return new a.View(this.app,{id:"field-"+h.id,extensions:h.extensions,multiple:h.multiple,type:h.type,data:h.options,onchange:function(){i.app.refresh()}})},_fieldSelect:function(h){var k=[];for(var l in h.options){var m=h.options[l];k.push({label:m[0],value:m[1]})}var n=g.Select;switch(h.display){case"checkboxes":n=g.Checkbox;break;case"radio":n=g.Radio;break}var j=this;return new n.View({id:"field-"+h.id,data:k,multiple:h.multiple,searchable:h.searchable,onchange:function(){j.app.refresh()}})},_fieldDrilldown:function(h){var i=this;return new g.Drilldown.View({id:"field-"+h.id,data:h.options,display:h.display,onchange:function(){i.app.refresh()}})},_fieldText:function(h){var i=this;return new g.Input({id:"field-"+h.id,area:h.area,onchange:function(){i.app.refresh()}})},_fieldSlider:function(h){return new g.Slider.View({id:"field-"+h.id,precise:h.type=="float",min:h.min,max:h.max})},_fieldHidden:function(h){return new g.Hidden({id:"field-"+h.id})},_fieldBoolean:function(h){return new g.RadioButton.View({id:"field-"+h.id,data:[{label:"Yes",value:"true"},{label:"No",value:"false"}]})}});return{View:f}}); \ No newline at end of file +define(["utils/utils","mvc/ui/ui-table","mvc/ui/ui-misc","mvc/tools/tools-repeat","mvc/tools/tools-select-content","mvc/tools/tools-input"],function(d,b,g,c,a,e){var f=Backbone.View.extend({initialize:function(i,h){this.app=i;this.inputs=h.inputs;h.cls_tr="section-row";this.table=new b.View(h);this.setElement(this.table.$el);this.render()},render:function(){this.table.delAll();for(var h in this.inputs){this._add(this.inputs[h])}},_add:function(j){var i=this;var h=jQuery.extend(true,{},j);h.id=j.id=d.uuid();this.app.input_list[h.id]=h;var k=h.type;switch(k){case"conditional":this._addConditional(h);break;case"repeat":this._addRepeat(h);break;default:this._addRow(h)}},_addConditional:function(h){var j=this;h.test_param.id=h.id;var m=this._addRow(h.test_param);m.options.onchange=function(t){var p=j.app.tree.matchCase(h,t);for(var r in h.cases){var w=h.cases[r];var u=h.id+"-section-"+r;var o=j.table.get(u);var v=false;for(var q in w.inputs){var s=w.inputs[q].type;if(s&&s!=="hidden"){v=true;break}}if(r==p&&v){o.fadeIn("fast")}else{o.hide()}}j.app.refresh()};for(var l in h.cases){var k=h.id+"-section-"+l;var n=new f(this.app,{inputs:h.cases[l].inputs,cls:"ui-table-plain"});n.$el.addClass("ui-table-form-section");this.table.add(n.$el);this.table.append(k)}m.trigger("change")},_addRepeat:function(o){var r=this;var p=0;function m(i,t){var s=o.id+"-section-"+(p++);var u=null;if(t){u=function(){k.del(s);k.retitle(o.title);r.app.rebuild();r.app.refresh()}}var v=new f(r.app,{inputs:i,cls:"ui-table-plain"});k.add({id:s,title:o.title,$el:v.$el,ondel:u});k.retitle(o.title)}var k=new c.View({title_new:o.title,max:o.max,onnew:function(){m(o.inputs,true);r.app.rebuild();r.app.refresh()}});var h=o.min;var q=_.size(o.cache);for(var l=0;l=h)}var j=new e(this.app,{label:o.title,help:o.help,field:k});j.$el.addClass("ui-table-form-section");this.table.add(j.$el);this.table.append(o.id)},_addRow:function(h){var k=h.id;var i=this._createField(h);if(h.is_dynamic){this.app.is_dynamic=true}this.app.field_list[k]=i;var j=new e(this.app,{label:h.label,optional:h.optional,help:h.help,field:i});this.app.element_list[k]=j;this.table.add(j.$el);this.table.append(k);return i},_createField:function(h){var i=null;switch(h.type){case"text":i=this._fieldText(h);break;case"select":i=this._fieldSelect(h);break;case"data":i=this._fieldData(h);break;case"data_column":h.error_text="Referenced dataset contains no suitable columns";i=this._fieldSelect(h);break;case"hidden":i=this._fieldHidden(h);break;case"integer":i=this._fieldSlider(h);break;case"float":i=this._fieldSlider(h);break;case"boolean":i=this._fieldBoolean(h);break;case"genomebuild":h.searchable=true;i=this._fieldSelect(h);break;case"drill_down":i=this._fieldDrilldown(h);break;case"baseurl":i=this._fieldHidden(h);break;default:this.app.incompatible=true;if(h.options){i=this._fieldSelect(h)}else{i=this._fieldText(h)}console.debug("tools-form::_addRow() : Auto matched field type ("+h.type+").")}if(h.value!==undefined){i.value(h.value)}return i},_fieldData:function(h){var i=this;return new a.View(this.app,{id:"field-"+h.id,extensions:h.extensions,multiple:h.multiple,type:h.type,data:h.options,onchange:function(){i.app.refresh()}})},_fieldSelect:function(h){var k=[];for(var l in h.options){var m=h.options[l];k.push({label:m[0],value:m[1]})}var n=g.Select;switch(h.display){case"checkboxes":n=g.Checkbox;break;case"radio":n=g.Radio;break}var j=this;return new n.View({id:"field-"+h.id,data:k,error_text:h.error_text||"No options available",multiple:h.multiple,searchable:h.searchable,onchange:function(){j.app.refresh()}})},_fieldDrilldown:function(h){var i=this;return new g.Drilldown.View({id:"field-"+h.id,data:h.options,display:h.display,onchange:function(){i.app.refresh()}})},_fieldText:function(h){var i=this;return new g.Input({id:"field-"+h.id,area:h.area,onchange:function(){i.app.refresh()}})},_fieldSlider:function(h){return new g.Slider.View({id:"field-"+h.id,precise:h.type=="float",min:h.min,max:h.max})},_fieldHidden:function(h){return new g.Hidden({id:"field-"+h.id})},_fieldBoolean:function(h){return new g.RadioButton.View({id:"field-"+h.id,data:[{label:"Yes",value:"true"},{label:"No",value:"false"}]})}});return{View:f}}); \ No newline at end of file diff --git a/static/scripts/packed/mvc/tools/tools-select-content.js b/static/scripts/packed/mvc/tools/tools-select-content.js index 0b69cedb6ee..7a3a9526e25 100644 --- a/static/scripts/packed/mvc/tools/tools-select-content.js +++ b/static/scripts/packed/mvc/tools/tools-select-content.js @@ -1 +1 @@ -define(["utils/utils","mvc/ui/ui-misc","mvc/ui/ui-tabs","mvc/tools/tools-template"],function(c,e,b,a){var d=Backbone.View.extend({initialize:function(k,g){this.app=k;this.options=g;var f=this;this.setElement("
");this.list={};var j=[];if(g.type=="data_collection"){this.mode="collection"}else{if(g.multiple){this.mode="multiple"}else{this.mode="single"}}this.current=this.mode;this.list={};if(this.mode=="single"){j.push({icon:"fa-file-o",label:"Single dataset",value:"single"});this.select_single=new e.Select.View({onchange:function(){f.trigger("change")}});this.list.single={field:this.select_single,type:"hda"}}if(this.mode=="single"||this.mode=="multiple"){j.push({icon:"fa-files-o",label:"Multiple datasets",value:"multiple"});this.select_multiple=new e.Select.View({multiple:true,onchange:function(){f.trigger("change")}});this.list.multiple={field:this.select_multiple,type:"hda"}}if(this.mode=="single"||this.mode=="collection"){j.push({icon:"fa-folder-o",label:"List of datasets",value:"collection"});this.select_collection=new e.Select.View({onchange:function(){f.trigger("change")}});this.list.collection={field:this.select_collection,type:"hdca"}}this.button_type=new e.RadioButton.View({value:this.current,data:j,onchange:function(i){f.current=i;f.refresh();f.trigger("change")}});this.$batch=$(a.batchMode());if(_.size(this.list)>1){this.$el.append(c.wrap(this.button_type.$el))}for(var h in this.list){this.$el.append(this.list[h].field.$el)}this.$el.append(this.$batch);this.update(g.data);if(this.options.value!==undefined){this.value(this.options.value)}this.refresh();this.on("change",function(){if(g.onchange){g.onchange(f.value())}})},wait:function(){for(var f in this.list){this.list[f].field.wait()}},unwait:function(){for(var f in this.list){this.list[f].field.unwait()}},update:function(g){var l=[];for(var j in g.hda){var k=g.hda[j];l.push({label:k.hid+": "+k.name,value:k.id})}var f=[];for(var j in g.hdca){var h=g.hdca[j];f.push({label:h.hid+": "+h.name,value:h.id})}this.select_single&&this.select_single.update(l);this.select_multiple&&this.select_multiple.update(l);this.select_collection&&this.select_collection.update(f);this.app.content.add(g)},value:function(m){if(m&&m.values){try{var l=[];for(var h in m.values){l.push(m.values[h].id)}if(m&&m.values.length>0&&m.values[0].src=="hcda"){this.current="collection";this.select_collection.value(l[0])}else{if(this.mode=="multiple"){this.current="multiple";this.select_multiple.value(l)}else{this.current="single";this.select_single.value(l[0])}}this.refresh();var g=this._select();if(!g.validate()){g.value(g.first())}}catch(k){console.debug("tools-select-content::value() - Skipped.")}}var j=this._select().value();if(!(j instanceof Array)){j=[j]}var f={batch:this.mode=="single"&&this.current!="single",values:[]};for(var h in j){f.values.push({id:j[h],src:this.list[this.current].type})}return f},validate:function(){return this._select().validate()},refresh:function(){for(var g in this.list){var f=this.list[g].field.$el;if(this.current==g){f.show()}else{f.hide()}}if(this.mode=="single"&&this.current!="single"){this.$batch.show()}else{this.$batch.hide()}},_select:function(){return this.list[this.current].field}});return{View:d}}); \ No newline at end of file +define(["utils/utils","mvc/ui/ui-misc","mvc/ui/ui-tabs","mvc/tools/tools-template"],function(c,e,b,a){var d=Backbone.View.extend({initialize:function(f,o){this.app=f;this.options=o;var n=this;this.setElement("
");this.list={};var m=[];if(o.type=="data_collection"){this.mode="collection"}else{if(o.multiple){this.mode="multiple"}else{this.mode="single"}}this.current=this.mode;this.list={};var j=o.extensions.toString();if(j){j=j.replace(",",", ");var k=j.lastIndexOf(", ");if(k!=-1){j=j.substr(0,k)+" or "+j.substr(k+1)}}var h="No dataset available";if(j){h="No dataset of type "+j+" available."}var l="No dataset list available";if(j){l="No dataset list of type "+j+" available."}if(this.mode=="single"){m.push({icon:"fa-file-o",label:"Single dataset",value:"single"});this.select_single=new e.Select.View({error_text:h,onchange:function(){n.trigger("change")}});this.list.single={field:this.select_single,type:"hda"}}if(this.mode=="single"||this.mode=="multiple"){m.push({icon:"fa-files-o",label:"Multiple datasets",value:"multiple"});this.select_multiple=new e.Select.View({multiple:true,error_text:h,onchange:function(){n.trigger("change")}});this.list.multiple={field:this.select_multiple,type:"hda"}}if(this.mode=="single"||this.mode=="collection"){m.push({icon:"fa-folder-o",label:"List of datasets",value:"collection"});this.select_collection=new e.Select.View({error_text:l,onchange:function(){n.trigger("change")}});this.list.collection={field:this.select_collection,type:"hdca"}}this.button_type=new e.RadioButton.View({value:this.current,data:m,onchange:function(i){n.current=i;n.refresh();n.trigger("change")}});this.$batch=$(a.batchMode());if(_.size(this.list)>1){this.$el.append(c.wrap(this.button_type.$el))}for(var g in this.list){this.$el.append(this.list[g].field.$el)}this.$el.append(this.$batch);this.update(o.data);if(this.options.value!==undefined){this.value(this.options.value)}this.refresh();this.on("change",function(){if(o.onchange){o.onchange(n.value())}})},wait:function(){for(var f in this.list){this.list[f].field.wait()}},unwait:function(){for(var f in this.list){this.list[f].field.unwait()}},update:function(g){var l=[];for(var j in g.hda){var k=g.hda[j];l.push({label:k.hid+": "+k.name,value:k.id})}var f=[];for(var j in g.hdca){var h=g.hdca[j];f.push({label:h.hid+": "+h.name,value:h.id})}this.select_single&&this.select_single.update(l);this.select_multiple&&this.select_multiple.update(l);this.select_collection&&this.select_collection.update(f);this.app.content.add(g)},value:function(m){if(m&&m.values){try{var l=[];for(var h in m.values){l.push(m.values[h].id)}if(m&&m.values.length>0&&m.values[0].src=="hcda"){this.current="collection";this.select_collection.value(l[0])}else{if(this.mode=="multiple"){this.current="multiple";this.select_multiple.value(l)}else{this.current="single";this.select_single.value(l[0])}}this.refresh();var g=this._select();if(!g.validate()){g.value(g.first())}}catch(k){console.debug("tools-select-content::value() - Skipped.")}}var j=this._select().value();if(!(j instanceof Array)){j=[j]}var f={batch:this.mode=="single"&&this.current!="single",values:[]};for(var h in j){f.values.push({id:j[h],src:this.list[this.current].type})}return f},validate:function(){return this._select().validate()},refresh:function(){for(var g in this.list){var f=this.list[g].field.$el;if(this.current==g){f.show()}else{f.hide()}}if(this.mode=="single"&&this.current!="single"){this.$batch.show()}else{this.$batch.hide()}},_select:function(){return this.list[this.current].field}});return{View:d}}); \ No newline at end of file diff --git a/static/scripts/packed/mvc/ui/ui-options.js b/static/scripts/packed/mvc/ui/ui-options.js index c6261e2fadb..53a6e1537ea 100644 --- a/static/scripts/packed/mvc/ui/ui-options.js +++ b/static/scripts/packed/mvc/ui/ui-options.js @@ -1 +1 @@ -define(["utils/utils"],function(b){var a=Backbone.View.extend({initialize:function(g){this.optionsDefault={visible:true,data:[],id:b.uuid(),errorText:"No data available.",waitText:"Please wait..."};this.options=b.merge(g,this.optionsDefault);this.setElement("
");this.$message=$("
");this.$options=$(this._template(g));this.$el.append(this.$message);this.$el.append(this.$options);if(!this.options.visible){this.$el.hide()}this.update(this.options.data);if(this.options.value!==undefined){this.value(this.options.value)}var f=this;this.on("change",function(){f._change()})},update:function(g){var j=this._getValue();this.$options.empty();if(this._templateOptions){this.$options.append(this._templateOptions(g))}else{for(var h in g){var i=$(this._templateOption(g[h]));i.addClass("ui-option");this.$options.append(i)}}var f=this;this.$el.find("input").on("change",function(){f.value(f._getValue());f._change()});this._refresh();this.value(j)},value:function(g){if(g!==undefined){if(!(g instanceof Array)){g=[g]}this.$el.find("input").prop("checked",false);for(var f in g){this.$el.find('input[value="'+g[f]+'"]').first().prop("checked",true)}}return this._getValue()},exists:function(g){if(g!==undefined){if(!(g instanceof Array)){g=[g]}for(var f in g){if(this.$el.find('input[value="'+g[f]+'"]').length>0){return true}}}return false},first:function(){var f=this.$el.find("input");if(f.length>0){return f.val()}else{return undefined}},validate:function(){var g=this.value();if(!(g instanceof Array)){g=[g]}for(var f in g){if([null,"null",undefined].indexOf(g[f])>-1){return false}}return true},wait:function(){if(this._size()==0){this._messageShow(this.options.waitText,"info");this.$options.hide()}},unwait:function(){this._messageHide();this._refresh()},_change:function(){if(this.options.onchange){this.options.onchange(this._getValue())}},_refresh:function(){if(this._size()==0){this._messageShow(this.options.errorText,"danger");this.$options.hide()}else{this._messageHide();this.$options.css("display","inline-block")}},_getValue:function(){var g=this.$el.find(":checked");if(g.length==0){return"null"}if(this.options.multiple){var f=[];g.each(function(){f.push($(this).val())});return f}else{return g.val()}},_size:function(){return this.$el.find(".ui-option").length},_messageShow:function(g,f){this.$message.show();this.$message.removeClass();this.$message.addClass("ui-message alert alert-"+f);this.$message.html(g)},_messageHide:function(){this.$message.hide()},_template:function(){return'
'}});var d={};d.View=a.extend({initialize:function(f){a.prototype.initialize.call(this,f)},_templateOption:function(f){return'
'+f.label+"
"}});var c={};c.View=a.extend({initialize:function(f){f.multiple=true;a.prototype.initialize.call(this,f)},_templateOption:function(f){return'
'+f.label+"
"}});var e={};e.View=a.extend({initialize:function(f){a.prototype.initialize.call(this,f)},value:function(f){if(f!==undefined){this.$el.find("input").prop("checked",false);this.$el.find("label").removeClass("active");this.$el.find('[value="'+f+'"]').prop("checked",true).closest("label").addClass("active")}return this._getValue()},_templateOption:function(g){var f='";return f},_template:function(){return'
'}});return{Base:a,Radio:d,RadioButton:e,Checkbox:c}}); \ No newline at end of file +define(["utils/utils"],function(b){var a=Backbone.View.extend({initialize:function(g){this.optionsDefault={visible:true,data:[],id:b.uuid(),error_text:"No data available.",wait_text:"Please wait..."};this.options=b.merge(g,this.optionsDefault);this.setElement("
");this.$message=$("
");this.$options=$(this._template(g));this.$el.append(this.$message);this.$el.append(this.$options);if(!this.options.visible){this.$el.hide()}this.update(this.options.data);if(this.options.value!==undefined){this.value(this.options.value)}var f=this;this.on("change",function(){f._change()})},update:function(g){var j=this._getValue();this.$options.empty();if(this._templateOptions){this.$options.append(this._templateOptions(g))}else{for(var h in g){var i=$(this._templateOption(g[h]));i.addClass("ui-option");this.$options.append(i)}}var f=this;this.$el.find("input").on("change",function(){f.value(f._getValue());f._change()});this._refresh();this.value(j)},value:function(g){if(g!==undefined){if(!(g instanceof Array)){g=[g]}this.$el.find("input").prop("checked",false);for(var f in g){this.$el.find('input[value="'+g[f]+'"]').first().prop("checked",true)}}return this._getValue()},exists:function(g){if(g!==undefined){if(!(g instanceof Array)){g=[g]}for(var f in g){if(this.$el.find('input[value="'+g[f]+'"]').length>0){return true}}}return false},first:function(){var f=this.$el.find("input");if(f.length>0){return f.val()}else{return undefined}},validate:function(){var g=this.value();if(!(g instanceof Array)){g=[g]}for(var f in g){if([null,"null",undefined].indexOf(g[f])>-1){return false}}return true},wait:function(){if(this._size()==0){this._messageShow(this.options.wait_text,"info");this.$options.hide()}},unwait:function(){this._messageHide();this._refresh()},_change:function(){if(this.options.onchange){this.options.onchange(this._getValue())}},_refresh:function(){if(this._size()==0){this._messageShow(this.options.error_text,"danger");this.$options.hide()}else{this._messageHide();this.$options.css("display","inline-block")}},_getValue:function(){var g=this.$el.find(":checked");if(g.length==0){return"null"}if(this.options.multiple){var f=[];g.each(function(){f.push($(this).val())});return f}else{return g.val()}},_size:function(){return this.$el.find(".ui-option").length},_messageShow:function(g,f){this.$message.show();this.$message.removeClass();this.$message.addClass("ui-message alert alert-"+f);this.$message.html(g)},_messageHide:function(){this.$message.hide()},_template:function(){return'
'}});var d={};d.View=a.extend({initialize:function(f){a.prototype.initialize.call(this,f)},_templateOption:function(f){return'
'+f.label+"
"}});var c={};c.View=a.extend({initialize:function(f){f.multiple=true;a.prototype.initialize.call(this,f)},_templateOption:function(f){return'
'+f.label+"
"}});var e={};e.View=a.extend({initialize:function(f){a.prototype.initialize.call(this,f)},value:function(f){if(f!==undefined){this.$el.find("input").prop("checked",false);this.$el.find("label").removeClass("active");this.$el.find('[value="'+f+'"]').prop("checked",true).closest("label").addClass("active")}return this._getValue()},_templateOption:function(g){var f='";return f},_template:function(){return'
'}});return{Base:a,Radio:d,RadioButton:e,Checkbox:c}}); \ No newline at end of file diff --git a/static/scripts/packed/mvc/ui/ui-select-default.js b/static/scripts/packed/mvc/ui/ui-select-default.js index 9e7245abf15..4255908df03 100644 --- a/static/scripts/packed/mvc/ui/ui-select-default.js +++ b/static/scripts/packed/mvc/ui/ui-select-default.js @@ -1 +1 @@ -define(["utils/utils"],function(a){var b=Backbone.View.extend({optionsDefault:{id:"",cls:"",empty:"No data available",visible:true,wait:false,multiple:false,searchable:false},initialize:function(d){this.options=a.merge(d,this.optionsDefault);this.setElement(this._template(this.options));this.$select=this.$el.find(".select");this.$icon=this.$el.find(".icon");this.$button=this.$el.find(".button");if(this.options.multiple){this.$select.prop("multiple",true);this.$select.addClass("ui-select-multiple");this.$icon.remove()}else{this.$el.addClass("ui-select")}this.update(this.options.data);if(this.options.value!==undefined){this.value(this.options.value)}if(!this.options.visible){this.hide()}if(this.options.wait){this.wait()}else{this.show()}var c=this;this.$select.on("change",function(){c._change()});this.on("change",function(){c._change()})},value:function(c){if(c!==undefined){this.$select.val(c);if(this.$select.select2){this.$select.select2("val",c)}}return this.$select.val()},first:function(){var c=this.$select.find("option");if(c.length>0){return c.val()}else{return undefined}},validate:function(){var d=this.value();if(!(d instanceof Array)){d=[d]}for(var c in d){if([null,"null",undefined].indexOf(d[c])>-1){return false}}return true},text:function(){return this.$select.find("option:selected").text()},show:function(){this.unwait();this.$select.show();this.$el.show()},hide:function(){this.$el.hide()},wait:function(){this.$icon.removeClass();this.$icon.addClass("fa fa-spinner fa-spin")},unwait:function(){this.$icon.removeClass();this.$icon.addClass("fa fa-caret-down")},disabled:function(){return this.$select.is(":disabled")},enable:function(){this.$select.prop("disabled",false)},disable:function(){this.$select.prop("disabled",true)},add:function(c){this.$select.append(this._templateOption(c));this._refresh()},del:function(c){this.$select.find("option[value="+c+"]").remove();this.$select.trigger("change");this._refresh()},update:function(c){var e=this.$select.val();this.$select.find("option").remove();for(var d in c){this.$select.append(this._templateOption(c[d]))}this._refresh();this.$select.val(e);if(!this.$select.val()){this.$select.val(this.first())}if(this.options.searchable){this.$button.hide();this.$select.select2("destroy");this.$select.select2()}},setOnChange:function(c){this.options.onchange=c},exists:function(c){return this.$select.find('option[value="'+c+'"]').length>0},_change:function(){if(this.options.onchange){this.options.onchange(this.$select.val())}},_refresh:function(){this.$select.find("option[value=null]").remove();var c=this.$select.find("option").length;if(c==0){this.disable();this.$select.append(this._templateOption({value:"null",label:this.options.empty}))}else{this.enable()}},_templateOption:function(c){return'"},_template:function(c){return'
'}});return{View:b}}); \ No newline at end of file +define(["utils/utils"],function(a){var b=Backbone.View.extend({optionsDefault:{id:"",cls:"",error_text:"No data available",visible:true,wait:false,multiple:false,searchable:false},initialize:function(d){this.options=a.merge(d,this.optionsDefault);this.setElement(this._template(this.options));this.$select=this.$el.find(".select");this.$icon=this.$el.find(".icon");this.$button=this.$el.find(".button");if(this.options.multiple){this.$select.prop("multiple",true);this.$select.addClass("ui-select-multiple");this.$icon.remove()}else{this.$el.addClass("ui-select")}this.update(this.options.data);if(this.options.value!==undefined){this.value(this.options.value)}if(!this.options.visible){this.hide()}if(this.options.wait){this.wait()}else{this.show()}var c=this;this.$select.on("change",function(){c._change()});this.on("change",function(){c._change()})},value:function(c){if(c!==undefined){this.$select.val(c);if(this.$select.select2){this.$select.select2("val",c)}}return this.$select.val()},first:function(){var c=this.$select.find("option");if(c.length>0){return c.val()}else{return undefined}},validate:function(){var d=this.value();if(!(d instanceof Array)){d=[d]}for(var c in d){if([null,"null",undefined].indexOf(d[c])>-1){return false}}return true},text:function(){return this.$select.find("option:selected").text()},show:function(){this.unwait();this.$select.show();this.$el.show()},hide:function(){this.$el.hide()},wait:function(){this.$icon.removeClass();this.$icon.addClass("fa fa-spinner fa-spin")},unwait:function(){this.$icon.removeClass();this.$icon.addClass("fa fa-caret-down")},disabled:function(){return this.$select.is(":disabled")},enable:function(){this.$select.prop("disabled",false)},disable:function(){this.$select.prop("disabled",true)},add:function(c){this.$select.append(this._templateOption(c));this._refresh()},del:function(c){this.$select.find("option[value="+c+"]").remove();this.$select.trigger("change");this._refresh()},update:function(c){var e=this.$select.val();this.$select.find("option").remove();for(var d in c){this.$select.append(this._templateOption(c[d]))}this._refresh();this.$select.val(e);if(!this.$select.val()){this.$select.val(this.first())}if(this.options.searchable){this.$button.hide();this.$select.select2("destroy");this.$select.select2()}},setOnChange:function(c){this.options.onchange=c},exists:function(c){return this.$select.find('option[value="'+c+'"]').length>0},_change:function(){if(this.options.onchange){this.options.onchange(this.$select.val())}},_refresh:function(){this.$select.find("option[value=null]").remove();var c=this.$select.find("option").length;if(c==0){this.disable();this.$select.append(this._templateOption({value:"null",label:this.options.error_text}))}else{this.enable()}},_templateOption:function(c){return'"},_template:function(c){return'
'}});return{View:b}}); \ No newline at end of file From b253f156d28ebad50f767f14b0c241585852d693 Mon Sep 17 00:00:00 2001 From: Aysam Guerler Date: Thu, 4 Dec 2014 11:53:22 -0500 Subject: [PATCH 15/20] ToolForm: Update error message --- .../galaxy/scripts/mvc/tools/tools-select-content.js | 10 +++++----- static/scripts/mvc/tools/tools-select-content.js | 10 +++++----- .../scripts/packed/mvc/tools/tools-select-content.js | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/client/galaxy/scripts/mvc/tools/tools-select-content.js b/client/galaxy/scripts/mvc/tools/tools-select-content.js index ae94518d081..2c22776fd41 100644 --- a/client/galaxy/scripts/mvc/tools/tools-select-content.js +++ b/client/galaxy/scripts/mvc/tools/tools-select-content.js @@ -41,16 +41,16 @@ var View = Backbone.View.extend({ extensions = extensions.replace(',', ', '); var pos = extensions.lastIndexOf(', '); if (pos != -1) { - extensions = extensions.substr(0, pos) + " or " + extensions.substr(pos+1); + extensions = extensions.substr(0, pos) + ' or ' + extensions.substr(pos+1); } } - var hda_error = 'No dataset available'; + var hda_error = 'No dataset available.'; if (extensions) { - hda_error = 'No dataset of type ' + extensions + ' available.'; + hda_error = 'No ' + extensions + ' dataset available.'; } - var hdca_error = 'No dataset list available'; + var hdca_error = 'No dataset list available.'; if (extensions) { - hdca_error = 'No dataset list of type ' + extensions + ' available.'; + hdca_error = 'No ' + extensions + ' dataset list available.'; } // add single dataset selector diff --git a/static/scripts/mvc/tools/tools-select-content.js b/static/scripts/mvc/tools/tools-select-content.js index ae94518d081..2c22776fd41 100644 --- a/static/scripts/mvc/tools/tools-select-content.js +++ b/static/scripts/mvc/tools/tools-select-content.js @@ -41,16 +41,16 @@ var View = Backbone.View.extend({ extensions = extensions.replace(',', ', '); var pos = extensions.lastIndexOf(', '); if (pos != -1) { - extensions = extensions.substr(0, pos) + " or " + extensions.substr(pos+1); + extensions = extensions.substr(0, pos) + ' or ' + extensions.substr(pos+1); } } - var hda_error = 'No dataset available'; + var hda_error = 'No dataset available.'; if (extensions) { - hda_error = 'No dataset of type ' + extensions + ' available.'; + hda_error = 'No ' + extensions + ' dataset available.'; } - var hdca_error = 'No dataset list available'; + var hdca_error = 'No dataset list available.'; if (extensions) { - hdca_error = 'No dataset list of type ' + extensions + ' available.'; + hdca_error = 'No ' + extensions + ' dataset list available.'; } // add single dataset selector diff --git a/static/scripts/packed/mvc/tools/tools-select-content.js b/static/scripts/packed/mvc/tools/tools-select-content.js index 7a3a9526e25..11c4d6ebccc 100644 --- a/static/scripts/packed/mvc/tools/tools-select-content.js +++ b/static/scripts/packed/mvc/tools/tools-select-content.js @@ -1 +1 @@ -define(["utils/utils","mvc/ui/ui-misc","mvc/ui/ui-tabs","mvc/tools/tools-template"],function(c,e,b,a){var d=Backbone.View.extend({initialize:function(f,o){this.app=f;this.options=o;var n=this;this.setElement("
");this.list={};var m=[];if(o.type=="data_collection"){this.mode="collection"}else{if(o.multiple){this.mode="multiple"}else{this.mode="single"}}this.current=this.mode;this.list={};var j=o.extensions.toString();if(j){j=j.replace(",",", ");var k=j.lastIndexOf(", ");if(k!=-1){j=j.substr(0,k)+" or "+j.substr(k+1)}}var h="No dataset available";if(j){h="No dataset of type "+j+" available."}var l="No dataset list available";if(j){l="No dataset list of type "+j+" available."}if(this.mode=="single"){m.push({icon:"fa-file-o",label:"Single dataset",value:"single"});this.select_single=new e.Select.View({error_text:h,onchange:function(){n.trigger("change")}});this.list.single={field:this.select_single,type:"hda"}}if(this.mode=="single"||this.mode=="multiple"){m.push({icon:"fa-files-o",label:"Multiple datasets",value:"multiple"});this.select_multiple=new e.Select.View({multiple:true,error_text:h,onchange:function(){n.trigger("change")}});this.list.multiple={field:this.select_multiple,type:"hda"}}if(this.mode=="single"||this.mode=="collection"){m.push({icon:"fa-folder-o",label:"List of datasets",value:"collection"});this.select_collection=new e.Select.View({error_text:l,onchange:function(){n.trigger("change")}});this.list.collection={field:this.select_collection,type:"hdca"}}this.button_type=new e.RadioButton.View({value:this.current,data:m,onchange:function(i){n.current=i;n.refresh();n.trigger("change")}});this.$batch=$(a.batchMode());if(_.size(this.list)>1){this.$el.append(c.wrap(this.button_type.$el))}for(var g in this.list){this.$el.append(this.list[g].field.$el)}this.$el.append(this.$batch);this.update(o.data);if(this.options.value!==undefined){this.value(this.options.value)}this.refresh();this.on("change",function(){if(o.onchange){o.onchange(n.value())}})},wait:function(){for(var f in this.list){this.list[f].field.wait()}},unwait:function(){for(var f in this.list){this.list[f].field.unwait()}},update:function(g){var l=[];for(var j in g.hda){var k=g.hda[j];l.push({label:k.hid+": "+k.name,value:k.id})}var f=[];for(var j in g.hdca){var h=g.hdca[j];f.push({label:h.hid+": "+h.name,value:h.id})}this.select_single&&this.select_single.update(l);this.select_multiple&&this.select_multiple.update(l);this.select_collection&&this.select_collection.update(f);this.app.content.add(g)},value:function(m){if(m&&m.values){try{var l=[];for(var h in m.values){l.push(m.values[h].id)}if(m&&m.values.length>0&&m.values[0].src=="hcda"){this.current="collection";this.select_collection.value(l[0])}else{if(this.mode=="multiple"){this.current="multiple";this.select_multiple.value(l)}else{this.current="single";this.select_single.value(l[0])}}this.refresh();var g=this._select();if(!g.validate()){g.value(g.first())}}catch(k){console.debug("tools-select-content::value() - Skipped.")}}var j=this._select().value();if(!(j instanceof Array)){j=[j]}var f={batch:this.mode=="single"&&this.current!="single",values:[]};for(var h in j){f.values.push({id:j[h],src:this.list[this.current].type})}return f},validate:function(){return this._select().validate()},refresh:function(){for(var g in this.list){var f=this.list[g].field.$el;if(this.current==g){f.show()}else{f.hide()}}if(this.mode=="single"&&this.current!="single"){this.$batch.show()}else{this.$batch.hide()}},_select:function(){return this.list[this.current].field}});return{View:d}}); \ No newline at end of file +define(["utils/utils","mvc/ui/ui-misc","mvc/ui/ui-tabs","mvc/tools/tools-template"],function(c,e,b,a){var d=Backbone.View.extend({initialize:function(f,o){this.app=f;this.options=o;var n=this;this.setElement("
");this.list={};var m=[];if(o.type=="data_collection"){this.mode="collection"}else{if(o.multiple){this.mode="multiple"}else{this.mode="single"}}this.current=this.mode;this.list={};var j=o.extensions.toString();if(j){j=j.replace(",",", ");var k=j.lastIndexOf(", ");if(k!=-1){j=j.substr(0,k)+" or "+j.substr(k+1)}}var h="No dataset available.";if(j){h="No "+j+" dataset available."}var l="No dataset list available.";if(j){l="No "+j+" dataset list available."}if(this.mode=="single"){m.push({icon:"fa-file-o",label:"Single dataset",value:"single"});this.select_single=new e.Select.View({error_text:h,onchange:function(){n.trigger("change")}});this.list.single={field:this.select_single,type:"hda"}}if(this.mode=="single"||this.mode=="multiple"){m.push({icon:"fa-files-o",label:"Multiple datasets",value:"multiple"});this.select_multiple=new e.Select.View({multiple:true,error_text:h,onchange:function(){n.trigger("change")}});this.list.multiple={field:this.select_multiple,type:"hda"}}if(this.mode=="single"||this.mode=="collection"){m.push({icon:"fa-folder-o",label:"List of datasets",value:"collection"});this.select_collection=new e.Select.View({error_text:l,onchange:function(){n.trigger("change")}});this.list.collection={field:this.select_collection,type:"hdca"}}this.button_type=new e.RadioButton.View({value:this.current,data:m,onchange:function(i){n.current=i;n.refresh();n.trigger("change")}});this.$batch=$(a.batchMode());if(_.size(this.list)>1){this.$el.append(c.wrap(this.button_type.$el))}for(var g in this.list){this.$el.append(this.list[g].field.$el)}this.$el.append(this.$batch);this.update(o.data);if(this.options.value!==undefined){this.value(this.options.value)}this.refresh();this.on("change",function(){if(o.onchange){o.onchange(n.value())}})},wait:function(){for(var f in this.list){this.list[f].field.wait()}},unwait:function(){for(var f in this.list){this.list[f].field.unwait()}},update:function(g){var l=[];for(var j in g.hda){var k=g.hda[j];l.push({label:k.hid+": "+k.name,value:k.id})}var f=[];for(var j in g.hdca){var h=g.hdca[j];f.push({label:h.hid+": "+h.name,value:h.id})}this.select_single&&this.select_single.update(l);this.select_multiple&&this.select_multiple.update(l);this.select_collection&&this.select_collection.update(f);this.app.content.add(g)},value:function(m){if(m&&m.values){try{var l=[];for(var h in m.values){l.push(m.values[h].id)}if(m&&m.values.length>0&&m.values[0].src=="hcda"){this.current="collection";this.select_collection.value(l[0])}else{if(this.mode=="multiple"){this.current="multiple";this.select_multiple.value(l)}else{this.current="single";this.select_single.value(l[0])}}this.refresh();var g=this._select();if(!g.validate()){g.value(g.first())}}catch(k){console.debug("tools-select-content::value() - Skipped.")}}var j=this._select().value();if(!(j instanceof Array)){j=[j]}var f={batch:this.mode=="single"&&this.current!="single",values:[]};for(var h in j){f.values.push({id:j[h],src:this.list[this.current].type})}return f},validate:function(){return this._select().validate()},refresh:function(){for(var g in this.list){var f=this.list[g].field.$el;if(this.current==g){f.show()}else{f.hide()}}if(this.mode=="single"&&this.current!="single"){this.$batch.show()}else{this.$batch.hide()}},_select:function(){return this.list[this.current].field}});return{View:d}}); \ No newline at end of file From ac6d206b64b97916cb2e4552cf708a4d9a6ab799 Mon Sep 17 00:00:00 2001 From: Aysam Guerler Date: Thu, 4 Dec 2014 11:59:21 -0500 Subject: [PATCH 16/20] ToolForm: Update error message for missing columns --- client/galaxy/scripts/mvc/tools/tools-section.js | 2 +- static/scripts/mvc/tools/tools-section.js | 2 +- static/scripts/packed/mvc/tools/tools-section.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client/galaxy/scripts/mvc/tools/tools-section.js b/client/galaxy/scripts/mvc/tools/tools-section.js index d18525676ff..528431a14c0 100644 --- a/client/galaxy/scripts/mvc/tools/tools-section.js +++ b/client/galaxy/scripts/mvc/tools/tools-section.js @@ -314,7 +314,7 @@ define(['utils/utils', 'mvc/ui/ui-table', 'mvc/ui/ui-misc', 'mvc/tools/tools-rep // data column case 'data_column': - input_def.error_text = 'Referenced dataset contains no suitable columns'; + input_def.error_text = 'Referenced dataset has no matching columns.'; field = this._fieldSelect(input_def); break; diff --git a/static/scripts/mvc/tools/tools-section.js b/static/scripts/mvc/tools/tools-section.js index d18525676ff..528431a14c0 100644 --- a/static/scripts/mvc/tools/tools-section.js +++ b/static/scripts/mvc/tools/tools-section.js @@ -314,7 +314,7 @@ define(['utils/utils', 'mvc/ui/ui-table', 'mvc/ui/ui-misc', 'mvc/tools/tools-rep // data column case 'data_column': - input_def.error_text = 'Referenced dataset contains no suitable columns'; + input_def.error_text = 'Referenced dataset has no matching columns.'; field = this._fieldSelect(input_def); break; diff --git a/static/scripts/packed/mvc/tools/tools-section.js b/static/scripts/packed/mvc/tools/tools-section.js index 5c5623c9e6c..9e901ffc44e 100644 --- a/static/scripts/packed/mvc/tools/tools-section.js +++ b/static/scripts/packed/mvc/tools/tools-section.js @@ -1 +1 @@ -define(["utils/utils","mvc/ui/ui-table","mvc/ui/ui-misc","mvc/tools/tools-repeat","mvc/tools/tools-select-content","mvc/tools/tools-input"],function(d,b,g,c,a,e){var f=Backbone.View.extend({initialize:function(i,h){this.app=i;this.inputs=h.inputs;h.cls_tr="section-row";this.table=new b.View(h);this.setElement(this.table.$el);this.render()},render:function(){this.table.delAll();for(var h in this.inputs){this._add(this.inputs[h])}},_add:function(j){var i=this;var h=jQuery.extend(true,{},j);h.id=j.id=d.uuid();this.app.input_list[h.id]=h;var k=h.type;switch(k){case"conditional":this._addConditional(h);break;case"repeat":this._addRepeat(h);break;default:this._addRow(h)}},_addConditional:function(h){var j=this;h.test_param.id=h.id;var m=this._addRow(h.test_param);m.options.onchange=function(t){var p=j.app.tree.matchCase(h,t);for(var r in h.cases){var w=h.cases[r];var u=h.id+"-section-"+r;var o=j.table.get(u);var v=false;for(var q in w.inputs){var s=w.inputs[q].type;if(s&&s!=="hidden"){v=true;break}}if(r==p&&v){o.fadeIn("fast")}else{o.hide()}}j.app.refresh()};for(var l in h.cases){var k=h.id+"-section-"+l;var n=new f(this.app,{inputs:h.cases[l].inputs,cls:"ui-table-plain"});n.$el.addClass("ui-table-form-section");this.table.add(n.$el);this.table.append(k)}m.trigger("change")},_addRepeat:function(o){var r=this;var p=0;function m(i,t){var s=o.id+"-section-"+(p++);var u=null;if(t){u=function(){k.del(s);k.retitle(o.title);r.app.rebuild();r.app.refresh()}}var v=new f(r.app,{inputs:i,cls:"ui-table-plain"});k.add({id:s,title:o.title,$el:v.$el,ondel:u});k.retitle(o.title)}var k=new c.View({title_new:o.title,max:o.max,onnew:function(){m(o.inputs,true);r.app.rebuild();r.app.refresh()}});var h=o.min;var q=_.size(o.cache);for(var l=0;l=h)}var j=new e(this.app,{label:o.title,help:o.help,field:k});j.$el.addClass("ui-table-form-section");this.table.add(j.$el);this.table.append(o.id)},_addRow:function(h){var k=h.id;var i=this._createField(h);if(h.is_dynamic){this.app.is_dynamic=true}this.app.field_list[k]=i;var j=new e(this.app,{label:h.label,optional:h.optional,help:h.help,field:i});this.app.element_list[k]=j;this.table.add(j.$el);this.table.append(k);return i},_createField:function(h){var i=null;switch(h.type){case"text":i=this._fieldText(h);break;case"select":i=this._fieldSelect(h);break;case"data":i=this._fieldData(h);break;case"data_column":h.error_text="Referenced dataset contains no suitable columns";i=this._fieldSelect(h);break;case"hidden":i=this._fieldHidden(h);break;case"integer":i=this._fieldSlider(h);break;case"float":i=this._fieldSlider(h);break;case"boolean":i=this._fieldBoolean(h);break;case"genomebuild":h.searchable=true;i=this._fieldSelect(h);break;case"drill_down":i=this._fieldDrilldown(h);break;case"baseurl":i=this._fieldHidden(h);break;default:this.app.incompatible=true;if(h.options){i=this._fieldSelect(h)}else{i=this._fieldText(h)}console.debug("tools-form::_addRow() : Auto matched field type ("+h.type+").")}if(h.value!==undefined){i.value(h.value)}return i},_fieldData:function(h){var i=this;return new a.View(this.app,{id:"field-"+h.id,extensions:h.extensions,multiple:h.multiple,type:h.type,data:h.options,onchange:function(){i.app.refresh()}})},_fieldSelect:function(h){var k=[];for(var l in h.options){var m=h.options[l];k.push({label:m[0],value:m[1]})}var n=g.Select;switch(h.display){case"checkboxes":n=g.Checkbox;break;case"radio":n=g.Radio;break}var j=this;return new n.View({id:"field-"+h.id,data:k,error_text:h.error_text||"No options available",multiple:h.multiple,searchable:h.searchable,onchange:function(){j.app.refresh()}})},_fieldDrilldown:function(h){var i=this;return new g.Drilldown.View({id:"field-"+h.id,data:h.options,display:h.display,onchange:function(){i.app.refresh()}})},_fieldText:function(h){var i=this;return new g.Input({id:"field-"+h.id,area:h.area,onchange:function(){i.app.refresh()}})},_fieldSlider:function(h){return new g.Slider.View({id:"field-"+h.id,precise:h.type=="float",min:h.min,max:h.max})},_fieldHidden:function(h){return new g.Hidden({id:"field-"+h.id})},_fieldBoolean:function(h){return new g.RadioButton.View({id:"field-"+h.id,data:[{label:"Yes",value:"true"},{label:"No",value:"false"}]})}});return{View:f}}); \ No newline at end of file +define(["utils/utils","mvc/ui/ui-table","mvc/ui/ui-misc","mvc/tools/tools-repeat","mvc/tools/tools-select-content","mvc/tools/tools-input"],function(d,b,g,c,a,e){var f=Backbone.View.extend({initialize:function(i,h){this.app=i;this.inputs=h.inputs;h.cls_tr="section-row";this.table=new b.View(h);this.setElement(this.table.$el);this.render()},render:function(){this.table.delAll();for(var h in this.inputs){this._add(this.inputs[h])}},_add:function(j){var i=this;var h=jQuery.extend(true,{},j);h.id=j.id=d.uuid();this.app.input_list[h.id]=h;var k=h.type;switch(k){case"conditional":this._addConditional(h);break;case"repeat":this._addRepeat(h);break;default:this._addRow(h)}},_addConditional:function(h){var j=this;h.test_param.id=h.id;var m=this._addRow(h.test_param);m.options.onchange=function(t){var p=j.app.tree.matchCase(h,t);for(var r in h.cases){var w=h.cases[r];var u=h.id+"-section-"+r;var o=j.table.get(u);var v=false;for(var q in w.inputs){var s=w.inputs[q].type;if(s&&s!=="hidden"){v=true;break}}if(r==p&&v){o.fadeIn("fast")}else{o.hide()}}j.app.refresh()};for(var l in h.cases){var k=h.id+"-section-"+l;var n=new f(this.app,{inputs:h.cases[l].inputs,cls:"ui-table-plain"});n.$el.addClass("ui-table-form-section");this.table.add(n.$el);this.table.append(k)}m.trigger("change")},_addRepeat:function(o){var r=this;var p=0;function m(i,t){var s=o.id+"-section-"+(p++);var u=null;if(t){u=function(){k.del(s);k.retitle(o.title);r.app.rebuild();r.app.refresh()}}var v=new f(r.app,{inputs:i,cls:"ui-table-plain"});k.add({id:s,title:o.title,$el:v.$el,ondel:u});k.retitle(o.title)}var k=new c.View({title_new:o.title,max:o.max,onnew:function(){m(o.inputs,true);r.app.rebuild();r.app.refresh()}});var h=o.min;var q=_.size(o.cache);for(var l=0;l=h)}var j=new e(this.app,{label:o.title,help:o.help,field:k});j.$el.addClass("ui-table-form-section");this.table.add(j.$el);this.table.append(o.id)},_addRow:function(h){var k=h.id;var i=this._createField(h);if(h.is_dynamic){this.app.is_dynamic=true}this.app.field_list[k]=i;var j=new e(this.app,{label:h.label,optional:h.optional,help:h.help,field:i});this.app.element_list[k]=j;this.table.add(j.$el);this.table.append(k);return i},_createField:function(h){var i=null;switch(h.type){case"text":i=this._fieldText(h);break;case"select":i=this._fieldSelect(h);break;case"data":i=this._fieldData(h);break;case"data_column":h.error_text="Referenced dataset has no matching columns.";i=this._fieldSelect(h);break;case"hidden":i=this._fieldHidden(h);break;case"integer":i=this._fieldSlider(h);break;case"float":i=this._fieldSlider(h);break;case"boolean":i=this._fieldBoolean(h);break;case"genomebuild":h.searchable=true;i=this._fieldSelect(h);break;case"drill_down":i=this._fieldDrilldown(h);break;case"baseurl":i=this._fieldHidden(h);break;default:this.app.incompatible=true;if(h.options){i=this._fieldSelect(h)}else{i=this._fieldText(h)}console.debug("tools-form::_addRow() : Auto matched field type ("+h.type+").")}if(h.value!==undefined){i.value(h.value)}return i},_fieldData:function(h){var i=this;return new a.View(this.app,{id:"field-"+h.id,extensions:h.extensions,multiple:h.multiple,type:h.type,data:h.options,onchange:function(){i.app.refresh()}})},_fieldSelect:function(h){var k=[];for(var l in h.options){var m=h.options[l];k.push({label:m[0],value:m[1]})}var n=g.Select;switch(h.display){case"checkboxes":n=g.Checkbox;break;case"radio":n=g.Radio;break}var j=this;return new n.View({id:"field-"+h.id,data:k,error_text:h.error_text||"No options available",multiple:h.multiple,searchable:h.searchable,onchange:function(){j.app.refresh()}})},_fieldDrilldown:function(h){var i=this;return new g.Drilldown.View({id:"field-"+h.id,data:h.options,display:h.display,onchange:function(){i.app.refresh()}})},_fieldText:function(h){var i=this;return new g.Input({id:"field-"+h.id,area:h.area,onchange:function(){i.app.refresh()}})},_fieldSlider:function(h){return new g.Slider.View({id:"field-"+h.id,precise:h.type=="float",min:h.min,max:h.max})},_fieldHidden:function(h){return new g.Hidden({id:"field-"+h.id})},_fieldBoolean:function(h){return new g.RadioButton.View({id:"field-"+h.id,data:[{label:"Yes",value:"true"},{label:"No",value:"false"}]})}});return{View:f}}); \ No newline at end of file From 7074efcc90693cc1e097ecc5b7c456a3808c7643 Mon Sep 17 00:00:00 2001 From: Aysam Guerler Date: Thu, 4 Dec 2014 12:01:34 -0500 Subject: [PATCH 17/20] ToolForm: Update error message again --- client/galaxy/scripts/mvc/tools/tools-section.js | 2 +- static/scripts/mvc/tools/tools-section.js | 2 +- static/scripts/packed/mvc/tools/tools-section.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client/galaxy/scripts/mvc/tools/tools-section.js b/client/galaxy/scripts/mvc/tools/tools-section.js index 528431a14c0..eb61413db61 100644 --- a/client/galaxy/scripts/mvc/tools/tools-section.js +++ b/client/galaxy/scripts/mvc/tools/tools-section.js @@ -314,7 +314,7 @@ define(['utils/utils', 'mvc/ui/ui-table', 'mvc/ui/ui-misc', 'mvc/tools/tools-rep // data column case 'data_column': - input_def.error_text = 'Referenced dataset has no matching columns.'; + input_def.error_text = 'Missing columns in referenced dataset.'; field = this._fieldSelect(input_def); break; diff --git a/static/scripts/mvc/tools/tools-section.js b/static/scripts/mvc/tools/tools-section.js index 528431a14c0..eb61413db61 100644 --- a/static/scripts/mvc/tools/tools-section.js +++ b/static/scripts/mvc/tools/tools-section.js @@ -314,7 +314,7 @@ define(['utils/utils', 'mvc/ui/ui-table', 'mvc/ui/ui-misc', 'mvc/tools/tools-rep // data column case 'data_column': - input_def.error_text = 'Referenced dataset has no matching columns.'; + input_def.error_text = 'Missing columns in referenced dataset.'; field = this._fieldSelect(input_def); break; diff --git a/static/scripts/packed/mvc/tools/tools-section.js b/static/scripts/packed/mvc/tools/tools-section.js index 9e901ffc44e..1f6152001e8 100644 --- a/static/scripts/packed/mvc/tools/tools-section.js +++ b/static/scripts/packed/mvc/tools/tools-section.js @@ -1 +1 @@ -define(["utils/utils","mvc/ui/ui-table","mvc/ui/ui-misc","mvc/tools/tools-repeat","mvc/tools/tools-select-content","mvc/tools/tools-input"],function(d,b,g,c,a,e){var f=Backbone.View.extend({initialize:function(i,h){this.app=i;this.inputs=h.inputs;h.cls_tr="section-row";this.table=new b.View(h);this.setElement(this.table.$el);this.render()},render:function(){this.table.delAll();for(var h in this.inputs){this._add(this.inputs[h])}},_add:function(j){var i=this;var h=jQuery.extend(true,{},j);h.id=j.id=d.uuid();this.app.input_list[h.id]=h;var k=h.type;switch(k){case"conditional":this._addConditional(h);break;case"repeat":this._addRepeat(h);break;default:this._addRow(h)}},_addConditional:function(h){var j=this;h.test_param.id=h.id;var m=this._addRow(h.test_param);m.options.onchange=function(t){var p=j.app.tree.matchCase(h,t);for(var r in h.cases){var w=h.cases[r];var u=h.id+"-section-"+r;var o=j.table.get(u);var v=false;for(var q in w.inputs){var s=w.inputs[q].type;if(s&&s!=="hidden"){v=true;break}}if(r==p&&v){o.fadeIn("fast")}else{o.hide()}}j.app.refresh()};for(var l in h.cases){var k=h.id+"-section-"+l;var n=new f(this.app,{inputs:h.cases[l].inputs,cls:"ui-table-plain"});n.$el.addClass("ui-table-form-section");this.table.add(n.$el);this.table.append(k)}m.trigger("change")},_addRepeat:function(o){var r=this;var p=0;function m(i,t){var s=o.id+"-section-"+(p++);var u=null;if(t){u=function(){k.del(s);k.retitle(o.title);r.app.rebuild();r.app.refresh()}}var v=new f(r.app,{inputs:i,cls:"ui-table-plain"});k.add({id:s,title:o.title,$el:v.$el,ondel:u});k.retitle(o.title)}var k=new c.View({title_new:o.title,max:o.max,onnew:function(){m(o.inputs,true);r.app.rebuild();r.app.refresh()}});var h=o.min;var q=_.size(o.cache);for(var l=0;l=h)}var j=new e(this.app,{label:o.title,help:o.help,field:k});j.$el.addClass("ui-table-form-section");this.table.add(j.$el);this.table.append(o.id)},_addRow:function(h){var k=h.id;var i=this._createField(h);if(h.is_dynamic){this.app.is_dynamic=true}this.app.field_list[k]=i;var j=new e(this.app,{label:h.label,optional:h.optional,help:h.help,field:i});this.app.element_list[k]=j;this.table.add(j.$el);this.table.append(k);return i},_createField:function(h){var i=null;switch(h.type){case"text":i=this._fieldText(h);break;case"select":i=this._fieldSelect(h);break;case"data":i=this._fieldData(h);break;case"data_column":h.error_text="Referenced dataset has no matching columns.";i=this._fieldSelect(h);break;case"hidden":i=this._fieldHidden(h);break;case"integer":i=this._fieldSlider(h);break;case"float":i=this._fieldSlider(h);break;case"boolean":i=this._fieldBoolean(h);break;case"genomebuild":h.searchable=true;i=this._fieldSelect(h);break;case"drill_down":i=this._fieldDrilldown(h);break;case"baseurl":i=this._fieldHidden(h);break;default:this.app.incompatible=true;if(h.options){i=this._fieldSelect(h)}else{i=this._fieldText(h)}console.debug("tools-form::_addRow() : Auto matched field type ("+h.type+").")}if(h.value!==undefined){i.value(h.value)}return i},_fieldData:function(h){var i=this;return new a.View(this.app,{id:"field-"+h.id,extensions:h.extensions,multiple:h.multiple,type:h.type,data:h.options,onchange:function(){i.app.refresh()}})},_fieldSelect:function(h){var k=[];for(var l in h.options){var m=h.options[l];k.push({label:m[0],value:m[1]})}var n=g.Select;switch(h.display){case"checkboxes":n=g.Checkbox;break;case"radio":n=g.Radio;break}var j=this;return new n.View({id:"field-"+h.id,data:k,error_text:h.error_text||"No options available",multiple:h.multiple,searchable:h.searchable,onchange:function(){j.app.refresh()}})},_fieldDrilldown:function(h){var i=this;return new g.Drilldown.View({id:"field-"+h.id,data:h.options,display:h.display,onchange:function(){i.app.refresh()}})},_fieldText:function(h){var i=this;return new g.Input({id:"field-"+h.id,area:h.area,onchange:function(){i.app.refresh()}})},_fieldSlider:function(h){return new g.Slider.View({id:"field-"+h.id,precise:h.type=="float",min:h.min,max:h.max})},_fieldHidden:function(h){return new g.Hidden({id:"field-"+h.id})},_fieldBoolean:function(h){return new g.RadioButton.View({id:"field-"+h.id,data:[{label:"Yes",value:"true"},{label:"No",value:"false"}]})}});return{View:f}}); \ No newline at end of file +define(["utils/utils","mvc/ui/ui-table","mvc/ui/ui-misc","mvc/tools/tools-repeat","mvc/tools/tools-select-content","mvc/tools/tools-input"],function(d,b,g,c,a,e){var f=Backbone.View.extend({initialize:function(i,h){this.app=i;this.inputs=h.inputs;h.cls_tr="section-row";this.table=new b.View(h);this.setElement(this.table.$el);this.render()},render:function(){this.table.delAll();for(var h in this.inputs){this._add(this.inputs[h])}},_add:function(j){var i=this;var h=jQuery.extend(true,{},j);h.id=j.id=d.uuid();this.app.input_list[h.id]=h;var k=h.type;switch(k){case"conditional":this._addConditional(h);break;case"repeat":this._addRepeat(h);break;default:this._addRow(h)}},_addConditional:function(h){var j=this;h.test_param.id=h.id;var m=this._addRow(h.test_param);m.options.onchange=function(t){var p=j.app.tree.matchCase(h,t);for(var r in h.cases){var w=h.cases[r];var u=h.id+"-section-"+r;var o=j.table.get(u);var v=false;for(var q in w.inputs){var s=w.inputs[q].type;if(s&&s!=="hidden"){v=true;break}}if(r==p&&v){o.fadeIn("fast")}else{o.hide()}}j.app.refresh()};for(var l in h.cases){var k=h.id+"-section-"+l;var n=new f(this.app,{inputs:h.cases[l].inputs,cls:"ui-table-plain"});n.$el.addClass("ui-table-form-section");this.table.add(n.$el);this.table.append(k)}m.trigger("change")},_addRepeat:function(o){var r=this;var p=0;function m(i,t){var s=o.id+"-section-"+(p++);var u=null;if(t){u=function(){k.del(s);k.retitle(o.title);r.app.rebuild();r.app.refresh()}}var v=new f(r.app,{inputs:i,cls:"ui-table-plain"});k.add({id:s,title:o.title,$el:v.$el,ondel:u});k.retitle(o.title)}var k=new c.View({title_new:o.title,max:o.max,onnew:function(){m(o.inputs,true);r.app.rebuild();r.app.refresh()}});var h=o.min;var q=_.size(o.cache);for(var l=0;l=h)}var j=new e(this.app,{label:o.title,help:o.help,field:k});j.$el.addClass("ui-table-form-section");this.table.add(j.$el);this.table.append(o.id)},_addRow:function(h){var k=h.id;var i=this._createField(h);if(h.is_dynamic){this.app.is_dynamic=true}this.app.field_list[k]=i;var j=new e(this.app,{label:h.label,optional:h.optional,help:h.help,field:i});this.app.element_list[k]=j;this.table.add(j.$el);this.table.append(k);return i},_createField:function(h){var i=null;switch(h.type){case"text":i=this._fieldText(h);break;case"select":i=this._fieldSelect(h);break;case"data":i=this._fieldData(h);break;case"data_column":h.error_text="Missing columns in referenced dataset.";i=this._fieldSelect(h);break;case"hidden":i=this._fieldHidden(h);break;case"integer":i=this._fieldSlider(h);break;case"float":i=this._fieldSlider(h);break;case"boolean":i=this._fieldBoolean(h);break;case"genomebuild":h.searchable=true;i=this._fieldSelect(h);break;case"drill_down":i=this._fieldDrilldown(h);break;case"baseurl":i=this._fieldHidden(h);break;default:this.app.incompatible=true;if(h.options){i=this._fieldSelect(h)}else{i=this._fieldText(h)}console.debug("tools-form::_addRow() : Auto matched field type ("+h.type+").")}if(h.value!==undefined){i.value(h.value)}return i},_fieldData:function(h){var i=this;return new a.View(this.app,{id:"field-"+h.id,extensions:h.extensions,multiple:h.multiple,type:h.type,data:h.options,onchange:function(){i.app.refresh()}})},_fieldSelect:function(h){var k=[];for(var l in h.options){var m=h.options[l];k.push({label:m[0],value:m[1]})}var n=g.Select;switch(h.display){case"checkboxes":n=g.Checkbox;break;case"radio":n=g.Radio;break}var j=this;return new n.View({id:"field-"+h.id,data:k,error_text:h.error_text||"No options available",multiple:h.multiple,searchable:h.searchable,onchange:function(){j.app.refresh()}})},_fieldDrilldown:function(h){var i=this;return new g.Drilldown.View({id:"field-"+h.id,data:h.options,display:h.display,onchange:function(){i.app.refresh()}})},_fieldText:function(h){var i=this;return new g.Input({id:"field-"+h.id,area:h.area,onchange:function(){i.app.refresh()}})},_fieldSlider:function(h){return new g.Slider.View({id:"field-"+h.id,precise:h.type=="float",min:h.min,max:h.max})},_fieldHidden:function(h){return new g.Hidden({id:"field-"+h.id})},_fieldBoolean:function(h){return new g.RadioButton.View({id:"field-"+h.id,data:[{label:"Yes",value:"true"},{label:"No",value:"false"}]})}});return{View:f}}); \ No newline at end of file From 91893c86d1952bddadcb5808730373d872841e78 Mon Sep 17 00:00:00 2001 From: Martin Cech Date: Fri, 5 Dec 2014 17:21:57 -0500 Subject: [PATCH 18/20] paginate library folder contents to prevent loooooong rendering when hundreds of items are in one folder --- client/galaxy/scripts/galaxy.library.js | 137 ++-- .../mvc/library/library-folderlist-view.js | 621 ++++++++++-------- .../mvc/library/library-foldertoolbar-view.js | 75 ++- .../mvc/library/library-librarylist-view.js | 28 +- static/scripts/galaxy.library.js | 137 ++-- .../mvc/library/library-folderlist-view.js | 621 ++++++++++-------- .../mvc/library/library-foldertoolbar-view.js | 75 ++- .../mvc/library/library-librarylist-view.js | 28 +- static/scripts/packed/galaxy.library.js | 2 +- .../mvc/library/library-folderlist-view.js | 2 +- .../mvc/library/library-foldertoolbar-view.js | 2 +- .../mvc/library/library-librarylist-view.js | 2 +- 12 files changed, 972 insertions(+), 758 deletions(-) diff --git a/client/galaxy/scripts/galaxy.library.js b/client/galaxy/scripts/galaxy.library.js index f45f2ee32b3..3f5277fb90d 100644 --- a/client/galaxy/scripts/galaxy.library.js +++ b/client/galaxy/scripts/galaxy.library.js @@ -36,7 +36,7 @@ var LibraryRouter = Backbone.Router.extend({ initialize: function() { this.routesHit = 0; //keep count of number of routes handled by the application - Backbone.history.on('route', function() { this.routesHit++; }, this); + Backbone.history.on( 'route', function() { this.routesHit++; }, this ); }, routes: { @@ -45,6 +45,7 @@ routes: { "library/:library_id/permissions" : "library_permissions", "folders/:folder_id/permissions" : "folder_permissions", "folders/:id" : "folder_content", + "folders/:id/page/:show_page" : "folder_page", "folders/:folder_id/datasets/:dataset_id" : "dataset_detail", "folders/:folder_id/datasets/:dataset_id/permissions" : "dataset_permissions", "folders/:folder_id/datasets/:dataset_id/versions/:ldda_id" : "dataset_version", @@ -53,13 +54,13 @@ routes: { }, back: function() { - if(this.routesHit > 1) { + if( this.routesHit > 1 ) { //more than one route hit -> user did not land to current page directly window.history.back(); } else { //otherwise go to the home page. Use replaceState if available so //the navigation doesn't create an extra history entry - this.navigate('#', {trigger:true, replace:true}); + this.navigate( '#', { trigger:true, replace:true } ); } } }); @@ -71,7 +72,8 @@ var LibraryPrefs = mod_baseMVC.SessionStorageModel.extend({ with_deleted : false, sort_order : 'asc', sort_by : 'name', - library_page_size : 20 + library_page_size : 20, + folder_page_size : 15 } }); @@ -94,10 +96,10 @@ var GalaxyLibrary = Backbone.View.extend({ this.library_router = new LibraryRouter(); - this.library_router.on('route:libraries', function() { - Galaxy.libraries.libraryToolbarView = new mod_librarytoolbar_view.LibraryToolbarView(); - Galaxy.libraries.libraryListView = new mod_librarylist_view.LibraryListView(); - }); + this.library_router.on( 'route:libraries', function() { + Galaxy.libraries.libraryToolbarView = new mod_librarytoolbar_view.LibraryToolbarView(); + Galaxy.libraries.libraryListView = new mod_librarylist_view.LibraryListView(); + }); this.library_router.on('route:libraries_page', function( show_page ) { if ( Galaxy.libraries.libraryToolbarView === null ){ @@ -108,66 +110,77 @@ var GalaxyLibrary = Backbone.View.extend({ } }); - this.library_router.on('route:folder_content', function(id) { + this.library_router.on( 'route:folder_content', function( id ) { if (Galaxy.libraries.folderToolbarView){ - Galaxy.libraries.folderToolbarView.$el.unbind('click'); - } - Galaxy.libraries.folderToolbarView = new mod_foldertoolbar_view.FolderToolbarView({id: id}); - Galaxy.libraries.folderListView = new mod_folderlist_view.FolderListView({id: id}); - }); + Galaxy.libraries.folderToolbarView.$el.unbind( 'click' ); + } + Galaxy.libraries.folderToolbarView = new mod_foldertoolbar_view.FolderToolbarView( { id: id } ); + Galaxy.libraries.folderListView = new mod_folderlist_view.FolderListView( { id: id } ); + }); - this.library_router.on('route:download', function(folder_id, format) { - if ($('#folder_list_body').find(':checked').length === 0) { - mod_toastr.info( 'You must select at least one dataset to download' ); - Galaxy.libraries.library_router.navigate('folders/' + folder_id, {trigger: true, replace: true}); - } else { - Galaxy.libraries.folderToolbarView.download(folder_id, format); - Galaxy.libraries.library_router.navigate('folders/' + folder_id, {trigger: false, replace: true}); - } - }); + this.library_router.on( 'route:folder_page', function( id, show_page ) { + if ( Galaxy.libraries.folderToolbarView === null ){ + Galaxy.libraries.folderToolbarView = new mod_foldertoolbar_view.FolderToolbarView( {id: id} ); + Galaxy.libraries.folderListView = new mod_folderlist_view.FolderListView( { id: id, show_page: show_page } ); + } else { + Galaxy.libraries.folderListView.render( { id: id, show_page: parseInt( show_page ) } ) + } + }); - this.library_router.on('route:dataset_detail', function(folder_id, dataset_id){ - if (Galaxy.libraries.datasetView){ - Galaxy.libraries.datasetView.$el.unbind('click'); - } - Galaxy.libraries.datasetView = new mod_library_dataset_view.LibraryDatasetView({id: dataset_id}); - }); - this.library_router.on('route:dataset_version', function(folder_id, dataset_id, ldda_id){ - if (Galaxy.libraries.datasetView){ - Galaxy.libraries.datasetView.$el.unbind('click'); - } - Galaxy.libraries.datasetView = new mod_library_dataset_view.LibraryDatasetView({id: dataset_id, ldda_id: ldda_id, show_version: true}); - }); + this.library_router.on( 'route:download', function( folder_id, format ) { + if ( $( '#folder_list_body' ).find( ':checked' ).length === 0 ) { + mod_toastr.info( 'You must select at least one dataset to download' ); + Galaxy.libraries.library_router.navigate( 'folders/' + folder_id, { trigger: true, replace: true } ); + } else { + Galaxy.libraries.folderToolbarView.download( folder_id, format ); + Galaxy.libraries.library_router.navigate( 'folders/' + folder_id, { trigger: false, replace: true } ); + } + }); - this.library_router.on('route:dataset_permissions', function(folder_id, dataset_id){ - if (Galaxy.libraries.datasetView){ - Galaxy.libraries.datasetView.$el.unbind('click'); - } - Galaxy.libraries.datasetView = new mod_library_dataset_view.LibraryDatasetView({id: dataset_id, show_permissions: true}); - }); + this.library_router.on( 'route:dataset_detail', function(folder_id, dataset_id){ + if (Galaxy.libraries.datasetView){ + Galaxy.libraries.datasetView.$el.unbind('click'); + } + Galaxy.libraries.datasetView = new mod_library_dataset_view.LibraryDatasetView({id: dataset_id}); + }); - this.library_router.on('route:library_permissions', function(library_id){ - if (Galaxy.libraries.libraryView){ - Galaxy.libraries.libraryView.$el.unbind('click'); - } - Galaxy.libraries.libraryView = new mod_library_library_view.LibraryView({id: library_id, show_permissions: true}); - }); + this.library_router.on( 'route:dataset_version', function(folder_id, dataset_id, ldda_id){ + if (Galaxy.libraries.datasetView){ + Galaxy.libraries.datasetView.$el.unbind('click'); + } + Galaxy.libraries.datasetView = new mod_library_dataset_view.LibraryDatasetView({id: dataset_id, ldda_id: ldda_id, show_version: true}); + }); - this.library_router.on('route:folder_permissions', function(folder_id){ - if (Galaxy.libraries.folderView){ - Galaxy.libraries.folderView.$el.unbind('click'); - } - Galaxy.libraries.folderView = new mod_library_folder_view.FolderView({id: folder_id, show_permissions: true}); - }); - this.library_router.on('route:import_datasets', function(folder_id, source){ - if (Galaxy.libraries.folderToolbarView && Galaxy.libraries.folderListView){ - Galaxy.libraries.folderToolbarView.showImportModal({source:source}); - } else { - Galaxy.libraries.folderToolbarView = new mod_foldertoolbar_view.FolderToolbarView({id: folder_id}); - Galaxy.libraries.folderListView = new mod_folderlist_view.FolderListView({id: folder_id}); - Galaxy.libraries.folderToolbarView.showImportModal({source: source}); - } - }); + this.library_router.on( 'route:dataset_permissions', function(folder_id, dataset_id){ + if (Galaxy.libraries.datasetView){ + Galaxy.libraries.datasetView.$el.unbind('click'); + } + Galaxy.libraries.datasetView = new mod_library_dataset_view.LibraryDatasetView({id: dataset_id, show_permissions: true}); + }); + + this.library_router.on( 'route:library_permissions', function(library_id){ + if (Galaxy.libraries.libraryView){ + Galaxy.libraries.libraryView.$el.unbind('click'); + } + Galaxy.libraries.libraryView = new mod_library_library_view.LibraryView({id: library_id, show_permissions: true}); + }); + + this.library_router.on( 'route:folder_permissions', function(folder_id){ + if (Galaxy.libraries.folderView){ + Galaxy.libraries.folderView.$el.unbind('click'); + } + Galaxy.libraries.folderView = new mod_library_folder_view.FolderView({id: folder_id, show_permissions: true}); + }); + + this.library_router.on( 'route:import_datasets', function( folder_id, source ){ + if ( Galaxy.libraries.folderToolbarView && Galaxy.libraries.folderListView ){ + Galaxy.libraries.folderToolbarView.showImportModal( { source:source } ); + } else { + Galaxy.libraries.folderToolbarView = new mod_foldertoolbar_view.FolderToolbarView( { id: folder_id } ); + Galaxy.libraries.folderListView = new mod_folderlist_view.FolderListView( { id: folder_id } ); + Galaxy.libraries.folderToolbarView.showImportModal( { source: source } ); + } + }); Backbone.history.start({pushState: false}); } diff --git a/client/galaxy/scripts/mvc/library/library-folderlist-view.js b/client/galaxy/scripts/mvc/library/library-folderlist-view.js index b361c7ea459..8ea1fe0831e 100644 --- a/client/galaxy/scripts/mvc/library/library-folderlist-view.js +++ b/client/galaxy/scripts/mvc/library/library-folderlist-view.js @@ -15,322 +15,359 @@ function(mod_masthead, ) { var FolderListView = Backbone.View.extend({ - el : '#folder_items_element', - defaults: { - 'include_deleted' : false - }, - // progress percentage - progress: 0, - // progress rate per one item - progressStep: 1, - // self modal - modal : null, + el : '#folder_items_element', + // progress percentage + progress: 0, + // progress rate per one item + progressStep: 1, - folderContainer: null, + folderContainer: null, - sort: 'asc', + sort: 'asc', - events: { - 'click #select-all-checkboxes' : 'selectAll', - 'click .dataset_row' : 'selectClickedRow', - 'click .sort-folder-link' : 'sortColumnClicked' - }, + events: { + 'click #select-all-checkboxes' : 'selectAll', + 'click .dataset_row' : 'selectClickedRow', + 'click .sort-folder-link' : 'sortColumnClicked' + }, - // cache of rendered views - rowViews: {}, - - initialize : function(options){ - this.options = _.defaults(this.options || {}, options); - this.fetchFolder(); - }, + collection: null, - fetchFolder: function(options){ - var options = options || {}; - this.options.include_deleted = options.include_deleted; - var that = this; + defaults: { + include_deleted: false, + page_count: null, + show_page: null + }, - this.collection = new mod_library_model.Folder(); + /** + * Initialize and fetch the folder from the server. + * @param {object} options an object with options + */ + initialize : function( options ){ + this.options = _.defaults( this.options || {}, this.defaults, options ); + this.modal = null; + // map of folder item ids to item views = cache + this.rowViews = {}; - // start to listen if someone modifies collection - this.listenTo(this.collection, 'add', this.renderOne); - this.listenTo(this.collection, 'remove', this.removeOne); + // create a collection of folder items for this view + this.collection = new mod_library_model.Folder(); - this.folderContainer = new mod_library_model.FolderContainer({id: this.options.id}); - this.folderContainer.url = this.folderContainer.attributes.urlRoot + this.options.id + '/contents'; - if (this.options.include_deleted){ - this.folderContainer.url = this.folderContainer.url + '?include_deleted=true'; - } - this.folderContainer.fetch({ - success: function(folder_container) { - that.folder_container = folder_container; - that.render(); - that.addAll(folder_container.get('folder').models); - if (that.options.dataset_id){ - row = _.findWhere(that.rowViews, {id: that.options.dataset_id}); - if (row) { + // start to listen if someone modifies the collection + this.listenTo( this.collection, 'add', this.renderOne ); + this.listenTo( this.collection, 'remove', this.removeOne ); + + this.fetchFolder(); + }, + + fetchFolder: function( options ){ + var options = options || {}; + this.options.include_deleted = options.include_deleted; + var that = this; + + this.folderContainer = new mod_library_model.FolderContainer( { id: this.options.id } ); + this.folderContainer.url = this.folderContainer.attributes.urlRoot + this.options.id + '/contents'; + + if ( this.options.include_deleted ){ + this.folderContainer.url = this.folderContainer.url + '?include_deleted=true'; + } + this.folderContainer.fetch({ + success: function( folder_container ) { + that.folder_container = folder_container; + that.render(); + }, + error: function( model, response ){ + if ( typeof response.responseJSON !== "undefined" ){ + mod_toastr.error( response.responseJSON.err_msg + ' Click this to go back.', '', { onclick: function() { Galaxy.libraries.library_router.back(); } } ); + } else { + mod_toastr.error( 'An error ocurred. Click this to go back.', '', { onclick: function() { Galaxy.libraries.library_router.back(); } } ); + } + } + }); + }, + + render: function ( options ){ + this.options = _.extend( this.options, options ); + var template = this.templateFolder(); + $(".tooltip").hide(); + + // find the upper id in the full path + var path = this.folderContainer.attributes.metadata.full_path; + var upper_folder_id; + if ( path.length === 1 ){ // the library is above us + upper_folder_id = 0; + } else { + upper_folder_id = path[ path.length-2 ][ 0 ]; + } + + this.$el.html( template( { + path: this.folderContainer.attributes.metadata.full_path, + parent_library_id: this.folderContainer.attributes.metadata.parent_library_id, + id: this.options.id, + upper_folder_id: upper_folder_id, + order: this.sort + } ) ); + + // when dataset_id is present render its details too + if ( this.options.dataset_id ){ + row = _.findWhere( that.rowViews, { id: this.options.dataset_id } ); + if ( row ) { row.showDatasetDetails(); } else { - mod_toastr.error('Dataset not found. Showing folder instead.'); + mod_toastr.error( 'Requested dataset not found. Showing folder instead.' ); } - } - }, - error: function(model, response){ - if (typeof response.responseJSON !== "undefined"){ - mod_toastr.error(response.responseJSON.err_msg + ' Click this to go back.', '', {onclick: function() {Galaxy.libraries.library_router.back();}}); - } else { - mod_toastr.error('An error ocurred. Click this to go back.', '', {onclick: function() {Galaxy.libraries.library_router.back();}}); - } + } else { + if ( this.options.show_page === null || this.options.show_page < 1 ){ + this.options.show_page = 1; + } + this.paginate(); } - }); - }, + $("#center [data-toggle]").tooltip(); + $("#center").css('overflow','auto'); + }, - render: function (options) { - this.options = _.defaults(this.options, options); - var template = this.templateFolder(); - $(".tooltip").hide(); + paginate: function( options ){ + this.options = _.extend( this.options, options ); - // TODO move to server - // find the upper id in the full path - var path = this.folderContainer.attributes.metadata.full_path; - var upper_folder_id; - if (path.length === 1){ // the library is above us - upper_folder_id = 0; - } else { - upper_folder_id = path[path.length-2][0]; - } + if ( this.options.show_page === null || this.options.show_page < 1 ){ + this.options.show_page = 1; + } + this.options.total_items_count = this.folder_container.get( 'folder' ).models.length; + this.options.page_count = Math.ceil( this.options.total_items_count / Galaxy.libraries.preferences.get( 'folder_page_size' ) ); + var page_start = ( Galaxy.libraries.preferences.get( 'folder_page_size' ) * ( this.options.show_page - 1 ) ); + var items_to_render = null; + items_to_render = this.folder_container.get( 'folder' ).models.slice( page_start, page_start + Galaxy.libraries.preferences.get( 'folder_page_size' ) ); + this.options.items_shown = items_to_render.length; + // User requests page with no items + if ( Galaxy.libraries.preferences.get( 'folder_page_size' ) * this.options.show_page > ( this.options.total_items_count + Galaxy.libraries.preferences.get( 'folder_page_size' ) ) ){ + items_to_render = []; + } + Galaxy.libraries.folderToolbarView.renderPaginator( this.options ); + this.collection.reset(); + this.addAll( items_to_render ) + }, - this.$el.html(template({ path: this.folderContainer.attributes.metadata.full_path, parent_library_id: this.folderContainer.attributes.metadata.parent_library_id, id: this.options.id, upper_folder_id: upper_folder_id, order: this.sort})); + /** + * Adds all given models to the collection. + * @param {array of Item or FolderAsModel} array of models that should + * be added to the view's collection. + */ + addAll: function( models ){ + _.each(models, function( model ) { + Galaxy.libraries.folderListView.collection.add( model ); + }); + $( "#center [data-toggle]" ).tooltip(); + this.checkEmptiness(); + this.postRender(); + }, - // initialize the library tooltips - $("#center [data-toggle]").tooltip(); - //hack to show scrollbars - $("#center").css('overflow','auto'); - }, + /** + * Call this after all models are added to the collection + * to ensure that the folder toolbar will show proper options + * and that event will be bound on all subviews. + */ + postRender: function(){ + var fetched_metadata = this.folderContainer.attributes.metadata; + fetched_metadata.contains_file = typeof this.collection.findWhere({type: 'file'}) !== 'undefined'; + Galaxy.libraries.folderToolbarView.configureElements(fetched_metadata); + $('.library-row').hover(function() { + $(this).find('.show_on_hover').show(); + }, function () { + $(this).find('.show_on_hover').hide(); + }); + }, - /** - * Call this after all models are added to the collection - * to ensure that the folder toolbar will show proper options - * and that event will be bound on all subviews. - */ - postRender: function(){ - var fetched_metadata = this.folderContainer.attributes.metadata; - fetched_metadata.contains_file = typeof this.collection.findWhere({type: 'file'}) !== 'undefined'; - Galaxy.libraries.folderToolbarView.configureElements(fetched_metadata); - $('.library-row').hover(function() { - $(this).find('.show_on_hover').show(); - }, function () { - $(this).find('.show_on_hover').hide(); - }); - }, + /** + * Iterates this view's collection and calls the render + * function for each. Also binds the hover behavior. + */ + renderAll: function(){ + var that = this; + _.each( this.collection.models.reverse(), function( model ) { + that.renderOne( model ); + }); + this.postRender(); + }, - /** - * Adds all given models to the collection. - * @param {array of Item or FolderAsModel} array of models that should - * be added to the view's collection. - */ - addAll: function(models){ - _.each(models.reverse(), function(model) { - Galaxy.libraries.folderListView.collection.add(model); - }); - - $("#center [data-toggle]").tooltip(); - this.checkEmptiness(); - - this.postRender(); - }, - - /** - * Iterates this view's collection and calls the render - * function for each. Also binds the hover behavior. - */ - renderAll: function(){ - var that = this; - _.each(this.collection.models.reverse(), function(model) { - that.renderOne(model); - }); - this.postRender(); - }, - - /** - * Creates a view for the given model and adds it to the folder view. - * @param {Item or FolderAsModel} model of the view that will be rendered - */ - renderOne: function(model){ - if (model.get('type') !== 'folder'){ - this.options.contains_file = true; - // model.set('readable_size', this.size_to_string(model.get('file_size'))); - } - model.set('folder_id', this.id); - var rowView = new mod_library_folderrow_view.FolderRowView(model); - - // save new rowView to cache - this.rowViews[model.get('id')] = rowView; - - this.$el.find('#first_folder_item').after(rowView.el); - - $('.library-row').hover(function() { - $(this).find('.show_on_hover').show(); - }, function () { - $(this).find('.show_on_hover').hide(); - }); - }, - - /** - * removes the view of the given model from the DOM - * @param {Item or FolderAsModel} model of the view that will be removed - */ - removeOne: function(model){ - this.$el.find('#' + model.id).remove(); - }, - - /** Checks whether the list is empty and adds/removes the message */ - checkEmptiness : function(){ - if ((this.$el.find('.dataset_row').length === 0) && (this.$el.find('.folder_row').length === 0)){ - this.$el.find('.empty-folder-message').show(); - } else { - this.$el.find('.empty-folder-message').hide(); - } - }, - - /** User clicked the table heading = he wants to sort stuff */ - sortColumnClicked : function(event){ - event.preventDefault(); - if (this.sort === 'asc'){ - this.sortFolder('name','desc'); - this.sort = 'desc'; - } else { - this.sortFolder('name','asc'); - this.sort = 'asc'; - } - this.render(); - this.renderAll(); - this.checkEmptiness(); - }, - - /** - * Sorts the underlying collection according to the parameters received. - * Currently supports only sorting by name. - */ - sortFolder: function(sort_by, order){ - if (sort_by === 'name'){ - if (order === 'asc'){ - return this.collection.sortByNameAsc(); - } else if (order === 'desc'){ - return this.collection.sortByNameDesc(); + /** + * Creates a view for the given model and adds it to the folder view. + * @param {Item or FolderAsModel} model of the view that will be rendered + */ + renderOne: function(model){ + if (model.get('type') !== 'folder'){ + this.options.contains_file = true; + // model.set('readable_size', this.size_to_string(model.get('file_size'))); } - } - }, + model.set('folder_id', this.id); + var rowView = new mod_library_folderrow_view.FolderRowView(model); - /** - * User clicked the checkbox in the table heading - * @param {context} event - */ - selectAll : function (event) { - var selected = event.target.checked; - that = this; - // Iterate each checkbox - $(':checkbox', '#folder_list_body').each(function() { - this.checked = selected; - $row = $(this.parentElement.parentElement); - // Change color of selected/unselected - if (selected) { - that.makeDarkRow($row); - } else { - that.makeWhiteRow($row); - } - }); - }, + // save new rowView to cache + this.rowViews[model.get('id')] = rowView; - /** - * Check checkbox if user clicks on the whole row or - * on the checkbox itself - */ - selectClickedRow : function (event) { - var checkbox = ''; - var $row; - var source; - if (event.target.localName === 'input'){ - checkbox = event.target; - $row = $(event.target.parentElement.parentElement); - source = 'input'; - } else if (event.target.localName === 'td') { - checkbox = $("#" + event.target.parentElement.id).find(':checkbox')[0]; - $row = $(event.target.parentElement); - source = 'td'; - } - if (checkbox.checked){ - if (source==='td'){ - checkbox.checked = ''; - this.makeWhiteRow($row); - } else if (source==='input') { - this.makeDarkRow($row); + this.$el.find('#first_folder_item').after(rowView.el); + + $('.library-row').hover(function() { + $(this).find('.show_on_hover').show(); + }, function () { + $(this).find('.show_on_hover').hide(); + }); + }, + + /** + * removes the view of the given model from the DOM + * @param {Item or FolderAsModel} model of the view that will be removed + */ + removeOne: function( model ){ + this.$el.find( '#' + model.id ).remove(); + }, + + /** Checks whether the list is empty and adds/removes the message */ + checkEmptiness : function(){ + if ((this.$el.find('.dataset_row').length === 0) && (this.$el.find('.folder_row').length === 0)){ + this.$el.find('.empty-folder-message').show(); + } else { + this.$el.find('.empty-folder-message').hide(); } - } else { - if (source==='td'){ - checkbox.checked = 'selected'; - this.makeDarkRow($row); - } else if (source==='input') { - this.makeWhiteRow($row); + }, + + /** User clicked the table heading = he wants to sort stuff */ + sortColumnClicked : function(event){ + event.preventDefault(); + if (this.sort === 'asc'){ + this.sortFolder('name','desc'); + this.sort = 'desc'; + } else { + this.sortFolder('name','asc'); + this.sort = 'asc'; } + this.render(); + this.renderAll(); + this.checkEmptiness(); + }, + + /** + * Sorts the underlying collection according to the parameters received. + * Currently supports only sorting by name. + */ + sortFolder: function(sort_by, order){ + if (sort_by === 'name'){ + if (order === 'asc'){ + return this.collection.sortByNameAsc(); + } else if (order === 'desc'){ + return this.collection.sortByNameDesc(); + } + } + }, + + /** + * User clicked the checkbox in the table heading + * @param {context} event + */ + selectAll : function (event) { + var selected = event.target.checked; + that = this; + // Iterate each checkbox + $(':checkbox', '#folder_list_body').each(function() { + this.checked = selected; + $row = $(this.parentElement.parentElement); + // Change color of selected/unselected + if (selected) { + that.makeDarkRow($row); + } else { + that.makeWhiteRow($row); + } + }); + }, + + /** + * Check checkbox if user clicks on the whole row or + * on the checkbox itself + */ + selectClickedRow : function (event) { + var checkbox = ''; + var $row; + var source; + if (event.target.localName === 'input'){ + checkbox = event.target; + $row = $(event.target.parentElement.parentElement); + source = 'input'; + } else if (event.target.localName === 'td') { + checkbox = $("#" + event.target.parentElement.id).find(':checkbox')[0]; + $row = $(event.target.parentElement); + source = 'td'; + } + if (checkbox.checked){ + if (source==='td'){ + checkbox.checked = ''; + this.makeWhiteRow($row); + } else if (source==='input') { + this.makeDarkRow($row); + } + } else { + if (source==='td'){ + checkbox.checked = 'selected'; + this.makeDarkRow($row); + } else if (source==='input') { + this.makeWhiteRow($row); + } + } + }, + + makeDarkRow: function($row){ + $row.removeClass('light').addClass('dark'); + $row.find('a').removeClass('light').addClass('dark'); + $row.find('.fa-file-o').removeClass('fa-file-o').addClass('fa-file'); + }, + + makeWhiteRow: function($row){ + $row.removeClass('dark').addClass('light'); + $row.find('a').removeClass('dark').addClass('light'); + $row.find('.fa-file').removeClass('fa-file').addClass('fa-file-o'); + }, + + templateFolder : function (){ + var tmpl_array = []; + + // BREADCRUMBS + tmpl_array.push(''); + + // FOLDER CONTENT + tmpl_array.push('
+
Data Manager: ${ data_table.name | h } - +
Name:${hda.name | h}
Created:${hda.create_time.strftime(trans.app.config.pretty_datetime_format)}
Filesize:${nice_size(hda.dataset.file_size)}
Created:${hda.create_time.strftime(trans.app.config.pretty_datetime_format) | h}
Filesize:${nice_size(hda.dataset.file_size) | h}
Tool Exit Code:${job.exit_code | h}
Full Path:${hda.file_name | h}
View complete info:${ hda.id | h }
Entry #${j}
Entry #${j | h}
${name | h}:${value | h}
'); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + + tmpl_array.push(' '); + tmpl_array.push('
name data typesizetime updated (UTC)
" title="Go to parent folder" class="btn_open_folder btn btn-default btn-xs">..
'); + tmpl_array.push(''); + + return _.template(tmpl_array.join('')); } - }, - - makeDarkRow: function($row){ - $row.removeClass('light').addClass('dark'); - $row.find('a').removeClass('light').addClass('dark'); - $row.find('.fa-file-o').removeClass('fa-file-o').addClass('fa-file'); - }, - - makeWhiteRow: function($row){ - $row.removeClass('dark').addClass('light'); - $row.find('a').removeClass('dark').addClass('light'); - $row.find('.fa-file').removeClass('fa-file').addClass('fa-file-o'); - }, - - templateFolder : function (){ - var tmpl_array = []; - - // BREADCRUMBS - tmpl_array.push(''); - - // FOLDER CONTENT - tmpl_array.push(''); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - - tmpl_array.push(' '); - tmpl_array.push('
name data typesizetime updated (UTC)
" title="Go to parent folder" class="btn_open_folder btn btn-default btn-xs">..
'); - tmpl_array.push(''); - - return _.template(tmpl_array.join('')); - } - + }); return { diff --git a/client/galaxy/scripts/mvc/library/library-foldertoolbar-view.js b/client/galaxy/scripts/mvc/library/library-foldertoolbar-view.js index ec532b71d74..d5f3b9a6d20 100644 --- a/client/galaxy/scripts/mvc/library/library-foldertoolbar-view.js +++ b/client/galaxy/scripts/mvc/library/library-foldertoolbar-view.js @@ -20,7 +20,9 @@ var FolderToolbarView = Backbone.View.extend({ 'click #toolbtn_bulk_import' : 'modalBulkImport', 'click #include_deleted_datasets_chk' : 'checkIncludeDeleted', 'click #toolbtn_show_libinfo' : 'showLibInfo', - 'click #toolbtn_bulk_delete' : 'deleteSelectedDatasets' + 'click #toolbtn_bulk_delete' : 'deleteSelectedDatasets', + 'click #page_size_prompt' : 'showPageSizePrompt' + }, defaults: { @@ -90,6 +92,22 @@ var FolderToolbarView = Backbone.View.extend({ this.$el.html(toolbar_template(template_defaults)); }, + /** + * Called from FolderListView when needed. + * @param {object} options common options + */ + renderPaginator: function( options ){ + this.options = _.extend( this.options, options ); + var paginator_template = this.templatePaginator(); + this.$el.find( '#folder_paginator' ).html( paginator_template({ + id: this.options.id, + show_page: parseInt( this.options.show_page ), + page_count: parseInt( this.options.page_count ), + total_items_count: this.options.total_items_count, + items_shown: this.options.items_shown + })); + }, + configureElements: function(options){ this.options = _.extend(this.options, options); @@ -833,11 +851,11 @@ var FolderToolbarView = Backbone.View.extend({ var popped_item = lddas_set.pop(); if ( typeof popped_item === "undefined" ) { if ( this.options.chain_call_control.failed_number === 0 ){ - mod_toastr.success( 'Selected datasets deleted' ); + mod_toastr.success( 'Selected datasets were deleted.' ); } else if ( this.options.chain_call_control.failed_number === this.options.chain_call_control.total_number ){ - mod_toastr.error( 'There was an error and no datasets were deleted.' ); + mod_toastr.error( 'There was an error and no datasets were deleted. Please make sure you have sufficient permissions.' ); } else if ( this.options.chain_call_control.failed_number < this.options.chain_call_control.total_number ){ - mod_toastr.warning( 'Some of the datasets could not be deleted' ); + mod_toastr.warning( 'Some of the datasets could not be deleted. Please make sure you have sufficient permissions.' ); } Galaxy.modal.hide(); return this.deleted_lddas; @@ -976,6 +994,14 @@ var FolderToolbarView = Backbone.View.extend({ } }, + showPageSizePrompt: function(){ + var folder_page_size = prompt( 'How many items per page do you want to see?', Galaxy.libraries.preferences.get( 'folder_page_size' ) ); + if ( ( folder_page_size != null ) && ( folder_page_size == parseInt( folder_page_size ) ) ) { + Galaxy.libraries.preferences.set( { 'folder_page_size': parseInt( folder_page_size ) } ); + Galaxy.libraries.folderListView.render( { id: this.options.id, show_page: 1 } ); + } + }, + templateToolBar: function(){ tmpl_array = []; @@ -1016,7 +1042,6 @@ var FolderToolbarView = Backbone.View.extend({ tmpl_array.push(' '); tmpl_array.push('<% } %>'); - tmpl_array.push(' '); tmpl_array.push(' '); // TOOLBAR END tmpl_array.push('
'); @@ -1239,7 +1268,41 @@ var FolderToolbarView = Backbone.View.extend({ tmpl_array.push(''); return _.template(tmpl_array.join('')); - } + }, + + templatePaginator: function(){ + tmpl_array = []; + + tmpl_array.push('
    '); + tmpl_array.push(' <% if ( ( show_page - 1 ) > 0 ) { %>'); + tmpl_array.push(' <% if ( ( show_page - 1 ) > page_count ) { %>'); // we are on higher page than total page count + tmpl_array.push('
  • '); + tmpl_array.push('
  • <% print( show_page - 1 ) %>
  • '); + tmpl_array.push(' <% } else { %>'); + tmpl_array.push('
  • '); + tmpl_array.push('
  • <% print( show_page - 1 ) %>
  • '); + tmpl_array.push(' <% } %>'); + tmpl_array.push(' <% } else { %>'); // we are on the first page + tmpl_array.push('
  • '); + tmpl_array.push('
  • <% print( show_page - 1 ) %>
  • '); + tmpl_array.push(' <% } %>'); + tmpl_array.push('
  • '); + tmpl_array.push(' <% print( show_page ) %>'); + tmpl_array.push('
  • '); + tmpl_array.push(' <% if ( ( show_page ) < page_count ) { %>'); + tmpl_array.push('
  • <% print( show_page + 1 ) %>
  • '); + tmpl_array.push('
  • '); + tmpl_array.push(' <% } else { %>'); + tmpl_array.push('
  • <% print( show_page + 1 ) %>
  • '); + tmpl_array.push('
  • '); + tmpl_array.push(' <% } %>'); + tmpl_array.push('
'); + tmpl_array.push(' '); + tmpl_array.push(' showing <%- items_shown %> of <%- total_items_count %> items'); + tmpl_array.push(' '); + + return _.template(tmpl_array.join('')); + }, }); diff --git a/client/galaxy/scripts/mvc/library/library-librarylist-view.js b/client/galaxy/scripts/mvc/library/library-librarylist-view.js index 65ddfc85c1a..e229395a340 100644 --- a/client/galaxy/scripts/mvc/library/library-librarylist-view.js +++ b/client/galaxy/scripts/mvc/library/library-librarylist-view.js @@ -21,20 +21,19 @@ var LibraryListView = Backbone.View.extend({ 'click .sort-libraries-link' : 'sort_clicked' }, - /** - * Initialize and fetch the libraries from server. - * Async render afterwards. - * @param {object} options an options object - */ defaults: { page_count: null, show_page: null }, + /** + * Initialize and fetch the libraries from server. + * Async render afterwards. + * @param {object} options an object with options + */ initialize : function( options ){ this.options = _.defaults( this.options || {}, this.defaults, options ); - - var that = this; + var that = this; this.modal = null; // map of library model ids to library views = cache this.rowViews = {}; @@ -61,19 +60,10 @@ var LibraryListView = Backbone.View.extend({ */ render: function ( options ) { this.options = _.extend( this.options, options ); - - if ( ( this.options.page_size != null ) && ( this.options.page_size == parseInt( this.options.page_size ) ) ) { - Galaxy.libraries.preferences.set( { 'library_page_size': parseInt( this.options.page_size ) } ); - } - - $( ".tooltip" ).hide(); - // this.options.show_page = this.options.show_page || 1; var template = this.templateLibraryList(); var libraries_to_render = null; var models = null; - if ( this.options.show_page === null || this.options.show_page < 1 ){ - this.options.show_page = 1; - } + $( ".tooltip" ).hide(); if ( typeof options !== 'undefined' ){ models = typeof options.models !== 'undefined' ? options.models : null; } @@ -89,6 +79,10 @@ var LibraryListView = Backbone.View.extend({ } else { libraries_to_render = []; } + // pagination + if ( this.options.show_page === null || this.options.show_page < 1 ){ + this.options.show_page = 1; + } this.options.total_libraries_count = libraries_to_render.length var page_start = ( Galaxy.libraries.preferences.get( 'library_page_size' ) * ( this.options.show_page - 1 ) ); this.options.page_count = Math.ceil( this.options.total_libraries_count / Galaxy.libraries.preferences.get( 'library_page_size' ) ); diff --git a/static/scripts/galaxy.library.js b/static/scripts/galaxy.library.js index f45f2ee32b3..3f5277fb90d 100644 --- a/static/scripts/galaxy.library.js +++ b/static/scripts/galaxy.library.js @@ -36,7 +36,7 @@ var LibraryRouter = Backbone.Router.extend({ initialize: function() { this.routesHit = 0; //keep count of number of routes handled by the application - Backbone.history.on('route', function() { this.routesHit++; }, this); + Backbone.history.on( 'route', function() { this.routesHit++; }, this ); }, routes: { @@ -45,6 +45,7 @@ routes: { "library/:library_id/permissions" : "library_permissions", "folders/:folder_id/permissions" : "folder_permissions", "folders/:id" : "folder_content", + "folders/:id/page/:show_page" : "folder_page", "folders/:folder_id/datasets/:dataset_id" : "dataset_detail", "folders/:folder_id/datasets/:dataset_id/permissions" : "dataset_permissions", "folders/:folder_id/datasets/:dataset_id/versions/:ldda_id" : "dataset_version", @@ -53,13 +54,13 @@ routes: { }, back: function() { - if(this.routesHit > 1) { + if( this.routesHit > 1 ) { //more than one route hit -> user did not land to current page directly window.history.back(); } else { //otherwise go to the home page. Use replaceState if available so //the navigation doesn't create an extra history entry - this.navigate('#', {trigger:true, replace:true}); + this.navigate( '#', { trigger:true, replace:true } ); } } }); @@ -71,7 +72,8 @@ var LibraryPrefs = mod_baseMVC.SessionStorageModel.extend({ with_deleted : false, sort_order : 'asc', sort_by : 'name', - library_page_size : 20 + library_page_size : 20, + folder_page_size : 15 } }); @@ -94,10 +96,10 @@ var GalaxyLibrary = Backbone.View.extend({ this.library_router = new LibraryRouter(); - this.library_router.on('route:libraries', function() { - Galaxy.libraries.libraryToolbarView = new mod_librarytoolbar_view.LibraryToolbarView(); - Galaxy.libraries.libraryListView = new mod_librarylist_view.LibraryListView(); - }); + this.library_router.on( 'route:libraries', function() { + Galaxy.libraries.libraryToolbarView = new mod_librarytoolbar_view.LibraryToolbarView(); + Galaxy.libraries.libraryListView = new mod_librarylist_view.LibraryListView(); + }); this.library_router.on('route:libraries_page', function( show_page ) { if ( Galaxy.libraries.libraryToolbarView === null ){ @@ -108,66 +110,77 @@ var GalaxyLibrary = Backbone.View.extend({ } }); - this.library_router.on('route:folder_content', function(id) { + this.library_router.on( 'route:folder_content', function( id ) { if (Galaxy.libraries.folderToolbarView){ - Galaxy.libraries.folderToolbarView.$el.unbind('click'); - } - Galaxy.libraries.folderToolbarView = new mod_foldertoolbar_view.FolderToolbarView({id: id}); - Galaxy.libraries.folderListView = new mod_folderlist_view.FolderListView({id: id}); - }); + Galaxy.libraries.folderToolbarView.$el.unbind( 'click' ); + } + Galaxy.libraries.folderToolbarView = new mod_foldertoolbar_view.FolderToolbarView( { id: id } ); + Galaxy.libraries.folderListView = new mod_folderlist_view.FolderListView( { id: id } ); + }); - this.library_router.on('route:download', function(folder_id, format) { - if ($('#folder_list_body').find(':checked').length === 0) { - mod_toastr.info( 'You must select at least one dataset to download' ); - Galaxy.libraries.library_router.navigate('folders/' + folder_id, {trigger: true, replace: true}); - } else { - Galaxy.libraries.folderToolbarView.download(folder_id, format); - Galaxy.libraries.library_router.navigate('folders/' + folder_id, {trigger: false, replace: true}); - } - }); + this.library_router.on( 'route:folder_page', function( id, show_page ) { + if ( Galaxy.libraries.folderToolbarView === null ){ + Galaxy.libraries.folderToolbarView = new mod_foldertoolbar_view.FolderToolbarView( {id: id} ); + Galaxy.libraries.folderListView = new mod_folderlist_view.FolderListView( { id: id, show_page: show_page } ); + } else { + Galaxy.libraries.folderListView.render( { id: id, show_page: parseInt( show_page ) } ) + } + }); - this.library_router.on('route:dataset_detail', function(folder_id, dataset_id){ - if (Galaxy.libraries.datasetView){ - Galaxy.libraries.datasetView.$el.unbind('click'); - } - Galaxy.libraries.datasetView = new mod_library_dataset_view.LibraryDatasetView({id: dataset_id}); - }); - this.library_router.on('route:dataset_version', function(folder_id, dataset_id, ldda_id){ - if (Galaxy.libraries.datasetView){ - Galaxy.libraries.datasetView.$el.unbind('click'); - } - Galaxy.libraries.datasetView = new mod_library_dataset_view.LibraryDatasetView({id: dataset_id, ldda_id: ldda_id, show_version: true}); - }); + this.library_router.on( 'route:download', function( folder_id, format ) { + if ( $( '#folder_list_body' ).find( ':checked' ).length === 0 ) { + mod_toastr.info( 'You must select at least one dataset to download' ); + Galaxy.libraries.library_router.navigate( 'folders/' + folder_id, { trigger: true, replace: true } ); + } else { + Galaxy.libraries.folderToolbarView.download( folder_id, format ); + Galaxy.libraries.library_router.navigate( 'folders/' + folder_id, { trigger: false, replace: true } ); + } + }); - this.library_router.on('route:dataset_permissions', function(folder_id, dataset_id){ - if (Galaxy.libraries.datasetView){ - Galaxy.libraries.datasetView.$el.unbind('click'); - } - Galaxy.libraries.datasetView = new mod_library_dataset_view.LibraryDatasetView({id: dataset_id, show_permissions: true}); - }); + this.library_router.on( 'route:dataset_detail', function(folder_id, dataset_id){ + if (Galaxy.libraries.datasetView){ + Galaxy.libraries.datasetView.$el.unbind('click'); + } + Galaxy.libraries.datasetView = new mod_library_dataset_view.LibraryDatasetView({id: dataset_id}); + }); - this.library_router.on('route:library_permissions', function(library_id){ - if (Galaxy.libraries.libraryView){ - Galaxy.libraries.libraryView.$el.unbind('click'); - } - Galaxy.libraries.libraryView = new mod_library_library_view.LibraryView({id: library_id, show_permissions: true}); - }); + this.library_router.on( 'route:dataset_version', function(folder_id, dataset_id, ldda_id){ + if (Galaxy.libraries.datasetView){ + Galaxy.libraries.datasetView.$el.unbind('click'); + } + Galaxy.libraries.datasetView = new mod_library_dataset_view.LibraryDatasetView({id: dataset_id, ldda_id: ldda_id, show_version: true}); + }); - this.library_router.on('route:folder_permissions', function(folder_id){ - if (Galaxy.libraries.folderView){ - Galaxy.libraries.folderView.$el.unbind('click'); - } - Galaxy.libraries.folderView = new mod_library_folder_view.FolderView({id: folder_id, show_permissions: true}); - }); - this.library_router.on('route:import_datasets', function(folder_id, source){ - if (Galaxy.libraries.folderToolbarView && Galaxy.libraries.folderListView){ - Galaxy.libraries.folderToolbarView.showImportModal({source:source}); - } else { - Galaxy.libraries.folderToolbarView = new mod_foldertoolbar_view.FolderToolbarView({id: folder_id}); - Galaxy.libraries.folderListView = new mod_folderlist_view.FolderListView({id: folder_id}); - Galaxy.libraries.folderToolbarView.showImportModal({source: source}); - } - }); + this.library_router.on( 'route:dataset_permissions', function(folder_id, dataset_id){ + if (Galaxy.libraries.datasetView){ + Galaxy.libraries.datasetView.$el.unbind('click'); + } + Galaxy.libraries.datasetView = new mod_library_dataset_view.LibraryDatasetView({id: dataset_id, show_permissions: true}); + }); + + this.library_router.on( 'route:library_permissions', function(library_id){ + if (Galaxy.libraries.libraryView){ + Galaxy.libraries.libraryView.$el.unbind('click'); + } + Galaxy.libraries.libraryView = new mod_library_library_view.LibraryView({id: library_id, show_permissions: true}); + }); + + this.library_router.on( 'route:folder_permissions', function(folder_id){ + if (Galaxy.libraries.folderView){ + Galaxy.libraries.folderView.$el.unbind('click'); + } + Galaxy.libraries.folderView = new mod_library_folder_view.FolderView({id: folder_id, show_permissions: true}); + }); + + this.library_router.on( 'route:import_datasets', function( folder_id, source ){ + if ( Galaxy.libraries.folderToolbarView && Galaxy.libraries.folderListView ){ + Galaxy.libraries.folderToolbarView.showImportModal( { source:source } ); + } else { + Galaxy.libraries.folderToolbarView = new mod_foldertoolbar_view.FolderToolbarView( { id: folder_id } ); + Galaxy.libraries.folderListView = new mod_folderlist_view.FolderListView( { id: folder_id } ); + Galaxy.libraries.folderToolbarView.showImportModal( { source: source } ); + } + }); Backbone.history.start({pushState: false}); } diff --git a/static/scripts/mvc/library/library-folderlist-view.js b/static/scripts/mvc/library/library-folderlist-view.js index b361c7ea459..8ea1fe0831e 100644 --- a/static/scripts/mvc/library/library-folderlist-view.js +++ b/static/scripts/mvc/library/library-folderlist-view.js @@ -15,322 +15,359 @@ function(mod_masthead, ) { var FolderListView = Backbone.View.extend({ - el : '#folder_items_element', - defaults: { - 'include_deleted' : false - }, - // progress percentage - progress: 0, - // progress rate per one item - progressStep: 1, - // self modal - modal : null, + el : '#folder_items_element', + // progress percentage + progress: 0, + // progress rate per one item + progressStep: 1, - folderContainer: null, + folderContainer: null, - sort: 'asc', + sort: 'asc', - events: { - 'click #select-all-checkboxes' : 'selectAll', - 'click .dataset_row' : 'selectClickedRow', - 'click .sort-folder-link' : 'sortColumnClicked' - }, + events: { + 'click #select-all-checkboxes' : 'selectAll', + 'click .dataset_row' : 'selectClickedRow', + 'click .sort-folder-link' : 'sortColumnClicked' + }, - // cache of rendered views - rowViews: {}, - - initialize : function(options){ - this.options = _.defaults(this.options || {}, options); - this.fetchFolder(); - }, + collection: null, - fetchFolder: function(options){ - var options = options || {}; - this.options.include_deleted = options.include_deleted; - var that = this; + defaults: { + include_deleted: false, + page_count: null, + show_page: null + }, - this.collection = new mod_library_model.Folder(); + /** + * Initialize and fetch the folder from the server. + * @param {object} options an object with options + */ + initialize : function( options ){ + this.options = _.defaults( this.options || {}, this.defaults, options ); + this.modal = null; + // map of folder item ids to item views = cache + this.rowViews = {}; - // start to listen if someone modifies collection - this.listenTo(this.collection, 'add', this.renderOne); - this.listenTo(this.collection, 'remove', this.removeOne); + // create a collection of folder items for this view + this.collection = new mod_library_model.Folder(); - this.folderContainer = new mod_library_model.FolderContainer({id: this.options.id}); - this.folderContainer.url = this.folderContainer.attributes.urlRoot + this.options.id + '/contents'; - if (this.options.include_deleted){ - this.folderContainer.url = this.folderContainer.url + '?include_deleted=true'; - } - this.folderContainer.fetch({ - success: function(folder_container) { - that.folder_container = folder_container; - that.render(); - that.addAll(folder_container.get('folder').models); - if (that.options.dataset_id){ - row = _.findWhere(that.rowViews, {id: that.options.dataset_id}); - if (row) { + // start to listen if someone modifies the collection + this.listenTo( this.collection, 'add', this.renderOne ); + this.listenTo( this.collection, 'remove', this.removeOne ); + + this.fetchFolder(); + }, + + fetchFolder: function( options ){ + var options = options || {}; + this.options.include_deleted = options.include_deleted; + var that = this; + + this.folderContainer = new mod_library_model.FolderContainer( { id: this.options.id } ); + this.folderContainer.url = this.folderContainer.attributes.urlRoot + this.options.id + '/contents'; + + if ( this.options.include_deleted ){ + this.folderContainer.url = this.folderContainer.url + '?include_deleted=true'; + } + this.folderContainer.fetch({ + success: function( folder_container ) { + that.folder_container = folder_container; + that.render(); + }, + error: function( model, response ){ + if ( typeof response.responseJSON !== "undefined" ){ + mod_toastr.error( response.responseJSON.err_msg + ' Click this to go back.', '', { onclick: function() { Galaxy.libraries.library_router.back(); } } ); + } else { + mod_toastr.error( 'An error ocurred. Click this to go back.', '', { onclick: function() { Galaxy.libraries.library_router.back(); } } ); + } + } + }); + }, + + render: function ( options ){ + this.options = _.extend( this.options, options ); + var template = this.templateFolder(); + $(".tooltip").hide(); + + // find the upper id in the full path + var path = this.folderContainer.attributes.metadata.full_path; + var upper_folder_id; + if ( path.length === 1 ){ // the library is above us + upper_folder_id = 0; + } else { + upper_folder_id = path[ path.length-2 ][ 0 ]; + } + + this.$el.html( template( { + path: this.folderContainer.attributes.metadata.full_path, + parent_library_id: this.folderContainer.attributes.metadata.parent_library_id, + id: this.options.id, + upper_folder_id: upper_folder_id, + order: this.sort + } ) ); + + // when dataset_id is present render its details too + if ( this.options.dataset_id ){ + row = _.findWhere( that.rowViews, { id: this.options.dataset_id } ); + if ( row ) { row.showDatasetDetails(); } else { - mod_toastr.error('Dataset not found. Showing folder instead.'); + mod_toastr.error( 'Requested dataset not found. Showing folder instead.' ); } - } - }, - error: function(model, response){ - if (typeof response.responseJSON !== "undefined"){ - mod_toastr.error(response.responseJSON.err_msg + ' Click this to go back.', '', {onclick: function() {Galaxy.libraries.library_router.back();}}); - } else { - mod_toastr.error('An error ocurred. Click this to go back.', '', {onclick: function() {Galaxy.libraries.library_router.back();}}); - } + } else { + if ( this.options.show_page === null || this.options.show_page < 1 ){ + this.options.show_page = 1; + } + this.paginate(); } - }); - }, + $("#center [data-toggle]").tooltip(); + $("#center").css('overflow','auto'); + }, - render: function (options) { - this.options = _.defaults(this.options, options); - var template = this.templateFolder(); - $(".tooltip").hide(); + paginate: function( options ){ + this.options = _.extend( this.options, options ); - // TODO move to server - // find the upper id in the full path - var path = this.folderContainer.attributes.metadata.full_path; - var upper_folder_id; - if (path.length === 1){ // the library is above us - upper_folder_id = 0; - } else { - upper_folder_id = path[path.length-2][0]; - } + if ( this.options.show_page === null || this.options.show_page < 1 ){ + this.options.show_page = 1; + } + this.options.total_items_count = this.folder_container.get( 'folder' ).models.length; + this.options.page_count = Math.ceil( this.options.total_items_count / Galaxy.libraries.preferences.get( 'folder_page_size' ) ); + var page_start = ( Galaxy.libraries.preferences.get( 'folder_page_size' ) * ( this.options.show_page - 1 ) ); + var items_to_render = null; + items_to_render = this.folder_container.get( 'folder' ).models.slice( page_start, page_start + Galaxy.libraries.preferences.get( 'folder_page_size' ) ); + this.options.items_shown = items_to_render.length; + // User requests page with no items + if ( Galaxy.libraries.preferences.get( 'folder_page_size' ) * this.options.show_page > ( this.options.total_items_count + Galaxy.libraries.preferences.get( 'folder_page_size' ) ) ){ + items_to_render = []; + } + Galaxy.libraries.folderToolbarView.renderPaginator( this.options ); + this.collection.reset(); + this.addAll( items_to_render ) + }, - this.$el.html(template({ path: this.folderContainer.attributes.metadata.full_path, parent_library_id: this.folderContainer.attributes.metadata.parent_library_id, id: this.options.id, upper_folder_id: upper_folder_id, order: this.sort})); + /** + * Adds all given models to the collection. + * @param {array of Item or FolderAsModel} array of models that should + * be added to the view's collection. + */ + addAll: function( models ){ + _.each(models, function( model ) { + Galaxy.libraries.folderListView.collection.add( model ); + }); + $( "#center [data-toggle]" ).tooltip(); + this.checkEmptiness(); + this.postRender(); + }, - // initialize the library tooltips - $("#center [data-toggle]").tooltip(); - //hack to show scrollbars - $("#center").css('overflow','auto'); - }, + /** + * Call this after all models are added to the collection + * to ensure that the folder toolbar will show proper options + * and that event will be bound on all subviews. + */ + postRender: function(){ + var fetched_metadata = this.folderContainer.attributes.metadata; + fetched_metadata.contains_file = typeof this.collection.findWhere({type: 'file'}) !== 'undefined'; + Galaxy.libraries.folderToolbarView.configureElements(fetched_metadata); + $('.library-row').hover(function() { + $(this).find('.show_on_hover').show(); + }, function () { + $(this).find('.show_on_hover').hide(); + }); + }, - /** - * Call this after all models are added to the collection - * to ensure that the folder toolbar will show proper options - * and that event will be bound on all subviews. - */ - postRender: function(){ - var fetched_metadata = this.folderContainer.attributes.metadata; - fetched_metadata.contains_file = typeof this.collection.findWhere({type: 'file'}) !== 'undefined'; - Galaxy.libraries.folderToolbarView.configureElements(fetched_metadata); - $('.library-row').hover(function() { - $(this).find('.show_on_hover').show(); - }, function () { - $(this).find('.show_on_hover').hide(); - }); - }, + /** + * Iterates this view's collection and calls the render + * function for each. Also binds the hover behavior. + */ + renderAll: function(){ + var that = this; + _.each( this.collection.models.reverse(), function( model ) { + that.renderOne( model ); + }); + this.postRender(); + }, - /** - * Adds all given models to the collection. - * @param {array of Item or FolderAsModel} array of models that should - * be added to the view's collection. - */ - addAll: function(models){ - _.each(models.reverse(), function(model) { - Galaxy.libraries.folderListView.collection.add(model); - }); - - $("#center [data-toggle]").tooltip(); - this.checkEmptiness(); - - this.postRender(); - }, - - /** - * Iterates this view's collection and calls the render - * function for each. Also binds the hover behavior. - */ - renderAll: function(){ - var that = this; - _.each(this.collection.models.reverse(), function(model) { - that.renderOne(model); - }); - this.postRender(); - }, - - /** - * Creates a view for the given model and adds it to the folder view. - * @param {Item or FolderAsModel} model of the view that will be rendered - */ - renderOne: function(model){ - if (model.get('type') !== 'folder'){ - this.options.contains_file = true; - // model.set('readable_size', this.size_to_string(model.get('file_size'))); - } - model.set('folder_id', this.id); - var rowView = new mod_library_folderrow_view.FolderRowView(model); - - // save new rowView to cache - this.rowViews[model.get('id')] = rowView; - - this.$el.find('#first_folder_item').after(rowView.el); - - $('.library-row').hover(function() { - $(this).find('.show_on_hover').show(); - }, function () { - $(this).find('.show_on_hover').hide(); - }); - }, - - /** - * removes the view of the given model from the DOM - * @param {Item or FolderAsModel} model of the view that will be removed - */ - removeOne: function(model){ - this.$el.find('#' + model.id).remove(); - }, - - /** Checks whether the list is empty and adds/removes the message */ - checkEmptiness : function(){ - if ((this.$el.find('.dataset_row').length === 0) && (this.$el.find('.folder_row').length === 0)){ - this.$el.find('.empty-folder-message').show(); - } else { - this.$el.find('.empty-folder-message').hide(); - } - }, - - /** User clicked the table heading = he wants to sort stuff */ - sortColumnClicked : function(event){ - event.preventDefault(); - if (this.sort === 'asc'){ - this.sortFolder('name','desc'); - this.sort = 'desc'; - } else { - this.sortFolder('name','asc'); - this.sort = 'asc'; - } - this.render(); - this.renderAll(); - this.checkEmptiness(); - }, - - /** - * Sorts the underlying collection according to the parameters received. - * Currently supports only sorting by name. - */ - sortFolder: function(sort_by, order){ - if (sort_by === 'name'){ - if (order === 'asc'){ - return this.collection.sortByNameAsc(); - } else if (order === 'desc'){ - return this.collection.sortByNameDesc(); + /** + * Creates a view for the given model and adds it to the folder view. + * @param {Item or FolderAsModel} model of the view that will be rendered + */ + renderOne: function(model){ + if (model.get('type') !== 'folder'){ + this.options.contains_file = true; + // model.set('readable_size', this.size_to_string(model.get('file_size'))); } - } - }, + model.set('folder_id', this.id); + var rowView = new mod_library_folderrow_view.FolderRowView(model); - /** - * User clicked the checkbox in the table heading - * @param {context} event - */ - selectAll : function (event) { - var selected = event.target.checked; - that = this; - // Iterate each checkbox - $(':checkbox', '#folder_list_body').each(function() { - this.checked = selected; - $row = $(this.parentElement.parentElement); - // Change color of selected/unselected - if (selected) { - that.makeDarkRow($row); - } else { - that.makeWhiteRow($row); - } - }); - }, + // save new rowView to cache + this.rowViews[model.get('id')] = rowView; - /** - * Check checkbox if user clicks on the whole row or - * on the checkbox itself - */ - selectClickedRow : function (event) { - var checkbox = ''; - var $row; - var source; - if (event.target.localName === 'input'){ - checkbox = event.target; - $row = $(event.target.parentElement.parentElement); - source = 'input'; - } else if (event.target.localName === 'td') { - checkbox = $("#" + event.target.parentElement.id).find(':checkbox')[0]; - $row = $(event.target.parentElement); - source = 'td'; - } - if (checkbox.checked){ - if (source==='td'){ - checkbox.checked = ''; - this.makeWhiteRow($row); - } else if (source==='input') { - this.makeDarkRow($row); + this.$el.find('#first_folder_item').after(rowView.el); + + $('.library-row').hover(function() { + $(this).find('.show_on_hover').show(); + }, function () { + $(this).find('.show_on_hover').hide(); + }); + }, + + /** + * removes the view of the given model from the DOM + * @param {Item or FolderAsModel} model of the view that will be removed + */ + removeOne: function( model ){ + this.$el.find( '#' + model.id ).remove(); + }, + + /** Checks whether the list is empty and adds/removes the message */ + checkEmptiness : function(){ + if ((this.$el.find('.dataset_row').length === 0) && (this.$el.find('.folder_row').length === 0)){ + this.$el.find('.empty-folder-message').show(); + } else { + this.$el.find('.empty-folder-message').hide(); } - } else { - if (source==='td'){ - checkbox.checked = 'selected'; - this.makeDarkRow($row); - } else if (source==='input') { - this.makeWhiteRow($row); + }, + + /** User clicked the table heading = he wants to sort stuff */ + sortColumnClicked : function(event){ + event.preventDefault(); + if (this.sort === 'asc'){ + this.sortFolder('name','desc'); + this.sort = 'desc'; + } else { + this.sortFolder('name','asc'); + this.sort = 'asc'; } + this.render(); + this.renderAll(); + this.checkEmptiness(); + }, + + /** + * Sorts the underlying collection according to the parameters received. + * Currently supports only sorting by name. + */ + sortFolder: function(sort_by, order){ + if (sort_by === 'name'){ + if (order === 'asc'){ + return this.collection.sortByNameAsc(); + } else if (order === 'desc'){ + return this.collection.sortByNameDesc(); + } + } + }, + + /** + * User clicked the checkbox in the table heading + * @param {context} event + */ + selectAll : function (event) { + var selected = event.target.checked; + that = this; + // Iterate each checkbox + $(':checkbox', '#folder_list_body').each(function() { + this.checked = selected; + $row = $(this.parentElement.parentElement); + // Change color of selected/unselected + if (selected) { + that.makeDarkRow($row); + } else { + that.makeWhiteRow($row); + } + }); + }, + + /** + * Check checkbox if user clicks on the whole row or + * on the checkbox itself + */ + selectClickedRow : function (event) { + var checkbox = ''; + var $row; + var source; + if (event.target.localName === 'input'){ + checkbox = event.target; + $row = $(event.target.parentElement.parentElement); + source = 'input'; + } else if (event.target.localName === 'td') { + checkbox = $("#" + event.target.parentElement.id).find(':checkbox')[0]; + $row = $(event.target.parentElement); + source = 'td'; + } + if (checkbox.checked){ + if (source==='td'){ + checkbox.checked = ''; + this.makeWhiteRow($row); + } else if (source==='input') { + this.makeDarkRow($row); + } + } else { + if (source==='td'){ + checkbox.checked = 'selected'; + this.makeDarkRow($row); + } else if (source==='input') { + this.makeWhiteRow($row); + } + } + }, + + makeDarkRow: function($row){ + $row.removeClass('light').addClass('dark'); + $row.find('a').removeClass('light').addClass('dark'); + $row.find('.fa-file-o').removeClass('fa-file-o').addClass('fa-file'); + }, + + makeWhiteRow: function($row){ + $row.removeClass('dark').addClass('light'); + $row.find('a').removeClass('dark').addClass('light'); + $row.find('.fa-file').removeClass('fa-file').addClass('fa-file-o'); + }, + + templateFolder : function (){ + var tmpl_array = []; + + // BREADCRUMBS + tmpl_array.push(''); + + // FOLDER CONTENT + tmpl_array.push(''); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + tmpl_array.push(' '); + + tmpl_array.push(' '); + tmpl_array.push('
name data typesizetime updated (UTC)
" title="Go to parent folder" class="btn_open_folder btn btn-default btn-xs">..
'); + tmpl_array.push(''); + + return _.template(tmpl_array.join('')); } - }, - - makeDarkRow: function($row){ - $row.removeClass('light').addClass('dark'); - $row.find('a').removeClass('light').addClass('dark'); - $row.find('.fa-file-o').removeClass('fa-file-o').addClass('fa-file'); - }, - - makeWhiteRow: function($row){ - $row.removeClass('dark').addClass('light'); - $row.find('a').removeClass('dark').addClass('light'); - $row.find('.fa-file').removeClass('fa-file').addClass('fa-file-o'); - }, - - templateFolder : function (){ - var tmpl_array = []; - - // BREADCRUMBS - tmpl_array.push(''); - - // FOLDER CONTENT - tmpl_array.push(''); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - tmpl_array.push(' '); - - tmpl_array.push(' '); - tmpl_array.push('
name data typesizetime updated (UTC)
" title="Go to parent folder" class="btn_open_folder btn btn-default btn-xs">..
'); - tmpl_array.push(''); - - return _.template(tmpl_array.join('')); - } - + }); return { diff --git a/static/scripts/mvc/library/library-foldertoolbar-view.js b/static/scripts/mvc/library/library-foldertoolbar-view.js index ec532b71d74..d5f3b9a6d20 100644 --- a/static/scripts/mvc/library/library-foldertoolbar-view.js +++ b/static/scripts/mvc/library/library-foldertoolbar-view.js @@ -20,7 +20,9 @@ var FolderToolbarView = Backbone.View.extend({ 'click #toolbtn_bulk_import' : 'modalBulkImport', 'click #include_deleted_datasets_chk' : 'checkIncludeDeleted', 'click #toolbtn_show_libinfo' : 'showLibInfo', - 'click #toolbtn_bulk_delete' : 'deleteSelectedDatasets' + 'click #toolbtn_bulk_delete' : 'deleteSelectedDatasets', + 'click #page_size_prompt' : 'showPageSizePrompt' + }, defaults: { @@ -90,6 +92,22 @@ var FolderToolbarView = Backbone.View.extend({ this.$el.html(toolbar_template(template_defaults)); }, + /** + * Called from FolderListView when needed. + * @param {object} options common options + */ + renderPaginator: function( options ){ + this.options = _.extend( this.options, options ); + var paginator_template = this.templatePaginator(); + this.$el.find( '#folder_paginator' ).html( paginator_template({ + id: this.options.id, + show_page: parseInt( this.options.show_page ), + page_count: parseInt( this.options.page_count ), + total_items_count: this.options.total_items_count, + items_shown: this.options.items_shown + })); + }, + configureElements: function(options){ this.options = _.extend(this.options, options); @@ -833,11 +851,11 @@ var FolderToolbarView = Backbone.View.extend({ var popped_item = lddas_set.pop(); if ( typeof popped_item === "undefined" ) { if ( this.options.chain_call_control.failed_number === 0 ){ - mod_toastr.success( 'Selected datasets deleted' ); + mod_toastr.success( 'Selected datasets were deleted.' ); } else if ( this.options.chain_call_control.failed_number === this.options.chain_call_control.total_number ){ - mod_toastr.error( 'There was an error and no datasets were deleted.' ); + mod_toastr.error( 'There was an error and no datasets were deleted. Please make sure you have sufficient permissions.' ); } else if ( this.options.chain_call_control.failed_number < this.options.chain_call_control.total_number ){ - mod_toastr.warning( 'Some of the datasets could not be deleted' ); + mod_toastr.warning( 'Some of the datasets could not be deleted. Please make sure you have sufficient permissions.' ); } Galaxy.modal.hide(); return this.deleted_lddas; @@ -976,6 +994,14 @@ var FolderToolbarView = Backbone.View.extend({ } }, + showPageSizePrompt: function(){ + var folder_page_size = prompt( 'How many items per page do you want to see?', Galaxy.libraries.preferences.get( 'folder_page_size' ) ); + if ( ( folder_page_size != null ) && ( folder_page_size == parseInt( folder_page_size ) ) ) { + Galaxy.libraries.preferences.set( { 'folder_page_size': parseInt( folder_page_size ) } ); + Galaxy.libraries.folderListView.render( { id: this.options.id, show_page: 1 } ); + } + }, + templateToolBar: function(){ tmpl_array = []; @@ -1016,7 +1042,6 @@ var FolderToolbarView = Backbone.View.extend({ tmpl_array.push(' '); tmpl_array.push('<% } %>'); - tmpl_array.push(' '); tmpl_array.push(' '); // TOOLBAR END tmpl_array.push('
'); @@ -1239,7 +1268,41 @@ var FolderToolbarView = Backbone.View.extend({ tmpl_array.push(''); return _.template(tmpl_array.join('')); - } + }, + + templatePaginator: function(){ + tmpl_array = []; + + tmpl_array.push('
    '); + tmpl_array.push(' <% if ( ( show_page - 1 ) > 0 ) { %>'); + tmpl_array.push(' <% if ( ( show_page - 1 ) > page_count ) { %>'); // we are on higher page than total page count + tmpl_array.push('
  • '); + tmpl_array.push('
  • <% print( show_page - 1 ) %>
  • '); + tmpl_array.push(' <% } else { %>'); + tmpl_array.push('
  • '); + tmpl_array.push('
  • <% print( show_page - 1 ) %>
  • '); + tmpl_array.push(' <% } %>'); + tmpl_array.push(' <% } else { %>'); // we are on the first page + tmpl_array.push('
  • '); + tmpl_array.push('
  • <% print( show_page - 1 ) %>
  • '); + tmpl_array.push(' <% } %>'); + tmpl_array.push('
  • '); + tmpl_array.push(' <% print( show_page ) %>'); + tmpl_array.push('
  • '); + tmpl_array.push(' <% if ( ( show_page ) < page_count ) { %>'); + tmpl_array.push('
  • <% print( show_page + 1 ) %>
  • '); + tmpl_array.push('
  • '); + tmpl_array.push(' <% } else { %>'); + tmpl_array.push('
  • <% print( show_page + 1 ) %>
  • '); + tmpl_array.push('
  • '); + tmpl_array.push(' <% } %>'); + tmpl_array.push('
'); + tmpl_array.push(' '); + tmpl_array.push(' showing <%- items_shown %> of <%- total_items_count %> items'); + tmpl_array.push(' '); + + return _.template(tmpl_array.join('')); + }, }); diff --git a/static/scripts/mvc/library/library-librarylist-view.js b/static/scripts/mvc/library/library-librarylist-view.js index 65ddfc85c1a..e229395a340 100644 --- a/static/scripts/mvc/library/library-librarylist-view.js +++ b/static/scripts/mvc/library/library-librarylist-view.js @@ -21,20 +21,19 @@ var LibraryListView = Backbone.View.extend({ 'click .sort-libraries-link' : 'sort_clicked' }, - /** - * Initialize and fetch the libraries from server. - * Async render afterwards. - * @param {object} options an options object - */ defaults: { page_count: null, show_page: null }, + /** + * Initialize and fetch the libraries from server. + * Async render afterwards. + * @param {object} options an object with options + */ initialize : function( options ){ this.options = _.defaults( this.options || {}, this.defaults, options ); - - var that = this; + var that = this; this.modal = null; // map of library model ids to library views = cache this.rowViews = {}; @@ -61,19 +60,10 @@ var LibraryListView = Backbone.View.extend({ */ render: function ( options ) { this.options = _.extend( this.options, options ); - - if ( ( this.options.page_size != null ) && ( this.options.page_size == parseInt( this.options.page_size ) ) ) { - Galaxy.libraries.preferences.set( { 'library_page_size': parseInt( this.options.page_size ) } ); - } - - $( ".tooltip" ).hide(); - // this.options.show_page = this.options.show_page || 1; var template = this.templateLibraryList(); var libraries_to_render = null; var models = null; - if ( this.options.show_page === null || this.options.show_page < 1 ){ - this.options.show_page = 1; - } + $( ".tooltip" ).hide(); if ( typeof options !== 'undefined' ){ models = typeof options.models !== 'undefined' ? options.models : null; } @@ -89,6 +79,10 @@ var LibraryListView = Backbone.View.extend({ } else { libraries_to_render = []; } + // pagination + if ( this.options.show_page === null || this.options.show_page < 1 ){ + this.options.show_page = 1; + } this.options.total_libraries_count = libraries_to_render.length var page_start = ( Galaxy.libraries.preferences.get( 'library_page_size' ) * ( this.options.show_page - 1 ) ); this.options.page_count = Math.ceil( this.options.total_libraries_count / Galaxy.libraries.preferences.get( 'library_page_size' ) ); diff --git a/static/scripts/packed/galaxy.library.js b/static/scripts/packed/galaxy.library.js index f1235f884d0..b2d085183f9 100644 --- a/static/scripts/packed/galaxy.library.js +++ b/static/scripts/packed/galaxy.library.js @@ -1 +1 @@ -define(["galaxy.masthead","utils/utils","libs/toastr","mvc/base-mvc","mvc/library/library-model","mvc/library/library-folderlist-view","mvc/library/library-librarylist-view","mvc/library/library-librarytoolbar-view","mvc/library/library-foldertoolbar-view","mvc/library/library-dataset-view","mvc/library/library-library-view","mvc/library/library-folder-view"],function(h,e,j,n,k,c,i,g,l,f,b,a){var o=Backbone.Router.extend({initialize:function(){this.routesHit=0;Backbone.history.on("route",function(){this.routesHit++},this)},routes:{"":"libraries","page/:show_page":"libraries_page","library/:library_id/permissions":"library_permissions","folders/:folder_id/permissions":"folder_permissions","folders/:id":"folder_content","folders/:folder_id/datasets/:dataset_id":"dataset_detail","folders/:folder_id/datasets/:dataset_id/permissions":"dataset_permissions","folders/:folder_id/datasets/:dataset_id/versions/:ldda_id":"dataset_version","folders/:folder_id/download/:format":"download","folders/:folder_id/import/:source":"import_datasets"},back:function(){if(this.routesHit>1){window.history.back()}else{this.navigate("#",{trigger:true,replace:true})}}});var m=n.SessionStorageModel.extend({defaults:{with_deleted:false,sort_order:"asc",sort_by:"name",library_page_size:20}});var d=Backbone.View.extend({libraryToolbarView:null,libraryListView:null,library_router:null,libraryView:null,folderToolbarView:null,folderListView:null,datasetView:null,initialize:function(){Galaxy.libraries=this;this.preferences=new m({id:"global-lib-prefs"});this.library_router=new o();this.library_router.on("route:libraries",function(){Galaxy.libraries.libraryToolbarView=new g.LibraryToolbarView();Galaxy.libraries.libraryListView=new i.LibraryListView()});this.library_router.on("route:libraries_page",function(p){if(Galaxy.libraries.libraryToolbarView===null){Galaxy.libraries.libraryToolbarView=new g.LibraryToolbarView();Galaxy.libraries.libraryListView=new i.LibraryListView({show_page:p})}else{Galaxy.libraries.libraryListView.render({show_page:p})}});this.library_router.on("route:folder_content",function(p){if(Galaxy.libraries.folderToolbarView){Galaxy.libraries.folderToolbarView.$el.unbind("click")}Galaxy.libraries.folderToolbarView=new l.FolderToolbarView({id:p});Galaxy.libraries.folderListView=new c.FolderListView({id:p})});this.library_router.on("route:download",function(p,q){if($("#folder_list_body").find(":checked").length===0){j.info("You must select at least one dataset to download");Galaxy.libraries.library_router.navigate("folders/"+p,{trigger:true,replace:true})}else{Galaxy.libraries.folderToolbarView.download(p,q);Galaxy.libraries.library_router.navigate("folders/"+p,{trigger:false,replace:true})}});this.library_router.on("route:dataset_detail",function(q,p){if(Galaxy.libraries.datasetView){Galaxy.libraries.datasetView.$el.unbind("click")}Galaxy.libraries.datasetView=new f.LibraryDatasetView({id:p})});this.library_router.on("route:dataset_version",function(q,p,r){if(Galaxy.libraries.datasetView){Galaxy.libraries.datasetView.$el.unbind("click")}Galaxy.libraries.datasetView=new f.LibraryDatasetView({id:p,ldda_id:r,show_version:true})});this.library_router.on("route:dataset_permissions",function(q,p){if(Galaxy.libraries.datasetView){Galaxy.libraries.datasetView.$el.unbind("click")}Galaxy.libraries.datasetView=new f.LibraryDatasetView({id:p,show_permissions:true})});this.library_router.on("route:library_permissions",function(p){if(Galaxy.libraries.libraryView){Galaxy.libraries.libraryView.$el.unbind("click")}Galaxy.libraries.libraryView=new b.LibraryView({id:p,show_permissions:true})});this.library_router.on("route:folder_permissions",function(p){if(Galaxy.libraries.folderView){Galaxy.libraries.folderView.$el.unbind("click")}Galaxy.libraries.folderView=new a.FolderView({id:p,show_permissions:true})});this.library_router.on("route:import_datasets",function(p,q){if(Galaxy.libraries.folderToolbarView&&Galaxy.libraries.folderListView){Galaxy.libraries.folderToolbarView.showImportModal({source:q})}else{Galaxy.libraries.folderToolbarView=new l.FolderToolbarView({id:p});Galaxy.libraries.folderListView=new c.FolderListView({id:p});Galaxy.libraries.folderToolbarView.showImportModal({source:q})}});Backbone.history.start({pushState:false})}});return{GalaxyApp:d}}); \ No newline at end of file +define(["galaxy.masthead","utils/utils","libs/toastr","mvc/base-mvc","mvc/library/library-model","mvc/library/library-folderlist-view","mvc/library/library-librarylist-view","mvc/library/library-librarytoolbar-view","mvc/library/library-foldertoolbar-view","mvc/library/library-dataset-view","mvc/library/library-library-view","mvc/library/library-folder-view"],function(h,e,j,n,k,c,i,g,l,f,b,a){var o=Backbone.Router.extend({initialize:function(){this.routesHit=0;Backbone.history.on("route",function(){this.routesHit++},this)},routes:{"":"libraries","page/:show_page":"libraries_page","library/:library_id/permissions":"library_permissions","folders/:folder_id/permissions":"folder_permissions","folders/:id":"folder_content","folders/:id/page/:show_page":"folder_page","folders/:folder_id/datasets/:dataset_id":"dataset_detail","folders/:folder_id/datasets/:dataset_id/permissions":"dataset_permissions","folders/:folder_id/datasets/:dataset_id/versions/:ldda_id":"dataset_version","folders/:folder_id/download/:format":"download","folders/:folder_id/import/:source":"import_datasets"},back:function(){if(this.routesHit>1){window.history.back()}else{this.navigate("#",{trigger:true,replace:true})}}});var m=n.SessionStorageModel.extend({defaults:{with_deleted:false,sort_order:"asc",sort_by:"name",library_page_size:20,folder_page_size:15}});var d=Backbone.View.extend({libraryToolbarView:null,libraryListView:null,library_router:null,libraryView:null,folderToolbarView:null,folderListView:null,datasetView:null,initialize:function(){Galaxy.libraries=this;this.preferences=new m({id:"global-lib-prefs"});this.library_router=new o();this.library_router.on("route:libraries",function(){Galaxy.libraries.libraryToolbarView=new g.LibraryToolbarView();Galaxy.libraries.libraryListView=new i.LibraryListView()});this.library_router.on("route:libraries_page",function(p){if(Galaxy.libraries.libraryToolbarView===null){Galaxy.libraries.libraryToolbarView=new g.LibraryToolbarView();Galaxy.libraries.libraryListView=new i.LibraryListView({show_page:p})}else{Galaxy.libraries.libraryListView.render({show_page:p})}});this.library_router.on("route:folder_content",function(p){if(Galaxy.libraries.folderToolbarView){Galaxy.libraries.folderToolbarView.$el.unbind("click")}Galaxy.libraries.folderToolbarView=new l.FolderToolbarView({id:p});Galaxy.libraries.folderListView=new c.FolderListView({id:p})});this.library_router.on("route:folder_page",function(q,p){if(Galaxy.libraries.folderToolbarView===null){Galaxy.libraries.folderToolbarView=new l.FolderToolbarView({id:q});Galaxy.libraries.folderListView=new c.FolderListView({id:q,show_page:p})}else{Galaxy.libraries.folderListView.render({id:q,show_page:parseInt(p)})}});this.library_router.on("route:download",function(p,q){if($("#folder_list_body").find(":checked").length===0){j.info("You must select at least one dataset to download");Galaxy.libraries.library_router.navigate("folders/"+p,{trigger:true,replace:true})}else{Galaxy.libraries.folderToolbarView.download(p,q);Galaxy.libraries.library_router.navigate("folders/"+p,{trigger:false,replace:true})}});this.library_router.on("route:dataset_detail",function(q,p){if(Galaxy.libraries.datasetView){Galaxy.libraries.datasetView.$el.unbind("click")}Galaxy.libraries.datasetView=new f.LibraryDatasetView({id:p})});this.library_router.on("route:dataset_version",function(q,p,r){if(Galaxy.libraries.datasetView){Galaxy.libraries.datasetView.$el.unbind("click")}Galaxy.libraries.datasetView=new f.LibraryDatasetView({id:p,ldda_id:r,show_version:true})});this.library_router.on("route:dataset_permissions",function(q,p){if(Galaxy.libraries.datasetView){Galaxy.libraries.datasetView.$el.unbind("click")}Galaxy.libraries.datasetView=new f.LibraryDatasetView({id:p,show_permissions:true})});this.library_router.on("route:library_permissions",function(p){if(Galaxy.libraries.libraryView){Galaxy.libraries.libraryView.$el.unbind("click")}Galaxy.libraries.libraryView=new b.LibraryView({id:p,show_permissions:true})});this.library_router.on("route:folder_permissions",function(p){if(Galaxy.libraries.folderView){Galaxy.libraries.folderView.$el.unbind("click")}Galaxy.libraries.folderView=new a.FolderView({id:p,show_permissions:true})});this.library_router.on("route:import_datasets",function(p,q){if(Galaxy.libraries.folderToolbarView&&Galaxy.libraries.folderListView){Galaxy.libraries.folderToolbarView.showImportModal({source:q})}else{Galaxy.libraries.folderToolbarView=new l.FolderToolbarView({id:p});Galaxy.libraries.folderListView=new c.FolderListView({id:p});Galaxy.libraries.folderToolbarView.showImportModal({source:q})}});Backbone.history.start({pushState:false})}});return{GalaxyApp:d}}); \ No newline at end of file diff --git a/static/scripts/packed/mvc/library/library-folderlist-view.js b/static/scripts/packed/mvc/library/library-folderlist-view.js index c495703b784..661a2f96c12 100644 --- a/static/scripts/packed/mvc/library/library-folderlist-view.js +++ b/static/scripts/packed/mvc/library/library-folderlist-view.js @@ -1 +1 @@ -define(["galaxy.masthead","utils/utils","libs/toastr","mvc/library/library-model","mvc/library/library-folderrow-view","mvc/library/library-dataset-view"],function(d,f,g,e,a,c){var b=Backbone.View.extend({el:"#folder_items_element",defaults:{include_deleted:false},progress:0,progressStep:1,modal:null,folderContainer:null,sort:"asc",events:{"click #select-all-checkboxes":"selectAll","click .dataset_row":"selectClickedRow","click .sort-folder-link":"sortColumnClicked"},rowViews:{},initialize:function(h){this.options=_.defaults(this.options||{},h);this.fetchFolder()},fetchFolder:function(h){var h=h||{};this.options.include_deleted=h.include_deleted;var i=this;this.collection=new e.Folder();this.listenTo(this.collection,"add",this.renderOne);this.listenTo(this.collection,"remove",this.removeOne);this.folderContainer=new e.FolderContainer({id:this.options.id});this.folderContainer.url=this.folderContainer.attributes.urlRoot+this.options.id+"/contents";if(this.options.include_deleted){this.folderContainer.url=this.folderContainer.url+"?include_deleted=true"}this.folderContainer.fetch({success:function(j){i.folder_container=j;i.render();i.addAll(j.get("folder").models);if(i.options.dataset_id){row=_.findWhere(i.rowViews,{id:i.options.dataset_id});if(row){row.showDatasetDetails()}else{g.error("Dataset not found. Showing folder instead.")}}},error:function(k,j){if(typeof j.responseJSON!=="undefined"){g.error(j.responseJSON.err_msg+" Click this to go back.","",{onclick:function(){Galaxy.libraries.library_router.back()}})}else{g.error("An error ocurred. Click this to go back.","",{onclick:function(){Galaxy.libraries.library_router.back()}})}}})},render:function(h){this.options=_.defaults(this.options,h);var i=this.templateFolder();$(".tooltip").hide();var j=this.folderContainer.attributes.metadata.full_path;var k;if(j.length===1){k=0}else{k=j[j.length-2][0]}this.$el.html(i({path:this.folderContainer.attributes.metadata.full_path,parent_library_id:this.folderContainer.attributes.metadata.parent_library_id,id:this.options.id,upper_folder_id:k,order:this.sort}));$("#center [data-toggle]").tooltip();$("#center").css("overflow","auto")},postRender:function(){var h=this.folderContainer.attributes.metadata;h.contains_file=typeof this.collection.findWhere({type:"file"})!=="undefined";Galaxy.libraries.folderToolbarView.configureElements(h);$(".library-row").hover(function(){$(this).find(".show_on_hover").show()},function(){$(this).find(".show_on_hover").hide()})},addAll:function(h){_.each(h.reverse(),function(i){Galaxy.libraries.folderListView.collection.add(i)});$("#center [data-toggle]").tooltip();this.checkEmptiness();this.postRender()},renderAll:function(){var h=this;_.each(this.collection.models.reverse(),function(i){h.renderOne(i)});this.postRender()},renderOne:function(i){if(i.get("type")!=="folder"){this.options.contains_file=true}i.set("folder_id",this.id);var h=new a.FolderRowView(i);this.rowViews[i.get("id")]=h;this.$el.find("#first_folder_item").after(h.el);$(".library-row").hover(function(){$(this).find(".show_on_hover").show()},function(){$(this).find(".show_on_hover").hide()})},removeOne:function(h){this.$el.find("#"+h.id).remove()},checkEmptiness:function(){if((this.$el.find(".dataset_row").length===0)&&(this.$el.find(".folder_row").length===0)){this.$el.find(".empty-folder-message").show()}else{this.$el.find(".empty-folder-message").hide()}},sortColumnClicked:function(h){h.preventDefault();if(this.sort==="asc"){this.sortFolder("name","desc");this.sort="desc"}else{this.sortFolder("name","asc");this.sort="asc"}this.render();this.renderAll();this.checkEmptiness()},sortFolder:function(i,h){if(i==="name"){if(h==="asc"){return this.collection.sortByNameAsc()}else{if(h==="desc"){return this.collection.sortByNameDesc()}}}},selectAll:function(i){var h=i.target.checked;that=this;$(":checkbox","#folder_list_body").each(function(){this.checked=h;$row=$(this.parentElement.parentElement);if(h){that.makeDarkRow($row)}else{that.makeWhiteRow($row)}})},selectClickedRow:function(i){var k="";var h;var j;if(i.target.localName==="input"){k=i.target;h=$(i.target.parentElement.parentElement);j="input"}else{if(i.target.localName==="td"){k=$("#"+i.target.parentElement.id).find(":checkbox")[0];h=$(i.target.parentElement);j="td"}}if(k.checked){if(j==="td"){k.checked="";this.makeWhiteRow(h)}else{if(j==="input"){this.makeDarkRow(h)}}}else{if(j==="td"){k.checked="selected";this.makeDarkRow(h)}else{if(j==="input"){this.makeWhiteRow(h)}}}},makeDarkRow:function(h){h.removeClass("light").addClass("dark");h.find("a").removeClass("light").addClass("dark");h.find(".fa-file-o").removeClass("fa-file-o").addClass("fa-file")},makeWhiteRow:function(h){h.removeClass("dark").addClass("light");h.find("a").removeClass("dark").addClass("light");h.find(".fa-file").removeClass("fa-file").addClass("fa-file-o")},templateFolder:function(){var h=[];h.push('");h.push('');h.push(" ");h.push(' ');h.push(' ');h.push(' ');h.push(' ');h.push(' ');h.push(' ');h.push(' ');h.push(" ");h.push(' ');h.push(' ');h.push(' ');h.push(" ");h.push(" ");h.push(" ");h.push(" ");h.push(" ");h.push(" ");h.push(" ");h.push(" ");h.push("
name data typesizetime updated (UTC)
" title="Go to parent folder" class="btn_open_folder btn btn-default btn-xs">..
");h.push('');return _.template(h.join(""))}});return{FolderListView:b}}); \ No newline at end of file +define(["galaxy.masthead","utils/utils","libs/toastr","mvc/library/library-model","mvc/library/library-folderrow-view","mvc/library/library-dataset-view"],function(d,f,g,e,a,c){var b=Backbone.View.extend({el:"#folder_items_element",progress:0,progressStep:1,folderContainer:null,sort:"asc",events:{"click #select-all-checkboxes":"selectAll","click .dataset_row":"selectClickedRow","click .sort-folder-link":"sortColumnClicked"},collection:null,defaults:{include_deleted:false,page_count:null,show_page:null},initialize:function(h){this.options=_.defaults(this.options||{},this.defaults,h);this.modal=null;this.rowViews={};this.collection=new e.Folder();this.listenTo(this.collection,"add",this.renderOne);this.listenTo(this.collection,"remove",this.removeOne);this.fetchFolder()},fetchFolder:function(h){var h=h||{};this.options.include_deleted=h.include_deleted;var i=this;this.folderContainer=new e.FolderContainer({id:this.options.id});this.folderContainer.url=this.folderContainer.attributes.urlRoot+this.options.id+"/contents";if(this.options.include_deleted){this.folderContainer.url=this.folderContainer.url+"?include_deleted=true"}this.folderContainer.fetch({success:function(j){i.folder_container=j;i.render()},error:function(k,j){if(typeof j.responseJSON!=="undefined"){g.error(j.responseJSON.err_msg+" Click this to go back.","",{onclick:function(){Galaxy.libraries.library_router.back()}})}else{g.error("An error ocurred. Click this to go back.","",{onclick:function(){Galaxy.libraries.library_router.back()}})}}})},render:function(h){this.options=_.extend(this.options,h);var i=this.templateFolder();$(".tooltip").hide();var j=this.folderContainer.attributes.metadata.full_path;var k;if(j.length===1){k=0}else{k=j[j.length-2][0]}this.$el.html(i({path:this.folderContainer.attributes.metadata.full_path,parent_library_id:this.folderContainer.attributes.metadata.parent_library_id,id:this.options.id,upper_folder_id:k,order:this.sort}));if(this.options.dataset_id){row=_.findWhere(that.rowViews,{id:this.options.dataset_id});if(row){row.showDatasetDetails()}else{g.error("Requested dataset not found. Showing folder instead.")}}else{if(this.options.show_page===null||this.options.show_page<1){this.options.show_page=1}this.paginate()}$("#center [data-toggle]").tooltip();$("#center").css("overflow","auto")},paginate:function(j){this.options=_.extend(this.options,j);if(this.options.show_page===null||this.options.show_page<1){this.options.show_page=1}this.options.total_items_count=this.folder_container.get("folder").models.length;this.options.page_count=Math.ceil(this.options.total_items_count/Galaxy.libraries.preferences.get("folder_page_size"));var i=(Galaxy.libraries.preferences.get("folder_page_size")*(this.options.show_page-1));var h=null;h=this.folder_container.get("folder").models.slice(i,i+Galaxy.libraries.preferences.get("folder_page_size"));this.options.items_shown=h.length;if(Galaxy.libraries.preferences.get("folder_page_size")*this.options.show_page>(this.options.total_items_count+Galaxy.libraries.preferences.get("folder_page_size"))){h=[]}Galaxy.libraries.folderToolbarView.renderPaginator(this.options);this.collection.reset();this.addAll(h)},addAll:function(h){_.each(h,function(i){Galaxy.libraries.folderListView.collection.add(i)});$("#center [data-toggle]").tooltip();this.checkEmptiness();this.postRender()},postRender:function(){var h=this.folderContainer.attributes.metadata;h.contains_file=typeof this.collection.findWhere({type:"file"})!=="undefined";Galaxy.libraries.folderToolbarView.configureElements(h);$(".library-row").hover(function(){$(this).find(".show_on_hover").show()},function(){$(this).find(".show_on_hover").hide()})},renderAll:function(){var h=this;_.each(this.collection.models.reverse(),function(i){h.renderOne(i)});this.postRender()},renderOne:function(i){if(i.get("type")!=="folder"){this.options.contains_file=true}i.set("folder_id",this.id);var h=new a.FolderRowView(i);this.rowViews[i.get("id")]=h;this.$el.find("#first_folder_item").after(h.el);$(".library-row").hover(function(){$(this).find(".show_on_hover").show()},function(){$(this).find(".show_on_hover").hide()})},removeOne:function(h){this.$el.find("#"+h.id).remove()},checkEmptiness:function(){if((this.$el.find(".dataset_row").length===0)&&(this.$el.find(".folder_row").length===0)){this.$el.find(".empty-folder-message").show()}else{this.$el.find(".empty-folder-message").hide()}},sortColumnClicked:function(h){h.preventDefault();if(this.sort==="asc"){this.sortFolder("name","desc");this.sort="desc"}else{this.sortFolder("name","asc");this.sort="asc"}this.render();this.renderAll();this.checkEmptiness()},sortFolder:function(i,h){if(i==="name"){if(h==="asc"){return this.collection.sortByNameAsc()}else{if(h==="desc"){return this.collection.sortByNameDesc()}}}},selectAll:function(i){var h=i.target.checked;that=this;$(":checkbox","#folder_list_body").each(function(){this.checked=h;$row=$(this.parentElement.parentElement);if(h){that.makeDarkRow($row)}else{that.makeWhiteRow($row)}})},selectClickedRow:function(i){var k="";var h;var j;if(i.target.localName==="input"){k=i.target;h=$(i.target.parentElement.parentElement);j="input"}else{if(i.target.localName==="td"){k=$("#"+i.target.parentElement.id).find(":checkbox")[0];h=$(i.target.parentElement);j="td"}}if(k.checked){if(j==="td"){k.checked="";this.makeWhiteRow(h)}else{if(j==="input"){this.makeDarkRow(h)}}}else{if(j==="td"){k.checked="selected";this.makeDarkRow(h)}else{if(j==="input"){this.makeWhiteRow(h)}}}},makeDarkRow:function(h){h.removeClass("light").addClass("dark");h.find("a").removeClass("light").addClass("dark");h.find(".fa-file-o").removeClass("fa-file-o").addClass("fa-file")},makeWhiteRow:function(h){h.removeClass("dark").addClass("light");h.find("a").removeClass("dark").addClass("light");h.find(".fa-file").removeClass("fa-file").addClass("fa-file-o")},templateFolder:function(){var h=[];h.push('");h.push('');h.push(" ");h.push(' ');h.push(' ');h.push(' ');h.push(' ');h.push(' ');h.push(' ');h.push(' ');h.push(" ");h.push(' ');h.push(' ');h.push(' ');h.push(" ");h.push(" ");h.push(" ");h.push(" ");h.push(" ");h.push(" ");h.push(" ");h.push(" ");h.push("
name data typesizetime updated (UTC)
" title="Go to parent folder" class="btn_open_folder btn btn-default btn-xs">..
");h.push('');return _.template(h.join(""))}});return{FolderListView:b}}); \ No newline at end of file diff --git a/static/scripts/packed/mvc/library/library-foldertoolbar-view.js b/static/scripts/packed/mvc/library/library-foldertoolbar-view.js index 261ca796839..663f15f446e 100644 --- a/static/scripts/packed/mvc/library/library-foldertoolbar-view.js +++ b/static/scripts/packed/mvc/library/library-foldertoolbar-view.js @@ -1 +1 @@ -define(["galaxy.masthead","utils/utils","libs/toastr","mvc/library/library-model","mvc/ui/ui-select"],function(c,e,f,d,a){var b=Backbone.View.extend({el:"#center",events:{"click #toolbtn_create_folder":"createFolderFromModal","click #toolbtn_bulk_import":"modalBulkImport","click #include_deleted_datasets_chk":"checkIncludeDeleted","click #toolbtn_show_libinfo":"showLibInfo","click #toolbtn_bulk_delete":"deleteSelectedDatasets"},defaults:{can_add_library_item:false,contains_file:false,chain_call_control:{total_number:0,failed_number:0},disabled_jstree_element:"folders"},modal:null,jstree:null,histories:null,select_genome:null,select_extension:null,list_extensions:[],auto:{id:"auto",text:"Auto-detect",description:"This system will try to detect the file type automatically. If your file is not detected properly as one of the known formats, it most likely means that it has some format problems (e.g., different number of columns on different rows). You can still coerce the system to set your data to the format you think it should be. You can also upload compressed files, which will automatically be decompressed."},list_genomes:[],initialize:function(g){this.options=_.defaults(g||{},this.defaults);this.fetchExtAndGenomes();this.render()},render:function(g){this.options=_.extend(this.options,g);var i=this.templateToolBar();var h={id:this.options.id,is_admin:false,is_anonym:true,mutiple_add_dataset_options:false};if(Galaxy.currUser){h.is_admin=Galaxy.currUser.isAdmin();h.is_anonym=Galaxy.currUser.isAnonymous();if(Galaxy.config.user_library_import_dir!==null||Galaxy.config.allow_library_path_paste!==false||Galaxy.config.library_import_dir!==null){h.mutiple_add_dataset_options=true}}this.$el.html(i(h))},configureElements:function(g){this.options=_.extend(this.options,g);if(this.options.can_add_library_item===true){$(".add-library-items").show()}else{$(".add-library-items").hide()}if(this.options.contains_file===true){if(Galaxy.currUser){if(!Galaxy.currUser.isAnonymous()){$(".logged-dataset-manipulation").show();$(".dataset-manipulation").show()}else{$(".dataset-manipulation").show();$(".logged-dataset-manipulation").hide()}}else{$(".logged-dataset-manipulation").hide();$(".dataset-manipulation").hide()}}else{$(".logged-dataset-manipulation").hide();$(".dataset-manipulation").hide()}this.$el.find("[data-toggle]").tooltip()},createFolderFromModal:function(i){i.preventDefault();i.stopPropagation();var g=this;var h=this.templateNewFolderInModal();this.modal=Galaxy.modal;this.modal.show({closing_events:true,title:"Create New Folder",body:h(),buttons:{Create:function(){g.create_new_folder_event()},Close:function(){Galaxy.modal.hide()}}})},create_new_folder_event:function(){var g=this.serialize_new_folder();if(this.validate_new_folder(g)){var h=new d.FolderAsModel();url_items=Backbone.history.fragment.split("/");current_folder_id=url_items[url_items.length-1];h.url=h.urlRoot+"/"+current_folder_id;h.save(g,{success:function(i){Galaxy.modal.hide();f.success("Folder created.");i.set({type:"folder"});Galaxy.libraries.folderListView.collection.add(i)},error:function(j,i){Galaxy.modal.hide();if(typeof i.responseJSON!=="undefined"){f.error(i.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})}else{f.error("Folder's name is missing.")}return false},serialize_new_folder:function(){return{name:$("input[name='Name']").val(),description:$("input[name='Description']").val()}},validate_new_folder:function(g){return g.name!==""},modalBulkImport:function(){var g=$("#folder_table").find(":checked");if(g.length===0){f.info("You must select some datasets first.")}else{this.refreshUserHistoriesList(function(i){var h=i.templateBulkImportInModal();i.modal=Galaxy.modal;i.modal.show({closing_events:true,title:"Import into History",body:h({histories:i.histories.models}),buttons:{Import:function(){i.importAllIntoHistory()},Close:function(){Galaxy.modal.hide()}}})})}},refreshUserHistoriesList:function(h){var g=this;this.histories=new d.GalaxyHistories();this.histories.fetch({success:function(){h(g)},error:function(j,i){if(typeof i.responseJSON!=="undefined"){f.error(i.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})},importAllIntoHistory:function(){this.modal.disableButton("Import");var k=$("select[name=dataset_import_bulk] option:selected").val();var n=$("select[name=dataset_import_bulk] option:selected").text();this.options.last_used_history_id=k;var h=[];$("#folder_table").find(":checked").each(function(){if(this.parentElement.parentElement.id!==""){h.push(this.parentElement.parentElement.id)}});var m=[];for(var j=h.length-1;j>=0;j--){var g=h[j];var l=new d.HistoryItem();l.url=l.urlRoot+k+"/contents";l.content=g;l.source="library";m.push(l)}this.initChainCallControl({length:m.length,action:"to_history",history_name:n});jQuery.getJSON(galaxy_config.root+"history/set_as_current?id="+k);this.chainCallImportingIntoHistory(m,n)},updateProgress:function(){this.progress+=this.progressStep;$(".progress-bar-import").width(Math.round(this.progress)+"%");txt_representation=Math.round(this.progress)+"% Complete";$(".completion_span").text(txt_representation)},download:function(g,k){var i=[];$("#folder_table").find(":checked").each(function(){if(this.parentElement.parentElement.id!==""){i.push(this.parentElement.parentElement.id)}});var h="/api/libraries/datasets/download/"+k;var j={ld_ids:i};this.processDownload(h,j,"get")},processDownload:function(h,i,j){if(h&&i){i=typeof i==="string"?i:$.param(i);var g="";$.each(i.split("&"),function(){var k=this.split("=");g+=''});$('
'+g+"
").appendTo("body").submit().remove();f.info("Your download will begin soon.")}else{f.error("An error occurred.")}},addFilesFromHistoryModal:function(){this.refreshUserHistoriesList(function(g){g.modal=Galaxy.modal;var h=g.templateAddFilesFromHistory();var i=g.options.full_path[g.options.full_path.length-1][1];g.modal.show({closing_events:true,title:"Adding datasets from your history to folder "+i,body:h({histories:g.histories.models}),buttons:{Add:function(){g.addAllDatasetsFromHistory()},Close:function(){Galaxy.modal.hide()}},closing_callback:function(){Galaxy.libraries.library_router.back()}});if(g.histories.models.length>0){g.fetchAndDisplayHistoryContents(g.histories.models[0].id);$("#dataset_add_bulk").change(function(j){g.fetchAndDisplayHistoryContents(j.target.value)})}else{f.error("An error ocurred.")}})},importFilesFromPathModal:function(){var h=this;this.modal=Galaxy.modal;var g=this.templateImportPathModal();this.modal.show({closing_events:true,title:"Please enter paths to import",body:g({}),buttons:{Import:function(){h.importFromPathsClicked(h)},Close:function(){Galaxy.modal.hide()}},closing_callback:function(){Galaxy.libraries.library_router.navigate("folders/"+h.id,{trigger:true})}});this.renderSelectBoxes()},fetchExtAndGenomes:function(){var g=this;e.get({url:galaxy_config.root+"api/datatypes?extension_only=False",success:function(h){for(key in h){g.list_extensions.push({id:h[key].extension,text:h[key].extension,description:h[key].description,description_url:h[key].description_url})}g.list_extensions.sort(function(j,i){return j.id>i.id?1:j.idi.id?1:j.id=0;k--){trimmed=m[k].trim();if(trimmed.length!==0){l.push(trimmed)}}this.initChainCallControl({length:l.length,action:"adding_datasets"});this.chainCallImportingFolders({paths:l,preserve_dirs:g,link_data:n,source:"admin_path",file_type:h,dbkey:j})}},initChainCallControl:function(g){var h;switch(g.action){case"adding_datasets":h=this.templateAddingDatasetsProgressBar();this.modal.$el.find(".modal-body").html(h({folder_name:this.options.folder_name}));break;case"deleting_datasets":h=this.templateDeletingDatasetsProgressBar();this.modal.$el.find(".modal-body").html(h());break;case"to_history":h=this.templateImportIntoHistoryProgressBar();this.modal.$el.find(".modal-body").html(h({history_name:g.history_name}));break;default:console.error("Wrong action specified.");break}this.progress=0;this.progressStep=100/g.length;this.options.chain_call_control.total_number=g.length;this.options.chain_call_control.failed_number=0},importFromJstreePath:function(n,r){var g=$("#jstree_browser").jstree().get_selected(true);var m=this.modal.$el.find(".preserve-checkbox").is(":checked");var o=this.modal.$el.find(".link-checkbox").is(":checked");var j=this.select_extension.value();var p=this.select_genome.value();var k=g[0].type;var q=[];if(g.length<1){f.info("Please select some items first.")}else{this.modal.disableButton("Import");for(var l=g.length-1;l>=0;l--){if(g[l].li_attr.full_path!==undefined){q.push(g[l].li_attr.full_path)}}this.initChainCallControl({length:q.length,action:"adding_datasets"});if(k==="folder"){var h=r.source+"_folder";this.chainCallImportingFolders({paths:q,preserve_dirs:m,link_data:o,source:h,file_type:j,dbkey:p})}else{if(k==="file"){var h=r.source+"_file";this.chainCallImportingUserdirFiles({paths:q,file_type:j,dbkey:p,source:h})}}}},fetchAndDisplayHistoryContents:function(i){var h=new d.HistoryContents({id:i});var g=this;h.fetch({success:function(k){var j=g.templateHistoryContents();g.histories.get(i).set({contents:k});g.modal.$el.find("#selected_history_content").html(j({history_contents:k.models.reverse()}))},error:function(k,j){if(typeof j.responseJSON!=="undefined"){f.error(j.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})},addAllDatasetsFromHistory:function(){var l=this.modal.$el.find("#selected_history_content").find(":checked");var g=[];var k=[];if(l.length<1){f.info("You must select some datasets first.")}else{this.modal.disableButton("Add");l.each(function(){var i=$(this.parentElement).data("id");if(i){g.push(i)}});for(var j=g.length-1;j>=0;j--){history_dataset_id=g[j];var h=new d.Item();h.url="/api/folders/"+this.options.id+"/contents";h.set({from_hda_id:history_dataset_id});k.push(h)}this.initChainCallControl({length:k.length,action:"adding_datasets"});this.chainCallAddingHdas(k)}},chainCallImportingIntoHistory:function(h,k){var g=this;var i=h.pop();if(typeof i=="undefined"){if(this.options.chain_call_control.failed_number===0){f.success("Selected datasets imported into history. Click this to start analysing it.","",{onclick:function(){window.location="/"}})}else{if(this.options.chain_call_control.failed_number===this.options.chain_call_control.total_number){f.error("There was an error and no datasets were imported into history.")}else{if(this.options.chain_call_control.failed_number=0;j--){var l=new d.Item({id:h[j]});m.push(l)}this.options.chain_call_control.total_number=h.length;this.chainCallDeletingHdas(m)}},showLibInfo:function(){var h=Galaxy.libraries.folderListView.folderContainer.attributes.metadata.parent_library_id;var g=null;var i=this;if(Galaxy.libraries.libraryListView!==null){g=Galaxy.libraries.libraryListView.collection.get(h);this.showLibInfoModal(g)}else{g=new d.Library({id:h});g.fetch({success:function(){i.showLibInfoModal(g)},error:function(k,j){if(typeof j.responseJSON!=="undefined"){f.error(j.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})}},showLibInfoModal:function(g){var h=this.templateLibInfoInModal();this.modal=Galaxy.modal;this.modal.show({closing_events:true,title:"Library Information",body:h({library:g}),buttons:{Close:function(){Galaxy.modal.hide()}}})},showImportModal:function(g){switch(g.source){case"history":this.addFilesFromHistoryModal();break;case"importdir":this.importFilesFromGalaxyFolderModal({source:"importdir"});break;case"path":this.importFilesFromPathModal();break;case"userdir":this.importFilesFromGalaxyFolderModal({source:"userdir"});break;default:Galaxy.libraries.library_router.back();f.error("Invalid import source.");break}},templateToolBar:function(){tmpl_array=[];tmpl_array.push('
');tmpl_array.push('
');tmpl_array.push(" DATA LIBRARIES");tmpl_array.push(' ');tmpl_array.push(' ');tmpl_array.push("<% if(mutiple_add_dataset_options) { %>");tmpl_array.push(' ");tmpl_array.push("<% } else { %>");tmpl_array.push(' ');tmpl_array.push("<% } %>");tmpl_array.push(' ');tmpl_array.push(' ");tmpl_array.push(' ');tmpl_array.push(' ');tmpl_array.push(' ');tmpl_array.push("
");tmpl_array.push('
');tmpl_array.push("
");tmpl_array.push("
");return _.template(tmpl_array.join(""))},templateLibInfoInModal:function(){tmpl_array=[];tmpl_array.push('
');tmpl_array.push("

Library name:

");tmpl_array.push('

<%- library.get("name") %>

');tmpl_array.push("

Library description:

");tmpl_array.push('

<%- library.get("description") %>

');tmpl_array.push("

Library synopsis:

");tmpl_array.push('

<%- library.get("synopsis") %>

');tmpl_array.push("
");return _.template(tmpl_array.join(""))},templateNewFolderInModal:function(){tmpl_array=[];tmpl_array.push('
');tmpl_array.push("
");tmpl_array.push('');tmpl_array.push('');tmpl_array.push("
");tmpl_array.push("
");return _.template(tmpl_array.join(""))},templateBulkImportInModal:function(){var g=[];g.push('');g.push("Select history: ");g.push('");g.push("");return _.template(g.join(""))},templateImportIntoHistoryProgressBar:function(){var g=[];g.push('
');g.push("Importing selected datasets to history <%= _.escape(history_name) %>");g.push("
");g.push('
');g.push('
');g.push(' 0% Complete');g.push("
");g.push("
");g.push("");return _.template(g.join(""))},templateAddingDatasetsProgressBar:function(){var g=[];g.push('
');g.push("Adding selected datasets to library folder <%= _.escape(folder_name) %>");g.push("
");g.push('
');g.push('
');g.push(' 0% Complete');g.push("
");g.push("
");g.push("");return _.template(g.join(""))},templateDeletingDatasetsProgressBar:function(){var g=[];g.push('
');g.push("
");g.push('
');g.push('
');g.push(' 0% Complete');g.push("
");g.push("
");g.push("");return _.template(g.join(""))},templateBrowserModal:function(){var g=[];g.push('
');g.push('
All files you select will be imported into the current folder.
');g.push('');g.push('
');g.push('");g.push('");g.push("
");g.push('
');g.push('");g.push('");g.push("
");g.push('
');g.push("
");g.push("
");g.push("

You can set extension type and genome for all imported datasets at once:

");g.push("
");g.push('Type: ');g.push(' Genome: ');g.push("
");g.push("
");return _.template(g.join(""))},templateImportPathModal:function(){var g=[];g.push('
');g.push('
All files within the given folders and their subfolders will be imported into the current folder.
');g.push('
');g.push('");g.push('");g.push("
");g.push('');g.push("
");g.push("

You can set extension type and genome for all imported datasets at once:

");g.push("
");g.push('Type: ');g.push(' Genome: ');g.push("
");g.push("
");return _.template(g.join(""))},templateAddFilesFromHistory:function(){var g=[];g.push('
');g.push('
');g.push("Select history: ");g.push('");g.push("
");g.push("
");g.push('
');g.push("
");g.push("
");return _.template(g.join(""))},templateHistoryContents:function(){var g=[];g.push("Choose the datasets to import:");g.push("
    ");g.push(" <% _.each(history_contents, function(history_item) { %>");g.push('
  • ">');g.push(' <%= _.escape(history_item.get("hid")) %>: <%= _.escape(history_item.get("name")) %>');g.push("
  • ");g.push(" <% }); %>");g.push("
");return _.template(g.join(""))}});return{FolderToolbarView:b}}); \ No newline at end of file +define(["galaxy.masthead","utils/utils","libs/toastr","mvc/library/library-model","mvc/ui/ui-select"],function(c,e,f,d,a){var b=Backbone.View.extend({el:"#center",events:{"click #toolbtn_create_folder":"createFolderFromModal","click #toolbtn_bulk_import":"modalBulkImport","click #include_deleted_datasets_chk":"checkIncludeDeleted","click #toolbtn_show_libinfo":"showLibInfo","click #toolbtn_bulk_delete":"deleteSelectedDatasets","click #page_size_prompt":"showPageSizePrompt"},defaults:{can_add_library_item:false,contains_file:false,chain_call_control:{total_number:0,failed_number:0},disabled_jstree_element:"folders"},modal:null,jstree:null,histories:null,select_genome:null,select_extension:null,list_extensions:[],auto:{id:"auto",text:"Auto-detect",description:"This system will try to detect the file type automatically. If your file is not detected properly as one of the known formats, it most likely means that it has some format problems (e.g., different number of columns on different rows). You can still coerce the system to set your data to the format you think it should be. You can also upload compressed files, which will automatically be decompressed."},list_genomes:[],initialize:function(g){this.options=_.defaults(g||{},this.defaults);this.fetchExtAndGenomes();this.render()},render:function(g){this.options=_.extend(this.options,g);var i=this.templateToolBar();var h={id:this.options.id,is_admin:false,is_anonym:true,mutiple_add_dataset_options:false};if(Galaxy.currUser){h.is_admin=Galaxy.currUser.isAdmin();h.is_anonym=Galaxy.currUser.isAnonymous();if(Galaxy.config.user_library_import_dir!==null||Galaxy.config.allow_library_path_paste!==false||Galaxy.config.library_import_dir!==null){h.mutiple_add_dataset_options=true}}this.$el.html(i(h))},renderPaginator:function(h){this.options=_.extend(this.options,h);var g=this.templatePaginator();this.$el.find("#folder_paginator").html(g({id:this.options.id,show_page:parseInt(this.options.show_page),page_count:parseInt(this.options.page_count),total_items_count:this.options.total_items_count,items_shown:this.options.items_shown}))},configureElements:function(g){this.options=_.extend(this.options,g);if(this.options.can_add_library_item===true){$(".add-library-items").show()}else{$(".add-library-items").hide()}if(this.options.contains_file===true){if(Galaxy.currUser){if(!Galaxy.currUser.isAnonymous()){$(".logged-dataset-manipulation").show();$(".dataset-manipulation").show()}else{$(".dataset-manipulation").show();$(".logged-dataset-manipulation").hide()}}else{$(".logged-dataset-manipulation").hide();$(".dataset-manipulation").hide()}}else{$(".logged-dataset-manipulation").hide();$(".dataset-manipulation").hide()}this.$el.find("[data-toggle]").tooltip()},createFolderFromModal:function(i){i.preventDefault();i.stopPropagation();var g=this;var h=this.templateNewFolderInModal();this.modal=Galaxy.modal;this.modal.show({closing_events:true,title:"Create New Folder",body:h(),buttons:{Create:function(){g.create_new_folder_event()},Close:function(){Galaxy.modal.hide()}}})},create_new_folder_event:function(){var g=this.serialize_new_folder();if(this.validate_new_folder(g)){var h=new d.FolderAsModel();url_items=Backbone.history.fragment.split("/");current_folder_id=url_items[url_items.length-1];h.url=h.urlRoot+"/"+current_folder_id;h.save(g,{success:function(i){Galaxy.modal.hide();f.success("Folder created.");i.set({type:"folder"});Galaxy.libraries.folderListView.collection.add(i)},error:function(j,i){Galaxy.modal.hide();if(typeof i.responseJSON!=="undefined"){f.error(i.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})}else{f.error("Folder's name is missing.")}return false},serialize_new_folder:function(){return{name:$("input[name='Name']").val(),description:$("input[name='Description']").val()}},validate_new_folder:function(g){return g.name!==""},modalBulkImport:function(){var g=$("#folder_table").find(":checked");if(g.length===0){f.info("You must select some datasets first.")}else{this.refreshUserHistoriesList(function(i){var h=i.templateBulkImportInModal();i.modal=Galaxy.modal;i.modal.show({closing_events:true,title:"Import into History",body:h({histories:i.histories.models}),buttons:{Import:function(){i.importAllIntoHistory()},Close:function(){Galaxy.modal.hide()}}})})}},refreshUserHistoriesList:function(h){var g=this;this.histories=new d.GalaxyHistories();this.histories.fetch({success:function(){h(g)},error:function(j,i){if(typeof i.responseJSON!=="undefined"){f.error(i.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})},importAllIntoHistory:function(){this.modal.disableButton("Import");var k=$("select[name=dataset_import_bulk] option:selected").val();var n=$("select[name=dataset_import_bulk] option:selected").text();this.options.last_used_history_id=k;var h=[];$("#folder_table").find(":checked").each(function(){if(this.parentElement.parentElement.id!==""){h.push(this.parentElement.parentElement.id)}});var m=[];for(var j=h.length-1;j>=0;j--){var g=h[j];var l=new d.HistoryItem();l.url=l.urlRoot+k+"/contents";l.content=g;l.source="library";m.push(l)}this.initChainCallControl({length:m.length,action:"to_history",history_name:n});jQuery.getJSON(galaxy_config.root+"history/set_as_current?id="+k);this.chainCallImportingIntoHistory(m,n)},updateProgress:function(){this.progress+=this.progressStep;$(".progress-bar-import").width(Math.round(this.progress)+"%");txt_representation=Math.round(this.progress)+"% Complete";$(".completion_span").text(txt_representation)},download:function(g,k){var i=[];$("#folder_table").find(":checked").each(function(){if(this.parentElement.parentElement.id!==""){i.push(this.parentElement.parentElement.id)}});var h="/api/libraries/datasets/download/"+k;var j={ld_ids:i};this.processDownload(h,j,"get")},processDownload:function(h,i,j){if(h&&i){i=typeof i==="string"?i:$.param(i);var g="";$.each(i.split("&"),function(){var k=this.split("=");g+=''});$('
'+g+"
").appendTo("body").submit().remove();f.info("Your download will begin soon.")}else{f.error("An error occurred.")}},addFilesFromHistoryModal:function(){this.refreshUserHistoriesList(function(g){g.modal=Galaxy.modal;var h=g.templateAddFilesFromHistory();var i=g.options.full_path[g.options.full_path.length-1][1];g.modal.show({closing_events:true,title:"Adding datasets from your history to folder "+i,body:h({histories:g.histories.models}),buttons:{Add:function(){g.addAllDatasetsFromHistory()},Close:function(){Galaxy.modal.hide()}},closing_callback:function(){Galaxy.libraries.library_router.back()}});if(g.histories.models.length>0){g.fetchAndDisplayHistoryContents(g.histories.models[0].id);$("#dataset_add_bulk").change(function(j){g.fetchAndDisplayHistoryContents(j.target.value)})}else{f.error("An error ocurred.")}})},importFilesFromPathModal:function(){var h=this;this.modal=Galaxy.modal;var g=this.templateImportPathModal();this.modal.show({closing_events:true,title:"Please enter paths to import",body:g({}),buttons:{Import:function(){h.importFromPathsClicked(h)},Close:function(){Galaxy.modal.hide()}},closing_callback:function(){Galaxy.libraries.library_router.navigate("folders/"+h.id,{trigger:true})}});this.renderSelectBoxes()},fetchExtAndGenomes:function(){var g=this;e.get({url:galaxy_config.root+"api/datatypes?extension_only=False",success:function(h){for(key in h){g.list_extensions.push({id:h[key].extension,text:h[key].extension,description:h[key].description,description_url:h[key].description_url})}g.list_extensions.sort(function(j,i){return j.id>i.id?1:j.idi.id?1:j.id=0;k--){trimmed=m[k].trim();if(trimmed.length!==0){l.push(trimmed)}}this.initChainCallControl({length:l.length,action:"adding_datasets"});this.chainCallImportingFolders({paths:l,preserve_dirs:g,link_data:n,source:"admin_path",file_type:h,dbkey:j})}},initChainCallControl:function(g){var h;switch(g.action){case"adding_datasets":h=this.templateAddingDatasetsProgressBar();this.modal.$el.find(".modal-body").html(h({folder_name:this.options.folder_name}));break;case"deleting_datasets":h=this.templateDeletingDatasetsProgressBar();this.modal.$el.find(".modal-body").html(h());break;case"to_history":h=this.templateImportIntoHistoryProgressBar();this.modal.$el.find(".modal-body").html(h({history_name:g.history_name}));break;default:console.error("Wrong action specified.");break}this.progress=0;this.progressStep=100/g.length;this.options.chain_call_control.total_number=g.length;this.options.chain_call_control.failed_number=0},importFromJstreePath:function(n,r){var g=$("#jstree_browser").jstree().get_selected(true);var m=this.modal.$el.find(".preserve-checkbox").is(":checked");var o=this.modal.$el.find(".link-checkbox").is(":checked");var j=this.select_extension.value();var p=this.select_genome.value();var k=g[0].type;var q=[];if(g.length<1){f.info("Please select some items first.")}else{this.modal.disableButton("Import");for(var l=g.length-1;l>=0;l--){if(g[l].li_attr.full_path!==undefined){q.push(g[l].li_attr.full_path)}}this.initChainCallControl({length:q.length,action:"adding_datasets"});if(k==="folder"){var h=r.source+"_folder";this.chainCallImportingFolders({paths:q,preserve_dirs:m,link_data:o,source:h,file_type:j,dbkey:p})}else{if(k==="file"){var h=r.source+"_file";this.chainCallImportingUserdirFiles({paths:q,file_type:j,dbkey:p,source:h})}}}},fetchAndDisplayHistoryContents:function(i){var h=new d.HistoryContents({id:i});var g=this;h.fetch({success:function(k){var j=g.templateHistoryContents();g.histories.get(i).set({contents:k});g.modal.$el.find("#selected_history_content").html(j({history_contents:k.models.reverse()}))},error:function(k,j){if(typeof j.responseJSON!=="undefined"){f.error(j.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})},addAllDatasetsFromHistory:function(){var l=this.modal.$el.find("#selected_history_content").find(":checked");var g=[];var k=[];if(l.length<1){f.info("You must select some datasets first.")}else{this.modal.disableButton("Add");l.each(function(){var i=$(this.parentElement).data("id");if(i){g.push(i)}});for(var j=g.length-1;j>=0;j--){history_dataset_id=g[j];var h=new d.Item();h.url="/api/folders/"+this.options.id+"/contents";h.set({from_hda_id:history_dataset_id});k.push(h)}this.initChainCallControl({length:k.length,action:"adding_datasets"});this.chainCallAddingHdas(k)}},chainCallImportingIntoHistory:function(h,k){var g=this;var i=h.pop();if(typeof i=="undefined"){if(this.options.chain_call_control.failed_number===0){f.success("Selected datasets imported into history. Click this to start analysing it.","",{onclick:function(){window.location="/"}})}else{if(this.options.chain_call_control.failed_number===this.options.chain_call_control.total_number){f.error("There was an error and no datasets were imported into history.")}else{if(this.options.chain_call_control.failed_number=0;j--){var l=new d.Item({id:h[j]});m.push(l)}this.options.chain_call_control.total_number=h.length;this.chainCallDeletingHdas(m)}},showLibInfo:function(){var h=Galaxy.libraries.folderListView.folderContainer.attributes.metadata.parent_library_id;var g=null;var i=this;if(Galaxy.libraries.libraryListView!==null){g=Galaxy.libraries.libraryListView.collection.get(h);this.showLibInfoModal(g)}else{g=new d.Library({id:h});g.fetch({success:function(){i.showLibInfoModal(g)},error:function(k,j){if(typeof j.responseJSON!=="undefined"){f.error(j.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})}},showLibInfoModal:function(g){var h=this.templateLibInfoInModal();this.modal=Galaxy.modal;this.modal.show({closing_events:true,title:"Library Information",body:h({library:g}),buttons:{Close:function(){Galaxy.modal.hide()}}})},showImportModal:function(g){switch(g.source){case"history":this.addFilesFromHistoryModal();break;case"importdir":this.importFilesFromGalaxyFolderModal({source:"importdir"});break;case"path":this.importFilesFromPathModal();break;case"userdir":this.importFilesFromGalaxyFolderModal({source:"userdir"});break;default:Galaxy.libraries.library_router.back();f.error("Invalid import source.");break}},showPageSizePrompt:function(){var g=prompt("How many items per page do you want to see?",Galaxy.libraries.preferences.get("folder_page_size"));if((g!=null)&&(g==parseInt(g))){Galaxy.libraries.preferences.set({folder_page_size:parseInt(g)});Galaxy.libraries.folderListView.render({id:this.options.id,show_page:1})}},templateToolBar:function(){tmpl_array=[];tmpl_array.push('
');tmpl_array.push('
');tmpl_array.push(" DATA LIBRARIES");tmpl_array.push(' ');tmpl_array.push(' ');tmpl_array.push("<% if(mutiple_add_dataset_options) { %>");tmpl_array.push(' ");tmpl_array.push("<% } else { %>");tmpl_array.push(' ');tmpl_array.push("<% } %>");tmpl_array.push(' ');tmpl_array.push(' ");tmpl_array.push(' ');tmpl_array.push(' ');tmpl_array.push(' ');tmpl_array.push(' ');tmpl_array.push(" ");tmpl_array.push("
");tmpl_array.push('
');tmpl_array.push("
");tmpl_array.push("
");return _.template(tmpl_array.join(""))},templateLibInfoInModal:function(){tmpl_array=[];tmpl_array.push('
');tmpl_array.push("

Library name:

");tmpl_array.push('

<%- library.get("name") %>

');tmpl_array.push("

Library description:

");tmpl_array.push('

<%- library.get("description") %>

');tmpl_array.push("

Library synopsis:

");tmpl_array.push('

<%- library.get("synopsis") %>

');tmpl_array.push("
");return _.template(tmpl_array.join(""))},templateNewFolderInModal:function(){tmpl_array=[];tmpl_array.push('
');tmpl_array.push("
");tmpl_array.push('');tmpl_array.push('');tmpl_array.push("
");tmpl_array.push("
");return _.template(tmpl_array.join(""))},templateBulkImportInModal:function(){var g=[];g.push('');g.push("Select history: ");g.push('");g.push("");return _.template(g.join(""))},templateImportIntoHistoryProgressBar:function(){var g=[];g.push('
');g.push("Importing selected datasets to history <%= _.escape(history_name) %>");g.push("
");g.push('
');g.push('
');g.push(' 0% Complete');g.push("
");g.push("
");g.push("");return _.template(g.join(""))},templateAddingDatasetsProgressBar:function(){var g=[];g.push('
');g.push("Adding selected datasets to library folder <%= _.escape(folder_name) %>");g.push("
");g.push('
');g.push('
');g.push(' 0% Complete');g.push("
");g.push("
");g.push("");return _.template(g.join(""))},templateDeletingDatasetsProgressBar:function(){var g=[];g.push('
');g.push("
");g.push('
');g.push('
');g.push(' 0% Complete');g.push("
");g.push("
");g.push("");return _.template(g.join(""))},templateBrowserModal:function(){var g=[];g.push('
');g.push('
All files you select will be imported into the current folder.
');g.push('');g.push('
');g.push('");g.push('");g.push("
");g.push('
');g.push('");g.push('");g.push("
");g.push('
');g.push("
");g.push("
");g.push("

You can set extension type and genome for all imported datasets at once:

");g.push("
");g.push('Type: ');g.push(' Genome: ');g.push("
");g.push("
");return _.template(g.join(""))},templateImportPathModal:function(){var g=[];g.push('
');g.push('
All files within the given folders and their subfolders will be imported into the current folder.
');g.push('
');g.push('");g.push('");g.push("
");g.push('');g.push("
");g.push("

You can set extension type and genome for all imported datasets at once:

");g.push("
");g.push('Type: ');g.push(' Genome: ');g.push("
");g.push("
");return _.template(g.join(""))},templateAddFilesFromHistory:function(){var g=[];g.push('
');g.push('
');g.push("Select history: ");g.push('");g.push("
");g.push("
");g.push('
');g.push("
");g.push("
");return _.template(g.join(""))},templateHistoryContents:function(){var g=[];g.push("Choose the datasets to import:");g.push("
    ");g.push(" <% _.each(history_contents, function(history_item) { %>");g.push('
  • ">');g.push(' <%= _.escape(history_item.get("hid")) %>: <%= _.escape(history_item.get("name")) %>');g.push("
  • ");g.push(" <% }); %>");g.push("
");return _.template(g.join(""))},templatePaginator:function(){tmpl_array=[];tmpl_array.push('
    ');tmpl_array.push(" <% if ( ( show_page - 1 ) > 0 ) { %>");tmpl_array.push(" <% if ( ( show_page - 1 ) > page_count ) { %>");tmpl_array.push('
  • ');tmpl_array.push('
  • <% print( show_page - 1 ) %>
  • ');tmpl_array.push(" <% } else { %>");tmpl_array.push('
  • ');tmpl_array.push('
  • <% print( show_page - 1 ) %>
  • ');tmpl_array.push(" <% } %>");tmpl_array.push(" <% } else { %>");tmpl_array.push('
  • ');tmpl_array.push('
  • <% print( show_page - 1 ) %>
  • ');tmpl_array.push(" <% } %>");tmpl_array.push('
  • ');tmpl_array.push(' <% print( show_page ) %>');tmpl_array.push("
  • ");tmpl_array.push(" <% if ( ( show_page ) < page_count ) { %>");tmpl_array.push('
  • <% print( show_page + 1 ) %>
  • ');tmpl_array.push('
  • ');tmpl_array.push(" <% } else { %>");tmpl_array.push('
  • <% print( show_page + 1 ) %>
  • ');tmpl_array.push('
  • ');tmpl_array.push(" <% } %>");tmpl_array.push("
");tmpl_array.push(" ");tmpl_array.push(' showing <%- items_shown %> of <%- total_items_count %> items');tmpl_array.push(" ");return _.template(tmpl_array.join(""))},});return{FolderToolbarView:b}}); \ No newline at end of file diff --git a/static/scripts/packed/mvc/library/library-librarylist-view.js b/static/scripts/packed/mvc/library/library-librarylist-view.js index 71457da652e..e6a94a1e132 100644 --- a/static/scripts/packed/mvc/library/library-librarylist-view.js +++ b/static/scripts/packed/mvc/library/library-librarylist-view.js @@ -1 +1 @@ -define(["galaxy.masthead","mvc/base-mvc","utils/utils","libs/toastr","mvc/library/library-model","mvc/library/library-libraryrow-view"],function(b,g,d,e,c,a){var f=Backbone.View.extend({el:"#libraries_element",events:{"click .sort-libraries-link":"sort_clicked"},defaults:{page_count:null,show_page:null},initialize:function(h){this.options=_.defaults(this.options||{},this.defaults,h);var i=this;this.modal=null;this.rowViews={};this.collection=new c.Libraries();this.collection.fetch({success:function(){i.render()},error:function(k,j){if(typeof j.responseJSON!=="undefined"){e.error(j.responseJSON.err_msg)}else{e.error("An error ocurred.")}}})},render:function(i){this.options=_.extend(this.options,i);if((this.options.page_size!=null)&&(this.options.page_size==parseInt(this.options.page_size))){Galaxy.libraries.preferences.set({library_page_size:parseInt(this.options.page_size)})}$(".tooltip").hide();var j=this.templateLibraryList();var k=null;var l=null;if(this.options.show_page===null||this.options.show_page<1){this.options.show_page=1}if(typeof i!=="undefined"){l=typeof i.models!=="undefined"?i.models:null}if(this.collection!==null&&l===null){this.sortLibraries();if(Galaxy.libraries.preferences.get("with_deleted")){k=this.collection.models}else{k=this.collection.where({deleted:false})}}else{if(l!==null){k=l}else{k=[]}}this.options.total_libraries_count=k.length;var h=(Galaxy.libraries.preferences.get("library_page_size")*(this.options.show_page-1));this.options.page_count=Math.ceil(this.options.total_libraries_count/Galaxy.libraries.preferences.get("library_page_size"));if(this.options.total_libraries_count>0&&(h(this.options.total_libraries_count+Galaxy.libraries.preferences.get("library_page_size"))){k=[]}this.$el.html(j({length:1,order:Galaxy.libraries.preferences.get("sort_order")}));Galaxy.libraries.libraryToolbarView.renderPaginator(this.options);this.renderRows(k)}else{this.$el.html(j({length:0,order:Galaxy.libraries.preferences.get("sort_order")}));Galaxy.libraries.libraryToolbarView.renderPaginator(this.options)}$("#center [data-toggle]").tooltip();$("#center").css("overflow","auto")},renderRows:function(l){for(var k=0;k');tmpl_array.push("<% if(length === 0) { %>");tmpl_array.push('
There are no libraries visible to you here. If you expected some to show up please consult the library security wikipage or visit the Galaxy support site.
');tmpl_array.push("<% } else{ %>");tmpl_array.push('');tmpl_array.push(" ");tmpl_array.push(' ');tmpl_array.push(' ');tmpl_array.push(' ');tmpl_array.push(' ');tmpl_array.push(" ");tmpl_array.push(' ');tmpl_array.push(" ");tmpl_array.push("
name descriptionsynopsis
");tmpl_array.push("<% }%>");tmpl_array.push("
");return _.template(tmpl_array.join(""))},});return{LibraryListView:f}}); \ No newline at end of file +define(["galaxy.masthead","mvc/base-mvc","utils/utils","libs/toastr","mvc/library/library-model","mvc/library/library-libraryrow-view"],function(b,g,d,e,c,a){var f=Backbone.View.extend({el:"#libraries_element",events:{"click .sort-libraries-link":"sort_clicked"},defaults:{page_count:null,show_page:null},initialize:function(h){this.options=_.defaults(this.options||{},this.defaults,h);var i=this;this.modal=null;this.rowViews={};this.collection=new c.Libraries();this.collection.fetch({success:function(){i.render()},error:function(k,j){if(typeof j.responseJSON!=="undefined"){e.error(j.responseJSON.err_msg)}else{e.error("An error ocurred.")}}})},render:function(i){this.options=_.extend(this.options,i);var j=this.templateLibraryList();var k=null;var l=null;$(".tooltip").hide();if(typeof i!=="undefined"){l=typeof i.models!=="undefined"?i.models:null}if(this.collection!==null&&l===null){this.sortLibraries();if(Galaxy.libraries.preferences.get("with_deleted")){k=this.collection.models}else{k=this.collection.where({deleted:false})}}else{if(l!==null){k=l}else{k=[]}}if(this.options.show_page===null||this.options.show_page<1){this.options.show_page=1}this.options.total_libraries_count=k.length;var h=(Galaxy.libraries.preferences.get("library_page_size")*(this.options.show_page-1));this.options.page_count=Math.ceil(this.options.total_libraries_count/Galaxy.libraries.preferences.get("library_page_size"));if(this.options.total_libraries_count>0&&(h(this.options.total_libraries_count+Galaxy.libraries.preferences.get("library_page_size"))){k=[]}this.$el.html(j({length:1,order:Galaxy.libraries.preferences.get("sort_order")}));Galaxy.libraries.libraryToolbarView.renderPaginator(this.options);this.renderRows(k)}else{this.$el.html(j({length:0,order:Galaxy.libraries.preferences.get("sort_order")}));Galaxy.libraries.libraryToolbarView.renderPaginator(this.options)}$("#center [data-toggle]").tooltip();$("#center").css("overflow","auto")},renderRows:function(l){for(var k=0;k');tmpl_array.push("<% if(length === 0) { %>");tmpl_array.push('
There are no libraries visible to you here. If you expected some to show up please consult the library security wikipage or visit the Galaxy support site.
');tmpl_array.push("<% } else{ %>");tmpl_array.push('');tmpl_array.push(" ");tmpl_array.push(' ');tmpl_array.push(' ');tmpl_array.push(' ');tmpl_array.push(' ');tmpl_array.push(" ");tmpl_array.push(' ');tmpl_array.push(" ");tmpl_array.push("
name descriptionsynopsis
");tmpl_array.push("<% }%>");tmpl_array.push("
");return _.template(tmpl_array.join(""))},});return{LibraryListView:f}}); \ No newline at end of file From c4f922e3e57fe0dd87b7945f31a125696ceae1be Mon Sep 17 00:00:00 2001 From: Aysam Guerler Date: Fri, 5 Dec 2014 17:35:46 -0500 Subject: [PATCH 19/20] ToolForm: Fix label for collections, set missing optional parameters to null --- client/galaxy/scripts/mvc/tools/tools-select-content.js | 2 +- client/galaxy/scripts/mvc/tools/tools-tree.js | 2 +- static/scripts/mvc/tools/tools-select-content.js | 2 +- static/scripts/mvc/tools/tools-tree.js | 2 +- static/scripts/packed/mvc/tools/tools-select-content.js | 2 +- static/scripts/packed/mvc/tools/tools-tree.js | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/client/galaxy/scripts/mvc/tools/tools-select-content.js b/client/galaxy/scripts/mvc/tools/tools-select-content.js index 2c22776fd41..27f15903949 100644 --- a/client/galaxy/scripts/mvc/tools/tools-select-content.js +++ b/client/galaxy/scripts/mvc/tools/tools-select-content.js @@ -86,7 +86,7 @@ var View = Backbone.View.extend({ // add collection selector if (this.mode == 'single' || this.mode == 'collection') { - radio_buttons.push({icon: 'fa-folder-o', label : 'List of datasets', value : 'collection' }); + radio_buttons.push({icon: 'fa-folder-o', label : 'Dataset collection', value : 'collection' }); this.select_collection = new Ui.Select.View({ error_text : hdca_error, onchange : function() { diff --git a/client/galaxy/scripts/mvc/tools/tools-tree.js b/client/galaxy/scripts/mvc/tools/tools-tree.js index 13d9a0a8eec..2ae5238713d 100644 --- a/client/galaxy/scripts/mvc/tools/tools-tree.js +++ b/client/galaxy/scripts/mvc/tools/tools-tree.js @@ -126,7 +126,7 @@ return Backbone.Model.extend({ // handle default value if (!field.skip) { if (input.optional && field.validate && !field.validate()) { - value = 'None'; + value = null; } add (job_input_id, input.id, value); } diff --git a/static/scripts/mvc/tools/tools-select-content.js b/static/scripts/mvc/tools/tools-select-content.js index 2c22776fd41..27f15903949 100644 --- a/static/scripts/mvc/tools/tools-select-content.js +++ b/static/scripts/mvc/tools/tools-select-content.js @@ -86,7 +86,7 @@ var View = Backbone.View.extend({ // add collection selector if (this.mode == 'single' || this.mode == 'collection') { - radio_buttons.push({icon: 'fa-folder-o', label : 'List of datasets', value : 'collection' }); + radio_buttons.push({icon: 'fa-folder-o', label : 'Dataset collection', value : 'collection' }); this.select_collection = new Ui.Select.View({ error_text : hdca_error, onchange : function() { diff --git a/static/scripts/mvc/tools/tools-tree.js b/static/scripts/mvc/tools/tools-tree.js index 13d9a0a8eec..2ae5238713d 100644 --- a/static/scripts/mvc/tools/tools-tree.js +++ b/static/scripts/mvc/tools/tools-tree.js @@ -126,7 +126,7 @@ return Backbone.Model.extend({ // handle default value if (!field.skip) { if (input.optional && field.validate && !field.validate()) { - value = 'None'; + value = null; } add (job_input_id, input.id, value); } diff --git a/static/scripts/packed/mvc/tools/tools-select-content.js b/static/scripts/packed/mvc/tools/tools-select-content.js index 11c4d6ebccc..9d2b730576e 100644 --- a/static/scripts/packed/mvc/tools/tools-select-content.js +++ b/static/scripts/packed/mvc/tools/tools-select-content.js @@ -1 +1 @@ -define(["utils/utils","mvc/ui/ui-misc","mvc/ui/ui-tabs","mvc/tools/tools-template"],function(c,e,b,a){var d=Backbone.View.extend({initialize:function(f,o){this.app=f;this.options=o;var n=this;this.setElement("
");this.list={};var m=[];if(o.type=="data_collection"){this.mode="collection"}else{if(o.multiple){this.mode="multiple"}else{this.mode="single"}}this.current=this.mode;this.list={};var j=o.extensions.toString();if(j){j=j.replace(",",", ");var k=j.lastIndexOf(", ");if(k!=-1){j=j.substr(0,k)+" or "+j.substr(k+1)}}var h="No dataset available.";if(j){h="No "+j+" dataset available."}var l="No dataset list available.";if(j){l="No "+j+" dataset list available."}if(this.mode=="single"){m.push({icon:"fa-file-o",label:"Single dataset",value:"single"});this.select_single=new e.Select.View({error_text:h,onchange:function(){n.trigger("change")}});this.list.single={field:this.select_single,type:"hda"}}if(this.mode=="single"||this.mode=="multiple"){m.push({icon:"fa-files-o",label:"Multiple datasets",value:"multiple"});this.select_multiple=new e.Select.View({multiple:true,error_text:h,onchange:function(){n.trigger("change")}});this.list.multiple={field:this.select_multiple,type:"hda"}}if(this.mode=="single"||this.mode=="collection"){m.push({icon:"fa-folder-o",label:"List of datasets",value:"collection"});this.select_collection=new e.Select.View({error_text:l,onchange:function(){n.trigger("change")}});this.list.collection={field:this.select_collection,type:"hdca"}}this.button_type=new e.RadioButton.View({value:this.current,data:m,onchange:function(i){n.current=i;n.refresh();n.trigger("change")}});this.$batch=$(a.batchMode());if(_.size(this.list)>1){this.$el.append(c.wrap(this.button_type.$el))}for(var g in this.list){this.$el.append(this.list[g].field.$el)}this.$el.append(this.$batch);this.update(o.data);if(this.options.value!==undefined){this.value(this.options.value)}this.refresh();this.on("change",function(){if(o.onchange){o.onchange(n.value())}})},wait:function(){for(var f in this.list){this.list[f].field.wait()}},unwait:function(){for(var f in this.list){this.list[f].field.unwait()}},update:function(g){var l=[];for(var j in g.hda){var k=g.hda[j];l.push({label:k.hid+": "+k.name,value:k.id})}var f=[];for(var j in g.hdca){var h=g.hdca[j];f.push({label:h.hid+": "+h.name,value:h.id})}this.select_single&&this.select_single.update(l);this.select_multiple&&this.select_multiple.update(l);this.select_collection&&this.select_collection.update(f);this.app.content.add(g)},value:function(m){if(m&&m.values){try{var l=[];for(var h in m.values){l.push(m.values[h].id)}if(m&&m.values.length>0&&m.values[0].src=="hcda"){this.current="collection";this.select_collection.value(l[0])}else{if(this.mode=="multiple"){this.current="multiple";this.select_multiple.value(l)}else{this.current="single";this.select_single.value(l[0])}}this.refresh();var g=this._select();if(!g.validate()){g.value(g.first())}}catch(k){console.debug("tools-select-content::value() - Skipped.")}}var j=this._select().value();if(!(j instanceof Array)){j=[j]}var f={batch:this.mode=="single"&&this.current!="single",values:[]};for(var h in j){f.values.push({id:j[h],src:this.list[this.current].type})}return f},validate:function(){return this._select().validate()},refresh:function(){for(var g in this.list){var f=this.list[g].field.$el;if(this.current==g){f.show()}else{f.hide()}}if(this.mode=="single"&&this.current!="single"){this.$batch.show()}else{this.$batch.hide()}},_select:function(){return this.list[this.current].field}});return{View:d}}); \ No newline at end of file +define(["utils/utils","mvc/ui/ui-misc","mvc/ui/ui-tabs","mvc/tools/tools-template"],function(c,e,b,a){var d=Backbone.View.extend({initialize:function(f,o){this.app=f;this.options=o;var n=this;this.setElement("
");this.list={};var m=[];if(o.type=="data_collection"){this.mode="collection"}else{if(o.multiple){this.mode="multiple"}else{this.mode="single"}}this.current=this.mode;this.list={};var j=o.extensions.toString();if(j){j=j.replace(",",", ");var k=j.lastIndexOf(", ");if(k!=-1){j=j.substr(0,k)+" or "+j.substr(k+1)}}var h="No dataset available.";if(j){h="No "+j+" dataset available."}var l="No dataset list available.";if(j){l="No "+j+" dataset list available."}if(this.mode=="single"){m.push({icon:"fa-file-o",label:"Single dataset",value:"single"});this.select_single=new e.Select.View({error_text:h,onchange:function(){n.trigger("change")}});this.list.single={field:this.select_single,type:"hda"}}if(this.mode=="single"||this.mode=="multiple"){m.push({icon:"fa-files-o",label:"Multiple datasets",value:"multiple"});this.select_multiple=new e.Select.View({multiple:true,error_text:h,onchange:function(){n.trigger("change")}});this.list.multiple={field:this.select_multiple,type:"hda"}}if(this.mode=="single"||this.mode=="collection"){m.push({icon:"fa-folder-o",label:"Dataset collection",value:"collection"});this.select_collection=new e.Select.View({error_text:l,onchange:function(){n.trigger("change")}});this.list.collection={field:this.select_collection,type:"hdca"}}this.button_type=new e.RadioButton.View({value:this.current,data:m,onchange:function(i){n.current=i;n.refresh();n.trigger("change")}});this.$batch=$(a.batchMode());if(_.size(this.list)>1){this.$el.append(c.wrap(this.button_type.$el))}for(var g in this.list){this.$el.append(this.list[g].field.$el)}this.$el.append(this.$batch);this.update(o.data);if(this.options.value!==undefined){this.value(this.options.value)}this.refresh();this.on("change",function(){if(o.onchange){o.onchange(n.value())}})},wait:function(){for(var f in this.list){this.list[f].field.wait()}},unwait:function(){for(var f in this.list){this.list[f].field.unwait()}},update:function(g){var l=[];for(var j in g.hda){var k=g.hda[j];l.push({label:k.hid+": "+k.name,value:k.id})}var f=[];for(var j in g.hdca){var h=g.hdca[j];f.push({label:h.hid+": "+h.name,value:h.id})}this.select_single&&this.select_single.update(l);this.select_multiple&&this.select_multiple.update(l);this.select_collection&&this.select_collection.update(f);this.app.content.add(g)},value:function(m){if(m&&m.values){try{var l=[];for(var h in m.values){l.push(m.values[h].id)}if(m&&m.values.length>0&&m.values[0].src=="hcda"){this.current="collection";this.select_collection.value(l[0])}else{if(this.mode=="multiple"){this.current="multiple";this.select_multiple.value(l)}else{this.current="single";this.select_single.value(l[0])}}this.refresh();var g=this._select();if(!g.validate()){g.value(g.first())}}catch(k){console.debug("tools-select-content::value() - Skipped.")}}var j=this._select().value();if(!(j instanceof Array)){j=[j]}var f={batch:this.mode=="single"&&this.current!="single",values:[]};for(var h in j){f.values.push({id:j[h],src:this.list[this.current].type})}return f},validate:function(){return this._select().validate()},refresh:function(){for(var g in this.list){var f=this.list[g].field.$el;if(this.current==g){f.show()}else{f.hide()}}if(this.mode=="single"&&this.current!="single"){this.$batch.show()}else{this.$batch.hide()}},_select:function(){return this.list[this.current].field}});return{View:d}}); \ No newline at end of file diff --git a/static/scripts/packed/mvc/tools/tools-tree.js b/static/scripts/packed/mvc/tools/tools-tree.js index 314ed98ae5a..1ef4764692e 100644 --- a/static/scripts/packed/mvc/tools/tools-tree.js +++ b/static/scripts/packed/mvc/tools/tools-tree.js @@ -1 +1 @@ -define([],function(){return Backbone.Model.extend({initialize:function(a){this.app=a},refresh:function(){this.dict={};this.xml=$("
");if(!this.app.section){return{}}this._iterate(this.app.section.$el,this.dict,this.xml)},finalize:function(d){d=d||{};var a=this;this.job_def={};this.job_ids={};function c(g,f,e){a.job_def[g]=e;a.job_ids[g]=f}function b(l,o){for(var j in o){var g=o[j];if(g.input){var q=g.input;var k=l;if(l!=""){k+="|"}k+=q.name;switch(q.type){case"repeat":var f="section-";var t=[];var n=null;for(var s in g){var m=s.indexOf(f);if(m!=-1){m+=f.length;t.push(parseInt(s.substr(m)));if(!n){n=s.substr(0,m)}}}t.sort(function(u,i){return u-i});var j=0;for(var h in t){b(k+"_"+j++,g[n+t[h]])}break;case"conditional":var r=a.app.field_list[q.id].value();if(d[q.test_param.type]){r=d[q.test_param.type](r)}c(k+"|"+q.test_param.name,q.id,r);var e=a.matchCase(q,r);if(e!=-1){b(k,o[q.id+"-section-"+e])}break;default:var p=a.app.field_list[q.id];var r=p.value();if(d[q.type]){r=d[q.type](r)}if(!p.skip){if(q.optional&&p.validate&&!p.validate()){r="None"}c(k,q.id,r)}}}}}b("",this.dict);return this.job_def},match:function(a){return this.job_ids&&this.job_ids[a]},matchCase:function(a,c){if(a.test_param.type=="boolean"){if(c=="true"){c=a.test_param.truevalue||"true"}else{c=a.test_param.falsevalue||"false"}}for(var b in a.cases){if(a.cases[b].value==c){return b}}return -1},matchModel:function(c,e){var a={};var b=this;function d(f,o){for(var l in o){var h=o[l];var m=h.name;if(f!=""){m=f+"|"+m}switch(h.type){case"repeat":for(var k in h.cache){d(m+"_"+k,h.cache[k])}break;case"conditional":var p=h.test_param&&h.test_param.value;var g=b.matchCase(h,p);if(g!=-1){d(m,h.cases[g].inputs)}break;default:var n=b.app.tree.job_ids[m];if(n){e(n,h)}}}}d("",c.inputs);return a},matchResponse:function(c){var a={};var b=this;function d(k,h){if(typeof h==="string"){var f=b.app.tree.job_ids[k];if(f){a[f]=h}}else{for(var g in h){var e=g;if(k!==""){var j="|";if(h instanceof Array){j="_"}e=k+j+e}d(e,h[g])}}}d("",c);return a},references:function(c,e){var g=[];var b=this;function d(h,j){var i=$(j).children();var l=[];var k=false;i.each(function(){var o=this;var n=$(o).attr("id");if(n!==c){var m=b.app.input_list[n];if(m){if(m.name==h){k=true;return false}if(m.data_ref==h&&m.type==e){l.push(n)}}}});if(!k){g=g.concat(l);i.each(function(){d(h,this)})}}var f=this.xml.find("#"+c);if(f.length>0){var a=this.app.input_list[c];if(a){d(a.name,f.parent())}}return g},_iterate:function(d,e,b){var a=this;var c=$(d).children();c.each(function(){var i=this;var h=$(i).attr("id");if($(i).hasClass("section-row")){e[h]={};var f=a.app.input_list[h];if(f){e[h]={input:f}}var g=$('
');b.append(g);a._iterate(i,e[h],g)}else{a._iterate(i,e,b)}})}})}); \ No newline at end of file +define([],function(){return Backbone.Model.extend({initialize:function(a){this.app=a},refresh:function(){this.dict={};this.xml=$("
");if(!this.app.section){return{}}this._iterate(this.app.section.$el,this.dict,this.xml)},finalize:function(d){d=d||{};var a=this;this.job_def={};this.job_ids={};function c(g,f,e){a.job_def[g]=e;a.job_ids[g]=f}function b(l,o){for(var j in o){var g=o[j];if(g.input){var q=g.input;var k=l;if(l!=""){k+="|"}k+=q.name;switch(q.type){case"repeat":var f="section-";var t=[];var n=null;for(var s in g){var m=s.indexOf(f);if(m!=-1){m+=f.length;t.push(parseInt(s.substr(m)));if(!n){n=s.substr(0,m)}}}t.sort(function(u,i){return u-i});var j=0;for(var h in t){b(k+"_"+j++,g[n+t[h]])}break;case"conditional":var r=a.app.field_list[q.id].value();if(d[q.test_param.type]){r=d[q.test_param.type](r)}c(k+"|"+q.test_param.name,q.id,r);var e=a.matchCase(q,r);if(e!=-1){b(k,o[q.id+"-section-"+e])}break;default:var p=a.app.field_list[q.id];var r=p.value();if(d[q.type]){r=d[q.type](r)}if(!p.skip){if(q.optional&&p.validate&&!p.validate()){r=null}c(k,q.id,r)}}}}}b("",this.dict);return this.job_def},match:function(a){return this.job_ids&&this.job_ids[a]},matchCase:function(a,c){if(a.test_param.type=="boolean"){if(c=="true"){c=a.test_param.truevalue||"true"}else{c=a.test_param.falsevalue||"false"}}for(var b in a.cases){if(a.cases[b].value==c){return b}}return -1},matchModel:function(c,e){var a={};var b=this;function d(f,o){for(var l in o){var h=o[l];var m=h.name;if(f!=""){m=f+"|"+m}switch(h.type){case"repeat":for(var k in h.cache){d(m+"_"+k,h.cache[k])}break;case"conditional":var p=h.test_param&&h.test_param.value;var g=b.matchCase(h,p);if(g!=-1){d(m,h.cases[g].inputs)}break;default:var n=b.app.tree.job_ids[m];if(n){e(n,h)}}}}d("",c.inputs);return a},matchResponse:function(c){var a={};var b=this;function d(k,h){if(typeof h==="string"){var f=b.app.tree.job_ids[k];if(f){a[f]=h}}else{for(var g in h){var e=g;if(k!==""){var j="|";if(h instanceof Array){j="_"}e=k+j+e}d(e,h[g])}}}d("",c);return a},references:function(c,e){var g=[];var b=this;function d(h,j){var i=$(j).children();var l=[];var k=false;i.each(function(){var o=this;var n=$(o).attr("id");if(n!==c){var m=b.app.input_list[n];if(m){if(m.name==h){k=true;return false}if(m.data_ref==h&&m.type==e){l.push(n)}}}});if(!k){g=g.concat(l);i.each(function(){d(h,this)})}}var f=this.xml.find("#"+c);if(f.length>0){var a=this.app.input_list[c];if(a){d(a.name,f.parent())}}return g},_iterate:function(d,e,b){var a=this;var c=$(d).children();c.each(function(){var i=this;var h=$(i).attr("id");if($(i).hasClass("section-row")){e[h]={};var f=a.app.input_list[h];if(f){e[h]={input:f}}var g=$('
');b.append(g);a._iterate(i,e[h],g)}else{a._iterate(i,e,b)}})}})}); \ No newline at end of file From 5b6c092aa0a85455b4daacd318541e92bd08b876 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Fri, 5 Dec 2014 20:35:22 -0500 Subject: [PATCH 20/20] Twill tool tests allowed selects specified by display text instead of value. This didn't work for API tests - restore this functionality and add test case in test/functional/tools/multi_select.xml to verify this behavior is correct. --- lib/galaxy/tools/test.py | 27 +++++++++++++++++++++++++- test/functional/tools/multi_select.xml | 8 ++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/lib/galaxy/tools/test.py b/lib/galaxy/tools/test.py index 243f1d5523f..333c90f3b9a 100644 --- a/lib/galaxy/tools/test.py +++ b/lib/galaxy/tools/test.py @@ -196,12 +196,37 @@ class ToolTestBuilder( object ): if not isinstance(param_value, list): param_value = [ param_value ] processed_value = [ self.__add_uploaded_dataset( context.for_state(), v, param_extra, value ) for v in param_value ] - if isinstance( value, basic.DataCollectionToolParameter ): + elif isinstance( value, basic.DataCollectionToolParameter ): assert 'collection' in param_extra collection_def = param_extra[ 'collection' ] for ( name, value, extra ) in collection_def.collect_inputs(): require_file( name, value, extra, self.required_files ) processed_value = collection_def + elif isinstance( value, basic.SelectToolParameter ): + # Tests may specify values as either raw value or the value + # as they appear in the list - the API doesn't and shouldn't + # accept the text value - so we need to convert the text + # into the form value. + def process_param_value( param_value ): + found_value = False + value_for_text = None + if value.static_options: + for (text, opt_value, selected) in value.static_options: + if param_value == opt_value: + found_value = True + if value_for_text is None and param_value == text: + value_for_text = opt_value + if not found_value and value_for_text is not None: + processed_value = value_for_text + else: + processed_value = param_value + return processed_value + # Do replacement described above for lists or singleton + # values. + if isinstance( param_value, list ): + processed_value = map( process_param_value, param_value ) + else: + processed_value = process_param_value( param_value ) else: processed_value = param_value expanded_inputs[ context.for_state() ] = processed_value diff --git a/test/functional/tools/multi_select.xml b/test/functional/tools/multi_select.xml index d1356157cae..db447057a2d 100644 --- a/test/functional/tools/multi_select.xml +++ b/test/functional/tools/multi_select.xml @@ -25,5 +25,13 @@ + + + + + + + +