Commit 6da80dbd authored by Clement Ho's avatar Clement Ho

[skip ci] more refactor

parent a252e26b
...@@ -2,11 +2,11 @@ import CollapsedAvatar from './avatar'; ...@@ -2,11 +2,11 @@ import CollapsedAvatar from './avatar';
export default { export default {
name: 'CollapsedAssignees', name: 'CollapsedAssignees',
data: { data() {
return { return {
defaultRenderCount: 5, defaultRenderCount: 5,
defaultMaxCounter: 99, defaultMaxCounter: 99,
} };
}, },
props: { props: {
users: { users: {
......
...@@ -41,7 +41,6 @@ export default { ...@@ -41,7 +41,6 @@ export default {
return { return {
store, store,
service, service,
loading: false,
}; };
}, },
computed: { computed: {
...@@ -62,13 +61,13 @@ export default { ...@@ -62,13 +61,13 @@ export default {
this.saveUsers(); this.saveUsers();
}, },
saveUsers() { saveUsers() {
this.loading = true; this.store.loading = true;
this.service.update(this.store.getUserIds()) this.service.update(this.store.getUserIds())
.then((response) => { .then((response) => {
this.loading = false; this.store.loading = false;
this.store.saveUsers(response.data.assignees); this.store.saveUsers(response.data.assignees);
}).catch(() => { }).catch(() => {
this.loading = false; this.store.loading = false;
return new Flash('An error occured while saving assignees', 'alert'); return new Flash('An error occured while saving assignees', 'alert');
}); });
}, },
...@@ -84,12 +83,12 @@ export default { ...@@ -84,12 +83,12 @@ export default {
<div> <div>
<assignee-title <assignee-title
:numberOfAssignees="store.users.length" :numberOfAssignees="store.users.length"
:loading="loading" :loading="store.loading"
:editable="store.editable" :editable="store.editable"
/> />
<collapsed-assignees :users="store.users"/> <collapsed-assignees :users="store.users"/>
<div class="value" v-if="!loading"> <div class="value" v-if="!store.loading">
<no-assignee v-if="numberOfAssignees === 0" /> <no-assignee v-if="numberOfAssignees === 0" />
<single-assignee <single-assignee
v-else-if="numberOfAssignees === 1" v-else-if="numberOfAssignees === 1"
......
...@@ -10,7 +10,6 @@ export default class SidebarAssigneesStore { ...@@ -10,7 +10,6 @@ export default class SidebarAssigneesStore {
this.users = []; this.users = [];
this.loading = false; this.loading = false;
this.editable = editable; this.editable = editable;
this.defaultRenderCount = 5;
assignees.forEach(a => this.addUser(this.destructUser(a))); assignees.forEach(a => this.addUser(this.destructUser(a)));
} }
...@@ -24,8 +23,6 @@ export default class SidebarAssigneesStore { ...@@ -24,8 +23,6 @@ export default class SidebarAssigneesStore {
username, username,
avatarUrl, avatarUrl,
}); });
console.log(`addUser()`);
console.log(user);
} }
addCurrentUser() { addCurrentUser() {
...@@ -33,8 +30,6 @@ export default class SidebarAssigneesStore { ...@@ -33,8 +30,6 @@ export default class SidebarAssigneesStore {
} }
removeUser(id) { removeUser(id) {
console.log(`removeUser()`);
console.log(id);
this.users = this.users.filter(u => u.id !== id); this.users = this.users.filter(u => u.id !== id);
} }
...@@ -43,12 +38,8 @@ export default class SidebarAssigneesStore { ...@@ -43,12 +38,8 @@ export default class SidebarAssigneesStore {
} }
getUserIds() { getUserIds() {
console.log(`getUserIds`);
const ids = this.users.map(u => u.id); const ids = this.users.map(u => u.id);
if (ids.length > 0 && ids[0] == undefined) {
debugger
}
// If there are no ids, that means we have to unassign (which is id = 0) // If there are no ids, that means we have to unassign (which is id = 0)
return ids.length > 0 ? ids : [0]; return ids.length > 0 ? ids : [0];
} }
......
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