Commit 4a3e1fb7 authored by Simon Knox's avatar Simon Knox

fix sidebar dropdown values

parent a62a1a47
......@@ -19,7 +19,6 @@ class ListIssue {
this.position = obj.relative_position || Infinity;
this.milestone_id = obj.milestone_id;
this.updateUrl = obj.update_url;
this.canEdit = true; //obj.can_edit;
this.project_id = obj.project_id;
if (obj.milestone) {
......
......@@ -14,8 +14,8 @@ class DropdownUser extends gl.FilteredSearchDropdown {
params: {
per_page: 20,
active: true,
project_id: this.getProjectId(),
current_user: true,
...this.projectOrGroupId(),
},
searchValueFunction: this.getSearchInput.bind(this),
loadingTemplate: this.loadingTemplate,
......@@ -46,10 +46,27 @@ class DropdownUser extends gl.FilteredSearchDropdown {
super.renderContent(forceShowList);
}
getGroupId() {
return this.input.getAttribute('data-group-id');
}
getProjectId() {
return this.input.getAttribute('data-project-id');
}
projectOrGroupId() {
const projectId = this.getProjectId();
const groupId = this.getGroupId();
if (groupId) {
return {
group_id: groupId,
};
}
return {
project_id: projectId,
};
}
getSearchInput() {
const query = gl.DropdownUtils.getSearchInput(this.input);
const { lastToken } = gl.FilteredSearchTokenizer.processTokens(query, this.tokenKeys.get());
......
......@@ -54,6 +54,14 @@ module BoardsHelper
@current_board_parent ||= @project || @group
end
def can_admin_issue
if @project
can?(current_user, :admin_issue, @project)
elsif @group
can?(current_user, :admin_board, @group)
end
end
def board_list_data
{
toggle: "dropdown",
......@@ -74,6 +82,7 @@ module BoardsHelper
first_user: current_user&.username,
current_user: 'true',
project_id: @project&.try(:id),
group_id: @group&.try(:id),
null_user: 'true',
multi_select: 'true',
'dropdown-header': dropdown_options[:data][:'dropdown-header'],
......
......@@ -143,7 +143,8 @@ module SearchHelper
id: "filtered-search-#{type}",
placeholder: 'Search or filter results...',
data: {
'project-id' => (@group || @project).id,
'project-id' => @project&.try(:id),
'group-id' => @group&.try(:id),
'username-params' => @users.to_json(only: [:id, :username]),
'base-endpoint' => base_endpoint
}
......
......@@ -33,7 +33,7 @@
":disabled" => "disabled",
":issue-link-base" => "issueLinkBase",
":root-path" => "rootPath",
":groupId" => (current_board_parent.id if @group),
":groupId" => ((current_board_parent.id if @group) || 'null'),
"ref" => "board-list" }
- if can?(current_user, :admin_list, current_board_parent)
%board-blank-state{ "v-if" => 'list.id == "blank"' }
......@@ -2,13 +2,13 @@
%template{ "v-if" => "issue.assignees" }
%assignee-title{ ":number-of-assignees" => "issue.assignees.length",
":loading" => "loadingAssignees",
":editable" => "issue.canEdit" }
":editable" => can_admin_issue }
%assignees.value{ "root-path" => "#{root_url}",
":users" => "issue.assignees",
":editable" => "issue.canEdit",
":editable" => can_admin_issue,
"@assign-self" => "assignSelf" }
%template{ "v-if" => "issue.canEdit" }
- if can_admin_issue
.selectbox.hide-collapsed
%input.js-vue{ type: "hidden",
name: "issue[assignee_ids][]",
......
.block.due_date
.title
Due date
%template{ "v-if" => "issue.canEdit" }
- if can_admin_issue
= icon("spinner spin", class: "block-loading")
= link_to "Edit", "#", class: "edit-link pull-right"
.value
......@@ -15,7 +15,7 @@
\-
%a.js-remove-due-date{ href: "#", role: "button" }
remove due date
%template{ "v-if" => "issue.canEdit" }
- if can_admin_issue
.selectbox
%input{ type: "hidden",
name: "issue[due_date]",
......
.block.labels
.title
Labels
%template{ "v-if" => "issue.canEdit" }
- if can_admin_issue
= icon("spinner spin", class: "block-loading")
= link_to "Edit", "#", class: "edit-link pull-right"
.value.issuable-show-labels
......@@ -11,7 +11,7 @@
"v-for" => "label in issue.labels" }
%span.label.color-label.has-tooltip{ ":style" => "{ backgroundColor: label.color, color: label.textColor }" }
{{ label.title }}
%template{ "v-if" => "issue.canEdit" }
- if can_admin_issue
.selectbox
%input{ type: "hidden",
name: "issue[label_names][]",
......@@ -24,7 +24,7 @@
show_no: "true",
show_any: "true",
project_id: @project&.try(:id),
labels: (project_labels_path(@project, :json) if @project),
labels: labels_filter_path(true),
namespace_path: @project.try(:namespace).try(:full_path),
project_path: @project.try(:path) },
":data-issue-update" => "'#{@issues_path}/' + issue.id + '.json'" }
......
.block.milestone
.title
Milestone
- if can?(current_user, :admin_issue, @project)
- if can_admin_issue
= icon("spinner spin", class: "block-loading")
= link_to "Edit", "#", class: "edit-link pull-right"
.value
......@@ -9,17 +9,17 @@
None
%span.bold.has-tooltip{ "v-if" => "issue.milestone" }
{{ issue.milestone.title }}
- if can?(current_user, :admin_issue, @project)
- if can_admin_issue
.selectbox
%input{ type: "hidden",
":value" => "issue.milestone.id",
name: "issue[milestone_id]",
"v-if" => "issue.milestone" }
.dropdown
%button.dropdown-menu-toggle.js-milestone-select.js-issue-board-sidebar{ type: "button", data: { toggle: "dropdown", show_no: "true", field_name: "issue[milestone_id]", project_id: @project.id, milestones: project_milestones_path(@project, :json), ability_name: "issue", use_id: "true", default_no: "true" },
%button.dropdown-menu-toggle.js-milestone-select.js-issue-board-sidebar{ type: "button", data: { toggle: "dropdown", show_no: "true", field_name: "issue[milestone_id]", milestones: milestones_filter_path(:json), ability_name: "issue", use_id: "true", default_no: "true" },
":data-selected" => "milestoneTitle",
":data-issuable-id" => "issue.id",
":data-issue-update" => "'#{project_issues_path(@project)}/' + issue.id + '.json'" }
":data-issue-update" => "'#{milestones_label_path}/' + issue.id + '.json'" }
Milestone
= icon("chevron-down")
.dropdown-menu.dropdown-select.dropdown-menu-selectable
......
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