mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
@@ -25,16 +25,15 @@ export default {
|
||||
},
|
||||
|
||||
// template
|
||||
grid_table: function(options) {
|
||||
return (
|
||||
'<form method="post" onsubmit="return false;">' +
|
||||
'<table id="grid-table" class="grid">' +
|
||||
'<thead id="grid-table-header"></thead>' +
|
||||
'<tbody id="grid-table-body"></tbody>' +
|
||||
'<tfoot id="grid-table-footer"></tfoot>' +
|
||||
"</table>" +
|
||||
"</form>"
|
||||
);
|
||||
grid_table: function() {
|
||||
return `
|
||||
<form method="post" onsubmit="return false;">
|
||||
<table id="grid-table" class="grid">
|
||||
<thead id="grid-table-header"></thead>
|
||||
<tbody id="grid-table-body"></tbody>
|
||||
<tfoot id="grid-table-footer"></tfoot>
|
||||
</table>
|
||||
</form>`;
|
||||
},
|
||||
|
||||
// template
|
||||
@@ -51,8 +50,7 @@ export default {
|
||||
'<li><a class="action-button" id="popup-global-actions" class="menubutton">Actions</a></li>' +
|
||||
'<div popupmenu="popup-global-actions">';
|
||||
}
|
||||
for (var i in options.global_actions) {
|
||||
var action = options.global_actions[i];
|
||||
for (let action of options.global_actions) {
|
||||
tmpl += `<li><a class="action-button use-target" target="${action.target}" href="${
|
||||
action.url_args
|
||||
}" onclick="return false;" >${action.label}</a></li>`;
|
||||
@@ -91,8 +89,7 @@ export default {
|
||||
}
|
||||
|
||||
// create header elements
|
||||
for (var i in options.columns) {
|
||||
var column = options.columns[i];
|
||||
for (let column of options.columns) {
|
||||
if (column.visible) {
|
||||
tmpl += `<th id="${column.key}-header">`;
|
||||
if (column.href) {
|
||||
@@ -119,19 +116,14 @@ export default {
|
||||
var items_length = options.items.length;
|
||||
|
||||
// empty grid?
|
||||
if (items_length == 0) {
|
||||
if (items_length === 0) {
|
||||
// No results.
|
||||
tmpl += '<tr><td colspan="100"><em>No Items</em></td></tr>';
|
||||
num_rows_rendered = 1;
|
||||
}
|
||||
|
||||
// create rows
|
||||
for (var i in options.items) {
|
||||
// encode ids
|
||||
var item = options.items[i];
|
||||
var encoded_id = item.encode_id;
|
||||
var popupmenu_id = `grid-${i}-popup`;
|
||||
|
||||
for (let item of options.items) {
|
||||
// Tag current
|
||||
tmpl += "<tr ";
|
||||
if (options.current_item_id == item.id) {
|
||||
@@ -141,14 +133,13 @@ export default {
|
||||
|
||||
// Item selection column
|
||||
if (options.show_item_checkboxes) {
|
||||
tmpl += `<td style="width: 1.5em;"><input type="checkbox" name="id" value="${encoded_id}" id="${
|
||||
encoded_id
|
||||
tmpl += `<td style="width: 1.5em;"><input type="checkbox" name="id" value="${item.encode_id}" id="${
|
||||
item.encode_id
|
||||
}" class="grid-row-select-checkbox" /></td>`;
|
||||
}
|
||||
|
||||
// Data columns
|
||||
for (var j in options.columns) {
|
||||
var column = options.columns[j];
|
||||
for (let column of options.columns) {
|
||||
if (column.visible) {
|
||||
// Nowrap
|
||||
var nowrap = "";
|
||||
@@ -173,9 +164,9 @@ export default {
|
||||
var id = "";
|
||||
var cls = "";
|
||||
if (column.attach_popup) {
|
||||
id = `grid-${i}-popup`;
|
||||
id = `grid-${item.encode_id}-popup`;
|
||||
cls = "menubutton";
|
||||
if (link != "") {
|
||||
if (link !== "") {
|
||||
cls += " split";
|
||||
}
|
||||
cls += " popup";
|
||||
@@ -186,19 +177,19 @@ export default {
|
||||
|
||||
// Link
|
||||
if (link) {
|
||||
if (options.operations.length != 0) {
|
||||
if (options.operations.length !== 0) {
|
||||
tmpl += `<div id="${id}" class="${cls}" style="float: left;">`;
|
||||
}
|
||||
tmpl += `<a class="menubutton-label use-target" target="${target}" href="${
|
||||
link
|
||||
}" onclick="return false;">${value}</a>`;
|
||||
if (options.operations.length != 0) {
|
||||
if (options.operations.length !== 0) {
|
||||
tmpl += "</div>";
|
||||
}
|
||||
} else {
|
||||
tmpl += `<div id="${id}" class="${cls}"><label id="${column.label_id_prefix}${
|
||||
encoded_id
|
||||
}" for="${encoded_id}">${value || ""}</label></div>`;
|
||||
item.encode_id
|
||||
}" for="${item.encode_id}">${value || ""}</label></div>`;
|
||||
}
|
||||
tmpl += "</td>";
|
||||
}
|
||||
@@ -247,7 +238,7 @@ export default {
|
||||
|
||||
// Second and final pass on min page to add any unused
|
||||
// offset from max to min.
|
||||
if (max_offset != 0) {
|
||||
if (max_offset !== 0) {
|
||||
min_page -= max_offset;
|
||||
if (min_page < 1) {
|
||||
min_page = 1;
|
||||
@@ -290,25 +281,25 @@ export default {
|
||||
tmpl += "</span>";
|
||||
|
||||
// Show all link
|
||||
tmpl +=
|
||||
'<span class="page-link" id="show-all-link-span"> | <a href="javascript:void(0);" onclick="return false;" page_num="all">Show All</a></span>' +
|
||||
"</td>" +
|
||||
"</tr>";
|
||||
tmpl += `
|
||||
<span class="page-link" id="show-all-link-span"> | <a href="javascript:void(0);" onclick="return false;" page_num="all">Show All</a></span>
|
||||
</td>
|
||||
</tr>`;
|
||||
}
|
||||
|
||||
// Grid operations for multiple items.
|
||||
if (options.show_item_checkboxes) {
|
||||
// start template
|
||||
tmpl +=
|
||||
"<tr>" +
|
||||
'<input type="hidden" id="operation" name="operation" value="">' +
|
||||
"<td></td>" +
|
||||
'<td colspan="100">' +
|
||||
'For <span class="grid-selected-count"></span> selected items: ';
|
||||
tmpl += `
|
||||
<tr>
|
||||
<input type="hidden" id="operation" name="operation" value="">
|
||||
<td></td>
|
||||
<td colspan="100">
|
||||
For <span class="grid-selected-count"></span> selected items:
|
||||
`;
|
||||
|
||||
// configure buttons for operations
|
||||
for (var i in options.operations) {
|
||||
var operation = options.operations[i];
|
||||
for (let operation of options.operations) {
|
||||
if (operation.allow_multiple) {
|
||||
tmpl += `<input type="button" value="${
|
||||
operation.label
|
||||
@@ -322,8 +313,8 @@ export default {
|
||||
|
||||
// count global operations
|
||||
var found_global = false;
|
||||
for (i in options.operations) {
|
||||
if (options.operations[i].global_operation) {
|
||||
for (let operation of options.operations) {
|
||||
if (operation.global_operation) {
|
||||
found_global = true;
|
||||
break;
|
||||
}
|
||||
@@ -332,8 +323,7 @@ export default {
|
||||
// add global operations
|
||||
if (found_global) {
|
||||
tmpl += "<tr>" + '<td colspan="100">';
|
||||
for (i in options.operations) {
|
||||
var operation = options.operations[i];
|
||||
for (let operation of options.operations) {
|
||||
if (operation.global_operation) {
|
||||
tmpl += `<a class="action-button" href="${operation.global_operation}">${operation.label}</a>`;
|
||||
}
|
||||
@@ -375,8 +365,7 @@ export default {
|
||||
|
||||
// identify columns with advanced filtering
|
||||
var show_advanced_search_link = false;
|
||||
for (var i in options.columns) {
|
||||
var column = options.columns[i];
|
||||
for (let column of options.columns) {
|
||||
if (column.filterable == "advanced") {
|
||||
var column_key = column.key;
|
||||
var f_key = filters[column_key];
|
||||
@@ -402,8 +391,7 @@ export default {
|
||||
};"><table><tr><td style="padding: 0;"><table>`;
|
||||
|
||||
// add standard filters
|
||||
for (var i in options.columns) {
|
||||
var column = options.columns[i];
|
||||
for (let column of options.columns) {
|
||||
if (column.filterable == "standard") {
|
||||
tmpl += this.grid_column_filter(options, column);
|
||||
}
|
||||
@@ -428,8 +416,7 @@ export default {
|
||||
}; margin-top: 5px; border: 1px solid #ccc;"><table><tr><td style="text-align: left" colspan="100"><a href="" class="advanced-search-toggle">Close Advanced Search</a></td></tr>`;
|
||||
|
||||
// add advanced filters
|
||||
for (var i in options.columns) {
|
||||
var column = options.columns[i];
|
||||
for (let column of options.columns) {
|
||||
if (column.filterable == "advanced") {
|
||||
tmpl += this.grid_column_filter(options, column);
|
||||
}
|
||||
@@ -445,7 +432,6 @@ export default {
|
||||
// template
|
||||
grid_column_filter: function(options, column) {
|
||||
// collect parameters
|
||||
var default_filter_dict = options.default_filter_dict;
|
||||
var filters = options.filters;
|
||||
var column_label = column.label;
|
||||
var column_key = column.key;
|
||||
@@ -463,15 +449,14 @@ export default {
|
||||
if (column.is_text) {
|
||||
tmpl += `<form class="text-filter-form" column_key="${column_key}" action="${options.url}" method="get" >`;
|
||||
// Carry forward filtering criteria with hidden inputs.
|
||||
for (i in options.columns) {
|
||||
var temp_column = options.columns[i];
|
||||
var filter_value = filters[temp_column.key];
|
||||
for (let column of options.columns) {
|
||||
var filter_value = filters[column.key];
|
||||
if (filter_value) {
|
||||
if (filter_value != "All") {
|
||||
if (temp_column.is_text) {
|
||||
if (column.is_text) {
|
||||
filter_value = JSON.stringify(filter_value);
|
||||
}
|
||||
tmpl += `<input type="hidden" id="${temp_column.key}" name="f-${temp_column.key}" value="${
|
||||
tmpl += `<input type="hidden" id="${column.key}" name="f-${column.key}" value="${
|
||||
filter_value
|
||||
}"/>`;
|
||||
}
|
||||
@@ -496,16 +481,13 @@ export default {
|
||||
|
||||
// multiple filter values
|
||||
if (type == "array") {
|
||||
for (var i in column_filter) {
|
||||
// get filter
|
||||
var filter = column_filter[i];
|
||||
|
||||
for (let i in column_filter) {
|
||||
// copy filters and remove entry
|
||||
var params = column_filter;
|
||||
params = params.slice(i);
|
||||
|
||||
// append template
|
||||
tmpl += this.filter_element(column_key, filter);
|
||||
tmpl += this.filter_element(column_key, column_filter[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -515,22 +497,27 @@ export default {
|
||||
|
||||
// Set value, size of search input field. Minimum size is 20 characters.
|
||||
var value = "";
|
||||
var size = 20;
|
||||
if (column.filterable == "standard") {
|
||||
value = column.label.toLowerCase();
|
||||
var size = value.length;
|
||||
if (size < 20) {
|
||||
size = 20;
|
||||
if (value.length < 20) {
|
||||
size = value.length;
|
||||
}
|
||||
// +4 to account for space after placeholder
|
||||
size = size + 4;
|
||||
}
|
||||
|
||||
// print input field for column
|
||||
tmpl += `<span class="search-box"><input class="search-box-input" id="input-${column_key}-filter" name="f-${
|
||||
tmpl += `
|
||||
<span class="search-box">
|
||||
<input class="search-box-input" id="input-${column_key}-filter" name="f-${
|
||||
column_key
|
||||
}" type="text" placeholder="${value}" size="${
|
||||
size
|
||||
}"/><button type="submit" style="background: transparent; border: none; padding: 4px; margin: 0px;"><i class="fa fa-search"></i></button></span></form>`;
|
||||
}" type="text" placeholder="${value}" size="${size}"/>
|
||||
<button type="submit" style="background: transparent; border: none; padding: 4px; margin: 0px;">
|
||||
<i class="fa fa-search"></i>
|
||||
</button>
|
||||
</span>
|
||||
</form>`;
|
||||
} else {
|
||||
// filter criteria
|
||||
tmpl += `<span id="${column_key}-filtering-criteria">`;
|
||||
|
||||
@@ -116,7 +116,9 @@ export default Backbone.View.extend({
|
||||
|
||||
// attach global event handler
|
||||
// TODO: redundant (the onload/standard page handlers do this) - but needed because these are constructed after page ready
|
||||
init_refresh_on_change();
|
||||
if (window.init_refresh_on_change) {
|
||||
window.init_refresh_on_change();
|
||||
}
|
||||
},
|
||||
|
||||
// Initialize grid controls
|
||||
@@ -247,7 +249,7 @@ export default Backbone.View.extend({
|
||||
// add inbound/outbound events
|
||||
//
|
||||
this.$el.find(".use-target").each(function() {
|
||||
$(this).click(function(e) {
|
||||
$(this).click(function() {
|
||||
self.execute({
|
||||
href: $(this).attr("href"),
|
||||
target: $(this).attr("target")
|
||||
@@ -258,15 +260,15 @@ export default Backbone.View.extend({
|
||||
|
||||
// empty grid?
|
||||
var items_length = options.items.length;
|
||||
if (items_length == 0) {
|
||||
if (items_length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// add operation popup menus
|
||||
_.each(options.items, (item, index) => {
|
||||
var button = self.$(`#grid-${index}-popup`).off();
|
||||
var button = self.$(`#grid-${item.encode_id}-popup`).off();
|
||||
var popup = new PopupMenu(button);
|
||||
_.each(options["operations"], operation => {
|
||||
_.each(options.operations, operation => {
|
||||
self._add_operation(popup, operation, item);
|
||||
});
|
||||
});
|
||||
@@ -448,9 +450,9 @@ export default Backbone.View.extend({
|
||||
// identify operation
|
||||
var operation_name = $(operation_button).val();
|
||||
|
||||
// verify in any item is selected
|
||||
// verify any item is selected
|
||||
var number_of_checked_ids = this.$el.find('input[name="id"]:checked').length;
|
||||
if (!number_of_checked_ids > 0) {
|
||||
if (number_of_checked_ids < 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -548,7 +550,7 @@ export default Backbone.View.extend({
|
||||
// show confirmation box
|
||||
if (
|
||||
confirmation_text &&
|
||||
confirmation_text != "" &&
|
||||
confirmation_text !== "" &&
|
||||
confirmation_text != "None" &&
|
||||
confirmation_text != "null"
|
||||
)
|
||||
@@ -640,7 +642,7 @@ export default Backbone.View.extend({
|
||||
type: method,
|
||||
url: self.grid.get("url_base"),
|
||||
data: self.grid.get_url_data(),
|
||||
error: function(response) {
|
||||
error: function() {
|
||||
alert("Grid refresh failed");
|
||||
},
|
||||
success: function(response_text) {
|
||||
|
||||
@@ -4,34 +4,8 @@ import Utils from "utils/utils";
|
||||
import GridView from "mvc/grid/grid-view";
|
||||
import HistoryModel from "mvc/history/history-model";
|
||||
import historyCopyDialog from "mvc/history/copy-dialog";
|
||||
var View = Backbone.View.extend({
|
||||
title: _l("Histories"),
|
||||
initialize: function(options) {
|
||||
var self = this;
|
||||
this.setElement($("<div/>"));
|
||||
this.model = new Backbone.Model();
|
||||
Utils.get({
|
||||
url: `${Galaxy.root}history/${options.action_id}?${$.param(Galaxy.params)}`,
|
||||
success: function(response) {
|
||||
response["dict_format"] = true;
|
||||
_.each(response["operations"], operation => {
|
||||
if (operation.label == "Copy") {
|
||||
operation.onclick = id => {
|
||||
self._showCopyDialog(id);
|
||||
};
|
||||
}
|
||||
});
|
||||
self.model.set(response);
|
||||
self.render();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
render: function() {
|
||||
var grid = new GridView(this.model.attributes);
|
||||
this.$el.empty().append(grid.$el);
|
||||
},
|
||||
|
||||
var HistoryGridView = GridView.extend({
|
||||
_showCopyDialog: function(id) {
|
||||
var history = new HistoryModel.History({ id: id });
|
||||
history
|
||||
@@ -47,6 +21,55 @@ var View = Backbone.View.extend({
|
||||
window.location.reload(true);
|
||||
});
|
||||
});
|
||||
},
|
||||
/** Add an operation to the items menu */
|
||||
_add_operation: function(popup, operation, item) {
|
||||
var self = this;
|
||||
var settings = item.operation_config[operation.label];
|
||||
if (operation.label == "Copy") {
|
||||
operation.onclick = id => {
|
||||
self._showCopyDialog(id);
|
||||
};
|
||||
}
|
||||
if (settings.allowed && operation.allow_popup) {
|
||||
popup.addItem({
|
||||
html: operation.label,
|
||||
href: settings.url_args,
|
||||
target: settings.target,
|
||||
confirmation_text: operation.confirm,
|
||||
func: function(e) {
|
||||
e.preventDefault();
|
||||
var label = $(e.target).html();
|
||||
if (operation.onclick) {
|
||||
operation.onclick(item.encode_id);
|
||||
} else {
|
||||
self.execute(this.findItemByHtml(label));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var View = Backbone.View.extend({
|
||||
title: _l("Histories"),
|
||||
initialize: function(options) {
|
||||
var self = this;
|
||||
this.setElement($("<div/>"));
|
||||
this.model = new Backbone.Model();
|
||||
Utils.get({
|
||||
url: `${Galaxy.root}history/${options.action_id}?${$.param(Galaxy.params)}`,
|
||||
success: function(response) {
|
||||
response.dict_format = true;
|
||||
self.model.set(response);
|
||||
self.render();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
render: function() {
|
||||
var grid = new HistoryGridView(this.model.attributes);
|
||||
this.$el.empty().append(grid.$el);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
|
||||
define("mvc/history/history-list",["exports","utils/localization","utils/utils","mvc/grid/grid-view","mvc/history/history-model","mvc/history/copy-dialog"],function(t,e,i,o,n,a){"use strict";function r(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(t,"__esModule",{value:!0});var l=r(e),d=r(i),s=r(o),c=r(n),u=r(a),f=Backbone.View.extend({title:(0,l.default)("Histories"),initialize:function(t){var e=this;this.setElement($("<div/>")),this.model=new Backbone.Model,d.default.get({url:Galaxy.root+"history/"+t.action_id+"?"+$.param(Galaxy.params),success:function(t){t.dict_format=!0,_.each(t.operations,function(t){"Copy"==t.label&&(t.onclick=function(t){e._showCopyDialog(t)})}),e.model.set(t),e.render()}})},render:function(){var t=new s.default(this.model.attributes);this.$el.empty().append(t.$el)},_showCopyDialog:function(t){var e=new c.default.History({id:t});e.fetch().fail(function(){alert("History could not be fetched. Please contact an administrator")}).done(function(){(0,u.default)(e,{}).done(function(){window.parent&&window.parent.Galaxy&&window.parent.Galaxy.currHistoryPanel&&window.parent.Galaxy.currHistoryPanel.loadCurrentHistory(),window.location.reload(!0)})})}});t.default={View:f}});
|
||||
define("mvc/history/history-list",["exports","utils/localization","utils/utils","mvc/grid/grid-view","mvc/history/history-model","mvc/history/copy-dialog"],function(t,e,i,o,n,a){"use strict";function l(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(t,"__esModule",{value:!0});var r=l(e),d=l(i),c=l(o),s=l(n),u=l(a),f=c.default.extend({_showCopyDialog:function(t){var e=new s.default.History({id:t});e.fetch().fail(function(){alert("History could not be fetched. Please contact an administrator")}).done(function(){(0,u.default)(e,{}).done(function(){window.parent&&window.parent.Galaxy&&window.parent.Galaxy.currHistoryPanel&&window.parent.Galaxy.currHistoryPanel.loadCurrentHistory(),window.location.reload(!0)})})},_add_operation:function(t,e,i){var o=this,n=i.operation_config[e.label];"Copy"==e.label&&(e.onclick=function(t){o._showCopyDialog(t)}),n.allowed&&e.allow_popup&&t.addItem({html:e.label,href:n.url_args,target:n.target,confirmation_text:e.confirm,func:function(t){t.preventDefault();var n=$(t.target).html();e.onclick?e.onclick(i.encode_id):o.execute(this.findItemByHtml(n))}})}}),y=Backbone.View.extend({title:(0,r.default)("Histories"),initialize:function(t){var e=this;this.setElement($("<div/>")),this.model=new Backbone.Model,d.default.get({url:Galaxy.root+"history/"+t.action_id+"?"+$.param(Galaxy.params),success:function(t){t.dict_format=!0,e.model.set(t),e.render()}})},render:function(){var t=new f(this.model.attributes);this.$el.empty().append(t.$el)}});t.default={View:y}});
|
||||
Reference in New Issue
Block a user