UNPKG

@agendize/vue-settings

Version:
253 lines (252 loc) 7.92 kB
import { ref as T, computed as $, reactive as E, onMounted as K, defineComponent as x, openBlock as D, createElementBlock as N, withDirectives as V, createElementVNode as d, vModelRadio as L, createBlock as A, unref as t, withCtx as u, withKeys as R, toDisplayString as h, createVNode as f } from "vue"; import { PageWithTabsAndPanel as O, Table as P } from "@agendize/design-system"; import { i as S, S as U } from "./index.d2d0aba2.js"; import { SchedulingRightsEntity as G } from "@agendize/js-calendar-api"; import "./vendor.26bbd9f1.js"; import "@agendize/az-i18n"; import "@agendize/vue-tools"; import "vue-router"; import "@agendize/vue-acl"; function W(p, i, o, s, c, r) { const l = S(s), n = T(!1), m = T(), w = $(() => { let g = l.global.t("settings.rights-details.title"); return m.value && (g += " - " + G.getUserName(m.value)), g; }), y = $(() => ({ title: w.value, titleTranslatable: !0, subTitle: l.global.t("settings.rights-details.subTitle"), tabs: [{ id: "detail", title: "" }] })), C = E({ columns: [ { label: l.global.t("settings.rights-details.table.column.company"), field: "name", width: "flex-5", sortable: !1 }, { label: l.global.t("settings.rights-details.table.column.administrator"), field: "administrator", width: "flex-1", sortable: !1, columnClasses: "az-text-center" }, { label: l.global.t("settings.rights-details.table.column.scheduler"), field: "scheduler", width: "flex-1", sortable: !1, columnClasses: "az-text-center" }, { label: l.global.t("settings.rights-details.table.column.reader"), field: "reader", width: "flex-1", sortable: !1, columnClasses: "az-text-center" }, { label: l.global.t("settings.rights-details.table.column.none"), field: "none", width: "flex-1", sortable: !1, columnClasses: "az-text-center" } ], sortable: { order: "name", sort: "asc" } }); async function a() { await (i == null ? void 0 : i.push({ name: U.Rights })); } async function e() { n.value = !0; try { !r || r === "0" || await p.updateSchedulingRights(c, r, m.value), o == null || o.success(l.global.t("settings.rights-details.save-success")), n.value = !1, await a(); } catch { o == null || o.error(l.global.t("settings.rights-details.save-error")), n.value = !1; } } function B(g) { var b, v; return Promise.resolve((v = (b = m.value) == null ? void 0 : b.companies) != null ? v : []); } function M(g, b) { return b = b.toLowerCase(), g.filter((v) => { var k; return (k = v.company.name) == null ? void 0 : k.toLowerCase().includes(b); }); } return K(async () => { if (n.value = !0, !r || r === "0") await a(); else try { const g = await p.getSchedulingRightsById(c, r); g && (m.value = g); } catch { await a(); } n.value = !1; }), { pageOptions: y, tableDescription: C, loading: n, backToList: a, saveRights: e, fetchCompaniesRight: B, filterCompaniesRight: M }; } const j = ["id", "name", "value"], q = ["for"], z = /* @__PURE__ */ x({ __name: "RightRadioButton", props: { value: {}, companyRight: {} }, setup(p) { const i = p; function o() { i.companyRight.right !== i.value && (i.companyRight.right = i.value); } return (s, c) => (D(), N("div", { onClick: c[1] || (c[1] = (r) => o()), class: "az-text-center az-cursor-pointer" }, [ V(d("input", { type: "radio", id: `radio-${s.companyRight.company.id}-${s.value}`, class: "az-radio-button az-hidden", name: `radio-${s.companyRight.company.id}`, "onUpdate:modelValue": c[0] || (c[0] = (r) => s.companyRight.right = r), value: s.value }, null, 8, j), [ [L, s.companyRight.right] ]), d("label", { for: `radio-${s.companyRight.company.id}-${s.value}`, class: "az-hidden az-align-middle" }, null, 8, q) ])); } }), F = ["disabled"], H = { class: "exclude-weglot" }, J = { class: "az-m-2 az-text-grey-700" }, lt = /* @__PURE__ */ x({ __name: "View", props: { api: {}, locale: {}, userId: {}, organisation: {}, router: {}, toaster: {}, logger: {} }, setup(p) { var y; const i = p, o = S(i.locale), { pageOptions: s, tableDescription: c, loading: r, backToList: l, saveRights: n, fetchCompaniesRight: m, filterCompaniesRight: w } = W(i.api, i.router, i.toaster, i.locale, (y = i.organisation.email) != null ? y : "", i.userId); return (C, a) => (D(), A(t(O), { id: "settings-rights-details", loading: t(r), options: t(s), locale: i.locale }, { actions: u(() => [ d("button", { id: "az-back-action", class: "az-btn az-btn-color-neutral", onClick: a[0] || (a[0] = (...e) => t(l) && t(l)(...e)), onKeypress: a[1] || (a[1] = R( (...e) => t(l) && t(l)(...e), ["enter"] )) }, h(t(o).global.t("common.action.back-to-list")), 33), d("button", { id: "az-save-action", class: "az-btn az-btn-color-primary az-whitespace-nowrap", disabled: t(r), onClick: a[2] || (a[2] = (...e) => t(n) && t(n)(...e)), onKeypress: a[3] || (a[3] = R( (...e) => t(n) && t(n)(...e), ["enter"] )) }, h(t(o).global.t("common.action.save")), 41, F) ]), mobileActions: u(() => [ d("button", { class: "az-btn az-btn-color-neutral", onClick: a[4] || (a[4] = (...e) => t(l) && t(l)(...e)), onKeypress: a[5] || (a[5] = R( (...e) => t(l) && t(l)(...e), ["enter"] )) }, h(t(o).global.t("settings.action.cancel")), 33), d("button", { class: "az-btn az-btn-color-primary", onClick: a[6] || (a[6] = (...e) => t(n) && t(n)(...e)), onKeypress: a[7] || (a[7] = R( (...e) => t(n) && t(n)(...e), ["enter"] )) }, h(t(o).global.t("common.action.save")), 33) ]), detail: u(() => [ f(t(P), { id: "az-rights", columns: t(c).columns, fetchMoreData: t(m), filter: t(w), "search-label": t(o).global.t("settings.rights-details.table.placeholder"), searchable: !0, selectable: !1, hover: !1, sortable: t(c).sortable }, { "col(name)": u(({ row: e }) => [ d("span", H, h(e.company.name), 1) ]), "col(administrator)": u(({ row: e }) => [ f(z, { companyRight: e, value: "1" }, null, 8, ["companyRight"]) ]), "col(scheduler)": u(({ row: e }) => [ f(z, { companyRight: e, value: "2" }, null, 8, ["companyRight"]) ]), "col(reader)": u(({ row: e }) => [ f(z, { companyRight: e, value: "3" }, null, 8, ["companyRight"]) ]), "col(none)": u(({ row: e }) => [ f(z, { companyRight: e, value: "" }, null, 8, ["companyRight"]) ]), noData: u(() => [ d("div", J, h(t(o).global.t("settings.rights-details.table.empty")), 1) ]), _: 1 }, 8, ["columns", "fetchMoreData", "filter", "search-label", "sortable"]) ]), _: 1 }, 8, ["loading", "options", "locale"])); } }); export { lt as default };