Commit 31bc52ee authored by Clement Ho's avatar Clement Ho Committed by Jacob Schatz

Add multiple assignees to issue board card

parent b9270cb9
...@@ -32,18 +32,36 @@ import eventHub from '../eventhub'; ...@@ -32,18 +32,36 @@ import eventHub from '../eventhub';
default: false, default: false,
}, },
}, },
data() {
return {
limitBeforeCounter: 3,
maxRender: 4,
maxCounter: 99,
};
},
computed: { computed: {
cardUrl() { numberOverLimit() {
return `${this.issueLinkBase}/${this.issue.id}`; return this.issue.assignees.length - this.limitBeforeCounter;
}, },
assigneeUrl() { assigneeCounterTooltip() {
return `${this.rootPath}${this.issue.assignee.username}`; return `${this.assigneeCounterLabel} more`;
},
assigneeCounterLabel() {
if (this.numberOverLimit > this.maxCounter) {
return `${this.maxCounter}+`;
}
return `+${this.numberOverLimit}`;
}, },
assigneeUrlTitle() { shouldRenderCounter() {
return `Assigned to ${this.issue.assignee.name}`; if (this.issue.assignees.length <= this.maxRender) {
return false;
}
return this.issue.assignees.length > this.numberOverLimit;
}, },
avatarUrlTitle() { cardUrl() {
return `Avatar for ${this.issue.assignee.name}`; return `${this.issueLinkBase}/${this.issue.id}`;
}, },
issueId() { issueId() {
return `#${this.issue.id}`; return `#${this.issue.id}`;
...@@ -53,6 +71,28 @@ import eventHub from '../eventhub'; ...@@ -53,6 +71,28 @@ import eventHub from '../eventhub';
}, },
}, },
methods: { methods: {
isIndexLessThanlimit(index) {
return index < this.limitBeforeCounter;
},
shouldRenderAssignee(index) {
// Eg. maxRender is 4,
// Render up to all 4 assignees if there are only 4 assigness
// Otherwise render up to the limitBeforeCounter
if (this.issue.assignees.length <= this.maxRender) {
return index < this.maxRender;
}
return index < this.limitBeforeCounter;
},
assigneeUrl(assignee) {
return `${this.rootPath}${assignee.username}`;
},
assigneeUrlTitle(assignee) {
return `Assigned to ${assignee.name}`;
},
avatarUrlTitle(assignee) {
return `Avatar for ${assignee.name}`;
},
showLabel(label) { showLabel(label) {
if (!this.list) return true; if (!this.list) return true;
...@@ -106,23 +146,37 @@ import eventHub from '../eventhub'; ...@@ -106,23 +146,37 @@ import eventHub from '../eventhub';
{{ issueId }} {{ issueId }}
</span> </span>
</h4> </h4>
<a <div class="card-assignee">
class="card-assignee has-tooltip js-no-trigger" <a
:href="assigneeUrl" class="has-tooltip js-no-trigger"
:title="assigneeUrlTitle" :href="assigneeUrl(assignee)"
v-if="issue.assignee" :title="assigneeUrlTitle(assignee)"
data-container="body" v-for="(assignee, index) in issue.assignees"
> v-if="shouldRenderAssignee(index)"
<img data-container="body"
class="avatar avatar-inline s20" data-placement="bottom"
:src="issue.assignee.avatar" >
width="20" <img
height="20" class="avatar avatar-inline s20"
:alt="avatarUrlTitle" :src="assignee.avatar"
/> width="20"
</a> height="20"
:alt="avatarUrlTitle(assignee)"
/>
</a>
<span
class="avatar-counter has-tooltip"
:title="assigneeCounterTooltip"
v-if="shouldRenderCounter"
>
{{ assigneeCounterLabel }}
</span>
</div>
</div> </div>
<div class="card-footer" v-if="showLabelFooter"> <div
class="card-footer"
v-if="showLabelFooter"
>
<button <button
class="label color-label has-tooltip" class="label color-label has-tooltip"
v-for="label in issue.labels" v-for="label in issue.labels"
......
...@@ -15,14 +15,9 @@ class ListIssue { ...@@ -15,14 +15,9 @@ class ListIssue {
this.subscribed = obj.subscribed; this.subscribed = obj.subscribed;
this.labels = []; this.labels = [];
this.selected = false; this.selected = false;
this.assignee = false;
this.position = obj.relative_position || Infinity; this.position = obj.relative_position || Infinity;
this.milestone_id = obj.milestone_id; this.milestone_id = obj.milestone_id;
if (obj.assignee) {
this.assignee = new ListUser(obj.assignee);
}
if (obj.milestone) { if (obj.milestone) {
this.milestone = new ListMilestone(obj.milestone); this.milestone = new ListMilestone(obj.milestone);
} }
...@@ -30,6 +25,8 @@ class ListIssue { ...@@ -30,6 +25,8 @@ class ListIssue {
obj.labels.forEach((label) => { obj.labels.forEach((label) => {
this.labels.push(new ListLabel(label)); this.labels.push(new ListLabel(label));
}); });
this.assignees = obj.assignees.map(a => new ListUser(a));
} }
addLabel (label) { addLabel (label) {
......
...@@ -236,8 +236,13 @@ ...@@ -236,8 +236,13 @@
margin-bottom: 5px; margin-bottom: 5px;
} }
&.is-active { &.is-active,
&.is-active .card-assignee:hover a {
background-color: $row-hover; background-color: $row-hover;
&:first-child:not(:only-child) {
box-shadow: -10px 0 10px 1px $row-hover;
}
} }
.label { .label {
...@@ -253,7 +258,7 @@ ...@@ -253,7 +258,7 @@
} }
.card-title { .card-title {
margin: 0; margin: 0 30px 0 0;
font-size: 1em; font-size: 1em;
line-height: inherit; line-height: inherit;
...@@ -269,10 +274,69 @@ ...@@ -269,10 +274,69 @@
min-height: 20px; min-height: 20px;
.card-assignee { .card-assignee {
margin-left: auto; display: flex;
margin-right: 5px; justify-content: flex-end;
padding-left: 10px; position: absolute;
right: 15px;
height: 20px; height: 20px;
width: 20px;
.avatar-counter {
display: none;
vertical-align: middle;
min-width: 20px;
line-height: 19px;
height: 20px;
padding-left: 2px;
padding-right: 2px;
border-radius: 2em;
}
img {
vertical-align: top;
}
a {
position: relative;
margin-left: -15px;
}
a:nth-child(1) {
z-index: 3;
}
a:nth-child(2) {
z-index: 2;
}
a:nth-child(3) {
z-index: 1;
}
a:nth-child(4) {
display: none;
}
&:hover {
.avatar-counter {
display: inline-block;
}
a {
position: static;
background-color: $white-light;
transition: background-color 0s;
margin-left: auto;
&:nth-child(4) {
display: block;
}
&:first-child:not(:only-child) {
box-shadow: -10px 0 10px 1px $white-light;
}
}
}
} }
.avatar { .avatar {
......
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