In Vue bootstrap, a b-table has a list (unknown length) of rows. A remove button should only appear if the email in the row matches the email of the current logged in user. This currently works if it is only checking one row.
<b-table
:items="selectedGrant.interested_agencies"
:fields="interestedAgenciesFields"
>
<template #cell(actions)="row">
<b-row v-if="loggedInUser.email === selectedGrant.interested_agencies[0]['user_email']">
<b-button variant="danger" class="mr-1" size="sm" @click="unmarkGrantAsInterested(row)">
<b-icon icon="trash-fill" aria-hidden="true"></b-icon>
</b-button>
</b-row>
</template>
</b-table>
How would I loop through all of the rows in the table?
Simply putting selectedGrant.interested_agencies[row]['user_email'] does not go through each individual row. Most of what I have found for looping is for li lists and not the b-table. I have also tried incorporating a v-for in the template and another b-row, to no avail.
I have also tried a computing method in its place, but it did not work:
loop() {
let i;
let match;
for (i = 0; i < this.interestedAgenciesFields.length(); i += 1) {
if (this.loggedInUser.email === this.selectedGrant.interested_agencies[i].user_email) {
match = true;
} else {
match = false;
}
}
return match;
},
Maybe it is something with javascript .find() method that could work? Again, I have enot found success with it.
Is there some way to loop through a b-table, whether it is inline of in a computing method, to check a specific value in each row? It should not be only checking one row.