|
|
|
|
@@ -111,7 +111,7 @@
|
|
|
|
|
? 'bg-blue-600 text-white cursor-pointer'
|
|
|
|
|
: 'bg-slate-400 text-slate-200 cursor-not-allowed',
|
|
|
|
|
]"
|
|
|
|
|
@click="handleMainAction"
|
|
|
|
|
@click="processSelectedMembers"
|
|
|
|
|
>
|
|
|
|
|
{{ buttonText }}
|
|
|
|
|
</button>
|
|
|
|
|
@@ -145,7 +145,7 @@ import { Contact } from "@/db/tables/contacts";
|
|
|
|
|
export default class BulkMembersDialog extends Vue {
|
|
|
|
|
@Prop({ default: "" }) activeDid!: string;
|
|
|
|
|
@Prop({ default: "" }) apiServer!: string;
|
|
|
|
|
@Prop({ required: true }) dialogType!: "admit" | "visibility";
|
|
|
|
|
// isOrganizer: true = organizer mode (admit members), false = member mode (set visibility)
|
|
|
|
|
@Prop({ required: true }) isOrganizer!: boolean;
|
|
|
|
|
|
|
|
|
|
// Vue notification system
|
|
|
|
|
@@ -252,15 +252,7 @@ export default class BulkMembersDialog extends Vue {
|
|
|
|
|
return this.selectedMembers.includes(memberDid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async handleMainAction() {
|
|
|
|
|
if (this.dialogType === "admit") {
|
|
|
|
|
await this.organizerAdmitAndAddWithVisibility();
|
|
|
|
|
} else {
|
|
|
|
|
await this.memberAddContactWithVisibility();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async organizerAdmitAndAddWithVisibility() {
|
|
|
|
|
async processSelectedMembers() {
|
|
|
|
|
try {
|
|
|
|
|
const selectedMembers: MemberData[] = this.membersData.filter((member) =>
|
|
|
|
|
this.selectedMembers.includes(member.did),
|
|
|
|
|
@@ -275,16 +267,20 @@ export default class BulkMembersDialog extends Vue {
|
|
|
|
|
|
|
|
|
|
for (const member of selectedMembers) {
|
|
|
|
|
try {
|
|
|
|
|
// First, admit the member
|
|
|
|
|
await this.admitMember(member);
|
|
|
|
|
|
|
|
|
|
// Register them
|
|
|
|
|
await this.registerMember(member);
|
|
|
|
|
admittedCount++;
|
|
|
|
|
// Organizer mode: admit and register the member first
|
|
|
|
|
if (this.isOrganizer) {
|
|
|
|
|
await this.admitMember(member);
|
|
|
|
|
await this.registerMember(member);
|
|
|
|
|
admittedCount++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If they're not a contact yet, add them as a contact
|
|
|
|
|
if (!member.isContact) {
|
|
|
|
|
await this.addAsContact(member, true);
|
|
|
|
|
// Organizer mode: set isRegistered to true, member mode: undefined
|
|
|
|
|
await this.addAsContact(
|
|
|
|
|
member,
|
|
|
|
|
this.isOrganizer ? true : undefined,
|
|
|
|
|
);
|
|
|
|
|
contactAddedCount++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -299,88 +295,51 @@ export default class BulkMembersDialog extends Vue {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Show success notification
|
|
|
|
|
if (admittedCount > 0) {
|
|
|
|
|
this.$notify(
|
|
|
|
|
{
|
|
|
|
|
group: "alert",
|
|
|
|
|
type: "success",
|
|
|
|
|
title: "Members Admitted Successfully",
|
|
|
|
|
text: `${admittedCount} member${admittedCount === 1 ? "" : "s"} admitted and registered${contactAddedCount === 0 ? "" : admittedCount === contactAddedCount ? " and" : `, ${contactAddedCount}`}${contactAddedCount === 0 ? "" : ` added as contact${contactAddedCount === 1 ? "" : "s"}`}.`,
|
|
|
|
|
},
|
|
|
|
|
10000,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
if (errors > 0) {
|
|
|
|
|
this.$notify(
|
|
|
|
|
{
|
|
|
|
|
group: "alert",
|
|
|
|
|
type: "danger",
|
|
|
|
|
title: "Error",
|
|
|
|
|
text: "Failed to fully admit some members. Work with them individually below.",
|
|
|
|
|
},
|
|
|
|
|
5000,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.close(notSelectedMembers.map((member) => member.did));
|
|
|
|
|
} catch (error) {
|
|
|
|
|
// eslint-disable-next-line no-console
|
|
|
|
|
console.error("Error admitting members:", error);
|
|
|
|
|
this.$notify(
|
|
|
|
|
{
|
|
|
|
|
group: "alert",
|
|
|
|
|
type: "danger",
|
|
|
|
|
title: "Error",
|
|
|
|
|
text: "Some errors occurred. Work with members individually below.",
|
|
|
|
|
},
|
|
|
|
|
5000,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async memberAddContactWithVisibility() {
|
|
|
|
|
try {
|
|
|
|
|
const selectedMembers: MemberData[] = this.membersData.filter((member) =>
|
|
|
|
|
this.selectedMembers.includes(member.did),
|
|
|
|
|
);
|
|
|
|
|
const notSelectedMembers: MemberData[] = this.membersData.filter(
|
|
|
|
|
(member) => !this.selectedMembers.includes(member.did),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
let contactsAddedCount = 0;
|
|
|
|
|
|
|
|
|
|
for (const member of selectedMembers) {
|
|
|
|
|
try {
|
|
|
|
|
// If they're not a contact yet, add them as a contact first
|
|
|
|
|
if (!member.isContact) {
|
|
|
|
|
await this.addAsContact(member, undefined);
|
|
|
|
|
contactsAddedCount++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Set their seesMe to true
|
|
|
|
|
await this.updateContactVisibility(member.did, true);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
// eslint-disable-next-line no-console
|
|
|
|
|
console.error(`Error processing member ${member.did}:`, error);
|
|
|
|
|
// Continue with other members even if one fails
|
|
|
|
|
if (this.isOrganizer) {
|
|
|
|
|
if (admittedCount > 0) {
|
|
|
|
|
this.$notify(
|
|
|
|
|
{
|
|
|
|
|
group: "alert",
|
|
|
|
|
type: "success",
|
|
|
|
|
title: "Members Admitted Successfully",
|
|
|
|
|
text: `${admittedCount} member${admittedCount === 1 ? "" : "s"} admitted and registered${contactAddedCount === 0 ? "" : admittedCount === contactAddedCount ? " and" : `, ${contactAddedCount}`}${contactAddedCount === 0 ? "" : ` added as contact${contactAddedCount === 1 ? "" : "s"}`}.`,
|
|
|
|
|
},
|
|
|
|
|
5000,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
if (errors > 0) {
|
|
|
|
|
this.$notify(
|
|
|
|
|
{
|
|
|
|
|
group: "alert",
|
|
|
|
|
type: "danger",
|
|
|
|
|
title: "Error",
|
|
|
|
|
text: "Failed to fully admit some members. Work with them individually below.",
|
|
|
|
|
},
|
|
|
|
|
5000,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// Member mode: show contacts added notification
|
|
|
|
|
if (contactAddedCount > 0) {
|
|
|
|
|
this.$notify(
|
|
|
|
|
{
|
|
|
|
|
group: "alert",
|
|
|
|
|
type: "success",
|
|
|
|
|
title: "Contacts Added Successfully",
|
|
|
|
|
text: `${contactAddedCount} member${contactAddedCount === 1 ? "" : "s"} added as contact${contactAddedCount === 1 ? "" : "s"}.`,
|
|
|
|
|
},
|
|
|
|
|
5000,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Show success notification
|
|
|
|
|
this.$notify(
|
|
|
|
|
{
|
|
|
|
|
group: "alert",
|
|
|
|
|
type: "success",
|
|
|
|
|
title: "Contacts Added Successfully",
|
|
|
|
|
text: `${contactsAddedCount} member${contactsAddedCount === 1 ? "" : "s"} added as contact${contactsAddedCount === 1 ? "" : "s"}.`,
|
|
|
|
|
},
|
|
|
|
|
5000,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
this.close(notSelectedMembers.map((member) => member.did));
|
|
|
|
|
} catch (error) {
|
|
|
|
|
// eslint-disable-next-line no-console
|
|
|
|
|
console.error("Error adding contacts:", error);
|
|
|
|
|
console.error(
|
|
|
|
|
`Error ${this.isOrganizer ? "admitting members" : "adding contacts"}:`,
|
|
|
|
|
error,
|
|
|
|
|
);
|
|
|
|
|
this.$notify(
|
|
|
|
|
{
|
|
|
|
|
group: "alert",
|
|
|
|
|
@@ -487,10 +446,10 @@ export default class BulkMembersDialog extends Vue {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
showContactInfo() {
|
|
|
|
|
const message =
|
|
|
|
|
this.dialogType === "admit"
|
|
|
|
|
? "This user is already your contact, but they are not yet admitted to the meeting."
|
|
|
|
|
: "This user is already your contact, but your activities are not visible to them yet.";
|
|
|
|
|
// isOrganizer: true = admit mode, false = visibility mode
|
|
|
|
|
const message = this.isOrganizer
|
|
|
|
|
? "This user is already your contact, but they are not yet admitted to the meeting."
|
|
|
|
|
: "This user is already your contact, but your activities are not visible to them yet.";
|
|
|
|
|
|
|
|
|
|
this.$notify(
|
|
|
|
|
{
|
|
|
|
|
|