Commit d05c72c3 authored by Clement Ho's avatar Clement Ho

[skip ci] rename user to assignee

parent 10d74f0a
......@@ -12,7 +12,7 @@ require('./models/issue');
require('./models/label');
require('./models/list');
require('./models/milestone');
require('./models/user');
require('./models/assignee');
require('./stores/boards_store');
require('./stores/modal_store');
require('./services/board_service');
......
......@@ -70,19 +70,19 @@ require('./sidebar/remove_issue');
// Notify gl dropdown that we are now assigning to current user
this.$refs.assigneeBlock.dispatchEvent(new Event('assignYourself'));
this.addUser(this.currentUser.id);
this.saveUsers();
this.addAssignee(this.currentUser);
this.saveAssignees();
},
removeUser (u) {
gl.issueBoards.BoardsStore.detail.issue.removeUser(u);
removeAssignee (a) {
gl.issueBoards.BoardsStore.detail.issue.removeAssignee(a);
},
addUser (u) {
gl.issueBoards.BoardsStore.detail.issue.addUser(u);
addAssignee (a) {
gl.issueBoards.BoardsStore.detail.issue.addAssignee(a);
},
removeAllUsers () {
gl.issueBoards.BoardsStore.detail.issue.removeAllUsers();
removeAllAssignees () {
gl.issueBoards.BoardsStore.detail.issue.removeAllAssignees();
},
saveUsers () {
saveAssignees () {
this.loadingAssignees = true;
gl.issueBoards.BoardsStore.detail.issue.update(this.endpoint)
......@@ -103,16 +103,16 @@ require('./sidebar/remove_issue');
},
created () {
// Get events from glDropdown
eventHub.$on('sidebar.removeUser', this.removeUser);
eventHub.$on('sidebar.addUser', this.addUser);
eventHub.$on('sidebar.removeAllUsers', this.removeAllUsers);
eventHub.$on('sidebar.saveUsers', this.saveUsers);
eventHub.$on('sidebar.removeAssignee', this.removeAssignee);
eventHub.$on('sidebar.addAssignee', this.addAssignee);
eventHub.$on('sidebar.removeAllAssignees', this.removeAllAssignees);
eventHub.$on('sidebar.saveAssignees', this.saveAssignees);
},
beforeDestroy() {
eventHub.$off('sidebar.removeUser', this.removeUser);
eventHub.$off('sidebar.addUser', this.addUser);
eventHub.$off('sidebar.removeAllUsers', this.removeAllUsers);
eventHub.$off('sidebar.saveUsers', this.saveUsers);
eventHub.$off('sidebar.removeAssignee', this.removeAssignee);
eventHub.$off('sidebar.addAssignee', this.addAssignee);
eventHub.$off('sidebar.removeAllAssignees', this.removeAllAssignees);
eventHub.$off('sidebar.saveAssignees', this.saveAssignees);
},
mounted () {
new IssuableContext(this.currentUser);
......
/* eslint-disable no-unused-vars */
class ListUser {
class ListAssignee {
constructor(user) {
this.id = user.id;
this.name = user.name;
......@@ -9,4 +9,4 @@ class ListUser {
}
}
window.ListUser = ListUser;
window.ListAssignee = ListAssignee;
/* eslint-disable no-unused-vars, space-before-function-paren, arrow-body-style, arrow-parens, comma-dangle, max-len */
/* global ListLabel */
/* global ListMilestone */
/* global ListUser */
/* global ListAssignee */
import Vue from 'vue';
......@@ -31,7 +31,7 @@ class ListIssue {
}
processAssignees(assignees) {
this.assignees = assignees.map(a => new ListUser(a));
this.assignees = assignees.map(a => new ListAssignee(a));
}
addLabel (label) {
......@@ -54,23 +54,23 @@ class ListIssue {
labels.forEach(this.removeLabel.bind(this));
}
addUser (user) {
if (!this.findUser(user)) {
this.assignees.push(new ListUser(user));
addAssignee (assignee) {
if (!this.findAssignee(assignee)) {
this.assignees.push(new ListAssignee(assignee));
}
}
findUser (user) {
return this.assignees.filter(assignee => assignee.id === user.id)[0];
findAssignee (findAssignee) {
return this.assignees.filter(assignee => assignee.id === findAssignee.id)[0];
}
removeUser (user) {
if (user) {
this.assignees = this.assignees.filter(assignee => assignee.id !== user.id);
removeAssignee (removeAssignee) {
if (assignee) {
this.assignees = this.assignees.filter(assignee => assignee.id !== removeAssignee.id);
}
}
removeAllUsers () {
removeAllAssignees () {
this.assignees = [];
}
......
/* eslint-disable func-names, space-before-function-paren, one-var, no-var, prefer-rest-params, wrap-iife, quotes, max-len, one-var-declaration-per-line, vars-on-top, prefer-arrow-callback, consistent-return, comma-dangle, object-shorthand, no-shadow, no-unused-vars, no-else-return, no-self-compare, prefer-template, no-unused-expressions, no-lonely-if, yoda, prefer-spread, no-void, camelcase, no-param-reassign */
/* global Issuable */
/* global ListUser */
import eventHub from './sidebar/event_hub';
......@@ -257,7 +256,7 @@ import eventHub from './sidebar/event_hub';
defaultLabel: defaultLabel,
hidden: function(e) {
if ($dropdown.hasClass('js-multiselect')) {
eventHub.$emit('sidebar.saveUsers');
eventHub.$emit('sidebar.saveAssignees');
}
$selectbox.hide();
......@@ -290,7 +289,7 @@ import eventHub from './sidebar/event_hub';
.find(`input[name='${$dropdown.data('field-name')}'][value=${firstSelectedId}]`);
firstSelected.remove();
eventHub.$emit('sidebar.removeUser', {
eventHub.$emit('sidebar.removeAssignee', {
id: firstSelectedId,
});
}
......@@ -302,10 +301,10 @@ import eventHub from './sidebar/event_hub';
const id = parseInt(element.value, 10);
element.remove();
});
eventHub.$emit('sidebar.removeAllUsers');
eventHub.$emit('sidebar.removeAllAssignees');
} else if (isActive) {
// user selected
eventHub.$emit('sidebar.addUser', user);
eventHub.$emit('sidebar.addAssignee', user);
// Remove unassigned selection (if it was previously selected)
const unassignedSelected = $dropdown.closest('.selectbox')
......@@ -321,7 +320,7 @@ import eventHub from './sidebar/event_hub';
}
// User unselected
eventHub.$emit('sidebar.removeUser', user);
eventHub.$emit('sidebar.removeAssignee', user);
}
}
......
/* global ListUser */
/* global ListAssignee */
/* global ListLabel */
/* global listObj */
/* global ListIssue */
......@@ -14,7 +14,7 @@ require('~/boards/components/issue_card_inner');
require('./mock_data');
describe('Issue card component', () => {
const user = new ListUser({
const user = new ListAssignee({
id: 1,
name: 'testing 123',
username: 'test',
......
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