PageRenderTime 66ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/client/galaxy/scripts/mvc/history/hdca-li.js

https://bitbucket.org/remy_d1/galaxy-central-manageapi
JavaScript | 79 lines | 52 code | 10 blank | 17 comment | 1 complexity | 86342307384a4da5a043c8f2685bb14b MD5 | raw file
Possible License(s): CC-BY-3.0
  1. define([
  2. "mvc/dataset/states",
  3. "mvc/collection/collection-li",
  4. "mvc/collection/collection-panel",
  5. "mvc/base-mvc",
  6. "utils/localization"
  7. ], function( STATES, DC_LI, DC_PANEL, BASE_MVC, _l ){
  8. /* global Backbone */
  9. //==============================================================================
  10. var _super = DC_LI.DCListItemView;
  11. /** @class Read only view for HistoryDatasetCollectionAssociation (a dataset collection inside a history).
  12. */
  13. var HDCAListItemView = _super.extend(
  14. /** @lends HDCAListItemView.prototype */{
  15. /** logger used to record this.log messages, commonly set to console */
  16. //logger : console,
  17. className : _super.prototype.className + " history-content",
  18. _getFoldoutPanelClass : function(){
  19. switch( this.model.get( 'collection_type' ) ){
  20. case 'list':
  21. return DC_PANEL.ListCollectionPanel;
  22. case 'paired':
  23. return DC_PANEL.PairCollectionPanel;
  24. case 'list:paired':
  25. return DC_PANEL.ListOfPairsCollectionPanel;
  26. }
  27. throw new TypeError( 'Uknown collection_type: ' + this.model.get( 'collection_type' ) );
  28. },
  29. /** In this override, add the state as a class for use with state-based CSS */
  30. _swapNewRender : function( $newRender ){
  31. _super.prototype._swapNewRender.call( this, $newRender );
  32. //TODO: model currently has no state
  33. var state = this.model.get( 'state' ) || STATES.OK;
  34. //if( this.model.has( 'state' ) ){
  35. this.$el.addClass( 'state-' + state );
  36. //}
  37. return this.$el;
  38. },
  39. // ......................................................................... misc
  40. /** String representation */
  41. toString : function(){
  42. var modelString = ( this.model )?( this.model + '' ):( '(no model)' );
  43. return 'HDCAListItemView(' + modelString + ')';
  44. }
  45. });
  46. /** underscore templates */
  47. HDCAListItemView.prototype.templates = (function(){
  48. // could steal this from hda-base (or use mixed content)
  49. var titleBarTemplate = BASE_MVC.wrapTemplate([
  50. // adding the hid display to the title
  51. '<div class="title-bar clear" tabindex="0">',
  52. '<span class="state-icon"></span>',
  53. '<div class="title">',
  54. //TODO: remove whitespace and use margin-right
  55. '<span class="hid"><%- collection.hid %></span> ',
  56. '<span class="name"><%- collection.name %></span>',
  57. '</div>',
  58. '<div class="subtitle"></div>',
  59. '</div>'
  60. ], 'collection' );
  61. return _.extend( {}, _super.prototype.templates, {
  62. titleBar : titleBarTemplate
  63. });
  64. }());
  65. //==============================================================================
  66. return {
  67. HDCAListItemView : HDCAListItemView
  68. };
  69. });