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

update labels

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