UNPKG

@agendize/vue-settings

Version:
151 lines (150 loc) 6.54 kB
import { defineComponent as H, ref as p, onMounted as J, openBlock as y, createElementBlock as K, createVNode as b, unref as s, withCtx as A, createBlock as B, createCommentVNode as P } from "vue"; import { StructuredLayout as Q, StructuredSection as R, Button as U, StructuredList as X, AzAvatar as Y } from "@agendize/design-system"; import { u as Z } from "./vendor.26bbd9f1.js"; import { defineAsyncComponentWithLoading as ee, useApi as te, useAccountStore as ne, personToInitials as ae, isStringIncludeInList as se } from "@agendize/vue-tools"; import { useToast as oe } from "vue-toastification"; const ue = /* @__PURE__ */ H({ __name: "ConferenceAttendee", props: { organisation: {}, conference: {} }, emits: ["hasChange", "valid"], setup(_, { expose: M, emit: ie }) { const o = _, x = ee(() => import("./AddAttendeeModal.38081cde.js")), { t: i } = Z(), m = te(); ne(); const k = p(), v = oe(), C = p(0), g = p(!1), N = p([]); function z(e, t) { var n, a, l, c, d, r, f, u; return se([`${(a = (n = e.object) == null ? void 0 : n.lastName) != null ? a : ""} ${(c = (l = e.object) == null ? void 0 : l.firstName) != null ? c : ""}`, (r = (d = e.title) == null ? void 0 : d.label) != null ? r : "", (u = (f = e.subTitle) == null ? void 0 : f.label) != null ? u : ""], t == null ? void 0 : t.basic); } function E(e) { var n, a; const t = `${(n = e.firstName) != null ? n : ""} ${(a = e.lastName) != null ? a : ""}`; return { id: e.id, title: { label: t, needTranslation: !1 }, subTitle: { label: e.emailAddress, needTranslation: !1 }, ariaLabel: i("settings.conferences.details.attendee.speaker.aria-label", { name: t }), object: e, type: "speaker" }; } function F(e) { var n, a; const t = `${(n = e.firstName) != null ? n : ""} ${(a = e.lastName) != null ? a : ""}`; return { id: e.id, title: { label: t, needTranslation: !1 }, subTitle: { label: e.emailAddress, needTranslation: !1 }, ariaLabel: i("settings.conferences.details.attendee.invitee.aria-label", { name: t }), object: e, type: "invitee" }; } function h(e, t) { var l, c, d, r, f, u, S, I, j, T, $, w; const n = ((c = (l = e.object) == null ? void 0 : l.firstName) != null ? c : "").localeCompare((r = (d = t.object) == null ? void 0 : d.firstName) != null ? r : ""); if (n != 0) return n; const a = ((u = (f = e.object) == null ? void 0 : f.lastName) != null ? u : "").localeCompare((I = (S = t.object) == null ? void 0 : S.lastName) != null ? I : ""); return a != 0 ? a : ((T = (j = e.object) == null ? void 0 : j.emailAddress) != null ? T : "").localeCompare((w = ($ = t.object) == null ? void 0 : $.emailAddress) != null ? w : ""); } async function V(e) { var l, c, d; if (!((l = o.conference) != null && l.id)) return []; let t = []; const n = await m.getAllConferenceSpeakers(o.organisation.email, o.conference.id); N.value = [...n.results], t = t.concat((c = n.results) == null ? void 0 : c.map((r) => E(r)).sort(h)); const a = await m.getAllConferenceInvitees(o.organisation.email, o.conference.id); return t = t.concat((d = a.results) == null ? void 0 : d.map((r) => F(r)).sort(h)), t; } async function O(e) { try { e.type === "invitee" ? await m.deleteConferenceInviteeById(o.organisation.email, o.conference.id, e.id) : e.type === "speaker" && await m.deleteConferenceSpeakerById(o.organisation.email, o.conference.id, e.id), v.success(i("settings.conferences.details.attendee.delete-success")), k.value.loadAndFetch(); } catch { v.error(i("settings.conferences.details.attendee.delete-error")); } } const D = { basicSearch: { filter: z, placeholder: i("settings.conferences.details.attendee.search.basic.placeholder"), ariaLabel: i("settings.conferences.details.attendee.search.basic.ariaLabel") } }; function W() { return []; } function q() { g.value = !0; } function L() { g.value = !1; } function G(e) { L(), C.value++; } return J(() => { }), M({ getConferenceAttendeesBeforeSave: W }), (e, t) => (y(), K("div", null, [ b(s(Q), null, { column1: A(() => [ b(s(R), { gap: 2, title: { label: s(i)("settings.conferences.details.attendee.section.title") }, "sub-title": { label: s(i)("settings.conferences.details.attendee.section.sub-title") } }, { action: A(() => [ b(s(U), { id: "attendee-add", color: "lightprimary", shape: "circle", "aria-label": s(i)("settings.conferences.details.attendee.add-button"), iconAlone: "fa fa-plus", onClick: t[0] || (t[0] = (n) => q()) }, null, 8, ["aria-label"]) ]), content: A(() => [ (y(), B(s(X), { ref_key: "conferenceAttendeeList", ref: k, id: "az-conference-attendee-list-container", "item-bordered": !0, "item-clickable": !1, fetchItems: V, searchOption: D, key: C.value, onDelete: t[1] || (t[1] = (n) => O(n)), deleteLabel: s(i)("settings.conferences.details.attendee.delete") }, { startItemSlot: A(({ item: n }) => [ b(s(Y), { id: `az-conference-attendee-list-item-icon-${n.id}`, initials: n.type === "speaker" ? s(ae)(n.object) : "", color: n.type === "speaker" ? "primary" : "neutral", icon: n.type === "speaker" ? "" : "fa fa-star" }, null, 8, ["id", "initials", "color", "icon"]) ]), _: 1 }, 8, ["deleteLabel"])) ]), _: 1 }, 8, ["title", "sub-title"]) ]), _: 1 }), g.value ? (y(), B(s(x), { key: 0, organisationEmail: e.organisation.email, conferenceId: o.conference.id, speakers: N.value, onClose: L, onAttendeeAdded: G }, null, 8, ["organisationEmail", "conferenceId", "speakers"])) : P("", !0) ])); } }); export { ue as default };