Fix account selection garbage

This commit is contained in:
Sol Fisher Romanoff 2022-06-16 08:25:09 +03:00
parent cf33b3295f
commit d1af4bdd51
No known key found for this signature in database
GPG key ID: 9D3F2B64F2341B62
4 changed files with 18 additions and 12 deletions

View file

@ -57,15 +57,16 @@ const ListNew = {
onInput () { onInput () {
this.search(this.query) this.search(this.query)
}, },
selectUser (user, event) { selectUser (user) {
if (this.selectedUserIds.includes(user.id)) { if (this.selectedUserIds.includes(user.id)) {
this.removeUser(user.id) this.removeUser(user.id)
event.target.classList.remove('selected')
} else { } else {
this.addUser(user) this.addUser(user)
event.target.classList.add('selected')
} }
}, },
isSelected (user) {
return this.selectedUserIds.includes(user.id)
},
addUser (user) { addUser (user) {
this.selectedUserIds.push(user.id) this.selectedUserIds.push(user.id)
}, },

View file

@ -41,9 +41,11 @@
:key="user.id" :key="user.id"
class="member" class="member"
> >
<div @click.capture.prevent="selectUser(user, $event)"> <BasicUserCard
<BasicUserCard :user="user" /> :user="user"
</div> :class="isSelected(user) ? 'selected' : ''"
@click.capture.prevent="selectUser(user)"
/>
</div> </div>
</div> </div>
<button <button

View file

@ -51,15 +51,16 @@ const ListNew = {
onInput () { onInput () {
this.search(this.query) this.search(this.query)
}, },
selectUser (user, event) { selectUser (user) {
if (this.selectedUserIds.includes(user.id)) { if (this.selectedUserIds.includes(user.id)) {
this.removeUser(user.id) this.removeUser(user.id)
event.target.classList.remove('selected')
} else { } else {
this.addUser(user) this.addUser(user)
event.target.classList.add('selected')
} }
}, },
isSelected (user) {
return this.selectedUserIds.includes(user.id)
},
addUser (user) { addUser (user) {
this.selectedUserIds.push(user.id) this.selectedUserIds.push(user.id)
}, },

View file

@ -41,9 +41,11 @@
:key="user.id" :key="user.id"
class="member" class="member"
> >
<div @click.capture.prevent="selectUser(user, $event)"> <BasicUserCard
<BasicUserCard :user="user" /> :user="user"
</div> :class="isSelected(user) ? 'selected' : ''"
@click.capture.prevent="selectUser(user)"
/>
</div> </div>
</div> </div>
<button <button