Commit 3d790c6d authored by Clement Ho's avatar Clement Ho

[skip ci] add loading indicator when saving users

parent b9d4f3c7
export default { export default {
name: 'AssigneeTitle', name: 'AssigneeTitle',
props: { props: {
loading: { type: Boolean, required: true },
numberOfAssignees: { type: Number, required: true }, numberOfAssignees: { type: Number, required: true },
}, },
computed: { computed: {
...@@ -16,7 +17,7 @@ export default { ...@@ -16,7 +17,7 @@ export default {
<template v-else> <template v-else>
Assignee Assignee
</template> </template>
<i aria-hidden="true" class="fa fa-spinner fa-spin block-loading" style="display: none;"></i> <i aria-hidden="true" class="fa fa-spinner fa-spin block-loading" :class="{ hidden: !loading }"></i>
<a class="edit-link pull-right" href="#">Edit</a> <a class="edit-link pull-right" href="#">Edit</a>
</div> </div>
`, `,
......
...@@ -27,7 +27,7 @@ export default { ...@@ -27,7 +27,7 @@ export default {
'show-more-assignees': ShowMoreAssignees, 'show-more-assignees': ShowMoreAssignees,
}, },
template: ` template: `
<div class="value hide-collapsed"> <div class="hide-collapsed">
<div class="hide-collapsed"> <div class="hide-collapsed">
<div class="user-list"> <div class="user-list">
<div class="user-item" v-for="(user, index) in assignees.users" v-if="showMore || (index < 5 && !showMore)"> <div class="user-item" v-for="(user, index) in assignees.users" v-if="showMore || (index < 5 && !showMore)">
......
...@@ -9,7 +9,7 @@ export default { ...@@ -9,7 +9,7 @@ export default {
} }
}, },
template: ` template: `
<div class="value hide-collapsed"> <div class="hide-collapsed">
<span class="assign-yourself no-value"> <span class="assign-yourself no-value">
No assignee - No assignee -
<button type="button" class="btn-link" @click="assignSelf"> <button type="button" class="btn-link" @click="assignSelf">
......
...@@ -9,7 +9,7 @@ export default { ...@@ -9,7 +9,7 @@ export default {
}, },
}, },
template: ` template: `
<div class="value hide-collapsed"> <div class="hide-collapsed">
<a class="author_link bold" :href="'/' + user.username"> <a class="author_link bold" :href="'/' + user.username">
<img width="32" class="avatar avatar-inline s32" alt="" :src="user.avatarUrl"> <img width="32" class="avatar avatar-inline s32" alt="" :src="user.avatarUrl">
<span class="author">{{user.name}}</span> <span class="author">{{user.name}}</span>
......
...@@ -50,8 +50,8 @@ const sidebarAssigneesOptions = () => ({ ...@@ -50,8 +50,8 @@ const sidebarAssigneesOptions = () => ({
}, },
template: ` template: `
<div class="sidebar-assignees"> <div class="sidebar-assignees">
<assignee-title :numberOfAssignees="assignees.users.length" /> <assignee-title :numberOfAssignees="assignees.users.length" :loading="assignees.loading" />
<component :is="componentName" :assignees="assignees" :class="{ hidden: hideComponent }" /> <component class="value" :is="componentName" :assignees="assignees" :class="{ hidden: hideComponent }" />
</div> </div>
`, `,
}); });
......
...@@ -4,6 +4,7 @@ export default class SidebarAssigneesStore { ...@@ -4,6 +4,7 @@ export default class SidebarAssigneesStore {
this.service = service; this.service = service;
this.users = []; this.users = [];
this.saved = true; this.saved = true;
this.loading = false;
} }
addUser(id, name, username, avatarUrl, saved) { addUser(id, name, username, avatarUrl, saved) {
...@@ -31,6 +32,7 @@ export default class SidebarAssigneesStore { ...@@ -31,6 +32,7 @@ export default class SidebarAssigneesStore {
saveUsers() { saveUsers() {
const ids = this.users.map((u) => u.id) || 0; const ids = this.users.map((u) => u.id) || 0;
this.loading = true;
this.service.update(ids.length > 0 ? ids : 0) this.service.update(ids.length > 0 ? ids : 0)
.then((response) => { .then((response) => {
const data = response.data; const data = response.data;
...@@ -42,9 +44,11 @@ export default class SidebarAssigneesStore { ...@@ -42,9 +44,11 @@ export default class SidebarAssigneesStore {
this.addUser(assignee.id, assignee.name, assignee.username, assignee.avatar_url, true); this.addUser(assignee.id, assignee.name, assignee.username, assignee.avatar_url, true);
} }
this.saved = true; this.saved = true;
this.loading = false;
}).catch((err) => { }).catch((err) => {
console.log(err); console.log(err);
console.log('error'); console.log('error');
this.loading = false;
}); });
} }
} }
\ No newline at end of file
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