Commit 471888d6 authored by Phil Hughes's avatar Phil Hughes

Moved sort endpoints into data attributes

parent 4b812d97
......@@ -19,12 +19,10 @@
});
};
Milestone.sortIssues = function(data) {
var sort_issues_url;
sort_issues_url = location.pathname + "/sort_issues";
Milestone.sortIssues = function(url, data) {
return $.ajax({
type: "PUT",
url: sort_issues_url,
url,
data: data,
success: function(_data) {
return Milestone.successCallback(_data);
......@@ -36,12 +34,10 @@
});
};
Milestone.sortMergeRequests = function(data) {
var sort_mr_url;
sort_mr_url = location.pathname + "/sort_merge_requests";
Milestone.sortMergeRequests = function(url, data) {
return $.ajax({
type: "PUT",
url: sort_mr_url,
url,
data: data,
success: function(_data) {
return Milestone.successCallback(_data);
......@@ -81,6 +77,9 @@
};
function Milestone() {
this.issuesSortEndpoint = $('#tab-issues').data('sort-endpoint');
this.mergeRequestsSortEndpoint = $('#tab-merge-requests').data('sort-endpoint');
this.bindIssuesSorting();
this.bindTabsSwitching();
......@@ -92,12 +91,16 @@
}
Milestone.prototype.bindIssuesSorting = function() {
if (!this.issuesSortEndpoint) return;
$('#issues-list-unassigned, #issues-list-ongoing, #issues-list-closed').each(function (i, el) {
this.createSortable(el, {
group: 'issue-list',
listEls: $('.issues-sortable-list'),
fieldName: 'issue',
sortCallback: Milestone.sortIssues,
sortCallback: (data) => {
Milestone.sortIssues(this.issuesSortEndpoint, data);
},
updateCallback: Milestone.updateIssue,
});
}.bind(this));
......@@ -113,12 +116,16 @@
};
Milestone.prototype.bindMergeRequestSorting = function() {
if (!this.mergeRequestsSortEndpoint) return;
$("#merge_requests-list-unassigned, #merge_requests-list-ongoing, #merge_requests-list-closed").each(function (i, el) {
this.createSortable(el, {
group: 'merge-request-list',
listEls: $(".merge_requests-sortable-list:not(#merge_requests-list-merged)"),
fieldName: 'merge_request',
sortCallback: Milestone.sortMergeRequests,
sortCallback: (data) => {
Milestone.sortMergeRequests(this.mergeRequestsSortEndpoint, data);
},
updateCallback: Milestone.updateMergeRequest,
});
}.bind(this));
......
......@@ -30,13 +30,13 @@
.tab-content.milestone-content
- if milestone.is_a?(GlobalMilestone) || can?(current_user, :read_issue, @project)
.tab-pane.active#tab-issues
.tab-pane.active#tab-issues{ data: { sort_endpoint: (sort_issues_namespace_project_milestone_path(@project.namespace, @project, @milestone) if @project && current_user) } }
= render 'shared/milestones/issues_tab', issues: milestone.issues_visible_to_user(current_user).include_associations, show_project_name: show_project_name, show_full_project_name: show_full_project_name
.tab-pane#tab-merge-requests
.tab-pane#tab-merge-requests{ data: { sort_endpoint: (sort_merge_requests_namespace_project_milestone_path(@project.namespace, @project, @milestone) if @project && current_user) } }
-# loaded async
= render "shared/milestones/tab_loading"
- else
.tab-pane.active#tab-merge-requests
.tab-pane.active#tab-merge-requests{ data: { sort_endpoint: (sort_merge_requests_namespace_project_milestone_path(@project.namespace, @project, @milestone) if @project && current_user) } }
-# loaded async
= render "shared/milestones/tab_loading"
.tab-pane#tab-participants
......
......@@ -8,6 +8,7 @@ shared_examples 'milestone tabs' do
get path, params.merge(extra_params)
end
describe '#merge_requests' do
context 'as html' do
before { go(:merge_requests, format: 'html') }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment