X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/f12986389693d4155847204210d9c84492ac6837..856d0e913c9e63b27021c53ea7be5c35aa74ec0e:/apps/workbench/app/views/application/_choose.js.erb diff --git a/apps/workbench/app/views/application/_choose.js.erb b/apps/workbench/app/views/application/_choose.js.erb index b033c9bf2f..9638028940 100644 --- a/apps/workbench/app/views/application/_choose.js.erb +++ b/apps/workbench/app/views/application/_choose.js.erb @@ -1,28 +1,31 @@ +<%# Copyright (C) The Arvados Authors. All rights reserved. + +SPDX-License-Identifier: AGPL-3.0 %> + +<% +=begin + +Parameters received from the caller/requestor of the modal are +attached to the action button (.btn-primary) as follows: + +action_class -- string -- added as a pseudoclass to the action button. + +action_href -- string -- will be available at $(btn).attr('data-action-href') + +action_data -- json-encoded object -- will be at $(btn).data('action-data') + +action_data_form_params -- array -- for each X in this array, the +value of params[X] during this "show chooser" request will be in +$(btn).data('action-data-from-params')[X]. + +=end +%> + $('body > .modal-container').html("<%= escape_javascript(render partial: 'choose.html', locals: {multiple: multiple}) %>"); $('body > .modal-container .modal').modal('show'); $('body > .modal-container .modal .modal-footer .btn-primary'). addClass('<%= j params[:action_class] %>'). attr('data-action-href', '<%= j params[:action_href] %>'). attr('data-method', '<%= j params[:action_method] %>'). - data('action-data', <%= raw params[:action_data] %>); -$(".chooser-show-project").on("click", function() { - $("#choose-scroll").html("
"); - $(".modal-dialog-preview-pane").html(''); - var t = $(this); - var d = { - partial: true, - multiple: <%= multiple || "false" %> - }; - if (t.attr("data-project-uuid") != null) { - d.project_uuid = t.attr("data-project-uuid"); - } - $.ajax('<%=j url_for %>', { - dataType: "json", - type: "GET", - data: d - }).done(function(data, status, jqxhr) { - $("#chooser-breadcrumb").text(t.text()); - $("#choose-scroll").html(data.content); - $("#choose-scroll").prop("data-infinite-content-href", "next_page_href"); - }); -}); + data('action-data', <%= raw params[:action_data] %>). + data('action-data-from-params', <%= raw params.select { |k,v| k.in?(params[:action_data_from_params] || []) }.to_json %>);