galaxy-commits
Threads by month
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
December 2014
- 2 participants
- 245 discussions
2 new commits in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/45653ba49df7/
Changeset: 45653ba49df7
User: jmchilton
Date: 2014-12-06 04:35:44+00:00
Summary: Include diffs for all errors when testing - don't stop at first.
Gives more details to aid testing (especially for tools with lots of outputs) and lets developer collect all correct test data files at once (when GALAXY_TEST_SAVE is set or using `planemo test` with --job_output_files argument) instead of needing to rerun the tool repeatedly.
Affected #: 1 file
diff -r e2bfb1e6e3c5845e4e1518e620dcf7fbcdc21a0c -r 45653ba49df7fb353dfd3dd4f9d30111818ff60b test/functional/test_toolbox.py
--- a/test/functional/test_toolbox.py
+++ b/test/functional/test_toolbox.py
@@ -61,6 +61,8 @@
messaage_template = "Incorrect number of outputs - expected %d, found %s."
message = messaage_template % ( expected, actual )
raise Exception( message )
+ found_exceptions = []
+
for output_index, output_tuple in enumerate(testdef.outputs):
# Get the correct hid
name, outfile, attributes = output_tuple
@@ -78,13 +80,18 @@
self.assertTrue( output_data is not None )
try:
galaxy_interactor.verify_output( history, jobs, output_data, output_testdef=output_testdef, shed_tool_id=shed_tool_id, maxseconds=maxseconds )
- except Exception:
- for job in jobs:
- job_stdio = galaxy_interactor.get_job_stdio( job[ 'id' ] )
- for stream in ['stdout', 'stderr']:
- if stream in job_stdio:
- print >>sys.stderr, self._format_stream( job_stdio[ stream ], stream=stream, format=True )
- raise
+ except Exception as e:
+ if not found_exceptions:
+ # Only print this stuff out once.
+ for job in jobs:
+ job_stdio = galaxy_interactor.get_job_stdio( job[ 'id' ] )
+ for stream in ['stdout', 'stderr']:
+ if stream in job_stdio:
+ print >>sys.stderr, self._format_stream( job_stdio[ stream ], stream=stream, format=True )
+ found_exceptions.append(e)
+ if found_exceptions:
+ big_message = "\n".join(map(str, found_exceptions))
+ raise AssertionError(big_message)
@nottest
https://bitbucket.org/galaxy/galaxy-central/commits/34ed52176b05/
Changeset: 34ed52176b05
User: jmchilton
Date: 2014-12-06 04:35:44+00:00
Summary: Twill interactor for tests is broken - so I am deleting.
It wasn't long for this world with a JavaScript tool form anyway - would be nice to implement a casperjs driven interactor though so the UI could be exercised for tests.
Affected #: 1 file
diff -r 45653ba49df7fb353dfd3dd4f9d30111818ff60b -r 34ed52176b054166d687c3a402391f0d40f339db test/base/interactor.py
--- a/test/base/interactor.py
+++ b/test/base/interactor.py
@@ -1,15 +1,11 @@
import os
import re
from StringIO import StringIO
-from galaxy.tools.parameters import grouping
from galaxy.tools import test
from galaxy import eggs
eggs.require( "requests" )
from galaxy import util
from galaxy.util.odict import odict
-import galaxy.model
-from galaxy.model.orm import and_, desc
-from functional import database_contexts
from requests import get
from requests import post
from json import dumps
@@ -407,120 +403,6 @@
return get( url, params=data )
-class GalaxyInteractorTwill( object ):
-
- def __init__( self, twill_test_case ):
- self.twill_test_case = twill_test_case
-
- def verify_output( self, history, output_data, output_testdef, shed_tool_id, maxseconds ):
- outfile = output_testdef.outfile
- attributes = output_testdef.attributes
-
- hid = output_data.get( 'hid' )
- self.twill_test_case.verify_dataset_correctness( outfile, hid=hid, attributes=attributes, shed_tool_id=shed_tool_id, maxseconds=maxseconds )
-
- def get_job_stream( self, history_id, output_data, stream ):
- data_id = self.twill_test_case.security.encode_id( output_data.get( 'id' ) )
- return self.twill_test_case._get_job_stream_output( data_id, stream=stream, format=False )
-
- def stage_data_async( self, test_data, history, shed_tool_id, async=True ):
- name = test_data.get( 'name', None )
- if name:
- async = False
- self.twill_test_case.upload_file( test_data['fname'],
- ftype=test_data['ftype'],
- dbkey=test_data['dbkey'],
- metadata=test_data['metadata'],
- composite_data=test_data['composite_data'],
- shed_tool_id=shed_tool_id,
- wait=(not async) )
- if name:
- hda_id = self.twill_test_case.get_history_as_data_list()[-1].get( 'id' )
- try:
- self.twill_test_case.edit_hda_attribute_info( hda_id=str(hda_id), new_name=name )
- except:
- print "### call to edit_hda failed for hda_id %s, new_name=%s" % (hda_id, name)
- return lambda: self.twill_test_case.wait()
-
- def run_tool( self, testdef, test_history ):
- # We need to handle the case where we've uploaded a valid compressed file since the upload
- # tool will have uncompressed it on the fly.
-
- # Lose tons of information to accomodate legacy repeat handling.
- all_inputs = {}
- for key, value in testdef.inputs.iteritems():
- all_inputs[ key.split("|")[-1] ] = value
-
- # See if we have a grouping.Repeat element
- repeat_name = None
- for input_name, input_value in testdef.tool.inputs_by_page[0].items():
- if isinstance( input_value, grouping.Repeat ) and all_inputs.get( input_name, 1 ) not in [ 0, "0" ]: # default behavior is to test 1 repeat, for backwards compatibility
- if not input_value.min: # If input_value.min == 1, the element is already on the page don't add new element.
- repeat_name = input_name
- break
-
- #check if we need to verify number of outputs created dynamically by tool
- if testdef.tool.force_history_refresh:
- job_finish_by_output_count = len( self.twill_test_case.get_history_as_data_list() )
- else:
- job_finish_by_output_count = False
-
- inputs_tree = testdef.inputs
- # # # HACK: Flatten single-value lists. Required when using expand_grouping
- # #for key, value in inputs_tree.iteritems():
- # if isinstance(value, list) and len(value) == 1:
- # inputs_tree[key] = value[0]
-
- # Strip out just a given page of inputs from inputs "tree".
- def filter_page_inputs( n ):
- page_input_keys = testdef.tool.inputs_by_page[ n ].keys()
- return dict( [ (k, v) for k, v in inputs_tree.iteritems() if k.split("|")[0] or k.split("|")[0].resplit("_", 1)[0] in page_input_keys ] )
-
- # Do the first page
- page_inputs = filter_page_inputs( 0 )
-
- # Run the tool
- self.twill_test_case.run_tool( testdef.tool.id, repeat_name=repeat_name, **page_inputs )
- print "page_inputs (0)", page_inputs
- # Do other pages if they exist
- for i in range( 1, testdef.tool.npages ):
- page_inputs = filter_page_inputs( i )
- self.twill_test_case.submit_form( **page_inputs )
- print "page_inputs (%i)" % i, page_inputs
-
- # Check the results ( handles single or multiple tool outputs ). Make sure to pass the correct hid.
- # The output datasets from the tool should be in the same order as the testdef.outputs.
- data_list = None
- while data_list is None:
- data_list = self.twill_test_case.get_history_as_data_list()
- if job_finish_by_output_count and len( testdef.outputs ) > ( len( data_list ) - job_finish_by_output_count ):
- data_list = None
- return data_list
-
- def new_history( self ):
- # Start with a new history
- self.twill_test_case.logout()
- self.twill_test_case.login( email='test(a)bx.psu.edu' )
- admin_user = database_contexts.galaxy_context.query( galaxy.model.User ).filter( galaxy.model.User.table.c.email == 'test(a)bx.psu.edu' ).one()
- self.twill_test_case.new_history()
- latest_history = database_contexts.galaxy_context.query( galaxy.model.History ) \
- .filter( and_( galaxy.model.History.table.c.deleted == False,
- galaxy.model.History.table.c.user_id == admin_user.id ) ) \
- .order_by( desc( galaxy.model.History.table.c.create_time ) ) \
- .first()
- assert latest_history is not None, "Problem retrieving latest_history from database"
- if len( self.twill_test_case.get_hids_in_history( self.twill_test_case.get_latest_history()[ 'id' ] ) ) > 0:
- raise AssertionError("ToolTestCase.do_it failed to create a new empty history")
- return latest_history
-
- def delete_history( self, latest_history ):
- self.twill_test_case.delete_history( id=self.twill_test_case.security.encode_id( latest_history.id ) )
-
- def output_hid( self, output_data ):
- return output_data.get( 'hid' )
-
-
GALAXY_INTERACTORS = {
'api': GalaxyInteractorApi,
- 'twill': GalaxyInteractorTwill,
}
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
2 new commits in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/0a0dc4011294/
Changeset: 0a0dc4011294
Branch: next-stable
User: jmchilton
Date: 2014-12-06 04:30:52+00:00
Summary: Mark test_toolbox:build_tests as "not a test".
This will prevent run_tests.sh from picking up the extra test when running full test tool box - the way planemo does (i.e. this fixes the problem where planemo always runs one extra passing test).
Affected #: 1 file
diff -r c906eacc8d543384ad84b87f34e6b515fc695bcd -r 0a0dc401129472073a93a095ced211179ff1c5a4 test/functional/test_toolbox.py
--- a/test/functional/test_toolbox.py
+++ b/test/functional/test_toolbox.py
@@ -5,6 +5,11 @@
from galaxy.tools import DataManagerTool
from galaxy.util import bunch
import logging
+try:
+ from nose.tools import nottest
+except ImportError:
+ nottest = lambda x: x
+
log = logging.getLogger( __name__ )
toolbox = None
@@ -82,6 +87,7 @@
raise
+@nottest
def build_tests( app=None, testing_shed_tools=False, master_api_key=None, user_api_key=None ):
"""
If the module level variable `toolbox` is set, generate `ToolTestCase`
https://bitbucket.org/galaxy/galaxy-central/commits/e2bfb1e6e3c5/
Changeset: e2bfb1e6e3c5
User: jmchilton
Date: 2014-12-06 04:31:48+00:00
Summary: Merge next-stable.
Affected #: 1 file
diff -r 79cea2ce170e61db6afd6d249379b96cf353f15b -r e2bfb1e6e3c5845e4e1518e620dcf7fbcdc21a0c test/functional/test_toolbox.py
--- a/test/functional/test_toolbox.py
+++ b/test/functional/test_toolbox.py
@@ -5,6 +5,11 @@
from galaxy.tools import DataManagerTool
from galaxy.util import bunch
import logging
+try:
+ from nose.tools import nottest
+except ImportError:
+ nottest = lambda x: x
+
log = logging.getLogger( __name__ )
toolbox = None
@@ -82,6 +87,7 @@
raise
+@nottest
def build_tests( app=None, testing_shed_tools=False, master_api_key=None, user_api_key=None ):
"""
If the module level variable `toolbox` is set, generate `ToolTestCase`
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
2 new commits in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/c906eacc8d54/
Changeset: c906eacc8d54
Branch: next-stable
User: jmchilton
Date: 2014-12-06 02:16:03+00:00
Summary: ... and not all select params have static_options attribute.
Bug fixes for bug fixes - why do I even try?
Affected #: 1 file
diff -r 7114d15a6d2234cb895d058e0e44c86f373c49b2 -r c906eacc8d543384ad84b87f34e6b515fc695bcd lib/galaxy/tools/test.py
--- a/lib/galaxy/tools/test.py
+++ b/lib/galaxy/tools/test.py
@@ -202,7 +202,7 @@
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 ):
+ elif isinstance( value, basic.SelectToolParameter ) and hasattr( value, 'static_options' ):
# 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
https://bitbucket.org/galaxy/galaxy-central/commits/79cea2ce170e/
Changeset: 79cea2ce170e
User: jmchilton
Date: 2014-12-06 02:16:13+00:00
Summary: Merge next-stable.
Affected #: 1 file
diff -r 719191cd0f3ea8ad2ff02ec303dabf0e22c31e60 -r 79cea2ce170e61db6afd6d249379b96cf353f15b lib/galaxy/tools/test.py
--- a/lib/galaxy/tools/test.py
+++ b/lib/galaxy/tools/test.py
@@ -202,7 +202,7 @@
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 ):
+ elif isinstance( value, basic.SelectToolParameter ) and hasattr( value, 'static_options' ):
# 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
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
2 new commits in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/7114d15a6d22/
Changeset: 7114d15a6d22
Branch: next-stable
User: jmchilton
Date: 2014-12-06 01:35:22+00:00
Summary: 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.
Affected #: 2 files
diff -r 149784a152afc3d7164eaf7dfa7d5dc97be92671 -r 7114d15a6d2234cb895d058e0e44c86f373c49b2 lib/galaxy/tools/test.py
--- a/lib/galaxy/tools/test.py
+++ b/lib/galaxy/tools/test.py
@@ -196,12 +196,37 @@
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 -r 149784a152afc3d7164eaf7dfa7d5dc97be92671 -r 7114d15a6d2234cb895d058e0e44c86f373c49b2 test/functional/tools/multi_select.xml
--- a/test/functional/tools/multi_select.xml
+++ b/test/functional/tools/multi_select.xml
@@ -25,5 +25,13 @@
</assert_contents></output></test>
+ <test>
+ <param name="select_ex" value="Ex1" />
+ <output name="output">
+ <assert_contents>
+ <has_line line="--ex1" />
+ </assert_contents>
+ </output>
+ </test></tests></tool>
https://bitbucket.org/galaxy/galaxy-central/commits/719191cd0f3e/
Changeset: 719191cd0f3e
User: jmchilton
Date: 2014-12-06 01:36:48+00:00
Summary: Merge next-stable.
Affected #: 31 files
diff -r 46a3d43d779fa7735029449935dad77474adf9b1 -r 719191cd0f3ea8ad2ff02ec303dabf0e22c31e60 client/galaxy/scripts/galaxy.library.js
--- a/client/galaxy/scripts/galaxy.library.js
+++ b/client/galaxy/scripts/galaxy.library.js
@@ -36,7 +36,7 @@
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 @@
"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 @@
},
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 @@
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 @@
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 @@
}
});
- 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 -r 46a3d43d779fa7735029449935dad77474adf9b1 -r 719191cd0f3ea8ad2ff02ec303dabf0e22c31e60 client/galaxy/scripts/mvc/library/library-folderlist-view.js
--- a/client/galaxy/scripts/mvc/library/library-folderlist-view.js
+++ b/client/galaxy/scripts/mvc/library/library-folderlist-view.js
@@ -15,322 +15,359 @@
) {
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.' );
}
+ } 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( options ){
+ this.options = _.extend( this.options, options );
+
+ 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 )
+ },
+
+ /**
+ * 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();
+ },
+
+ /**
+ * 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();
+ },
+
+ /**
+ * 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')));
}
- },
- 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();}});
- }
+ 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();
}
- });
- },
+ },
- render: function (options) {
- this.options = _.defaults(this.options, options);
- var template = this.templateFolder();
- $(".tooltip").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();
+ },
- // 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];
+ /**
+ * 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('<ol class="breadcrumb">');
+ tmpl_array.push(' <li><a title="Return to the list of libraries" href="#">Libraries</a></li>');
+ tmpl_array.push(' <% _.each(path, function(path_item) { %>');
+ tmpl_array.push(' <% if (path_item[0] != id) { %>');
+ tmpl_array.push(' <li><a title="Return to this folder" href="#/folders/<%- path_item[0] %>"><%- path_item[1] %></a></li> ');
+ tmpl_array.push( '<% } else { %>');
+ tmpl_array.push(' <li class="active"><span title="You are in this folder"><%- path_item[1] %></span></li>');
+ tmpl_array.push(' <% } %>');
+ tmpl_array.push(' <% }); %>');
+ tmpl_array.push('</ol>');
+
+ // FOLDER CONTENT
+ tmpl_array.push('<table data-library-id="<%- parent_library_id %>" id="folder_table" class="grid table table-condensed">');
+ tmpl_array.push(' <thead>');
+ tmpl_array.push(' <th class="button_heading"></th>');
+ tmpl_array.push(' <th style="text-align: center; width: 20px; " title="Check to select all datasets"><input id="select-all-checkboxes" style="margin: 0;" type="checkbox"></th>');
+ tmpl_array.push(' <th><a class="sort-folder-link" title="Click to reverse order" href="#">name</a><span title="Sorted alphabetically" class="fa fa-sort-alpha-<%- order %>"></span></th>');
+ tmpl_array.push(' <th style="width:5%;">data type</th>');
+ tmpl_array.push(' <th style="width:10%;">size</th>');
+ tmpl_array.push(' <th style="width:160px;">time updated (UTC)</th>');
+ tmpl_array.push(' <th style="width:10%;"></th> ');
+ tmpl_array.push(' </thead>');
+ tmpl_array.push(' <tbody id="folder_list_body">');
+ tmpl_array.push(' <tr id="first_folder_item">');
+ tmpl_array.push(' <td><a href="#<% if (upper_folder_id !== 0){ print("folders/" + upper_folder_id)} %>" title="Go to parent folder" class="btn_open_folder btn btn-default btn-xs">..<a></td>');
+ tmpl_array.push(' <td></td>');
+ tmpl_array.push(' <td></td>');
+ tmpl_array.push(' <td></td>');
+ tmpl_array.push(' <td></td>');
+ tmpl_array.push(' <td></td>');
+ tmpl_array.push(' <td></td>');
+ tmpl_array.push(' </tr>');
+
+ tmpl_array.push(' </tbody>');
+ tmpl_array.push('</table>');
+ tmpl_array.push('<div class="empty-folder-message" style="display:none;">This folder is either empty or you do not have proper access permissions to see the contents. If you expected something to show up please consult the <a href="https://wiki.galaxyproject.org/Admin/DataLibraries/LibrarySecurity" target="_blank">library security wikipage</a> or visit the <a href="https://biostar.usegalaxy.org/" target="_blank">Galaxy support site</a>.</div>');
+
+ return _.template(tmpl_array.join(''));
}
-
- 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}));
-
- // 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();
- });
- },
-
- /**
- * 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();
- }
- }
- },
-
- /**
- * 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('<ol class="breadcrumb">');
- tmpl_array.push(' <li><a title="Return to the list of libraries" href="#">Libraries</a></li>');
- tmpl_array.push(' <% _.each(path, function(path_item) { %>');
- tmpl_array.push(' <% if (path_item[0] != id) { %>');
- tmpl_array.push(' <li><a title="Return to this folder" href="#/folders/<%- path_item[0] %>"><%- path_item[1] %></a></li> ');
- tmpl_array.push( '<% } else { %>');
- tmpl_array.push(' <li class="active"><span title="You are in this folder"><%- path_item[1] %></span></li>');
- tmpl_array.push(' <% } %>');
- tmpl_array.push(' <% }); %>');
- tmpl_array.push('</ol>');
-
- // FOLDER CONTENT
- tmpl_array.push('<table data-library-id="<%- parent_library_id %>" id="folder_table" class="grid table table-condensed">');
- tmpl_array.push(' <thead>');
- tmpl_array.push(' <th class="button_heading"></th>');
- tmpl_array.push(' <th style="text-align: center; width: 20px; " title="Check to select all datasets"><input id="select-all-checkboxes" style="margin: 0;" type="checkbox"></th>');
- tmpl_array.push(' <th><a class="sort-folder-link" title="Click to reverse order" href="#">name</a><span title="Sorted alphabetically" class="fa fa-sort-alpha-<%- order %>"></span></th>');
- tmpl_array.push(' <th style="width:5%;">data type</th>');
- tmpl_array.push(' <th style="width:10%;">size</th>');
- tmpl_array.push(' <th style="width:160px;">time updated (UTC)</th>');
- tmpl_array.push(' <th style="width:10%;"></th> ');
- tmpl_array.push(' </thead>');
- tmpl_array.push(' <tbody id="folder_list_body">');
- tmpl_array.push(' <tr id="first_folder_item">');
- tmpl_array.push(' <td><a href="#<% if (upper_folder_id !== 0){ print("folders/" + upper_folder_id)} %>" title="Go to parent folder" class="btn_open_folder btn btn-default btn-xs">..<a></td>');
- tmpl_array.push(' <td></td>');
- tmpl_array.push(' <td></td>');
- tmpl_array.push(' <td></td>');
- tmpl_array.push(' <td></td>');
- tmpl_array.push(' <td></td>');
- tmpl_array.push(' <td></td>');
- tmpl_array.push(' </tr>');
-
- tmpl_array.push(' </tbody>');
- tmpl_array.push('</table>');
- tmpl_array.push('<div class="empty-folder-message" style="display:none;">This folder is either empty or you do not have proper access permissions to see the contents. If you expected something to show up please consult the <a href="https://wiki.galaxyproject.org/Admin/DataLibraries/LibrarySecurity" target="_blank">library security wikipage</a> or visit the <a href="https://biostar.usegalaxy.org/" target="_blank">Galaxy support site</a>.</div>');
-
- return _.template(tmpl_array.join(''));
- }
-
+
});
return {
diff -r 46a3d43d779fa7735029449935dad77474adf9b1 -r 719191cd0f3ea8ad2ff02ec303dabf0e22c31e60 client/galaxy/scripts/mvc/library/library-foldertoolbar-view.js
--- a/client/galaxy/scripts/mvc/library/library-foldertoolbar-view.js
+++ b/client/galaxy/scripts/mvc/library/library-foldertoolbar-view.js
@@ -20,7 +20,9 @@
'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 @@
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 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 @@
}
},
+ 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 @@
tmpl_array.push(' <button style="display:none;" data-toggle="tooltip" data-placement="top" title="Add Datasets to Current Folder" id="toolbtn_add_files" class="btn btn-default toolbtn_add_files primary-button add-library-items" type="button"><span class="fa fa-plus"></span><span class="fa fa-file"></span></span></button>');
tmpl_array.push('<% } %>');
-
tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Import selected datasets into history" id="toolbtn_bulk_import" class="primary-button dataset-manipulation" style="margin-left: 0.5em; display:none;" type="button"><span class="fa fa-book"></span> to History</button>');
tmpl_array.push(' <div id="toolbtn_dl" class="btn-group dataset-manipulation" style="margin-left: 0.5em; display:none; ">');
tmpl_array.push(' <button title="Download selected datasets as archive" id="drop_toggle" type="button" class="primary-button dropdown-toggle" data-toggle="dropdown">');
@@ -1032,6 +1057,10 @@
tmpl_array.push(' <button data-id="<%- id %>" data-toggle="tooltip" data-placement="top" title="Show library information" id="toolbtn_show_libinfo" class="primary-button" style="margin-left: 0.5em;" type="button"><span class="fa fa-info-circle"></span> Library Info</button>');
tmpl_array.push(' <span class="help-button" data-toggle="tooltip" data-placement="top" title="Visit Libraries Wiki"><a href="https://wiki.galaxyproject.org/DataLibraries/screen/FolderContents" target="_blank"><button class="primary-button" type="button"><span class="fa fa-question-circle"></span> Help</button></a></span>');
+ tmpl_array.push(' <span id="folder_paginator" class="library-paginator">');
+ // paginator will append here
+ tmpl_array.push(' </span>');
+
tmpl_array.push(' </div>');
// TOOLBAR END
tmpl_array.push(' <div id="folder_items_element">');
@@ -1239,7 +1268,41 @@
tmpl_array.push('</ul>');
return _.template(tmpl_array.join(''));
- }
+ },
+
+ templatePaginator: function(){
+ tmpl_array = [];
+
+ tmpl_array.push(' <ul class="pagination pagination-sm">');
+ 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(' <li><a href="#folders/<%= id %>/page/1"><span class="fa fa-angle-double-left"></span></a></li>');
+ tmpl_array.push(' <li class="disabled"><a href="#folders/<%= id %>/page/<% print( show_page ) %>"><% print( show_page - 1 ) %></a></li>');
+ tmpl_array.push(' <% } else { %>');
+ tmpl_array.push(' <li><a href="#folders/<%= id %>/page/1"><span class="fa fa-angle-double-left"></span></a></li>');
+ tmpl_array.push(' <li><a href="#folders/<%= id %>/page/<% print( show_page - 1 ) %>"><% print( show_page - 1 ) %></a></li>');
+ tmpl_array.push(' <% } %>');
+ tmpl_array.push(' <% } else { %>'); // we are on the first page
+ tmpl_array.push(' <li class="disabled"><a href="#folders/<%= id %>/page/1"><span class="fa fa-angle-double-left"></span></a></li>');
+ tmpl_array.push(' <li class="disabled"><a href="#folders/<%= id %>/page/<% print( show_page ) %>"><% print( show_page - 1 ) %></a></li>');
+ tmpl_array.push(' <% } %>');
+ tmpl_array.push(' <li class="active">');
+ tmpl_array.push(' <a href="#folders/<%= id %>/page/<% print( show_page ) %>"><% print( show_page ) %></a>');
+ tmpl_array.push(' </li>');
+ tmpl_array.push(' <% if ( ( show_page ) < page_count ) { %>');
+ tmpl_array.push(' <li><a href="#folders/<%= id %>/page/<% print( show_page + 1 ) %>"><% print( show_page + 1 ) %></a></li>');
+ tmpl_array.push(' <li><a href="#folders/<%= id %>/page/<% print( page_count ) %>"><span class="fa fa-angle-double-right"></span></a></li>');
+ tmpl_array.push(' <% } else { %>');
+ tmpl_array.push(' <li class="disabled"><a href="#folders/<%= id %>/page/<% print( show_page ) %>"><% print( show_page + 1 ) %></a></li>');
+ tmpl_array.push(' <li class="disabled"><a href="#folders/<%= id %>/page/<% print( page_count ) %>"><span class="fa fa-angle-double-right"></span></a></li>');
+ tmpl_array.push(' <% } %>');
+ tmpl_array.push(' </ul>');
+ tmpl_array.push(' <span>');
+ tmpl_array.push(' showing <a data-toggle="tooltip" data-placement="top" title="Click to change the number of items on page" id="page_size_prompt"><%- items_shown %></a> of <%- total_items_count %> items');
+ tmpl_array.push(' </span>');
+
+ return _.template(tmpl_array.join(''));
+ },
});
diff -r 46a3d43d779fa7735029449935dad77474adf9b1 -r 719191cd0f3ea8ad2ff02ec303dabf0e22c31e60 client/galaxy/scripts/mvc/library/library-librarylist-view.js
--- a/client/galaxy/scripts/mvc/library/library-librarylist-view.js
+++ b/client/galaxy/scripts/mvc/library/library-librarylist-view.js
@@ -21,20 +21,19 @@
'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 @@
*/
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 @@
} 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 -r 46a3d43d779fa7735029449935dad77474adf9b1 -r 719191cd0f3ea8ad2ff02ec303dabf0e22c31e60 client/galaxy/scripts/mvc/tools/tools-tree.js
--- a/client/galaxy/scripts/mvc/tools/tools-tree.js
+++ b/client/galaxy/scripts/mvc/tools/tools-tree.js
@@ -126,7 +126,7 @@
// 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 -r 46a3d43d779fa7735029449935dad77474adf9b1 -r 719191cd0f3ea8ad2ff02ec303dabf0e22c31e60 lib/galaxy/managers/folders.py
--- a/lib/galaxy/managers/folders.py
+++ b/lib/galaxy/managers/folders.py
@@ -16,14 +16,14 @@
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 @@
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 @@
# 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 @@
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 -r 46a3d43d779fa7735029449935dad77474adf9b1 -r 719191cd0f3ea8ad2ff02ec303dabf0e22c31e60 lib/galaxy/model/__init__.py
--- a/lib/galaxy/model/__init__.py
+++ b/lib/galaxy/model/__init__.py
@@ -2192,7 +2192,7 @@
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 -r 46a3d43d779fa7735029449935dad77474adf9b1 -r 719191cd0f3ea8ad2ff02ec303dabf0e22c31e60 lib/galaxy/tools/test.py
--- a/lib/galaxy/tools/test.py
+++ b/lib/galaxy/tools/test.py
@@ -196,12 +196,37 @@
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 -r 46a3d43d779fa7735029449935dad77474adf9b1 -r 719191cd0f3ea8ad2ff02ec303dabf0e22c31e60 lib/galaxy/webapps/galaxy/api/folders.py
--- a/lib/galaxy/webapps/galaxy/api/folders.py
+++ b/lib/galaxy/webapps/galaxy/api/folders.py
@@ -44,7 +44,7 @@
: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 @@
'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 ):
"""
diff -r 46a3d43d779fa7735029449935dad77474adf9b1 -r 719191cd0f3ea8ad2ff02ec303dabf0e22c31e60 lib/galaxy/webapps/galaxy/controllers/dataset.py
--- a/lib/galaxy/webapps/galaxy/controllers/dataset.py
+++ b/lib/galaxy/webapps/galaxy/controllers/dataset.py
@@ -932,11 +932,14 @@
@web.expose
def show_params( self, trans, dataset_id=None, from_noframe=None, **kwd ):
"""
- Show the parameters used for an HDA
+ Show the parameters used for the job associated with an HDA
"""
- hda = trans.sa_session.query( trans.app.model.HistoryDatasetAssociation ).get( trans.security.decode_id( dataset_id ) )
+ try:
+ hda = trans.sa_session.query( trans.app.model.HistoryDatasetAssociation ).get( trans.security.decode_id( dataset_id ) )
+ except ValueError:
+ hda = None
if not hda:
- raise paste.httpexceptions.HTTPRequestRangeNotSatisfiable( "Invalid reference dataset id: %s." % str( dataset_id ) )
+ raise paste.httpexceptions.HTTPRequestRangeNotSatisfiable( "Invalid reference dataset id: %s." % escape( str( dataset_id ) ) )
if not self._can_access_dataset( trans, hda ):
return trans.show_error_message( "You are not allowed to access this dataset" )
@@ -961,19 +964,30 @@
toolbox = self.get_toolbox()
tool = toolbox.get_tool( job.tool_id )
assert tool is not None, 'Requested tool has not been loaded.'
- #Load parameter objects, if a parameter type has changed, it's possible for the value to no longer be valid
+ # Load parameter objects, if a parameter type has changed, it's possible for the value to no longer be valid
try:
params_objects = job.get_param_values( trans.app, ignore_errors=False )
except:
params_objects = job.get_param_values( trans.app, ignore_errors=True )
- upgrade_messages = tool.check_and_update_param_values( job.get_param_values( trans.app, ignore_errors=True ), trans, update_values=False ) #use different param_objects here, since we want to display original values as much as possible
+ # use different param_objects in the following line, since we want to display original values as much as possible
+ upgrade_messages = tool.check_and_update_param_values( job.get_param_values( trans.app, ignore_errors=True ),
+ trans,
+ update_values=False )
has_parameter_errors = True
except:
pass
if job is None:
return trans.show_error_message( "Job information is not available for this dataset." )
- #TODO: we should provide the basic values along with the objects, in order to better handle reporting of old values during upgrade
- return trans.fill_template( "show_params.mako", inherit_chain=inherit_chain, history=trans.get_history(), hda=hda, job=job, tool=tool, params_objects=params_objects, upgrade_messages=upgrade_messages, has_parameter_errors=has_parameter_errors )
+ # TODO: we should provide the basic values along with the objects, in order to better handle reporting of old values during upgrade
+ return trans.fill_template( "show_params.mako",
+ inherit_chain=inherit_chain,
+ history=trans.get_history(),
+ hda=hda,
+ job=job,
+ tool=tool,
+ params_objects=params_objects,
+ upgrade_messages=upgrade_messages,
+ has_parameter_errors=has_parameter_errors )
@web.expose
def copy_datasets( self, trans, source_history=None, source_content_ids="", target_history_id=None, target_history_ids="", new_history_name="", do_copy=False, **kwd ):
diff -r 46a3d43d779fa7735029449935dad77474adf9b1 -r 719191cd0f3ea8ad2ff02ec303dabf0e22c31e60 lib/galaxy/webapps/galaxy/controllers/search.py
--- a/lib/galaxy/webapps/galaxy/controllers/search.py
+++ b/lib/galaxy/webapps/galaxy/controllers/search.py
@@ -1,4 +1,3 @@
-
"""
Contains a basic search interface for Galaxy
"""
@@ -8,7 +7,13 @@
log = logging.getLogger( __name__ )
+
class SearchController( BaseUIController ):
+
@web.expose
def index(self, trans):
- return trans.fill_template( "search/index.mako")
+ """
+ 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. Watch the release notes and check back later!")
diff -r 46a3d43d779fa7735029449935dad77474adf9b1 -r 719191cd0f3ea8ad2ff02ec303dabf0e22c31e60 static/scripts/galaxy.library.js
--- a/static/scripts/galaxy.library.js
+++ b/static/scripts/galaxy.library.js
@@ -36,7 +36,7 @@
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 @@
"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 @@
},
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 @@
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 @@
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 @@
}
});
- 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});
}
This diff is so big that we needed to truncate the remainder.
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
commit/galaxy-central: guerler: ToolForm: Fix label for collections, set missing optional parameters to null
by commits-noreply@bitbucket.org 05 Dec '14
by commits-noreply@bitbucket.org 05 Dec '14
05 Dec '14
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/149784a152af/
Changeset: 149784a152af
Branch: next-stable
User: guerler
Date: 2014-12-05 22:35:46+00:00
Summary: ToolForm: Fix label for collections, set missing optional parameters to null
Affected #: 6 files
diff -r 20942ced453dc9f31b2d238855d1b8f5da3f078b -r 149784a152afc3d7164eaf7dfa7d5dc97be92671 client/galaxy/scripts/mvc/tools/tools-select-content.js
--- a/client/galaxy/scripts/mvc/tools/tools-select-content.js
+++ b/client/galaxy/scripts/mvc/tools/tools-select-content.js
@@ -86,7 +86,7 @@
// 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 -r 20942ced453dc9f31b2d238855d1b8f5da3f078b -r 149784a152afc3d7164eaf7dfa7d5dc97be92671 client/galaxy/scripts/mvc/tools/tools-tree.js
--- a/client/galaxy/scripts/mvc/tools/tools-tree.js
+++ b/client/galaxy/scripts/mvc/tools/tools-tree.js
@@ -126,7 +126,7 @@
// 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 -r 20942ced453dc9f31b2d238855d1b8f5da3f078b -r 149784a152afc3d7164eaf7dfa7d5dc97be92671 static/scripts/mvc/tools/tools-select-content.js
--- a/static/scripts/mvc/tools/tools-select-content.js
+++ b/static/scripts/mvc/tools/tools-select-content.js
@@ -86,7 +86,7 @@
// 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 -r 20942ced453dc9f31b2d238855d1b8f5da3f078b -r 149784a152afc3d7164eaf7dfa7d5dc97be92671 static/scripts/mvc/tools/tools-tree.js
--- a/static/scripts/mvc/tools/tools-tree.js
+++ b/static/scripts/mvc/tools/tools-tree.js
@@ -126,7 +126,7 @@
// 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 -r 20942ced453dc9f31b2d238855d1b8f5da3f078b -r 149784a152afc3d7164eaf7dfa7d5dc97be92671 static/scripts/packed/mvc/tools/tools-select-content.js
--- a/static/scripts/packed/mvc/tools/tools-select-content.js
+++ b/static/scripts/packed/mvc/tools/tools-select-content.js
@@ -1,1 +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("<div/>");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("<div/>");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 -r 20942ced453dc9f31b2d238855d1b8f5da3f078b -r 149784a152afc3d7164eaf7dfa7d5dc97be92671 static/scripts/packed/mvc/tools/tools-tree.js
--- a/static/scripts/packed/mvc/tools/tools-tree.js
+++ b/static/scripts/packed/mvc/tools/tools-tree.js
@@ -1,1 +1,1 @@
-define([],function(){return Backbone.Model.extend({initialize:function(a){this.app=a},refresh:function(){this.dict={};this.xml=$("<div/>");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=$('<div id="'+h+'"/>');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=$("<div/>");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=$('<div id="'+h+'"/>');b.append(g);a._iterate(i,e[h],g)}else{a._iterate(i,e,b)}})}})});
\ No newline at end of file
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
commit/galaxy-central: martenson: paginate library folder contents to prevent loooooong rendering when hundreds of items are in one folder
by commits-noreply@bitbucket.org 05 Dec '14
by commits-noreply@bitbucket.org 05 Dec '14
05 Dec '14
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/20942ced453d/
Changeset: 20942ced453d
Branch: next-stable
User: martenson
Date: 2014-12-05 22:21:57+00:00
Summary: paginate library folder contents to prevent loooooong rendering when hundreds of items are in one folder
Affected #: 12 files
diff -r 9ddc3efa9c3245a7dfd24680bdb816f3d4852094 -r 20942ced453dc9f31b2d238855d1b8f5da3f078b client/galaxy/scripts/galaxy.library.js
--- a/client/galaxy/scripts/galaxy.library.js
+++ b/client/galaxy/scripts/galaxy.library.js
@@ -36,7 +36,7 @@
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 @@
"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 @@
},
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 @@
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 @@
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 @@
}
});
- 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 -r 9ddc3efa9c3245a7dfd24680bdb816f3d4852094 -r 20942ced453dc9f31b2d238855d1b8f5da3f078b client/galaxy/scripts/mvc/library/library-folderlist-view.js
--- a/client/galaxy/scripts/mvc/library/library-folderlist-view.js
+++ b/client/galaxy/scripts/mvc/library/library-folderlist-view.js
@@ -15,322 +15,359 @@
) {
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.' );
}
+ } 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( options ){
+ this.options = _.extend( this.options, options );
+
+ 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 )
+ },
+
+ /**
+ * 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();
+ },
+
+ /**
+ * 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();
+ },
+
+ /**
+ * 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')));
}
- },
- 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();}});
- }
+ 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();
}
- });
- },
+ },
- render: function (options) {
- this.options = _.defaults(this.options, options);
- var template = this.templateFolder();
- $(".tooltip").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();
+ },
- // 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];
+ /**
+ * 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('<ol class="breadcrumb">');
+ tmpl_array.push(' <li><a title="Return to the list of libraries" href="#">Libraries</a></li>');
+ tmpl_array.push(' <% _.each(path, function(path_item) { %>');
+ tmpl_array.push(' <% if (path_item[0] != id) { %>');
+ tmpl_array.push(' <li><a title="Return to this folder" href="#/folders/<%- path_item[0] %>"><%- path_item[1] %></a></li> ');
+ tmpl_array.push( '<% } else { %>');
+ tmpl_array.push(' <li class="active"><span title="You are in this folder"><%- path_item[1] %></span></li>');
+ tmpl_array.push(' <% } %>');
+ tmpl_array.push(' <% }); %>');
+ tmpl_array.push('</ol>');
+
+ // FOLDER CONTENT
+ tmpl_array.push('<table data-library-id="<%- parent_library_id %>" id="folder_table" class="grid table table-condensed">');
+ tmpl_array.push(' <thead>');
+ tmpl_array.push(' <th class="button_heading"></th>');
+ tmpl_array.push(' <th style="text-align: center; width: 20px; " title="Check to select all datasets"><input id="select-all-checkboxes" style="margin: 0;" type="checkbox"></th>');
+ tmpl_array.push(' <th><a class="sort-folder-link" title="Click to reverse order" href="#">name</a><span title="Sorted alphabetically" class="fa fa-sort-alpha-<%- order %>"></span></th>');
+ tmpl_array.push(' <th style="width:5%;">data type</th>');
+ tmpl_array.push(' <th style="width:10%;">size</th>');
+ tmpl_array.push(' <th style="width:160px;">time updated (UTC)</th>');
+ tmpl_array.push(' <th style="width:10%;"></th> ');
+ tmpl_array.push(' </thead>');
+ tmpl_array.push(' <tbody id="folder_list_body">');
+ tmpl_array.push(' <tr id="first_folder_item">');
+ tmpl_array.push(' <td><a href="#<% if (upper_folder_id !== 0){ print("folders/" + upper_folder_id)} %>" title="Go to parent folder" class="btn_open_folder btn btn-default btn-xs">..<a></td>');
+ tmpl_array.push(' <td></td>');
+ tmpl_array.push(' <td></td>');
+ tmpl_array.push(' <td></td>');
+ tmpl_array.push(' <td></td>');
+ tmpl_array.push(' <td></td>');
+ tmpl_array.push(' <td></td>');
+ tmpl_array.push(' </tr>');
+
+ tmpl_array.push(' </tbody>');
+ tmpl_array.push('</table>');
+ tmpl_array.push('<div class="empty-folder-message" style="display:none;">This folder is either empty or you do not have proper access permissions to see the contents. If you expected something to show up please consult the <a href="https://wiki.galaxyproject.org/Admin/DataLibraries/LibrarySecurity" target="_blank">library security wikipage</a> or visit the <a href="https://biostar.usegalaxy.org/" target="_blank">Galaxy support site</a>.</div>');
+
+ return _.template(tmpl_array.join(''));
}
-
- 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}));
-
- // 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();
- });
- },
-
- /**
- * 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();
- }
- }
- },
-
- /**
- * 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('<ol class="breadcrumb">');
- tmpl_array.push(' <li><a title="Return to the list of libraries" href="#">Libraries</a></li>');
- tmpl_array.push(' <% _.each(path, function(path_item) { %>');
- tmpl_array.push(' <% if (path_item[0] != id) { %>');
- tmpl_array.push(' <li><a title="Return to this folder" href="#/folders/<%- path_item[0] %>"><%- path_item[1] %></a></li> ');
- tmpl_array.push( '<% } else { %>');
- tmpl_array.push(' <li class="active"><span title="You are in this folder"><%- path_item[1] %></span></li>');
- tmpl_array.push(' <% } %>');
- tmpl_array.push(' <% }); %>');
- tmpl_array.push('</ol>');
-
- // FOLDER CONTENT
- tmpl_array.push('<table data-library-id="<%- parent_library_id %>" id="folder_table" class="grid table table-condensed">');
- tmpl_array.push(' <thead>');
- tmpl_array.push(' <th class="button_heading"></th>');
- tmpl_array.push(' <th style="text-align: center; width: 20px; " title="Check to select all datasets"><input id="select-all-checkboxes" style="margin: 0;" type="checkbox"></th>');
- tmpl_array.push(' <th><a class="sort-folder-link" title="Click to reverse order" href="#">name</a><span title="Sorted alphabetically" class="fa fa-sort-alpha-<%- order %>"></span></th>');
- tmpl_array.push(' <th style="width:5%;">data type</th>');
- tmpl_array.push(' <th style="width:10%;">size</th>');
- tmpl_array.push(' <th style="width:160px;">time updated (UTC)</th>');
- tmpl_array.push(' <th style="width:10%;"></th> ');
- tmpl_array.push(' </thead>');
- tmpl_array.push(' <tbody id="folder_list_body">');
- tmpl_array.push(' <tr id="first_folder_item">');
- tmpl_array.push(' <td><a href="#<% if (upper_folder_id !== 0){ print("folders/" + upper_folder_id)} %>" title="Go to parent folder" class="btn_open_folder btn btn-default btn-xs">..<a></td>');
- tmpl_array.push(' <td></td>');
- tmpl_array.push(' <td></td>');
- tmpl_array.push(' <td></td>');
- tmpl_array.push(' <td></td>');
- tmpl_array.push(' <td></td>');
- tmpl_array.push(' <td></td>');
- tmpl_array.push(' </tr>');
-
- tmpl_array.push(' </tbody>');
- tmpl_array.push('</table>');
- tmpl_array.push('<div class="empty-folder-message" style="display:none;">This folder is either empty or you do not have proper access permissions to see the contents. If you expected something to show up please consult the <a href="https://wiki.galaxyproject.org/Admin/DataLibraries/LibrarySecurity" target="_blank">library security wikipage</a> or visit the <a href="https://biostar.usegalaxy.org/" target="_blank">Galaxy support site</a>.</div>');
-
- return _.template(tmpl_array.join(''));
- }
-
+
});
return {
diff -r 9ddc3efa9c3245a7dfd24680bdb816f3d4852094 -r 20942ced453dc9f31b2d238855d1b8f5da3f078b client/galaxy/scripts/mvc/library/library-foldertoolbar-view.js
--- a/client/galaxy/scripts/mvc/library/library-foldertoolbar-view.js
+++ b/client/galaxy/scripts/mvc/library/library-foldertoolbar-view.js
@@ -20,7 +20,9 @@
'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 @@
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 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 @@
}
},
+ 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 @@
tmpl_array.push(' <button style="display:none;" data-toggle="tooltip" data-placement="top" title="Add Datasets to Current Folder" id="toolbtn_add_files" class="btn btn-default toolbtn_add_files primary-button add-library-items" type="button"><span class="fa fa-plus"></span><span class="fa fa-file"></span></span></button>');
tmpl_array.push('<% } %>');
-
tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Import selected datasets into history" id="toolbtn_bulk_import" class="primary-button dataset-manipulation" style="margin-left: 0.5em; display:none;" type="button"><span class="fa fa-book"></span> to History</button>');
tmpl_array.push(' <div id="toolbtn_dl" class="btn-group dataset-manipulation" style="margin-left: 0.5em; display:none; ">');
tmpl_array.push(' <button title="Download selected datasets as archive" id="drop_toggle" type="button" class="primary-button dropdown-toggle" data-toggle="dropdown">');
@@ -1032,6 +1057,10 @@
tmpl_array.push(' <button data-id="<%- id %>" data-toggle="tooltip" data-placement="top" title="Show library information" id="toolbtn_show_libinfo" class="primary-button" style="margin-left: 0.5em;" type="button"><span class="fa fa-info-circle"></span> Library Info</button>');
tmpl_array.push(' <span class="help-button" data-toggle="tooltip" data-placement="top" title="Visit Libraries Wiki"><a href="https://wiki.galaxyproject.org/DataLibraries/screen/FolderContents" target="_blank"><button class="primary-button" type="button"><span class="fa fa-question-circle"></span> Help</button></a></span>');
+ tmpl_array.push(' <span id="folder_paginator" class="library-paginator">');
+ // paginator will append here
+ tmpl_array.push(' </span>');
+
tmpl_array.push(' </div>');
// TOOLBAR END
tmpl_array.push(' <div id="folder_items_element">');
@@ -1239,7 +1268,41 @@
tmpl_array.push('</ul>');
return _.template(tmpl_array.join(''));
- }
+ },
+
+ templatePaginator: function(){
+ tmpl_array = [];
+
+ tmpl_array.push(' <ul class="pagination pagination-sm">');
+ 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(' <li><a href="#folders/<%= id %>/page/1"><span class="fa fa-angle-double-left"></span></a></li>');
+ tmpl_array.push(' <li class="disabled"><a href="#folders/<%= id %>/page/<% print( show_page ) %>"><% print( show_page - 1 ) %></a></li>');
+ tmpl_array.push(' <% } else { %>');
+ tmpl_array.push(' <li><a href="#folders/<%= id %>/page/1"><span class="fa fa-angle-double-left"></span></a></li>');
+ tmpl_array.push(' <li><a href="#folders/<%= id %>/page/<% print( show_page - 1 ) %>"><% print( show_page - 1 ) %></a></li>');
+ tmpl_array.push(' <% } %>');
+ tmpl_array.push(' <% } else { %>'); // we are on the first page
+ tmpl_array.push(' <li class="disabled"><a href="#folders/<%= id %>/page/1"><span class="fa fa-angle-double-left"></span></a></li>');
+ tmpl_array.push(' <li class="disabled"><a href="#folders/<%= id %>/page/<% print( show_page ) %>"><% print( show_page - 1 ) %></a></li>');
+ tmpl_array.push(' <% } %>');
+ tmpl_array.push(' <li class="active">');
+ tmpl_array.push(' <a href="#folders/<%= id %>/page/<% print( show_page ) %>"><% print( show_page ) %></a>');
+ tmpl_array.push(' </li>');
+ tmpl_array.push(' <% if ( ( show_page ) < page_count ) { %>');
+ tmpl_array.push(' <li><a href="#folders/<%= id %>/page/<% print( show_page + 1 ) %>"><% print( show_page + 1 ) %></a></li>');
+ tmpl_array.push(' <li><a href="#folders/<%= id %>/page/<% print( page_count ) %>"><span class="fa fa-angle-double-right"></span></a></li>');
+ tmpl_array.push(' <% } else { %>');
+ tmpl_array.push(' <li class="disabled"><a href="#folders/<%= id %>/page/<% print( show_page ) %>"><% print( show_page + 1 ) %></a></li>');
+ tmpl_array.push(' <li class="disabled"><a href="#folders/<%= id %>/page/<% print( page_count ) %>"><span class="fa fa-angle-double-right"></span></a></li>');
+ tmpl_array.push(' <% } %>');
+ tmpl_array.push(' </ul>');
+ tmpl_array.push(' <span>');
+ tmpl_array.push(' showing <a data-toggle="tooltip" data-placement="top" title="Click to change the number of items on page" id="page_size_prompt"><%- items_shown %></a> of <%- total_items_count %> items');
+ tmpl_array.push(' </span>');
+
+ return _.template(tmpl_array.join(''));
+ },
});
diff -r 9ddc3efa9c3245a7dfd24680bdb816f3d4852094 -r 20942ced453dc9f31b2d238855d1b8f5da3f078b client/galaxy/scripts/mvc/library/library-librarylist-view.js
--- a/client/galaxy/scripts/mvc/library/library-librarylist-view.js
+++ b/client/galaxy/scripts/mvc/library/library-librarylist-view.js
@@ -21,20 +21,19 @@
'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 @@
*/
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 @@
} 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 -r 9ddc3efa9c3245a7dfd24680bdb816f3d4852094 -r 20942ced453dc9f31b2d238855d1b8f5da3f078b static/scripts/galaxy.library.js
--- a/static/scripts/galaxy.library.js
+++ b/static/scripts/galaxy.library.js
@@ -36,7 +36,7 @@
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 @@
"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 @@
},
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 @@
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 @@
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 @@
}
});
- 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 -r 9ddc3efa9c3245a7dfd24680bdb816f3d4852094 -r 20942ced453dc9f31b2d238855d1b8f5da3f078b static/scripts/mvc/library/library-folderlist-view.js
--- a/static/scripts/mvc/library/library-folderlist-view.js
+++ b/static/scripts/mvc/library/library-folderlist-view.js
@@ -15,322 +15,359 @@
) {
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.' );
}
+ } 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( options ){
+ this.options = _.extend( this.options, options );
+
+ 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 )
+ },
+
+ /**
+ * 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();
+ },
+
+ /**
+ * 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();
+ },
+
+ /**
+ * 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')));
}
- },
- 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();}});
- }
+ 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();
}
- });
- },
+ },
- render: function (options) {
- this.options = _.defaults(this.options, options);
- var template = this.templateFolder();
- $(".tooltip").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();
+ },
- // 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];
+ /**
+ * 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('<ol class="breadcrumb">');
+ tmpl_array.push(' <li><a title="Return to the list of libraries" href="#">Libraries</a></li>');
+ tmpl_array.push(' <% _.each(path, function(path_item) { %>');
+ tmpl_array.push(' <% if (path_item[0] != id) { %>');
+ tmpl_array.push(' <li><a title="Return to this folder" href="#/folders/<%- path_item[0] %>"><%- path_item[1] %></a></li> ');
+ tmpl_array.push( '<% } else { %>');
+ tmpl_array.push(' <li class="active"><span title="You are in this folder"><%- path_item[1] %></span></li>');
+ tmpl_array.push(' <% } %>');
+ tmpl_array.push(' <% }); %>');
+ tmpl_array.push('</ol>');
+
+ // FOLDER CONTENT
+ tmpl_array.push('<table data-library-id="<%- parent_library_id %>" id="folder_table" class="grid table table-condensed">');
+ tmpl_array.push(' <thead>');
+ tmpl_array.push(' <th class="button_heading"></th>');
+ tmpl_array.push(' <th style="text-align: center; width: 20px; " title="Check to select all datasets"><input id="select-all-checkboxes" style="margin: 0;" type="checkbox"></th>');
+ tmpl_array.push(' <th><a class="sort-folder-link" title="Click to reverse order" href="#">name</a><span title="Sorted alphabetically" class="fa fa-sort-alpha-<%- order %>"></span></th>');
+ tmpl_array.push(' <th style="width:5%;">data type</th>');
+ tmpl_array.push(' <th style="width:10%;">size</th>');
+ tmpl_array.push(' <th style="width:160px;">time updated (UTC)</th>');
+ tmpl_array.push(' <th style="width:10%;"></th> ');
+ tmpl_array.push(' </thead>');
+ tmpl_array.push(' <tbody id="folder_list_body">');
+ tmpl_array.push(' <tr id="first_folder_item">');
+ tmpl_array.push(' <td><a href="#<% if (upper_folder_id !== 0){ print("folders/" + upper_folder_id)} %>" title="Go to parent folder" class="btn_open_folder btn btn-default btn-xs">..<a></td>');
+ tmpl_array.push(' <td></td>');
+ tmpl_array.push(' <td></td>');
+ tmpl_array.push(' <td></td>');
+ tmpl_array.push(' <td></td>');
+ tmpl_array.push(' <td></td>');
+ tmpl_array.push(' <td></td>');
+ tmpl_array.push(' </tr>');
+
+ tmpl_array.push(' </tbody>');
+ tmpl_array.push('</table>');
+ tmpl_array.push('<div class="empty-folder-message" style="display:none;">This folder is either empty or you do not have proper access permissions to see the contents. If you expected something to show up please consult the <a href="https://wiki.galaxyproject.org/Admin/DataLibraries/LibrarySecurity" target="_blank">library security wikipage</a> or visit the <a href="https://biostar.usegalaxy.org/" target="_blank">Galaxy support site</a>.</div>');
+
+ return _.template(tmpl_array.join(''));
}
-
- 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}));
-
- // 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();
- });
- },
-
- /**
- * 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();
- }
- }
- },
-
- /**
- * 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('<ol class="breadcrumb">');
- tmpl_array.push(' <li><a title="Return to the list of libraries" href="#">Libraries</a></li>');
- tmpl_array.push(' <% _.each(path, function(path_item) { %>');
- tmpl_array.push(' <% if (path_item[0] != id) { %>');
- tmpl_array.push(' <li><a title="Return to this folder" href="#/folders/<%- path_item[0] %>"><%- path_item[1] %></a></li> ');
- tmpl_array.push( '<% } else { %>');
- tmpl_array.push(' <li class="active"><span title="You are in this folder"><%- path_item[1] %></span></li>');
- tmpl_array.push(' <% } %>');
- tmpl_array.push(' <% }); %>');
- tmpl_array.push('</ol>');
-
- // FOLDER CONTENT
- tmpl_array.push('<table data-library-id="<%- parent_library_id %>" id="folder_table" class="grid table table-condensed">');
- tmpl_array.push(' <thead>');
- tmpl_array.push(' <th class="button_heading"></th>');
- tmpl_array.push(' <th style="text-align: center; width: 20px; " title="Check to select all datasets"><input id="select-all-checkboxes" style="margin: 0;" type="checkbox"></th>');
- tmpl_array.push(' <th><a class="sort-folder-link" title="Click to reverse order" href="#">name</a><span title="Sorted alphabetically" class="fa fa-sort-alpha-<%- order %>"></span></th>');
- tmpl_array.push(' <th style="width:5%;">data type</th>');
- tmpl_array.push(' <th style="width:10%;">size</th>');
- tmpl_array.push(' <th style="width:160px;">time updated (UTC)</th>');
- tmpl_array.push(' <th style="width:10%;"></th> ');
- tmpl_array.push(' </thead>');
- tmpl_array.push(' <tbody id="folder_list_body">');
- tmpl_array.push(' <tr id="first_folder_item">');
- tmpl_array.push(' <td><a href="#<% if (upper_folder_id !== 0){ print("folders/" + upper_folder_id)} %>" title="Go to parent folder" class="btn_open_folder btn btn-default btn-xs">..<a></td>');
- tmpl_array.push(' <td></td>');
- tmpl_array.push(' <td></td>');
- tmpl_array.push(' <td></td>');
- tmpl_array.push(' <td></td>');
- tmpl_array.push(' <td></td>');
- tmpl_array.push(' <td></td>');
- tmpl_array.push(' </tr>');
-
- tmpl_array.push(' </tbody>');
- tmpl_array.push('</table>');
- tmpl_array.push('<div class="empty-folder-message" style="display:none;">This folder is either empty or you do not have proper access permissions to see the contents. If you expected something to show up please consult the <a href="https://wiki.galaxyproject.org/Admin/DataLibraries/LibrarySecurity" target="_blank">library security wikipage</a> or visit the <a href="https://biostar.usegalaxy.org/" target="_blank">Galaxy support site</a>.</div>');
-
- return _.template(tmpl_array.join(''));
- }
-
+
});
return {
This diff is so big that we needed to truncate the remainder.
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
5 new commits in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/77f9f54744d4/
Changeset: 77f9f54744d4
Branch: next-stable
User: guerler
Date: 2014-12-03 22:29:34+00:00
Summary: ToolForm: Add data collection parameter
Affected #: 7 files
diff -r 8f76a6abc5d7d5c98b6c148c4cfe75cc1c159e90 -r 77f9f54744d480948aec2f0662657139f35f87fb client/galaxy/scripts/mvc/tools/tools-section.js
--- a/client/galaxy/scripts/mvc/tools/tools-section.js
+++ b/client/galaxy/scripts/mvc/tools/tools-section.js
@@ -307,6 +307,11 @@
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 @@
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 -r 8f76a6abc5d7d5c98b6c148c4cfe75cc1c159e90 -r 77f9f54744d480948aec2f0662657139f35f87fb client/galaxy/scripts/mvc/tools/tools-select-content.js
--- a/client/galaxy/scripts/mvc/tools/tools-select-content.js
+++ b/client/galaxy/scripts/mvc/tools/tools-select-content.js
@@ -20,15 +20,23 @@
// radio button options
var radio_buttons = [];
+ // identify selector type
+ if (options.type == 'data_collection') {
+ this.mode = 'collection';
+ } else {
+ if (options.multiple) {
+ this.mode = 'multiple';
+ } else {
+ this.mode = 'single';
+ }
+ }
+
// set initial state
- if (!options.multiple) {
- this.current = 'single';
- } else {
- this.current = 'multiple';
- }
-
+ 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 @@
}
// 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 @@
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 @@
// 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 @@
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 @@
// prepare result dict
var result = {
- batch : !this.options.multiple && this.current != 'single',
+ batch : this.mode == 'single' && this.current != 'single',
values : []
}
@@ -227,7 +241,7 @@
$el.hide();
}
}
- if (this.current != 'single' && !this.options.multiple) {
+ if (this.mode == 'single' && this.current != 'single') {
this.$batch.show();
} else {
this.$batch.hide();
diff -r 8f76a6abc5d7d5c98b6c148c4cfe75cc1c159e90 -r 77f9f54744d480948aec2f0662657139f35f87fb lib/galaxy/tools/parameters/basic.py
--- a/lib/galaxy/tools/parameters/basic.py
+++ b/lib/galaxy/tools/parameters/basic.py
@@ -2310,6 +2310,47 @@
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 -r 8f76a6abc5d7d5c98b6c148c4cfe75cc1c159e90 -r 77f9f54744d480948aec2f0662657139f35f87fb static/scripts/mvc/tools/tools-section.js
--- a/static/scripts/mvc/tools/tools-section.js
+++ b/static/scripts/mvc/tools/tools-section.js
@@ -307,6 +307,11 @@
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 @@
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 -r 8f76a6abc5d7d5c98b6c148c4cfe75cc1c159e90 -r 77f9f54744d480948aec2f0662657139f35f87fb static/scripts/mvc/tools/tools-select-content.js
--- a/static/scripts/mvc/tools/tools-select-content.js
+++ b/static/scripts/mvc/tools/tools-select-content.js
@@ -20,15 +20,23 @@
// radio button options
var radio_buttons = [];
+ // identify selector type
+ if (options.type == 'data_collection') {
+ this.mode = 'collection';
+ } else {
+ if (options.multiple) {
+ this.mode = 'multiple';
+ } else {
+ this.mode = 'single';
+ }
+ }
+
// set initial state
- if (!options.multiple) {
- this.current = 'single';
- } else {
- this.current = 'multiple';
- }
-
+ 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 @@
}
// 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 @@
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 @@
// 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 @@
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 @@
// prepare result dict
var result = {
- batch : !this.options.multiple && this.current != 'single',
+ batch : this.mode == 'single' && this.current != 'single',
values : []
}
@@ -227,7 +241,7 @@
$el.hide();
}
}
- if (this.current != 'single' && !this.options.multiple) {
+ if (this.mode == 'single' && this.current != 'single') {
this.$batch.show();
} else {
this.$batch.hide();
diff -r 8f76a6abc5d7d5c98b6c148c4cfe75cc1c159e90 -r 77f9f54744d480948aec2f0662657139f35f87fb static/scripts/packed/mvc/tools/tools-section.js
--- a/static/scripts/packed/mvc/tools/tools-section.js
+++ b/static/scripts/packed/mvc/tools/tools-section.js
@@ -1,1 +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<Math.max(q,h);l++){var n=null;if(l<q){n=o.cache[l]}else{n=o.inputs}m(n,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<Math.max(q,h);l++){var n=null;if(l<q){n=o.cache[l]}else{n=o.inputs}m(n,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 -r 8f76a6abc5d7d5c98b6c148c4cfe75cc1c159e90 -r 77f9f54744d480948aec2f0662657139f35f87fb static/scripts/packed/mvc/tools/tools-select-content.js
--- a/static/scripts/packed/mvc/tools/tools-select-content.js
+++ b/static/scripts/packed/mvc/tools/tools-select-content.js
@@ -1,1 +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("<div/>");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("<div/>");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
https://bitbucket.org/galaxy/galaxy-central/commits/97f0146a1ff0/
Changeset: 97f0146a1ff0
Branch: next-stable
User: guerler
Date: 2014-12-04 16:45:18+00:00
Summary: ToolForm: Add dataset types to error message
Affected #: 15 files
diff -r 77f9f54744d480948aec2f0662657139f35f87fb -r 97f0146a1ff06851a999e0a78a3cb512a4cc644c client/galaxy/scripts/mvc/tools/tools-form.js
--- a/client/galaxy/scripts/mvc/tools/tools-form.js
+++ b/client/galaxy/scripts/mvc/tools/tools-form.js
@@ -340,7 +340,7 @@
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 -r 77f9f54744d480948aec2f0662657139f35f87fb -r 97f0146a1ff06851a999e0a78a3cb512a4cc644c client/galaxy/scripts/mvc/tools/tools-section.js
--- a/client/galaxy/scripts/mvc/tools/tools-section.js
+++ b/client/galaxy/scripts/mvc/tools/tools-section.js
@@ -314,6 +314,7 @@
// 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 @@
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 -r 77f9f54744d480948aec2f0662657139f35f87fb -r 97f0146a1ff06851a999e0a78a3cb512a4cc644c client/galaxy/scripts/mvc/tools/tools-select-content.js
--- a/client/galaxy/scripts/mvc/tools/tools-select-content.js
+++ b/client/galaxy/scripts/mvc/tools/tools-select-content.js
@@ -35,10 +35,29 @@
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 @@
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 @@
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 -r 77f9f54744d480948aec2f0662657139f35f87fb -r 97f0146a1ff06851a999e0a78a3cb512a4cc644c client/galaxy/scripts/mvc/ui/ui-options.js
--- a/client/galaxy/scripts/mvc/ui/ui-options.js
+++ b/client/galaxy/scripts/mvc/ui/ui-options.js
@@ -10,8 +10,8 @@
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 @@
*/
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 @@
*/
_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 -r 77f9f54744d480948aec2f0662657139f35f87fb -r 97f0146a1ff06851a999e0a78a3cb512a4cc644c client/galaxy/scripts/mvc/ui/ui-select-default.js
--- a/client/galaxy/scripts/mvc/ui/ui-select-default.js
+++ b/client/galaxy/scripts/mvc/ui/ui-select-default.js
@@ -9,7 +9,7 @@
optionsDefault : {
id : '',
cls : '',
- empty : 'No data available',
+ error_text : 'No data available',
visible : true,
wait : false,
multiple : false,
@@ -247,7 +247,7 @@
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 -r 77f9f54744d480948aec2f0662657139f35f87fb -r 97f0146a1ff06851a999e0a78a3cb512a4cc644c static/scripts/mvc/tools/tools-form.js
--- a/static/scripts/mvc/tools/tools-form.js
+++ b/static/scripts/mvc/tools/tools-form.js
@@ -340,7 +340,7 @@
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 -r 77f9f54744d480948aec2f0662657139f35f87fb -r 97f0146a1ff06851a999e0a78a3cb512a4cc644c static/scripts/mvc/tools/tools-section.js
--- a/static/scripts/mvc/tools/tools-section.js
+++ b/static/scripts/mvc/tools/tools-section.js
@@ -314,6 +314,7 @@
// 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 @@
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 -r 77f9f54744d480948aec2f0662657139f35f87fb -r 97f0146a1ff06851a999e0a78a3cb512a4cc644c static/scripts/mvc/tools/tools-select-content.js
--- a/static/scripts/mvc/tools/tools-select-content.js
+++ b/static/scripts/mvc/tools/tools-select-content.js
@@ -35,10 +35,29 @@
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 @@
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 @@
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 -r 77f9f54744d480948aec2f0662657139f35f87fb -r 97f0146a1ff06851a999e0a78a3cb512a4cc644c static/scripts/mvc/ui/ui-options.js
--- a/static/scripts/mvc/ui/ui-options.js
+++ b/static/scripts/mvc/ui/ui-options.js
@@ -10,8 +10,8 @@
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 @@
*/
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 @@
*/
_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 -r 77f9f54744d480948aec2f0662657139f35f87fb -r 97f0146a1ff06851a999e0a78a3cb512a4cc644c static/scripts/mvc/ui/ui-select-default.js
--- a/static/scripts/mvc/ui/ui-select-default.js
+++ b/static/scripts/mvc/ui/ui-select-default.js
@@ -9,7 +9,7 @@
optionsDefault : {
id : '',
cls : '',
- empty : 'No data available',
+ error_text : 'No data available',
visible : true,
wait : false,
multiple : false,
@@ -247,7 +247,7 @@
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 -r 77f9f54744d480948aec2f0662657139f35f87fb -r 97f0146a1ff06851a999e0a78a3cb512a4cc644c static/scripts/packed/mvc/tools/tools-form.js
--- a/static/scripts/packed/mvc/tools/tools-form.js
+++ b/static/scripts/packed/mvc/tools/tools-form.js
@@ -1,1 +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("<div/>");$(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:"<b>"+this.model.name+"</b> "+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=$("<div/>");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("<div/>");$(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:"<b>"+this.model.name+"</b> "+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=$("<div/>");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 -r 77f9f54744d480948aec2f0662657139f35f87fb -r 97f0146a1ff06851a999e0a78a3cb512a4cc644c static/scripts/packed/mvc/tools/tools-section.js
--- a/static/scripts/packed/mvc/tools/tools-section.js
+++ b/static/scripts/packed/mvc/tools/tools-section.js
@@ -1,1 +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<Math.max(q,h);l++){var n=null;if(l<q){n=o.cache[l]}else{n=o.inputs}m(n,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<Math.max(q,h);l++){var n=null;if(l<q){n=o.cache[l]}else{n=o.inputs}m(n,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 -r 77f9f54744d480948aec2f0662657139f35f87fb -r 97f0146a1ff06851a999e0a78a3cb512a4cc644c static/scripts/packed/mvc/tools/tools-select-content.js
--- a/static/scripts/packed/mvc/tools/tools-select-content.js
+++ b/static/scripts/packed/mvc/tools/tools-select-content.js
@@ -1,1 +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("<div/>");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("<div/>");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 -r 77f9f54744d480948aec2f0662657139f35f87fb -r 97f0146a1ff06851a999e0a78a3cb512a4cc644c static/scripts/packed/mvc/ui/ui-options.js
--- a/static/scripts/packed/mvc/ui/ui-options.js
+++ b/static/scripts/packed/mvc/ui/ui-options.js
@@ -1,1 +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("<div/>");this.$message=$("<div/>");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'<div class="ui-options"/>'}});var d={};d.View=a.extend({initialize:function(f){a.prototype.initialize.call(this,f)},_templateOption:function(f){return'<div><input type="radio" name="'+this.options.id+'" value="'+f.value+'"/>'+f.label+"<br></div>"}});var c={};c.View=a.extend({initialize:function(f){f.multiple=true;a.prototype.initialize.call(this,f)},_templateOption:function(f){return'<div><input type="checkbox" name="'+this.options.id+'" value="'+f.value+'"/>'+f.label+"<br></div>"}});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='<label class="btn btn-default">';if(g.icon){f+='<i class="fa '+g.icon+'"/>'}f+='<input type="radio" name="'+this.options.id+'" value="'+g.value+'">'+g.label+"</label>";return f},_template:function(){return'<div class="btn-group ui-radiobutton" data-toggle="buttons"/>'}});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("<div/>");this.$message=$("<div/>");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'<div class="ui-options"/>'}});var d={};d.View=a.extend({initialize:function(f){a.prototype.initialize.call(this,f)},_templateOption:function(f){return'<div><input type="radio" name="'+this.options.id+'" value="'+f.value+'"/>'+f.label+"<br></div>"}});var c={};c.View=a.extend({initialize:function(f){f.multiple=true;a.prototype.initialize.call(this,f)},_templateOption:function(f){return'<div><input type="checkbox" name="'+this.options.id+'" value="'+f.value+'"/>'+f.label+"<br></div>"}});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='<label class="btn btn-default">';if(g.icon){f+='<i class="fa '+g.icon+'"/>'}f+='<input type="radio" name="'+this.options.id+'" value="'+g.value+'">'+g.label+"</label>";return f},_template:function(){return'<div class="btn-group ui-radiobutton" data-toggle="buttons"/>'}});return{Base:a,Radio:d,RadioButton:e,Checkbox:c}});
\ No newline at end of file
diff -r 77f9f54744d480948aec2f0662657139f35f87fb -r 97f0146a1ff06851a999e0a78a3cb512a4cc644c static/scripts/packed/mvc/ui/ui-select-default.js
--- a/static/scripts/packed/mvc/ui/ui-select-default.js
+++ b/static/scripts/packed/mvc/ui/ui-select-default.js
@@ -1,1 +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'<option value="'+c.value+'">'+c.label+"</option>"},_template:function(c){return'<div id="'+c.id+'"><select id="select" class="select '+c.cls+" "+c.id+'"></select><div class="button"><i class="icon"/></div></div>'}});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'<option value="'+c.value+'">'+c.label+"</option>"},_template:function(c){return'<div id="'+c.id+'"><select id="select" class="select '+c.cls+" "+c.id+'"></select><div class="button"><i class="icon"/></div></div>'}});return{View:b}});
\ No newline at end of file
https://bitbucket.org/galaxy/galaxy-central/commits/7b1b9a075317/
Changeset: 7b1b9a075317
Branch: next-stable
User: guerler
Date: 2014-12-04 16:53:22+00:00
Summary: ToolForm: Update error message
Affected #: 3 files
diff -r 97f0146a1ff06851a999e0a78a3cb512a4cc644c -r 7b1b9a075317a5c87b4be21a3ef4da6ef38f6420 client/galaxy/scripts/mvc/tools/tools-select-content.js
--- a/client/galaxy/scripts/mvc/tools/tools-select-content.js
+++ b/client/galaxy/scripts/mvc/tools/tools-select-content.js
@@ -41,16 +41,16 @@
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 -r 97f0146a1ff06851a999e0a78a3cb512a4cc644c -r 7b1b9a075317a5c87b4be21a3ef4da6ef38f6420 static/scripts/mvc/tools/tools-select-content.js
--- a/static/scripts/mvc/tools/tools-select-content.js
+++ b/static/scripts/mvc/tools/tools-select-content.js
@@ -41,16 +41,16 @@
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 -r 97f0146a1ff06851a999e0a78a3cb512a4cc644c -r 7b1b9a075317a5c87b4be21a3ef4da6ef38f6420 static/scripts/packed/mvc/tools/tools-select-content.js
--- a/static/scripts/packed/mvc/tools/tools-select-content.js
+++ b/static/scripts/packed/mvc/tools/tools-select-content.js
@@ -1,1 +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("<div/>");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("<div/>");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
https://bitbucket.org/galaxy/galaxy-central/commits/89bfc7488769/
Changeset: 89bfc7488769
Branch: next-stable
User: guerler
Date: 2014-12-04 16:59:21+00:00
Summary: ToolForm: Update error message for missing columns
Affected #: 3 files
diff -r 7b1b9a075317a5c87b4be21a3ef4da6ef38f6420 -r 89bfc74887698d8433b5a4c38aa8e33087f4cb2c client/galaxy/scripts/mvc/tools/tools-section.js
--- a/client/galaxy/scripts/mvc/tools/tools-section.js
+++ b/client/galaxy/scripts/mvc/tools/tools-section.js
@@ -314,7 +314,7 @@
// 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 -r 7b1b9a075317a5c87b4be21a3ef4da6ef38f6420 -r 89bfc74887698d8433b5a4c38aa8e33087f4cb2c static/scripts/mvc/tools/tools-section.js
--- a/static/scripts/mvc/tools/tools-section.js
+++ b/static/scripts/mvc/tools/tools-section.js
@@ -314,7 +314,7 @@
// 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 -r 7b1b9a075317a5c87b4be21a3ef4da6ef38f6420 -r 89bfc74887698d8433b5a4c38aa8e33087f4cb2c static/scripts/packed/mvc/tools/tools-section.js
--- a/static/scripts/packed/mvc/tools/tools-section.js
+++ b/static/scripts/packed/mvc/tools/tools-section.js
@@ -1,1 +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<Math.max(q,h);l++){var n=null;if(l<q){n=o.cache[l]}else{n=o.inputs}m(n,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<Math.max(q,h);l++){var n=null;if(l<q){n=o.cache[l]}else{n=o.inputs}m(n,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
https://bitbucket.org/galaxy/galaxy-central/commits/9ddc3efa9c32/
Changeset: 9ddc3efa9c32
Branch: next-stable
User: guerler
Date: 2014-12-04 17:01:34+00:00
Summary: ToolForm: Update error message again
Affected #: 3 files
diff -r 89bfc74887698d8433b5a4c38aa8e33087f4cb2c -r 9ddc3efa9c3245a7dfd24680bdb816f3d4852094 client/galaxy/scripts/mvc/tools/tools-section.js
--- a/client/galaxy/scripts/mvc/tools/tools-section.js
+++ b/client/galaxy/scripts/mvc/tools/tools-section.js
@@ -314,7 +314,7 @@
// 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 -r 89bfc74887698d8433b5a4c38aa8e33087f4cb2c -r 9ddc3efa9c3245a7dfd24680bdb816f3d4852094 static/scripts/mvc/tools/tools-section.js
--- a/static/scripts/mvc/tools/tools-section.js
+++ b/static/scripts/mvc/tools/tools-section.js
@@ -314,7 +314,7 @@
// 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 -r 89bfc74887698d8433b5a4c38aa8e33087f4cb2c -r 9ddc3efa9c3245a7dfd24680bdb816f3d4852094 static/scripts/packed/mvc/tools/tools-section.js
--- a/static/scripts/packed/mvc/tools/tools-section.js
+++ b/static/scripts/packed/mvc/tools/tools-section.js
@@ -1,1 +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<Math.max(q,h);l++){var n=null;if(l<q){n=o.cache[l]}else{n=o.inputs}m(n,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<Math.max(q,h);l++){var n=null;if(l<q){n=o.cache[l]}else{n=o.inputs}m(n,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
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
commit/galaxy-central: natefoo: Update tag latest_2014.10.06 for changeset 8e45b1cefba1
by commits-noreply@bitbucket.org 05 Dec '14
by commits-noreply@bitbucket.org 05 Dec '14
05 Dec '14
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/885f940bff64/
Changeset: 885f940bff64
Branch: stable
User: natefoo
Date: 2014-12-05 21:00:16+00:00
Summary: Update tag latest_2014.10.06 for changeset 8e45b1cefba1
Affected #: 1 file
diff -r 8e45b1cefba16727d4d3a7d0dceaaaf1ef400a0c -r 885f940bff64bbb6769fd31b21b0c73f4bfe1642 .hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -20,4 +20,4 @@
ca45b78adb4152fc6e7395514d46eba6b7d0b838 release_2014.08.11
548ab24667d6206780237bd807f7d857a484c461 latest_2014.08.11
2092948937ac30ef82f71463a235c66d34987088 release_2014.10.06
-9c482e1d9b3cfdb2936b3f230d434c1f27898eff latest_2014.10.06
+8e45b1cefba16727d4d3a7d0dceaaaf1ef400a0c latest_2014.10.06
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
4 new commits in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/d2a8b1c249c8/
Changeset: d2a8b1c249c8
Branch: disable_mobile
User: martenson
Date: 2014-12-03 16:57:20+00:00
Summary: disable the mobile version of the site; redirect to index from every used URL
Affected #: 1 file
diff -r 795336f22d8b94b86256b1d4738ee1bf24e18b57 -r d2a8b1c249c823fa3dd56be34158607d3a65680f lib/galaxy/webapps/galaxy/controllers/mobile.py
--- a/lib/galaxy/webapps/galaxy/controllers/mobile.py
+++ b/lib/galaxy/webapps/galaxy/controllers/mobile.py
@@ -1,60 +1,71 @@
+from galaxy import web
from galaxy.web.base.controller import *
+
class Mobile( BaseUIController ):
+
@web.expose
def index( self, trans, **kwargs ):
- return trans.fill_template( "mobile/index.mako" )
+ return trans.response.send_redirect( web.url_for(controller='root', action='index' ) )
+ # return trans.fill_template( "mobile/index.mako" )
@web.expose
def history_list( self, trans ):
- return trans.fill_template( "mobile/history/list.mako" )
+ return trans.response.send_redirect( web.url_for(controller='root', action='index' ) )
+ # return trans.fill_template( "mobile/history/list.mako" )
@web.expose
def history_detail( self, trans, id ):
- history = trans.sa_session.query( trans.app.model.History ).get( id )
- assert history.user == trans.user
- return trans.fill_template( "mobile/history/detail.mako", history=history )
+ return trans.response.send_redirect( web.url_for(controller='root', action='index' ) )
+ # history = trans.sa_session.query( trans.app.model.History ).get( id )
+ # assert history.user == trans.user
+ # return trans.fill_template( "mobile/history/detail.mako", history=history )
@web.expose
def dataset_detail( self, trans, id ):
- dataset = trans.sa_session.query( trans.app.model.HistoryDatasetAssociation ).get( id )
- assert dataset.history.user == trans.user
- return trans.fill_template( "mobile/dataset/detail.mako", dataset=dataset )
+ return trans.response.send_redirect( web.url_for(controller='root', action='index' ) )
+ # dataset = trans.sa_session.query( trans.app.model.HistoryDatasetAssociation ).get( id )
+ # assert dataset.history.user == trans.user
+ # return trans.fill_template( "mobile/dataset/detail.mako", dataset=dataset )
@web.expose
def dataset_peek( self, trans, id ):
- dataset = trans.sa_session.query( trans.app.model.HistoryDatasetAssociation ).get( id )
- assert dataset.history.user == trans.user
- return trans.fill_template( "mobile/dataset/peek.mako", dataset=dataset )
+ return trans.response.send_redirect( web.url_for(controller='root', action='index' ) )
+ # dataset = trans.sa_session.query( trans.app.model.HistoryDatasetAssociation ).get( id )
+ # assert dataset.history.user == trans.user
+ # return trans.fill_template( "mobile/dataset/peek.mako", dataset=dataset )
@web.expose
def settings( self, trans, email=None, password=None ):
- message = None
- if email is not None and password is not None:
- if email == "":
- self.__logout( trans )
- message = "Logged out"
- else:
- error = self.__login( trans, email, password )
- message = error or "Login changed"
- return trans.fill_template( "mobile/settings.mako", message=message )
+ return trans.response.send_redirect( web.url_for(controller='root', action='index' ) )
+ # message = None
+ # if email is not None and password is not None:
+ # if email == "":
+ # self.__logout( trans )
+ # message = "Logged out"
+ # else:
+ # error = self.__login( trans, email, password )
+ # message = error or "Login changed"
+ # return trans.fill_template( "mobile/settings.mako", message=message )
def __logout( self, trans ):
- trans.log_event( "User logged out" )
- trans.handle_user_logout()
+ return trans.response.send_redirect( web.url_for(controller='root', action='index' ) )
+ # trans.log_event( "User logged out" )
+ # trans.handle_user_logout()
def __login( self, trans, email="", password="" ):
- error = password_error = None
- user = trans.sa_session.query( model.User ).filter_by( email = email ).first()
- if not user:
- error = "No such user (please note that login is case sensitive)"
- elif user.deleted:
- error = "This account has been marked deleted, contact your Galaxy administrator to restore the account."
- elif user.external:
- error = "This account was created for use with an external authentication method, contact your local Galaxy administrator to activate it."
- elif not user.check_password( password ):
- error = "Invalid password"
- else:
- trans.handle_user_login( user )
- trans.log_event( "User logged in" )
- return error
+ return trans.response.send_redirect( web.url_for(controller='root', action='index' ) )
+ # error = password_error = None
+ # user = trans.sa_session.query( model.User ).filter_by( email = email ).first()
+ # if not user:
+ # error = "No such user (please note that login is case sensitive)"
+ # elif user.deleted:
+ # error = "This account has been marked deleted, contact your Galaxy administrator to restore the account."
+ # elif user.external:
+ # error = "This account was created for use with an external authentication method, contact your local Galaxy administrator to activate it."
+ # elif not user.check_password( password ):
+ # error = "Invalid password"
+ # else:
+ # trans.handle_user_login( user )
+ # trans.log_event( "User logged in" )
+ # return error
https://bitbucket.org/galaxy/galaxy-central/commits/b65f60a842c1/
Changeset: b65f60a842c1
Branch: mako_escape_requests
User: martenson
Date: 2014-12-04 16:56:46+00:00
Summary: Closed branch mako_escape_requests
Affected #: 0 files
https://bitbucket.org/galaxy/galaxy-central/commits/2ee22028d4de/
Changeset: 2ee22028d4de
Branch: disable_mobile
User: martenson
Date: 2014-12-04 16:57:19+00:00
Summary: Closed branch disable_mobile
Affected #: 0 files
https://bitbucket.org/galaxy/galaxy-central/commits/8f76a6abc5d7/
Changeset: 8f76a6abc5d7
Branch: next-stable
User: martenson
Date: 2014-12-05 20:11:16+00:00
Summary: add API endpoint to un/mark library folder as deleted
Affected #: 3 files
diff -r c1d4e82df5cbf8a6d551221a0d4013d658ad4748 -r 8f76a6abc5d7d5c98b6c148c4cfe75cc1c159e90 lib/galaxy/managers/folders.py
--- a/lib/galaxy/managers/folders.py
+++ b/lib/galaxy/managers/folders.py
@@ -16,14 +16,14 @@
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 @@
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 @@
# 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 @@
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 -r c1d4e82df5cbf8a6d551221a0d4013d658ad4748 -r 8f76a6abc5d7d5c98b6c148c4cfe75cc1c159e90 lib/galaxy/model/__init__.py
--- a/lib/galaxy/model/__init__.py
+++ b/lib/galaxy/model/__init__.py
@@ -2192,7 +2192,7 @@
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 -r c1d4e82df5cbf8a6d551221a0d4013d658ad4748 -r 8f76a6abc5d7d5c98b6c148c4cfe75cc1c159e90 lib/galaxy/webapps/galaxy/api/folders.py
--- a/lib/galaxy/webapps/galaxy/api/folders.py
+++ b/lib/galaxy/webapps/galaxy/api/folders.py
@@ -44,7 +44,7 @@
: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 @@
'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 ):
"""
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
2 new commits in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/3065d710f638/
Changeset: 3065d710f638
Branch: admin_cleanup_datasets_fix
User: dannon
Date: 2014-12-05 19:23:07+00:00
Summary: Branch prune.
Affected #: 0 files
https://bitbucket.org/galaxy/galaxy-central/commits/a89b1dca8dd5/
Changeset: a89b1dca8dd5
Branch: mako_escape_requests
User: dannon
Date: 2014-12-05 19:23:15+00:00
Summary: Branch prune.
Affected #: 0 files
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0