Commit 6ff83017 authored by Simon Knox's avatar Simon Knox

update labels

parent 2dbc6b05
...@@ -73,6 +73,7 @@ $(() => { ...@@ -73,6 +73,7 @@ $(() => {
authorUsername: $boardApp.dataset.boardAuthorUsername, authorUsername: $boardApp.dataset.boardAuthorUsername,
assigneeUsername: $boardApp.dataset.boardAssigneeUsername, assigneeUsername: $boardApp.dataset.boardAssigneeUsername,
labelIds: $boardApp.dataset.label_ids || [], labelIds: $boardApp.dataset.label_ids || [],
labels: JSON.parse($boardApp.dataset.labels || []),
defaultAvatar: $boardApp.dataset.defaultAvatar, defaultAvatar: $boardApp.dataset.defaultAvatar,
cantEdit: [], cantEdit: [],
}, },
...@@ -95,15 +96,12 @@ $(() => { ...@@ -95,15 +96,12 @@ $(() => {
updateFilterPath('weight', this.weight, 'weight'); updateFilterPath('weight', this.weight, 'weight');
updateFilterPath('author_username', this.authorUsername, 'author'); updateFilterPath('author_username', this.authorUsername, 'author');
updateFilterPath('assignee_username', this.assigneeUsername, 'assignee'); updateFilterPath('assignee_username', this.assigneeUsername, 'assignee');
this.labels.forEach((label) => {
if (this.labelIds.length > 0) { const querystring = `label_id[]=${label.title}`;
this.labelsIds.forEach((labelId) => {
const querystring = `label_id[]=${labelId}`;
Store.filter.path = [querystring].concat( Store.filter.path = [querystring].concat(
Store.filter.path.split('&').filter(param => param.match(new RegExp(`^${querystring}$`, 'g')) === null) Store.filter.path.split('&').filter(param => param.match(new RegExp(`^${querystring}$`, 'g')) === null)
).join('&'); ).join('&');
}); });
}
Store.updateFiltersUrl(true); Store.updateFiltersUrl(true);
......
...@@ -73,6 +73,7 @@ ...@@ -73,6 +73,7 @@
<form-block> <form-block>
<board-labels-select <board-labels-select
:board="board" :board="board"
:selected="board.labels"
title="Labels" title="Labels"
default-text="Any label" default-text="Any label"
:can-edit="canAdminBoard" :can-edit="canAdminBoard"
......
...@@ -31,10 +31,18 @@ ...@@ -31,10 +31,18 @@
</div> </div>
<div class="selectbox" style="display: none"> <div class="selectbox" style="display: none">
<input
type="hidden"
name="label_id[]"
v-for="labelId in labelIds"
:key="labelId"
:value="labelId"
>
<div class="dropdown"> <div class="dropdown">
<button <button
class="dropdown-menu-toggle wide js-label-select js-multiselect js-board-config-modal" class="dropdown-menu-toggle wide js-label-select js-multiselect js-board-config-modal"
data-field-name="issue[label_names][]" data-field-name="label_id[]"
v-bind:data-labels="labelsPath" v-bind:data-labels="labelsPath"
data-toggle="dropdown" data-toggle="dropdown"
type="button" type="button"
...@@ -98,6 +106,10 @@ export default { ...@@ -98,6 +106,10 @@ export default {
required: false, required: false,
default: false, default: false,
}, },
selected: {
type: Array,
required: true,
},
}, },
data() { data() {
return { return {
...@@ -108,6 +120,11 @@ export default { ...@@ -108,6 +120,11 @@ export default {
components: { components: {
loadingIcon, loadingIcon,
}, },
computed: {
labelIds() {
return this.selected.map(label => label.id).join(',');
},
},
methods: { methods: {
open() { open() {
this.isOpen = true; this.isOpen = true;
......
...@@ -31,7 +31,9 @@ class BoardService { ...@@ -31,7 +31,9 @@ class BoardService {
createBoard (board) { createBoard (board) {
if (board.labels && board.labels.length > 0) { if (board.labels && board.labels.length > 0) {
board.label_ids = board.labels.map(b => b.id); board.board = board.board || {};
board.board.label_ids = board.labels.map(b => b.id);
board.board.milestone_id = board.milestone_id;
} }
if (board.assignee) { if (board.assignee) {
board.assignee_id = board.assignee.id; board.assignee_id = board.assignee.id;
......
...@@ -26,12 +26,7 @@ module BoardsHelper ...@@ -26,12 +26,7 @@ module BoardsHelper
board = @board || @boards.first board = @board || @boards.first
board.to_json( board.to_json(
only: [:id, :name, :milestone_id, :author_id, :assignee_id, :weight], only: [:id, :name, :milestone_id],
include: {
milestone: { only: [:title] },
author: { only: [:name, :username ], methods: [:avatar_url] },
assignee: { only: [:name, :username ], methods: [:avatar_url] }
}
) )
end end
......
...@@ -9,10 +9,11 @@ module EE ...@@ -9,10 +9,11 @@ module EE
board_milestone_title: board&.milestone&.title, board_milestone_title: board&.milestone&.title,
board_author_username: board&.author&.username, board_author_username: board&.author&.username,
board_assignee_username: board&.assignee&.username, board_assignee_username: board&.assignee&.username,
label_ids: board&.label_ids,
labels: board&.labels.to_json(only: [:id, :title, :color] ),
board_weight: board&.weight, board_weight: board&.weight,
focus_mode_available: parent.feature_available?(:issue_board_focus_mode).to_s, focus_mode_available: parent.feature_available?(:issue_board_focus_mode).to_s,
show_promotion: (@project && show_promotions? && (!@project.feature_available?(:multiple_issue_boards) || !@project.feature_available?(:scoped_issue_board) || !@project.feature_available?(:issue_board_focus_mode))).to_s show_promotion: (@project && show_promotions? && (!@project.feature_available?(:multiple_issue_boards) || !@project.feature_available?(:scoped_issue_board) || !@project.feature_available?(:issue_board_focus_mode))).to_s
} }
super.merge(data) super.merge(data)
...@@ -24,6 +25,20 @@ module EE ...@@ -24,6 +25,20 @@ module EE
"/#{@board.group.path}/:project_path/issues" "/#{@board.group.path}/:project_path/issues"
end end
def current_board_json
board = @board || @boards.first
board.to_json(
only: [:id, :name, :milestone_id, :author_id, :assignee_id, :weight, :label_ids],
include: {
milestone: { only: [:title] },
author: { only: [:id, :name, :username ], methods: [:avatar_url] },
assignee: { only: [:id, :name, :username ], methods: [:avatar_url] },
labels: { only: [:title, :color, :id] }
}
)
end
def board_base_url def board_base_url
if board.group_board? if board.group_board?
group_boards_url(@group) group_boards_url(@group)
......
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