Skip to content

Commit

Permalink
Add optional event handler to edit portlet title text
Browse files Browse the repository at this point in the history
  • Loading branch information
guerler committed Jan 10, 2017
1 parent 5ea926e commit 6dfc362
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 18 deletions.
15 changes: 8 additions & 7 deletions client/galaxy/scripts/mvc/form/form-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,14 @@ function( Utils, Portlet, Ui, FormSection, FormData ) {
this.message = new Ui.Message();
this.section = new FormSection.View( this, { inputs: this.options.inputs } );
this.portlet = new Portlet.View({
icon : this.options.icon,
title : this.options.title,
cls : this.options.cls,
operations : this.options.operations,
buttons : this.options.buttons,
collapsible : this.options.collapsible,
collapsed : this.options.collapsed
icon : this.options.icon,
title : this.options.title,
cls : this.options.cls,
operations : this.options.operations,
buttons : this.options.buttons,
collapsible : this.options.collapsible,
collapsed : this.options.collapsed,
onchange_title : this.options.onchange_title
});
this.portlet.append( this.message.$el );
this.portlet.append( this.section.$el );
Expand Down
10 changes: 9 additions & 1 deletion client/galaxy/scripts/mvc/ui/ui-portlet.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var View = Backbone.View.extend({
collapsible : false,
collapsible_button : false,
collapsed : false,
editable_title : false
onchange_title : null
} ).set( options );
this.setElement( this._template() );

Expand Down Expand Up @@ -67,6 +67,14 @@ var View = Backbone.View.extend({
options.collapsed ? this.collapse() : this.expand();
}

// allow title editing
this.$title_text.prop( 'disabled', !options.onchange_title );
options.onchange_title && this.$title_text.make_text_editable({
on_finish: function( new_title ) {
options.onchange_title( new_title );
}
});

// render buttons
if ( options.buttons ) {
this.$buttons.empty().show();
Expand Down
3 changes: 3 additions & 0 deletions client/galaxy/scripts/mvc/workflow/workflow-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,9 @@ define([
form = new ToolForm.View( options );
} else {
content.cls = 'ui-portlet-narrow';
content.onchange_title = function( new_title ) {
alert( new_title );
};
if ( content.inputs && content.inputs.length > 0 ) {
content.inputs.unshift({
type : 'text',
Expand Down
2 changes: 1 addition & 1 deletion static/maps/mvc/form/form-view.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion static/maps/mvc/ui/ui-portlet.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion static/maps/mvc/workflow/workflow-view.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions static/scripts/bundled/analysis.bundled.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion static/scripts/bundled/analysis.bundled.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion static/scripts/bundled/libs.bundled.js.map

Large diffs are not rendered by default.

0 comments on commit 6dfc362

Please sign in to comment.