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