mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Merge pull request #6134 from jmchilton/rule_fixes_8
Improve data initialization of rule builder for long term support.
This commit is contained in:
@@ -285,7 +285,7 @@
|
||||
</button>
|
||||
<div class="dropdown-menu" role="menu">
|
||||
<rule-target-component :builder="this" rule-type="add_column_basename" />
|
||||
<rule-target-component :builder="this" rule-type="add_column_metadata" v-if="elementsType == 'collection_contents'"/>
|
||||
<rule-target-component :builder="this" rule-type="add_column_metadata" v-if="metadataOptions"/>
|
||||
<rule-target-component :builder="this" rule-type="add_column_regex" />
|
||||
<rule-target-component :builder="this" rule-type="add_column_concatenate" />
|
||||
<rule-target-component :builder="this" rule-type="add_column_rownum" />
|
||||
@@ -833,6 +833,27 @@ export default {
|
||||
value: "identifier0"
|
||||
});
|
||||
}
|
||||
} else if (this.elementsType == "datasets") {
|
||||
rules.push(
|
||||
{
|
||||
type: "add_column_metadata",
|
||||
value: "hid"
|
||||
},
|
||||
{
|
||||
type: "add_column_metadata",
|
||||
value: "name"
|
||||
}
|
||||
);
|
||||
} else if (this.elementsType == "library_datasets") {
|
||||
rules.push({
|
||||
type: "add_column_metadata",
|
||||
value: "name"
|
||||
});
|
||||
} else if (this.elementsType == "ftp") {
|
||||
rules.push({
|
||||
type: "add_column_metadata",
|
||||
value: "path"
|
||||
});
|
||||
}
|
||||
}
|
||||
return {
|
||||
@@ -1061,14 +1082,14 @@ export default {
|
||||
},
|
||||
hotData() {
|
||||
let data, sources, columns;
|
||||
if (this.elementsType == "datasets") {
|
||||
data = this.initialElements.map(el => [el["hid"], el["name"]]);
|
||||
if (
|
||||
this.elementsType == "datasets" ||
|
||||
this.elementsType == "library_datasets" ||
|
||||
this.elementsType == "ftp"
|
||||
) {
|
||||
data = this.initialElements.map(el => []);
|
||||
sources = this.initialElements.slice();
|
||||
columns = ["new", "new"];
|
||||
} else if (this.elementsType == "library_datasets") {
|
||||
data = this.initialElements.map(el => [el["name"]]);
|
||||
sources = this.initialElements.slice();
|
||||
columns = ["new"];
|
||||
columns = [];
|
||||
} else if (this.elementsType == "collection_contents") {
|
||||
const collection = this.initialElements;
|
||||
if (collection) {
|
||||
@@ -1134,7 +1155,7 @@ export default {
|
||||
return asDict;
|
||||
},
|
||||
metadataOptions() {
|
||||
const metadataOptions = {};
|
||||
let metadataOptions = {};
|
||||
if (this.elementsType == "collection_contents") {
|
||||
let collectionType;
|
||||
if (this.initialElements) {
|
||||
@@ -1153,6 +1174,15 @@ export default {
|
||||
metadataOptions["identifier" + index] = _l("Paired Identifier");
|
||||
}
|
||||
}
|
||||
} else if ( this.elementsType == "ftp" ) {
|
||||
metadataOptions["path"] = _l("Path");
|
||||
} else if ( this.elementsType == "library_datasets" ) {
|
||||
metadataOptions["name"] = _l("Name");
|
||||
} else if ( this.elementsType == "datasets" ) {
|
||||
metadataOptions["hid"] = _l("History ID (hid)");
|
||||
metadataOptions["name"] = _l("Name");
|
||||
} else {
|
||||
metadataOptions = null;
|
||||
}
|
||||
return metadataOptions;
|
||||
},
|
||||
|
||||
@@ -1138,6 +1138,10 @@ function createCollectionViaRules(selection, defaultHideSourceItems) {
|
||||
elements = selection.toJSON();
|
||||
elementsType = "datasets";
|
||||
importType = "collections";
|
||||
} else if (selection.elements) {
|
||||
elementsType = selection.selectionType;
|
||||
importType = selection.dataType || "collections";
|
||||
elements = selection.elements;
|
||||
} else {
|
||||
const hasNonWhitespaceChars = RegExp(/[^\s]/);
|
||||
// Have pasted data, data from a history dataset, or FTP list.
|
||||
|
||||
@@ -166,11 +166,22 @@ const RULES = {
|
||||
},
|
||||
apply: (rule, data, sources, columns) => {
|
||||
const ruleValue = rule.value;
|
||||
const identifierIndex = parseInt(ruleValue.substring("identifier".length));
|
||||
function newRow(row, index) {
|
||||
const newRow = row.slice();
|
||||
newRow.push(sources[index]["identifiers"][identifierIndex]);
|
||||
return newRow;
|
||||
let newRow;
|
||||
if (ruleValue.startsWith("identifier")) {
|
||||
const identifierIndex = parseInt(ruleValue.substring("identifier".length));
|
||||
newRow = (row, index) => {
|
||||
const newRow = row.slice();
|
||||
newRow.push(sources[index]["identifiers"][identifierIndex]);
|
||||
return newRow;
|
||||
};
|
||||
} else if (ruleValue == "hid" || ruleValue == "name" || ruleValue == "path") {
|
||||
newRow = (row, index) => {
|
||||
const newRow = row.slice();
|
||||
newRow.push(sources[index][ruleValue]);
|
||||
return newRow;
|
||||
};
|
||||
} else {
|
||||
return { error: `Unknown metadata type [${ruleValue}}]` };
|
||||
}
|
||||
data = data.map(newRow);
|
||||
columns.push(NEW_COLUMN);
|
||||
|
||||
@@ -8,6 +8,7 @@ export default Backbone.View.extend({
|
||||
initialize: function(app) {
|
||||
this.app = app;
|
||||
this.options = app.options;
|
||||
this.ftpFiles = [];
|
||||
this.ftpUploadSite = app.currentFtp();
|
||||
this.setElement(this._template());
|
||||
this.btnBuild = new Ui.Button({
|
||||
@@ -100,6 +101,7 @@ export default Backbone.View.extend({
|
||||
} else if (selectionType == "ftp") {
|
||||
UploadUtils.getRemoteFiles(ftp_files => {
|
||||
this._setPreview(ftp_files.map(file => file["path"]).join("\n"));
|
||||
this.ftpFiles = ftp_files;
|
||||
});
|
||||
}
|
||||
this._updateScreen();
|
||||
@@ -137,13 +139,15 @@ export default Backbone.View.extend({
|
||||
|
||||
_buildSelection: function(content) {
|
||||
const selectionType = this.selectionType;
|
||||
const selection = { content: content };
|
||||
const selection = {};
|
||||
if (selectionType == "dataset" || selectionType == "paste") {
|
||||
selection.selectionType = "raw";
|
||||
selection.content = content;
|
||||
} else if (selectionType == "ftp") {
|
||||
selection.selectionType = "ftp";
|
||||
selection.elements = this.ftpFiles;
|
||||
selection.ftpUploadSite = this.ftpUploadSite;
|
||||
}
|
||||
selection.ftpUploadSite = this.ftpUploadSite;
|
||||
selection.dataType = this.dataType;
|
||||
Galaxy.currHistoryPanel.buildCollection("rules", selection, true);
|
||||
this.app.modal.hide();
|
||||
|
||||
Reference in New Issue
Block a user