More bundling, always bundling.

This commit is contained in:
Dannon Baker
2017-12-12 16:18:11 -05:00
parent 30f98eac21
commit 993c0b7341
2 changed files with 80 additions and 85 deletions
+5 -1
View File
@@ -15,6 +15,7 @@ import HistoryContents from "mvc/history/history-contents";
import MultiPanel from "mvc/history/multi-panel";
import HistoryView from "mvc/history/history-view";
import HistoryViewEdit from "mvc/history/history-view-edit";
import HistoryViewAnnotated from "mvc/history/history-view-annotated";
import HistoryCopyDialog from "mvc/history/copy-dialog";
import addLogging from "utils/add-logging";
@@ -171,7 +172,10 @@ export const bundleEntries = {
multiHistory: multiHistoryEntry,
history: historyEntry,
History: History.History,
HistoryContents: HistoryContents.HistoryContents
HistoryContents: HistoryContents.HistoryContents,
HistoryCopyDialog,
HistoryViewAnnotated
};
console.debug(bundleEntries);
window.bundleEntries = bundleEntries;
+75 -84
View File
@@ -40,96 +40,87 @@
// In order to handle this, find this script and cache the previous node (the div above).
// (Since we need thisScript to be locally scoped or it will get overwritten, enclose in self-calling function)
(function(){
var scripts = document.getElementsByTagName( 'script' ),
var scripts = document.getElementsByTagName( 'script' );
// this is executed immediately, so the last script will be this script
thisScript = scripts[ scripts.length - 1 ],
$embeddedHistory = $( thisScript ).prev();
var thisScript = scripts[ scripts.length - 1 ];
var $embeddedHistory = $( thisScript ).prev();
require.config({
baseUrl: "${h.url_for( '/static/scripts' )}",
urlArgs: 'v=${app.server_starttime}'
});
require([
'mvc/history/history-view-annotated',
'mvc/history/copy-dialog'
], function( viewMod, historyCopyDialog ){
var $embeddedHistory = $( thisScript ).prev();
$embeddedHistory.find( '.item-content' ).addClass( 'flex-vertical-container' );
var $embeddedHistory = $( thisScript ).prev();
$embeddedHistory.find( '.item-content' ).addClass( 'flex-vertical-container' );
$(function(){
var HistoryContentsWithAnnotations = window.bundleEntries.HistoryContents.extend({
_buildFetchData : function( options ){
console.log( '_buildFetchData:' );
options = options || {};
if( !options.keys && !options.view ){
options.view = 'summary';
options.keys = 'annotation,tags';
}
return window.bundleEntries.HistoryContents.prototype._buildFetchData.call( this, options );
$(function(){
var HistoryContentsWithAnnotations = window.bundleEntries.HistoryContents.extend({
_buildFetchData : function( options ){
console.log( '_buildFetchData:' );
options = options || {};
if( !options.keys && !options.view ){
options.view = 'summary';
options.keys = 'annotation,tags';
}
return window.bundleEntries.HistoryContents.prototype._buildFetchData.call( this, options );
}
});
var HistoryWithAnnotations = window.bundleEntries.History.extend({
contentsClass : HistoryContentsWithAnnotations
});
var historyJSON = ${h.dumps( history_dict )};
var historyModel = new HistoryWithAnnotations( historyJSON, null, {
order : 'hid-asc',
});
var historyView = new window.bundleEntries.HistoryViewAnnotated.AnnotatedHistoryView({
el : $embeddedHistory.find( ".history-panel" ),
className : window.bundleEntries.HistoryViewAnnotated.AnnotatedHistoryView.prototype.className + ' wide',
model : historyModel
});
historyView.trigger( 'loading' );
historyModel.fetchContents({ silent: true })
.fail( function(){ alert( 'Galaxy history failed to load' ); })
.done( function(){
historyView.trigger( 'loading-done' );
historyView.render();
});
function toggleExpanded( ev ){
ev.preventDefault();
$embeddedHistory.find( '.expand-content-btn' ).toggleClass( 'toggle-expand' ).toggleClass( 'toggle' );
$embeddedHistory.find( ".summary-content" ).slideToggle( "fast" );
$embeddedHistory.find( ".annotation" ).slideToggle( "fast" );
$embeddedHistory.find( ".expanded-content" ).slideToggle( "fast" );
}
$embeddedHistory.find( '.expand-content-btn' ).click( toggleExpanded );
$embeddedHistory.find( '.toggle-embed' ).click( toggleExpanded );
function showConfirmationModal( name ){
var body = [
'<div class="donemessagelarge">',
_l( 'History imported' ), ': ', _.escape( historyModel.get( 'name' ) ),
'</div>'
].join('');
Galaxy.modal.show({
title : _l( 'Success!' ),
body : $( body ),
buttons : {
'Return to the published page' : function(){
Galaxy.modal.hide();
},
'Start using the history' : function(){
window.location = Galaxy.root;
},
}
});
var HistoryWithAnnotations = window.bundleEntries.History.extend({
contentsClass : HistoryContentsWithAnnotations
});
Galaxy.modal.$( '.modal-header' ).hide();
Galaxy.modal.$( '.modal-body' ).css( 'padding-bottom', 0 );
Galaxy.modal.$( '.modal-footer' ).css({ border : 0, 'padding-top': 0 });
}
var historyJSON = ${h.dumps( history_dict )};
var historyModel = new HistoryWithAnnotations( historyJSON, null, {
order : 'hid-asc',
});
var historyView = new viewMod.default.AnnotatedHistoryView({
el : $embeddedHistory.find( ".history-panel" ),
className : viewMod.default.AnnotatedHistoryView.prototype.className + ' wide',
model : historyModel
});
historyView.trigger( 'loading' );
historyModel.fetchContents({ silent: true })
.fail( function(){ alert( 'Galaxy history failed to load' ); })
.done( function(){
historyView.trigger( 'loading-done' );
historyView.render();
});
function toggleExpanded( ev ){
ev.preventDefault();
$embeddedHistory.find( '.expand-content-btn' ).toggleClass( 'toggle-expand' ).toggleClass( 'toggle' );
$embeddedHistory.find( ".summary-content" ).slideToggle( "fast" );
$embeddedHistory.find( ".annotation" ).slideToggle( "fast" );
$embeddedHistory.find( ".expanded-content" ).slideToggle( "fast" );
}
$embeddedHistory.find( '.expand-content-btn' ).click( toggleExpanded );
$embeddedHistory.find( '.toggle-embed' ).click( toggleExpanded );
function showConfirmationModal( name ){
var body = [
'<div class="donemessagelarge">',
_l( 'History imported' ), ': ', _.escape( historyModel.get( 'name' ) ),
'</div>'
].join('');
Galaxy.modal.show({
title : _l( 'Success!' ),
body : $( body ),
buttons : {
'Return to the published page' : function(){
Galaxy.modal.hide();
},
'Start using the history' : function(){
window.location = Galaxy.root;
},
}
});
Galaxy.modal.$( '.modal-header' ).hide();
Galaxy.modal.$( '.modal-body' ).css( 'padding-bottom', 0 );
Galaxy.modal.$( '.modal-footer' ).css({ border : 0, 'padding-top': 0 });
}
$embeddedHistory.find( '.import' ).click( function( ev ){
var dialogOptions = { useImport: true, allowAll: false, autoClose: false };
historyCopyDialog.default( historyModel, dialogOptions ).done( showConfirmationModal );
})
});
$embeddedHistory.find( '.import' ).click( function( ev ){
var dialogOptions = { useImport: true, allowAll: false, autoClose: false };
window.bundleEntries.HistoryCopyDialog( historyModel, dialogOptions ).done( showConfirmationModal );
})
});
})();
</script>