mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Improve consistency of collection builder handling
This commit is contained in:
@@ -26,7 +26,7 @@ function listCollectionCreatorModal(elements, options) {
|
||||
/** Use a modal to create a list collection, then add it to the given history contents.
|
||||
* @returns {Promise} resolved when the collection is added to the history.
|
||||
*/
|
||||
function createListCollection(contents, defaultHideSourceItems) {
|
||||
function createListCollection(contents, defaultHideSourceItems = true) {
|
||||
const elements = contents.toJSON();
|
||||
let copyElements;
|
||||
const promise = listCollectionCreatorModal(elements, {
|
||||
|
||||
@@ -22,7 +22,7 @@ function pairCollectionCreatorModal(elements, options) {
|
||||
return promise;
|
||||
});
|
||||
}
|
||||
function createPairCollection(contents, defaultHideSourceItems) {
|
||||
function createPairCollection(contents, defaultHideSourceItems = true) {
|
||||
var elements = contents.toJSON();
|
||||
var copyElements;
|
||||
var promise = pairCollectionCreatorModal(elements, {
|
||||
|
||||
@@ -42,7 +42,7 @@ function ruleBasedCollectionCreatorModal(elements, elementsType, importType, opt
|
||||
}
|
||||
);
|
||||
}
|
||||
function createCollectionViaRules(selection, defaultHideSourceItems) {
|
||||
function createCollectionViaRules(selection, defaultHideSourceItems = true) {
|
||||
let elements;
|
||||
let elementsType;
|
||||
let importType;
|
||||
|
||||
@@ -61,7 +61,7 @@ export class HistoryPanelProxy {
|
||||
this.model.id = historyId;
|
||||
store.dispatch("history/setCurrentHistory", historyId);
|
||||
}
|
||||
async buildCollection(collectionType, selection, hideSourceItems, fromRulesInput = false, historyId = null) {
|
||||
async buildCollection(collectionType, historyId, selection, fromRulesInput = false) {
|
||||
let selectionContent = null;
|
||||
historyId = historyId || this.model.id;
|
||||
if (fromRulesInput) {
|
||||
@@ -72,13 +72,7 @@ export class HistoryPanelProxy {
|
||||
selectionContent.set(obj.id, obj);
|
||||
});
|
||||
}
|
||||
const modalResult = await buildCollectionModal(
|
||||
collectionType,
|
||||
historyId,
|
||||
selectionContent,
|
||||
hideSourceItems,
|
||||
fromRulesInput
|
||||
);
|
||||
const modalResult = await buildCollectionModal(collectionType, historyId, selectionContent, fromRulesInput);
|
||||
if (modalResult) {
|
||||
console.debug("Submitting collection build request.", modalResult);
|
||||
await createDatasetCollection({ id: historyId }, modalResult);
|
||||
|
||||
@@ -15,13 +15,7 @@ import LIST_OF_PAIRS_COLLECTION_CREATOR from "components/Collections/PairedListC
|
||||
import RULE_BASED_COLLECTION_CREATOR from "components/Collections/RuleBasedCollectionCreatorModal";
|
||||
|
||||
// stand-in for buildCollection from history-view-edit.js
|
||||
export async function buildCollectionModal(
|
||||
collectionType,
|
||||
history_id,
|
||||
selectedContent,
|
||||
hideSourceItems = true,
|
||||
fromRulesInput = false
|
||||
) {
|
||||
export async function buildCollectionModal(collectionType, historyId, selectedContent, fromRulesInput = false) {
|
||||
// select legacy function
|
||||
let createFunc;
|
||||
if (collectionType == "list") {
|
||||
@@ -37,10 +31,10 @@ export async function buildCollectionModal(
|
||||
}
|
||||
// pull up cached content by type_ids;
|
||||
if (fromRulesInput) {
|
||||
return await createFunc(selectedContent, hideSourceItems);
|
||||
return await createFunc(selectedContent);
|
||||
} else {
|
||||
const fakeBackboneContent = createBackboneContent(history_id, selectedContent);
|
||||
return await createFunc(fakeBackboneContent, hideSourceItems);
|
||||
const fakeBackboneContent = createBackboneContent(historyId, selectedContent);
|
||||
return await createFunc(fakeBackboneContent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -110,7 +110,7 @@ var ImportCollectionModal = Backbone.View.extend({
|
||||
models: collectionElements,
|
||||
};
|
||||
const Galaxy = getGalaxyInstance();
|
||||
Galaxy.currHistoryPanel.buildCollection(this.collectionType, selection, true, historyId);
|
||||
Galaxy.currHistoryPanel.buildCollection(this.collectionType, historyId, selection);
|
||||
},
|
||||
templateCollectionSelectModal: function () {
|
||||
return _.template(
|
||||
|
||||
@@ -273,7 +273,7 @@ export default {
|
||||
models: Object.values(models),
|
||||
historyId: Galaxy.currHistoryPanel.model.id,
|
||||
};
|
||||
Galaxy.currHistoryPanel.buildCollection(this.collectionType, selection, true);
|
||||
Galaxy.currHistoryPanel.buildCollection(this.collectionType, null, selection);
|
||||
this.counterRunning = 0;
|
||||
this._updateStateForCounters();
|
||||
this._eventReset();
|
||||
|
||||
@@ -200,7 +200,7 @@ export default {
|
||||
selection.elements = this.uris;
|
||||
}
|
||||
selection.dataType = this.dataType;
|
||||
Galaxy.currHistoryPanel.buildCollection("rules", selection, true, true);
|
||||
Galaxy.currHistoryPanel.buildCollection("rules", null, selection, true);
|
||||
this.$emit("dismiss");
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user