Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | 92x 96x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 2x 2x 2x 2x 2x 2x 2x 1x 1x 1x 1x 1x 1x 1x 1x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 91x 91x 91x 91x 91x 91x 91x 91x 91x 91x 91x 91x 91x 91x 91x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x | import { css, html, TemplateResult } from 'lit';
import { property } from 'lit/decorators.js';
import { Group } from '../interfaces';
import { debounce, getClasses } from '../utils';
import { Icon } from '../Icons';
import { ContactStoreElement } from './ContactStoreElement';
const STATUS = {
stopped: { name: 'Stopped' },
blocked: { name: 'Blocked' },
archived: { name: 'Archived' }
};
export class ContactBadges extends ContactStoreElement {
static get styles() {
return css`
.wrapper {
display: flex;
flex-direction: column;
align-items: center;
}
temba-label {
margin: 0.3em;
}
.expanded .badges {
max-height: inherit;
}
.expanded .show-button {
opacity: 1;
margin-bottom: 0em;
margin-top: -0.5em;
}
.expanded .show-line {
width: 98%;
opacity: 1;
}
.badges {
display: flex;
overflow: hidden;
flex-wrap: wrap;
max-height: 2.2em;
align-self: flex-start;
}
.show-button {
transition: all var(--transition-speed) ease-in-out
var(--transition-speed);
opacity: 0;
display: flex;
padding: 0em 1em;
margin-top: -0.8em;
cursor: pointer;
--icon-color-circle: #fff;
margin-bottom: -1.5em;
}
.show-line {
height: 1px;
width: 100%;
background: rgba(0, 0, 0, 0.05);
margin-top: 1em;
width: 0px;
transition: width calc(var(--transition-speed) * 2) linear
var(--transition-speed);
}
.has-more .show-line {
width: 98%;
}
.has-more .show-button {
opacity: 1;
margin-bottom: 0em;
margin-top: -0.5em;
}
.show-button temba-icon {
border-radius: 9999px;
}
`;
}
@property({ type: Boolean })
hasMore = false;
@property({ type: Boolean })
expanded = false;
private handleResized() {
if (this.shadowRoot) {
const badges = this.shadowRoot.querySelector('.badges');
if (badges) {
this.hasMore = badges.scrollHeight > badges.clientHeight;
}
}
}
public updated(changedProperties: Map<string, any>) {
super.updated(changedProperties);
if (changedProperties.has('data')) {
if (!changedProperties.get('data')) {
const badges = this.shadowRoot.querySelector('.badges');
new ResizeObserver(
debounce(this.handleResized.bind(this), 200)
).observe(badges);
}
}
}
public render(): TemplateResult {
if (this.data) {
const status = STATUS[this.data.status];
return html`
<div
class=${getClasses({
wrapper: true,
'has-more': this.hasMore,
expanded: this.expanded
})}
>
<div class="badges">
${status && this.data.status !== 'active'
? html`
<temba-label
icon="icon.contact_${this.data.status}"
onclick="goto(event)"
href="/contact/${status.name.toLowerCase()}/"
secondary
clickable
shadow
>
${status.name}
</temba-label>
`
: null}
${this.data.flow
? html`
<temba-label
icon="flow"
onclick="goto(event)"
href="/contact/?search=flow+%3D+${encodeURIComponent(
'"' + this.data.flow.name + '"'
)}"
clickable
primary
shadow
>
${this.data.flow.name}
</temba-label>
`
: null}
${this.data.language
? html`
<temba-label
icon=${Icon.language}
onclick="goto(event)"
href="/contact/?search=language+%3D+${encodeURIComponent(
'"' + this.data.language + '"'
)}"
clickable
primary
shadow
>
${this.store.getLanguageName(this.data.language)}
</temba-label>
`
: null}
${this.data.groups.map((group: Group) => {
return html`
<temba-label
class="group"
onclick="goto(event)"
href="/contact/group/${group.uuid}/"
icon=${group.is_dynamic ? Icon.group_smart : Icon.group}
clickable
shadow
>
${group.name}
</temba-label>
`;
})}
</div>
<div class="show-line"></div>
<div class="show-button">
<temba-icon
@click=${() => {
this.expanded = !this.expanded;
}}
circled
name=${!this.expanded ? Icon.down : Icon.up}
animateChange="spin"
></temba-icon>
</div>
</div>
`;
} else {
return null;
}
}
}
|