Skip to content

Commit

Permalink
Store parameters in container data and take them afterwards
Browse files Browse the repository at this point in the history
  • Loading branch information
ncounter committed Mar 28, 2024
1 parent b0ce25b commit ce5c8a9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
8 changes: 7 additions & 1 deletion src/api/app/assets/javascripts/webui/request.js
Expand Up @@ -185,8 +185,14 @@ function loadDiffs(element){
});
}

function loadChanges(requestNumber, requestActionId, diffToSupersededId) { // jshint ignore:line
function loadChanges() { // jshint ignore:line
$('.tab-content.sourcediff .loading').removeClass('invisible');

// Take the parameters from the container data
var requestNumber = $('#sourcediff-container').data('bs-request-number');
var requestActionId = $('#sourcediff-container').data('action-id');
var diffToSupersededId = $('#sourcediff-container').data('diff-to-superseded-id');

var queryString = diffToSupersededId ? '?diff_to_superseded=' + diffToSupersededId : '';
var url = '/request/' + requestNumber + '/request_action/' + requestActionId + '/changes' + queryString;
$.ajax({
Expand Down
3 changes: 1 addition & 2 deletions src/api/app/components/sourcediff_component.html.haml
Expand Up @@ -2,8 +2,7 @@
.col
- if @action.diff_not_cached
.clearfix.mb-2.text-center
.btn.btn-outline-primary.cache-refresh{ title: 'Refresh results',
onclick: "loadChanges(#{@bs_request.number}, #{@action.id}, #{@diff_to_superseded_id});" }
.btn.btn-outline-primary.cache-refresh{ title: 'Refresh results', onclick: "loadChanges()" }
Crunching the latest data. Refresh again in a few seconds
%i.fas.fa-sync-alt{ id: "cache#0-reload" }
.text-center.p-4.loading.invisible
Expand Down
7 changes: 5 additions & 2 deletions src/api/app/views/webui/request/changes.html.haml
Expand Up @@ -14,14 +14,17 @@
locals: { bs_request: @bs_request, action: @action, issues: @issues,
actions_count: @actions.count, active_tab: @active_tab }
.container.p-4
.tab-content.sourcediff
.tab-content.sourcediff{ data: { bs_request_number: @bs_request.number,
action_id: @action.id,
diff_to_superseded_id: @diff_to_superseded_id },
id: 'sourcediff-container' }
.result
// The content of this div is set by JavaScript which calls the partial ../_changes_content.html.haml
.text-center.p-4
%i.fas.fa-spinner.fa-spin.me-1
Loading changes...
:javascript
loadChanges('#{@bs_request.number}', '#{@action.id}', '#{@diff_to_superseded_id}');
loadChanges();
= render DeleteConfirmationDialogComponent.new(modal_id: 'delete-comment-modal',
method: :delete,
options: { modal_title: 'Delete comment?', remote: true })

0 comments on commit ce5c8a9

Please sign in to comment.