UNPKG

@agendize/vue-settings

Version:
187 lines (186 loc) 8.19 kB
import { defineComponent as H, ref as s, computed as L, onMounted as J, openBlock as v, createBlock as p, unref as l, withCtx as N, createVNode as F, createCommentVNode as g } from "vue"; import { AddressObject as Q, ModalDialogBox as R, StructuredFormLayout as W, FieldSelect as I, Mandatory as f, Address as Y, FieldInput as M, FieldUrl as Z } from "@agendize/design-system"; import { u as $ } from "./vendor.26bbd9f1.js"; import { ConferenceLocationEntity as _ } from "@agendize/js-calendar-api"; import { useApi as ee } from "@agendize/vue-tools"; import { g as le } from "./View.905e917a.js"; import "vue-router"; import "./index.d2d0aba2.js"; import "@agendize/az-i18n"; import "@agendize/vue-acl"; import "vue-toastification"; const ve = /* @__PURE__ */ H({ __name: "ConferenceLocationModal", props: { conference: {}, organisation: {} }, emits: ["validate", "close"], setup(S, { emit: j }) { var U; const D = S, E = ee(), { t: n, locale: G } = $(), w = j, K = (U = {}.VITE_MAPBOX_TOKEN) != null ? U : "", k = s([]), d = { value: "companyAddress", label: n("settings.conferences.details.general.location.address.company.title") }, i = { value: "address", label: n("settings.conferences.details.general.location.address.title") }, u = { value: "link", label: n("settings.conferences.details.general.location.link.title") }, m = { value: "custom", label: n("settings.conferences.details.general.location.custom.title") }, z = s([i, u, m]), y = s([i.value]), V = s(), r = s(new Q()), A = s(), C = s(), x = s(), B = s(!1), O = s(!1), h = s(!1), T = s(!1), c = L(() => y.value.length > 0 ? y.value[0] : i.value), P = L(() => { switch (c.value) { case d.value: return B.value; case i.value: return O.value; case u.value: return h.value; case m.value: return T.value; default: return !1; } }); function b(a, e) { const o = typeof e == "boolean" ? e : e.isValid; switch (a) { case d.value: B.value = o; break; case i.value: O.value = o; break; case u.value: h.value = o; break; case m.value: T.value = o; break; } } function X() { var e, o; let a = new _(); switch (c.value) { case d.value: a.type = "schedulingCompanyAddress", a.companyId = ((o = (e = V.value) == null ? void 0 : e.length) != null ? o : 0) === 0 ? "" : V.value[0]; break; case i.value: a.type = "address", a.street = r.value.street, a.additionalStreet = r.value.otherStreet, a.zipCode = r.value.zipCode, a.city = r.value.city, a.country = r.value.country, a.state = r.value.state, r.value.latitude && r.value.longitude && (a.geolocation = { lat: r.value.latitude, lng: r.value.longitude }); break; case u.value: a.type = "link", a.title = A.value, a.link = C.value; break; case m.value: a.type = "custom", a.text = x.value; break; } w("validate", a); } function q() { w("close"); } return J(async () => { var e; const a = new Intl.DisplayNames([G.value], { type: "region" }); k.value = ((e = (await E.getAllCompanies(D.organisation.email)).results) != null ? e : []).filter( (o) => o.address !== void 0 && o.address.street !== "" && o.address.city !== "" ).map((o) => { var t; return { value: (t = o.id) != null ? t : "", label: le(o, a) }; }), k.value.length > 0 && (z.value.unshift(d), y.value = [d.value]); }), (a, e) => (v(), p(l(R), { id: "az-conference-location", title: l(n)("settings.conferences.details.general.location.title"), closeOnBlurClick: !0, primaryLabel: l(n)("settings.conferences.details.general.location.validate"), primaryAction: X, primaryDisabled: !P.value, hasNeutral: !1, modalAutofocus: !1, size: 700, contentOverflow: "unset", onClose: q }, { content: N(() => [ F(l(W), null, { default: N(() => { var o; return [ F(l(I), { id: "az-conference-location-type", modelValue: y.value, "onUpdate:modelValue": e[0] || (e[0] = (t) => y.value = t), values: z.value, clearable: !1, label: l(n)("settings.conferences.details.general.location.type"), mandatory: l(f).mandatory, placeholder: "" }, null, 8, ["modelValue", "values", "label", "mandatory"]), c.value == d.value ? (v(), p(l(I), { key: 0, id: "az-conference-location-company-address", modelValue: V.value, "onUpdate:modelValue": e[1] || (e[1] = (t) => V.value = t), values: k.value, clearable: !1, label: l(n)("settings.conferences.details.general.location.address.company.field.title"), mandatory: l(f).mandatory, placeholder: l(n)("settings.conferences.details.general.location.address.company.field.placeholder"), onValidated: e[2] || (e[2] = (t) => { b(d.value, t); }) }, null, 8, ["modelValue", "values", "label", "mandatory", "placeholder"])) : g("", !0), c.value == i.value ? (v(), p(l(Y), { key: 1, id: "az-conference-location-address", mandatory: l(f).mandatory, mapBoxToken: (o = l(K)) != null ? o : "", modelValue: r.value, useBrowserGeolocation: !1, onValidated: e[3] || (e[3] = (t) => { b(i.value, t); }) }, null, 8, ["mandatory", "mapBoxToken", "modelValue"])) : g("", !0), c.value == u.value ? (v(), p(l(M), { key: 2, id: "az-conference-location-url-text", modelValue: A.value, "onUpdate:modelValue": e[4] || (e[4] = (t) => A.value = t), mandatory: l(f).optional, label: l(n)("settings.conferences.details.general.location.link.field.description.title"), placeholder: l(n)("settings.conferences.details.general.location.link.field.description.placeholder") }, null, 8, ["modelValue", "mandatory", "label", "placeholder"])) : g("", !0), c.value == u.value ? (v(), p(l(Z), { key: 3, id: "az-conference-location-url", mandatory: l(f).mandatory, modelValue: C.value, "onUpdate:modelValue": e[5] || (e[5] = (t) => C.value = t), onValidated: e[6] || (e[6] = (t) => { b(u.value, t); }), label: l(n)("settings.conferences.details.general.location.link.field.link.title"), placeholder: l(n)("settings.conferences.details.general.location.link.field.link.placeholder") }, null, 8, ["mandatory", "modelValue", "label", "placeholder"])) : g("", !0), c.value == m.value ? (v(), p(l(M), { key: 4, id: "az-conference-location-text", modelValue: x.value, "onUpdate:modelValue": e[7] || (e[7] = (t) => x.value = t), mandatory: l(f).mandatory, onValidated: e[8] || (e[8] = (t) => { b(m.value, t); }), label: l(n)("settings.conferences.details.general.location.custom.field.title"), placeholder: l(n)("settings.conferences.details.general.location.custom.field.placeholder") }, null, 8, ["modelValue", "mandatory", "label", "placeholder"])) : g("", !0) ]; }), _: 1 }) ]), _: 1 }, 8, ["title", "primaryLabel", "primaryDisabled"])); } }); export { ve as default };