From e67ee2f68ee9e9e796e494d7eb8e59a228dbf897 Mon Sep 17 00:00:00 2001 From: Alireza Heidari Date: Mon, 29 Jul 2024 15:34:47 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A5:=20remove=20`addFilesFromHistoryMo?= =?UTF-8?q?dal`=20and=20related=20methods=20from=20`add-datasets.js`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LibraryFolder/TopToolbar/add-datasets.js | 260 ------------------ 1 file changed, 260 deletions(-) diff --git a/client/src/components/Libraries/LibraryFolder/TopToolbar/add-datasets.js b/client/src/components/Libraries/LibraryFolder/TopToolbar/add-datasets.js index 5733e40d4957..42e5db51eb4b 100644 --- a/client/src/components/Libraries/LibraryFolder/TopToolbar/add-datasets.js +++ b/client/src/components/Libraries/LibraryFolder/TopToolbar/add-datasets.js @@ -32,9 +32,6 @@ var AddDatasets = Backbone.View.extend({ */ showImportModal: function (options) { switch (options.source) { - case "history": - this.addFilesFromHistoryModal(); - break; case "importdir": this.importFilesFromGalaxyFolderModal({ source: "importdir", @@ -176,46 +173,6 @@ var AddDatasets = Backbone.View.extend({ value: "auto", }); }, - addFilesFromHistoryModal: function () { - const Galaxy = getGalaxyInstance(); - this.histories = new mod_library_model.GalaxyHistories(); - this.histories - .fetch() - .done(() => { - this.modal = Galaxy.modal; - var template_modal = this.templateAddFilesFromHistory(); - this.modal.show({ - closing_events: true, - title: _l("Adding datasets from your history"), - body: template_modal({ - histories: this.histories.models, - }), - buttons: { - Add: () => { - this.addAllDatasetsFromHistory(); - }, - Close: () => { - Galaxy.modal.hide(); - }, - }, - closing_callback: () => { - // TODO update table without fetching new content from the server - // Galaxy.libraries.library_router.navigate(`folders/${this.id}`, { trigger: true }); - }, - }); - this.fetchAndDisplayHistoryContents(this.histories.models[0].id); - $("#dataset_add_bulk").change((event) => { - this.fetchAndDisplayHistoryContents(event.target.value); - }); - }) - .fail((model, response) => { - if (typeof response.responseJSON !== "undefined") { - Toast.error(response.responseJSON.err_msg); - } else { - Toast.error("An error occurred."); - } - }); - }, /** * Create modal for importing from given directory * on Galaxy. Bind jQuery events. @@ -546,49 +503,6 @@ var AddDatasets = Backbone.View.extend({ this.chainCallImportingFolders(options); }); }, - - fetchAndDisplayHistoryContents: function (history_id) { - var history_contents = new mod_library_model.HistoryContents({ - id: history_id, - }); - history_contents.fetch({ - success: (history_contents) => { - var history_contents_template = this.templateHistoryContents(); - - if (history_contents.length > 0) { - this.histories.get(history_id).set({ contents: history_contents }); - this.modal.$el.find(".library_selected_history_content").html( - history_contents_template({ - history_contents: history_contents.models.reverse(), - }) - ); - this.modal.$el.find(".history-import-select-all").bind("click", () => { - $(".library_selected_history_content [type=checkbox]").prop("checked", true); - }); - this.modal.$el.find(".history-import-unselect-all").bind("click", () => { - $(".library_selected_history_content [type=checkbox]").prop("checked", false); - }); - - this.modal.$el.find(".history-import-toggle-all").bind("click", (e) => { - this.selectAll(e); - }); - - this.modal.$el.find(".dataset_row").bind("click", (e) => { - this.selectClickedRow(e); - }); - } else { - this.modal.$el.find(".library_selected_history_content").html(`

Selected history is empty.

`); - } - }, - error: (model, response) => { - if (typeof response.responseJSON !== "undefined") { - Toast.error(response.responseJSON.err_msg); - } else { - Toast.error("An error occurred."); - } - }, - }); - }, templateAddingDatasetsProgressBar: function () { return _.template( `
@@ -602,180 +516,6 @@ var AddDatasets = Backbone.View.extend({
` ); }, - templateAddFilesFromHistory: function () { - return _.template( - `
-
- - -
-
-
-
` - ); - }, - templateHistoryContents: function () { - return _.template( - `
- -
- - - - - - - - - - <% _.each(history_contents, function(history_item) { %> - <% if (history_item.get("deleted") != true ) { %> - <% var item_name = history_item.get("name") %> - <% if (history_item.get("type") === "collection") { %> - <% var collection_type = history_item.get("collection_type") %> - <% if (collection_type === "list") { %> - " - data-name="<%= _.escape(history_item.get("type")) %>"> - - - - - <% } else { %> - - - - - - <% } %> - <% } else if (history_item.get("visible") === true && history_item.get("state") === "ok") { %> - " - data-name="<%= _.escape(history_item.get("type")) %>"> - - - - - <% } %> - <% } %> - <% }); %> - -
- - Name
<%= _.escape(history_item.get("hid")) %> - <%= item_name.length > 75 ? _.escape("...".concat(item_name.substr(-75))) : _.escape(item_name) %> - (Dataset Collection) -
<%= _.escape(history_item.get("hid")) %> - <%= item_name.length > 75 ? _.escape("...".concat(item_name.substr(-75))) : _.escape(item_name) %> - (Dataset Collection of type <%= _.escape(collection_type) %> not supported.) -
<%= _.escape(history_item.get("hid")) %> - <%= item_name.length > 75 ? _.escape("...".concat(item_name.substr(-75))) : _.escape(item_name) %> -
-
-
` - ); - }, - /** - * Check checkbox if user clicks on the whole row or - * on the checkbox itself - */ - selectClickedRow: function (event) { - var checkbox = ""; - var $row; - var source; - $row = $(event.target).closest("tr"); - if (event.target.localName === "input") { - checkbox = event.target; - source = "input"; - } else if (event.target.localName === "td") { - checkbox = $row.find(":checkbox")[0]; - source = "td"; - } - if (checkbox.checked) { - if (source === "td") { - checkbox.checked = ""; - this.makeWhiteRow($row); - } else if (source === "input") { - this.makeDarkRow($row); - } - } else { - if (source === "td") { - checkbox.checked = "selected"; - this.makeDarkRow($row); - } else if (source === "input") { - this.makeWhiteRow($row); - } - } - }, - - /** - * User clicked the checkbox in the table heading - * @param {context} event - */ - selectAll: function (event) { - var selected = event.target.checked; - var self = this; - // Iterate each checkbox - $(":checkbox", "#dataset_list tbody").each(function () { - this.checked = selected; - var $row = $(this).closest("tr"); - // Change color of selected/unselected - if (selected) { - self.makeDarkRow($row); - } else { - self.makeWhiteRow($row); - } - }); - }, - - makeDarkRow: function ($row) { - $row.addClass("table-primary"); - }, - - makeWhiteRow: function ($row) { - $row.removeClass("table-primary"); - }, - /** - * Import all selected datasets from history into the current folder. - */ - addAllDatasetsFromHistory: function () { - var checked_hdas = this.modal.$el.find(".library_selected_history_content").find(":checked"); - var history_item_ids = []; // can be hda or hdca - var history_item_types = []; - var items_to_add = []; - if (checked_hdas.length < 1) { - Toast.info("You must select some datasets first."); - } else { - this.modal.disableButton("Add"); - checked_hdas.each(function () { - var hid = $(this).closest("tr").data("id"); - if (hid) { - var item_type = $(this).closest("tr").data("name"); - history_item_ids.push(hid); - history_item_types.push(item_type); - } - }); - for (let i = history_item_ids.length - 1; i >= 0; i--) { - var history_item_id = history_item_ids[i]; - var folder_item = new mod_library_model.Item(); - folder_item.url = `${getAppRoot()}api/folders/${this.options.id}/contents`; - if (history_item_types[i] === "collection") { - folder_item.set({ from_hdca_id: history_item_id }); - } else { - folder_item.set({ from_hda_id: history_item_id }); - } - items_to_add.push(folder_item); - } - this.initChainCallControlAddingDatasets({ - length: items_to_add.length, - }); - this.chainCallAddingHdas(items_to_add); - } - }, initChainCallControlAddingDatasets: function (options) { var template; template = this.templateAddingDatasetsProgressBar();