Commit 5fb3b644 authored by Simon Knox's avatar Simon Knox

fix No and Any selection for Weight and Milestone dropdowns

parent 33398e04
...@@ -68,8 +68,9 @@ $(() => { ...@@ -68,8 +68,9 @@ $(() => {
rootPath: $boardApp.dataset.rootPath, rootPath: $boardApp.dataset.rootPath,
bulkUpdatePath: $boardApp.dataset.bulkUpdatePath, bulkUpdatePath: $boardApp.dataset.bulkUpdatePath,
detailIssue: Store.detail, detailIssue: Store.detail,
milestoneId: parseInt($boardApp.dataset.boardMilestoneId, 10),
milestoneTitle: $boardApp.dataset.boardMilestoneTitle, milestoneTitle: $boardApp.dataset.boardMilestoneTitle,
weight: $boardApp.dataset.boardWeight, weight: parseInt($boardApp.dataset.boardWeight, 10),
assigneeUsername: $boardApp.dataset.boardAssigneeUsername, assigneeUsername: $boardApp.dataset.boardAssigneeUsername,
labels: JSON.parse($boardApp.dataset.labels || []), labels: JSON.parse($boardApp.dataset.labels || []),
defaultAvatar: $boardApp.dataset.defaultAvatar, defaultAvatar: $boardApp.dataset.defaultAvatar,
...@@ -87,14 +88,24 @@ $(() => { ...@@ -87,14 +88,24 @@ $(() => {
Store.filter.path = [querystring].concat( Store.filter.path = [querystring].concat(
Store.filter.path.split('&').filter(param => param.match(new RegExp(`^${key}=(.*)$`, 'g')) === null) Store.filter.path.split('&').filter(param => param.match(new RegExp(`^${key}=(.*)$`, 'g')) === null)
).join('&'); ).join('&');
this.cantEdit.push({ this.cantEdit.push(tokenName);
name: tokenName,
value,
});
}; };
updateFilterPath('milestone_title', this.milestoneTitle, 'milestone'); if (this.milestoneId !== -1) {
updateFilterPath('weight', this.weight, 'weight'); let milestoneTitle = this.milestoneTitle;
if (this.milestoneId === 0) {
milestoneTitle = 'No+Milestone';
}
updateFilterPath('milestone_title', milestoneTitle, 'milestone');
}
let weight = this.weight;
if (weight !== -1) {
if (weight === 0) {
weight = 'No+Weight';
}
updateFilterPath('weight', weight, 'weight');
}
updateFilterPath('assignee_username', this.assigneeUsername, 'assignee'); updateFilterPath('assignee_username', this.assigneeUsername, 'assignee');
const filterPath = gl.issueBoards.BoardsStore.filter.path.split('&'); const filterPath = gl.issueBoards.BoardsStore.filter.path.split('&');
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
/* global BoardService, MilestoneSelect */ /* global BoardService, MilestoneSelect */
import loadingIcon from '~/vue_shared/components/loading_icon.vue'; import loadingIcon from '~/vue_shared/components/loading_icon.vue';
import extraMilestones from '../mixins/extra_milestones';
const ANY_MILESTONE = 'Any Milestone'; const ANY_MILESTONE = 'Any Milestone';
const NO_MILESTONE = 'No Milestone';
export default { export default {
props: { props: {
...@@ -31,20 +31,32 @@ export default { ...@@ -31,20 +31,32 @@ export default {
}, },
computed: { computed: {
milestoneTitle() { milestoneTitle() {
if (this.noMilestone) return NO_MILESTONE;
return this.board.milestone ? this.board.milestone.title : ANY_MILESTONE; return this.board.milestone ? this.board.milestone.title : ANY_MILESTONE;
}, },
noMilestone() {
return this.milestoneId === 0;
},
milestoneId() { milestoneId() {
return this.board.milestone ? this.board.milestone.id : ''; return this.board.milestone_id;
}, },
milestoneTitleClass() { milestoneTitleClass() {
return this.milestoneTitle === ANY_MILESTONE ? 'text-secondary': 'bold'; return this.milestoneTitle === ANY_MILESTONE ? 'text-secondary': 'bold';
}, },
selected() { selected() {
if (this.noMilestone) return NO_MILESTONE;
return this.board.milestone ? this.board.milestone.name : ''; return this.board.milestone ? this.board.milestone.name : '';
} }
}, },
methods: { methods: {
selectMilestone(milestone) { selectMilestone(milestone) {
// swap the IDs of 'Any' and 'No' milestone to what backend requires
if (milestone.title === ANY_MILESTONE) {
milestone.id = -1;
} else if (milestone.title === NO_MILESTONE) {
milestone.id = 0;
}
this.$set(this.board, 'milestone_id', milestone.id);
this.$set(this.board, 'milestone', milestone); this.$set(this.board, 'milestone', milestone);
}, },
}, },
......
...@@ -6,6 +6,7 @@ import loadingIcon from '~/vue_shared/components/loading_icon.vue'; ...@@ -6,6 +6,7 @@ import loadingIcon from '~/vue_shared/components/loading_icon.vue';
import eventHub from '../eventhub'; import eventHub from '../eventhub';
const ANY_WEIGHT = 'Any Weight'; const ANY_WEIGHT = 'Any Weight';
const NO_WEIGHT = 'No Weight';
export default { export default {
props: { props: {
...@@ -47,11 +48,19 @@ export default { ...@@ -47,11 +48,19 @@ export default {
return 'bold'; return 'bold';
}, },
valueText() { valueText() {
return this.value || ANY_WEIGHT; if (this.value > 0) return this.value;
if (this.value == 0) return NO_WEIGHT;
return ANY_WEIGHT;
} }
}, },
methods: { methods: {
selectWeight(weight) { selectWeight(weight) {
if (weight === ANY_WEIGHT) {
weight = -1;
}
if (weight === NO_WEIGHT) {
weight = 0;
}
this.$set(this.board, 'weight', weight); this.$set(this.board, 'weight', weight);
}, },
}, },
......
...@@ -11,8 +11,8 @@ export default class FilteredSearchBoards extends gl.FilteredSearchManager { ...@@ -11,8 +11,8 @@ export default class FilteredSearchBoards extends gl.FilteredSearchManager {
// Issue boards is slightly different, we handle all the requests async // Issue boards is slightly different, we handle all the requests async
// instead or reloading the page, we just re-fire the list ajax requests // instead or reloading the page, we just re-fire the list ajax requests
this.isHandledAsync = true; this.isHandledAsync = true;
this.cantEdit = cantEdit; this.cantEdit = cantEdit.filter(i => typeof i === 'string');
this.hiddenTokenNames = cantEdit.map(i => i.tokenName); this.cantEditWithValue = cantEdit.filter(i => typeof i === 'object');
} }
updateObject(path) { updateObject(path) {
...@@ -44,10 +44,7 @@ export default class FilteredSearchBoards extends gl.FilteredSearchManager { ...@@ -44,10 +44,7 @@ export default class FilteredSearchBoards extends gl.FilteredSearchManager {
} }
canEdit(tokenName, tokenValue) { canEdit(tokenName, tokenValue) {
// only hide tokens if both name and value match. This allows mix of hidden and visible Label tokens if (this.cantEdit.includes(tokenName)) return false;
if (tokenValue) { return this.cantEditWithValue.findIndex(t => t.name === tokenName && t.value === tokenValue) === -1;
return this.cantEdit.findIndex(t => t.name === tokenName && t.value === tokenValue) === -1;
}
return this.hiddenTokenNames.indexOf(tokenName) === -1;
} }
} }
...@@ -11,9 +11,10 @@ module EE ...@@ -11,9 +11,10 @@ module EE
!@project.feature_available?(:issue_board_focus_mode))).to_s !@project.feature_available?(:issue_board_focus_mode))).to_s
data = { data = {
board_milestone_title: board&.milestone&.title, board_milestone_title: board&.milestone&.title,
board_milestone_id: board&.milestone_id,
board_assignee_username: board&.assignee&.username, board_assignee_username: board&.assignee&.username,
label_ids: board&.label_ids, label_ids: board&.label_ids,
labels: board&.labels.to_json(only: [:id, :title, :color] ), labels: board&.labels.to_json(only: [:id, :title, :color, :text_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: show_feature_promotion show_promotion: show_feature_promotion
......
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