@ozdao/prometheus-framework 0.1.19 → 0.1.21

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. package/dist/BackofficeGallery-3bb55ea2.mjs +357 -0
  2. package/dist/BackofficeGallery-7ae8fbba.mjs +307 -0
  3. package/dist/BackofficeGallery-e54a33a3.js +1 -0
  4. package/dist/BackofficeGallery-fe39cff3.js +1 -0
  5. package/dist/Breadcrumbs.vue_vue_type_style_index_0_lang-8660f9cb.js +1 -0
  6. package/dist/Breadcrumbs.vue_vue_type_style_index_0_lang-bd3889ee.mjs +1945 -0
  7. package/dist/ButtonFollow-81508d85.mjs +132 -0
  8. package/dist/ButtonFollow-df6317f0.js +1 -0
  9. package/dist/CardOrganization-d8f209ee.js +1 -0
  10. package/dist/CardOrganization-de8ec36e.mjs +230 -0
  11. package/dist/Feed-a75d053e.js +1 -0
  12. package/dist/Feed-c4084664.mjs +368 -0
  13. package/dist/Feed-fea84ce7.mjs +439 -0
  14. package/dist/Feed-ff3b96b2.js +1 -0
  15. package/dist/Image-1281bc48.mjs +477 -0
  16. package/dist/Image-8e67dd2d.js +9 -0
  17. package/dist/Popup-b7609baa.js +1 -0
  18. package/dist/Popup-d5c4cb46.mjs +76 -0
  19. package/dist/Product-3c7b2921.mjs +841 -0
  20. package/dist/Product-6df77924.js +7 -0
  21. package/dist/ProductEdit-737e2a5a.mjs +302 -0
  22. package/dist/ProductEdit-c99ab559.js +1 -0
  23. package/dist/ProfileBlogposts-4293a1e3.js +1 -0
  24. package/dist/ProfileBlogposts-4c326fed.mjs +65 -0
  25. package/dist/ProfileComments-03f88b54.mjs +44 -0
  26. package/dist/ProfileComments-761ce00e.js +1 -0
  27. package/dist/ProfileEvents-0bdd36e4.mjs +57 -0
  28. package/dist/ProfileEvents-a9b96fec.js +1 -0
  29. package/dist/ProfileLikes-3edf6fb8.mjs +44 -0
  30. package/dist/ProfileLikes-51729962.js +1 -0
  31. package/dist/ProfileOrganizations-8961aaee.mjs +213 -0
  32. package/dist/ProfileOrganizations-f52e62e1.js +1 -0
  33. package/dist/Publics-70a0ca9c.mjs +45 -0
  34. package/dist/Publics-bbab7a79.js +1 -0
  35. package/dist/Select-90d4b7c8.mjs +81 -0
  36. package/dist/Select-b9299fb6.js +1 -0
  37. package/dist/Select.vue_vue_type_style_index_0_scoped_a78dbba1_lang-0ea8fbf8.js +1 -0
  38. package/dist/Select.vue_vue_type_style_index_0_scoped_a78dbba1_lang-4ed993c7.mjs +1 -0
  39. package/dist/UploadImage-c9711af2.js +1 -0
  40. package/dist/UploadImage-ec3714e8.mjs +83 -0
  41. package/dist/UploadImageMultiple-b4c8d627.js +1 -0
  42. package/dist/UploadImageMultiple-ebcc51e6.mjs +58 -0
  43. package/dist/auth-78d9392a.mjs +612 -0
  44. package/dist/auth-96449d96.js +7 -0
  45. package/dist/auth.client.cjs +8 -8
  46. package/dist/auth.client.js +8 -8
  47. package/dist/auth.validation-9e493d2f.mjs +20 -0
  48. package/dist/auth.validation-d4795c25.js +1 -0
  49. package/dist/backoffice.client.cjs +1 -1
  50. package/dist/backoffice.client.js +44 -49
  51. package/dist/community.client.cjs +1 -1
  52. package/dist/community.client.js +44 -42
  53. package/dist/events.client.cjs +2 -2
  54. package/dist/events.client.js +25 -24
  55. package/dist/index-2a0269fc.js +2 -0
  56. package/dist/index-9128ade5.mjs +1228 -0
  57. package/dist/landing.client.cjs +1 -1
  58. package/dist/modules/backoffice/components/layouts/Backoffice.vue.d.ts +2 -0
  59. package/dist/modules/gallery/components/sections/BackofficeGallery.vue.d.ts +2 -0
  60. package/dist/organizations-0fb56927.mjs +122 -0
  61. package/dist/organizations-195ec134.js +1 -0
  62. package/dist/organizations.client-b39db194.js +3 -0
  63. package/dist/organizations.client-df5e8a6f.mjs +3020 -0
  64. package/dist/organizations.client.cjs +1 -1
  65. package/dist/organizations.client.js +46 -44
  66. package/dist/style.css +1 -1
  67. package/dist/users.client.cjs +1 -1
  68. package/dist/users.client.js +23 -23
  69. package/package.json +1 -1
  70. package/src/modules/backoffice/components/layouts/{Account.vue → Backoffice.vue} +0 -11
  71. package/src/modules/backoffice/router/account.js +64 -43
  72. package/src/modules/backoffice/router/admin.js +105 -84
  73. package/src/modules/backoffice/router/backoffice.js +3 -3
  74. package/src/modules/gallery/components/sections/{Gallery.vue → BackofficeGallery.vue} +3 -1
@@ -0,0 +1,357 @@
1
+ import ee, { reactive as te, ref as h, watchEffect as le, openBlock as u, createElementBlock as m, createVNode as b, unref as $, withCtx as P, Fragment as Q, renderList as W, createElementVNode as s, computed as ae, onMounted as oe, createCommentVNode as j, Transition as J, createTextVNode as Y, toDisplayString as D, withDirectives as ne, vShow as se, pushScopeId as ie, popScopeId as re } from "vue";
2
+ import { a as Z } from "./index-a661083c.mjs";
3
+ import { V as ce } from "./vue-draggable-next.esm-bundler-ff6e3f52.mjs";
4
+ import { _ as de } from "./UploadImageMultiple-cb6c7188.mjs";
5
+ import { useRoute as ue } from "vue-router";
6
+ import { _ as me } from "./_plugin-vue_export-helper-dad06003.mjs";
7
+ var F = {};
8
+ (function(o) {
9
+ Object.defineProperties(o, { __esModule: { value: !0 }, [Symbol.toStringTag]: { value: "Module" } });
10
+ var e = ee;
11
+ const c = { class: "flex-nowrap flex-v-center flex pd-medium bg-white" }, i = { key: 0, class: "t-left mn-r-small w-33" }, r = { class: "w-100" }, V = ["value", "placeholder"], w = e.defineComponent({ __name: "Field", props: { label: { default: "Label" }, placeholder: { default: "Enter something here" }, field: { default: null }, validation: { type: Boolean, default: !1 } }, emits: ["update:modelValue"], setup(t, { emit: a }) {
12
+ const l = t, d = e.ref(l.field);
13
+ return (p, y) => (e.openBlock(), e.createElementBlock("div", c, [t.label ? (e.openBlock(), e.createElementBlock("div", i, [e.createElementVNode("label", null, e.toDisplayString(t.label), 1)])) : e.createCommentVNode("", !0), e.createElementVNode("div", r, [e.createElementVNode("input", { onInput: y[0] || (y[0] = (z) => {
14
+ var g;
15
+ return d.value = a("update:modelValue", (g = z.target) == null ? void 0 : g.value);
16
+ }), type: "text", class: "w-100", value: t.field, placeholder: t.placeholder }, null, 40, V)])]));
17
+ } }), v = { class: "input-wrapper" }, C = { class: "t-transp p-small" }, x = { key: 0, class: "flex-nojustify flex-v-center flex-nowrap flex w-100" }, S = { key: 1, class: "w-100" }, N = ["onClick"], n = { __name: "Select", props: ["obj", "label", "prop", "value", "options", "content", "textarea", "placeholder", "size"], setup(t) {
18
+ const a = t, l = e.ref(null), d = e.ref(!1);
19
+ e.ref("Please select an item");
20
+ let p = e.computed(() => {
21
+ if (a.prop[a.content]) {
22
+ var g = a.options.indexOf(a.prop[a.content]), k = a.options.map((f) => f);
23
+ return g != -1 && k.splice(g, 1), k;
24
+ } else
25
+ return a.options;
26
+ });
27
+ a.prop[a.content] && (l.value = a.prop[a.content]);
28
+ function y() {
29
+ d.value = !d.value;
30
+ }
31
+ function z(g, k, f) {
32
+ var H = f;
33
+ l.value = H, d.value = !d.value, g[k] = H;
34
+ }
35
+ return (g, k) => (e.openBlock(), e.createElementBlock("div", v, [e.createElementVNode("span", C, e.toDisplayString(t.label), 1), e.createElementVNode("li", { onClick: k[0] || (k[0] = e.withModifiers((f) => y(), ["stop"])), class: e.normalizeClass([{ "input-small": t.size === "small" }, "pd-small flex-center flex-nowrap flex bg-grey input-select input"]) }, [l.value ? (e.openBlock(), e.createElementBlock("span", x, [e.createElementVNode("span", null, e.toDisplayString(l.value.name ? l.value.name : l.value), 1)])) : (e.openBlock(), e.createElementBlock("span", S, e.toDisplayString(t.placeholder ? t.placeholder : "Please select"), 1))], 2), d.value ? (e.openBlock(), e.createElementBlock("ul", { key: 0, class: e.normalizeClass([{ "dropdown-small": t.size === "small" }, "bg-grey dropdown-menu"]) }, [(e.openBlock(!0), e.createElementBlock(e.Fragment, null, e.renderList(e.unref(p), (f) => (e.openBlock(), e.createElementBlock("li", { class: e.normalizeClass([{ "input-small": t.size === "small" }, "pd-small bg-grey input-select input"]) }, [f ? (e.openBlock(), e.createElementBlock("span", { key: 0, onClick: (H) => z(t.prop, t.content, f), class: "flex-nojustify flex-v-center flex-nowrap flex w-100" }, [e.createElementVNode("span", null, e.toDisplayString(f.name ? f.name : f), 1)], 8, N)) : e.createCommentVNode("", !0)], 2))), 256))], 2)) : e.createCommentVNode("", !0)]));
36
+ } }, B = ["disabled"], I = { key: 0 }, R = { key: 0, class: "loading" }, E = e.createElementVNode("span", null, [e.createElementVNode("svg", { class: "i-default", width: "135", height: "140", viewBox: "0 0 135 140", xmlns: "http://www.w3.org/2000/svg", fill: "#fff" }, [e.createElementVNode("rect", { y: "10", width: "15", height: "120", rx: "6" }, [e.createElementVNode("animate", { attributeName: "height", begin: "0.5s", dur: "1s", values: "120;110;100;90;80;70;60;50;40;140;120", calcMode: "linear", repeatCount: "indefinite" }), e.createTextVNode(), e.createElementVNode("animate", { attributeName: "y", begin: "0.5s", dur: "1s", values: "10;15;20;25;30;35;40;45;50;0;10", calcMode: "linear", repeatCount: "indefinite" })]), e.createElementVNode("rect", { x: "30", y: "10", width: "15", height: "120", rx: "6" }, [e.createElementVNode("animate", { attributeName: "height", begin: "0.25s", dur: "1s", values: "120;110;100;90;80;70;60;50;40;140;120", calcMode: "linear", repeatCount: "indefinite" }), e.createTextVNode(), e.createElementVNode("animate", { attributeName: "y", begin: "0.25s", dur: "1s", values: "10;15;20;25;30;35;40;45;50;0;10", calcMode: "linear", repeatCount: "indefinite" })]), e.createElementVNode("rect", { x: "60", width: "15", height: "140", rx: "6" }, [e.createElementVNode("animate", { attributeName: "height", begin: "0s", dur: "1s", values: "120;110;100;90;80;70;60;50;40;140;120", calcMode: "linear", repeatCount: "indefinite" }), e.createTextVNode(), e.createElementVNode("animate", { attributeName: "y", begin: "0s", dur: "1s", values: "10;15;20;25;30;35;40;45;50;0;10", calcMode: "linear", repeatCount: "indefinite" })]), e.createElementVNode("rect", { x: "90", y: "10", width: "15", height: "120", rx: "6" }, [e.createElementVNode("animate", { attributeName: "height", begin: "0.25s", dur: "1s", values: "120;110;100;90;80;70;60;50;40;140;120", calcMode: "linear", repeatCount: "indefinite" }), e.createTextVNode(), e.createElementVNode("animate", { attributeName: "y", begin: "0.25s", dur: "1s", values: "10;15;20;25;30;35;40;45;50;0;10", calcMode: "linear", repeatCount: "indefinite" })]), e.createElementVNode("rect", { x: "120", y: "10", width: "15", height: "120", rx: "6" }, [e.createElementVNode("animate", { attributeName: "height", begin: "0.5s", dur: "1s", values: "120;110;100;90;80;70;60;50;40;140;120", calcMode: "linear", repeatCount: "indefinite" }), e.createTextVNode(), e.createElementVNode("animate", { attributeName: "y", begin: "0.5s", dur: "1s", values: "10;15;20;25;30;35;40;45;50;0;10", calcMode: "linear", repeatCount: "indefinite" })])])], -1), T = [E], A = { key: 0, class: "h4 loading" }, O = e.createElementVNode("span", { class: "t-white" }, "✔", -1), q = [O], X = { key: 0, class: "error" }, L = e.defineComponent({ __name: "Button", props: { submit: { type: Function, default: async () => {
37
+ console.log("Button click.");
38
+ } }, callback: { type: Function, default: async () => {
39
+ console.log("Button callback.");
40
+ } }, validation: { type: Boolean, default: !1 } }, setup(t) {
41
+ const a = t, l = e.ref(null), d = e.ref(null), p = e.ref(!1), y = e.ref(!1);
42
+ async function z() {
43
+ l.value.style["pointer-events"] = "none", d.value = null, p.value = !0;
44
+ try {
45
+ await a.submit(), l.value.classList.add("bg-light-blue"), l.value.classList.remove("bg-blue"), p.value = !1, y.value = !0, setTimeout(() => a.callback(), 750);
46
+ } catch {
47
+ l.value.classList.add("bg-light-red"), l.value.classList.remove("bg-blue"), d.value = "❌", setTimeout(() => {
48
+ l.value.classList.add("bg-blue"), l.value.classList.remove("bg-light-red"), l.value.style.pointerEvents = "auto", p.value = !1, y.value = !1, d.value = null;
49
+ }, 1e3);
50
+ }
51
+ }
52
+ return (g, k) => (e.openBlock(), e.createElementBlock("button", { onClick: z, disabled: t.validation, ref_key: "button", ref: l, class: "w-100 t-white bg-blue button" }, [e.createVNode(e.Transition, { mode: "out-in", name: "fadeIn" }, { default: e.withCtx(() => [!p.value && !d.value && !y.value ? (e.openBlock(), e.createElementBlock("span", I, [e.renderSlot(g.$slots, "default")])) : e.createCommentVNode("", !0)]), _: 3 }), e.createVNode(e.Transition, { mode: "out-in", name: "fadeIn" }, { default: e.withCtx(() => [p.value && !d.value ? (e.openBlock(), e.createElementBlock("div", R, T)) : e.createCommentVNode("", !0)]), _: 1 }), e.createVNode(e.Transition, { mode: "out-in", name: "fadeIn" }, { default: e.withCtx(() => [y.value ? (e.openBlock(), e.createElementBlock("div", A, q)) : e.createCommentVNode("", !0)]), _: 1 }), e.createVNode(e.Transition, { mode: "out-in", name: "fadeIn" }, { default: e.withCtx(() => [d.value ? (e.openBlock(), e.createElementBlock("div", X, [e.createElementVNode("span", null, e.toDisplayString(d.value), 1)])) : e.createCommentVNode("", !0)]), _: 1 })], 8, B));
53
+ } });
54
+ var U = { install: (t) => {
55
+ t.component("Field", w), t.component("Button", L), t.component("Select", n);
56
+ } };
57
+ o.Button = L, o.Field = w, o.Select = n, o.default = U;
58
+ })(F);
59
+ const pe = process.env.API_URL, K = Z.create({ baseURL: pe, withCredentials: !0 }), _ = te({
60
+ gallery: []
61
+ }), M = {
62
+ async fetchGallery(o, e) {
63
+ const c = [];
64
+ o && c.push(`page=${o}`), e && c.push(`limit=${e}`);
65
+ const i = `/api/gallery${c.length ? `?${c.join("&")}` : ""}`;
66
+ try {
67
+ const r = await K.get(i);
68
+ if (console.log(r), r && r.data)
69
+ return _.gallery = [..._.gallery, ...r.data], r.data;
70
+ } catch (r) {
71
+ throw console.error("Error fetching gallery:", r), r;
72
+ }
73
+ },
74
+ async createPhoto(o) {
75
+ try {
76
+ const e = await K.post("/api/gallery/create", o);
77
+ console.log(e.data), _.gallery = [...e.data, ..._.gallery];
78
+ } catch (e) {
79
+ console.error(e);
80
+ }
81
+ },
82
+ async updatePhoto(o) {
83
+ try {
84
+ const e = {
85
+ ...o,
86
+ categories: typeof o.categories == "string" ? o.categories.split(",").map((r) => r.trim()) : o.categories
87
+ }, c = await Z.post("/api/gallery/update", e), i = _.gallery.findIndex((r) => r._id === o._id);
88
+ i !== -1 && (_.gallery[i] = c.data);
89
+ } catch (e) {
90
+ console.error(e);
91
+ }
92
+ },
93
+ async deletePhoto(o) {
94
+ try {
95
+ const e = await K.post(`/api/gallery/delete/${o}`), c = _.gallery.findIndex((i) => i._id === o);
96
+ c !== -1 && _.gallery.splice(c, 1);
97
+ } catch (e) {
98
+ console.error(e);
99
+ }
100
+ }
101
+ };
102
+ const ve = { class: "pos-relative" }, ge = ["src"], fe = ["onClick"], he = {
103
+ __name: "EditImages",
104
+ props: {
105
+ images: Array
106
+ },
107
+ emits: ["update"],
108
+ setup(o, { emit: e }) {
109
+ const c = o, i = h([...c.images]);
110
+ le(() => {
111
+ i.value = [...c.images];
112
+ });
113
+ const r = () => {
114
+ e("update:images", i.value);
115
+ }, V = (v) => {
116
+ i.value = [...i.value, ...v], r();
117
+ }, w = (v) => {
118
+ i.value.splice(v, 1), r();
119
+ };
120
+ return (v, C) => (u(), m("div", null, [
121
+ b(de, {
122
+ "onUpdate:images": V,
123
+ uploadPath: "photos",
124
+ class: "mn-semi pd-small w-100 button bg-black t-white"
125
+ }),
126
+ b($(ce), {
127
+ class: "gap-small flex dragArea list-group w-full",
128
+ modelValue: i.value,
129
+ "onUpdate:modelValue": C[0] || (C[0] = (x) => i.value = x),
130
+ onChange: r
131
+ }, {
132
+ default: P(() => [
133
+ (u(!0), m(Q, null, W(i.value, (x, S) => (u(), m("div", ve, [
134
+ s("img", {
135
+ class: "i-extra radius-small o-hidden mn-thin",
136
+ src: (v.FILE_SERVER_URL || "") + x
137
+ }, null, 8, ge),
138
+ s("a", {
139
+ onClick: (N) => w(S),
140
+ class: "pos-absolute t-center radius-extra i-medium bg-red pos-t-0 pos-r-0"
141
+ }, "X", 8, fe)
142
+ ]))), 256))
143
+ ]),
144
+ _: 1
145
+ }, 8, ["modelValue"])
146
+ ]));
147
+ }
148
+ };
149
+ const G = (o) => (ie("data-v-f1c3938d"), o = o(), re(), o), _e = { class: "pos-relative w-100" }, ye = { class: "w-100 o-hidden" }, be = { class: "pd-medium flex-nowrap flex pd-t-thin pd-b-thin o-scroll" }, ke = ["data-id"], we = ["src", "onClick"], xe = {
150
+ key: 1,
151
+ class: "pd-small radius-small bg-white"
152
+ }, Ne = ["src", "onClick"], Ee = { class: "t-black p-small mn-small" }, Ve = /* @__PURE__ */ G(() => /* @__PURE__ */ s("span", { class: "uppercase t-transp" }, "Size", -1)), Ce = /* @__PURE__ */ G(() => /* @__PURE__ */ s("br", null, null, -1)), Be = { class: "pd-2px radius-big d-inline-block bg-grey" }, Se = { class: "t-black p-small mn-small uppe" }, Ie = /* @__PURE__ */ G(() => /* @__PURE__ */ s("span", { class: "uppercase t-transp" }, "Categories", -1)), ze = /* @__PURE__ */ G(() => /* @__PURE__ */ s("br", null, null, -1)), Me = { class: "pd-2px radius-big d-inline-block bg-grey t-semi" }, $e = { class: "flex-nowrap flex" }, Pe = ["onClick"], Te = { class: "modal pd-thin" }, Le = { class: "modal-content radius-big" }, Ue = { class: "" }, je = ["src"], De = {
153
+ key: 0,
154
+ class: "flex-v-center flex m modal pd-big"
155
+ }, Fe = { class: "modal-content radius-small pd-medium bg-white" }, Ge = ["src"], Re = ["src"], Ae = {
156
+ __name: "BackofficeGallery",
157
+ setup(o) {
158
+ ue();
159
+ const e = h(!0), c = h(null);
160
+ let i = 1;
161
+ const r = 10;
162
+ let V = h(null), w = h(!1);
163
+ const v = h([]), C = (t) => {
164
+ v.value = t;
165
+ }, x = ae(() => U.value === "all" ? _.gallery : _.gallery.filter((t) => t.categories.includes(U.value))), S = async () => {
166
+ w.value = !0, await M.fetchGallery(i, r), w.value = !1;
167
+ }, N = h(null), n = h({
168
+ categories: "",
169
+ size: "",
170
+ image: !1
171
+ }), B = h(null), I = (t) => {
172
+ console.log(e.value), e.value ? R(t) : (N.value = "modal", n.value.image = t, T());
173
+ }, R = (t) => {
174
+ N.value = "edit-modal", n.value = t || {
175
+ categories: "",
176
+ size: "",
177
+ image: null
178
+ }, T();
179
+ }, E = () => {
180
+ n.value = {
181
+ categories: "",
182
+ size: "",
183
+ image: !1
184
+ }, B.value = null, A();
185
+ }, T = () => {
186
+ document.body.style.overflow = "hidden", document.documentElement.style.overflow = "hidden";
187
+ }, A = () => {
188
+ document.body.style.overflow = "", document.documentElement.style.overflow = "";
189
+ }, O = [
190
+ { name: "Small", value: "" },
191
+ { name: "Regular", value: "grid-item--width1 grid-item--height1" },
192
+ { name: "Medium", value: "grid-item--width2 grid-item--height2" },
193
+ { name: "Big", value: "grid-item--width3 grid-item--height3" }
194
+ ], q = async (t) => {
195
+ await M.deletePhoto(t);
196
+ }, X = async () => {
197
+ await M.updatePhoto(n.value), E();
198
+ }, L = async (t) => {
199
+ if (v.length < 1 || !n.value.categories || !n.value.size) {
200
+ console.error("All fields are required.");
201
+ return;
202
+ }
203
+ await M.createPhoto({
204
+ images: v.value,
205
+ size: n.value.size,
206
+ categories: typeof n.value.categories == "string" ? n.value.categories.split(",").map((a) => a.trim()) : n.value.categories
207
+ }), E();
208
+ };
209
+ let U = h("all");
210
+ return oe(async () => {
211
+ await M.fetchGallery(i, r), typeof window < "u" && new IntersectionObserver((a) => {
212
+ a.some((l) => l.isIntersecting) && (i += 1, S());
213
+ }).observe(V.value);
214
+ }), (t, a) => (u(), m("div", _e, [
215
+ s("div", ye, [
216
+ s("div", be, [
217
+ e.value ? (u(), m("button", {
218
+ key: 0,
219
+ onClick: a[0] || (a[0] = (l) => I(null)),
220
+ class: "mn-r-small t-white t-black bg-second button-small button"
221
+ }, "Add photos +")) : j("", !0)
222
+ ])
223
+ ]),
224
+ s("div", {
225
+ ref_key: "grid",
226
+ ref: c,
227
+ class: "pd-medium cols-4 gap-thin"
228
+ }, [
229
+ (u(!0), m(Q, null, W($(x), (l, d) => (u(), m("div", {
230
+ key: l.id,
231
+ "data-id": l.id
232
+ }, [
233
+ b(J, {
234
+ name: "scaleIn",
235
+ mode: "in-out"
236
+ }, {
237
+ default: P(() => [
238
+ !e.value && c.value ? (u(), m("img", {
239
+ key: 0,
240
+ src: "https://thecommunephuket.com/photos/" + l.cover,
241
+ class: "w-100 h-100 o-hidden radius-medium object-fit-cover",
242
+ onClick: (p) => I(l.image)
243
+ }, null, 8, we)) : (u(), m("div", xe, [
244
+ Y(D(l._id) + " ", 1),
245
+ s("img", {
246
+ src: "https://thecommunephuket.com/photos/" + l.cover,
247
+ class: "w-100 radius-small mn-small h-10r object-fit-cover",
248
+ onClick: (p) => I(l)
249
+ }, null, 8, Ne),
250
+ s("p", Ee, [
251
+ Ve,
252
+ Ce,
253
+ s("span", Be, D(l.size.name), 1)
254
+ ]),
255
+ s("p", Se, [
256
+ Ie,
257
+ ze,
258
+ (u(!0), m(Q, null, W(l.categories, (p) => (u(), m("span", Me, D(p), 1))), 256))
259
+ ]),
260
+ s("div", $e, [
261
+ s("button", {
262
+ class: "button-small w-100 button",
263
+ onClick: (p) => q(l._id)
264
+ }, "Delete", 8, Pe)
265
+ ])
266
+ ]))
267
+ ]),
268
+ _: 2
269
+ }, 1024)
270
+ ], 8, ke))), 128)),
271
+ s("div", {
272
+ ref_key: "sentinel",
273
+ ref: V,
274
+ class: "sentinel"
275
+ }, null, 512),
276
+ b(J, { name: "modal" }, {
277
+ default: P(() => [
278
+ ne(s("div", Te, [
279
+ s("div", Le, [
280
+ s("div", Ue, [
281
+ s("span", {
282
+ class: "close",
283
+ onClick: E
284
+ }, "×"),
285
+ s("img", {
286
+ src: "https://thecommunephuket.com/photos/" + n.value.image
287
+ }, null, 8, je)
288
+ ])
289
+ ])
290
+ ], 512), [
291
+ [se, n.value.image !== !1 && N.value === "modal"]
292
+ ])
293
+ ]),
294
+ _: 1
295
+ }),
296
+ b(J, { name: "modal" }, {
297
+ default: P(() => [
298
+ n.value.image !== !1 && N.value === "edit-modal" ? (u(), m("div", De, [
299
+ s("div", Fe, [
300
+ s("span", {
301
+ class: "close",
302
+ onClick: E
303
+ }, "×"),
304
+ typeof B.value == "string" ? (u(), m("img", {
305
+ key: 0,
306
+ src: B.value,
307
+ class: "radius-small w-100 mn-small h-20r object-fit-cover"
308
+ }, null, 8, Ge)) : j("", !0),
309
+ typeof B.value == "object" && n.value.image !== null ? (u(), m("img", {
310
+ key: 1,
311
+ class: "radius-small w-100 mn-small h-20r object-fit-cover",
312
+ src: "/photos/" + n.value.cover
313
+ }, null, 8, Re)) : j("", !0),
314
+ b($(F.Select), {
315
+ options: O,
316
+ label: "Size",
317
+ select: n.value.size,
318
+ "onUpdate:select": a[1] || (a[1] = (l) => n.value.size = l),
319
+ placeholder: "Select Size",
320
+ class: "bg-grey pd-thin radius-small mn-thin t-black"
321
+ }, null, 8, ["select"]),
322
+ b($(F.Field), {
323
+ field: n.value.categories,
324
+ "onUpdate:field": a[2] || (a[2] = (l) => n.value.categories = l),
325
+ type: "text",
326
+ label: "Categories",
327
+ placeholder: "Enter categories for image (comma separated)",
328
+ class: "bg-grey pd-thin radius-small mn-medium t-black"
329
+ }, null, 8, ["field"]),
330
+ b(he, {
331
+ images: v.value,
332
+ "onUpdate:images": C,
333
+ uploadPath: "photos",
334
+ class: "mn-semi"
335
+ }, null, 8, ["images"]),
336
+ b($(F.Button), {
337
+ submit: n.value._id ? X : L,
338
+ callback: E,
339
+ class: "mn-thin"
340
+ }, {
341
+ default: P(() => [
342
+ Y(D(n.value._id ? "Update" : "Create"), 1)
343
+ ]),
344
+ _: 1
345
+ }, 8, ["submit"])
346
+ ])
347
+ ])) : j("", !0)
348
+ ]),
349
+ _: 1
350
+ })
351
+ ], 512)
352
+ ]));
353
+ }
354
+ }, Qe = /* @__PURE__ */ me(Ae, [["__scopeId", "data-v-f1c3938d"]]);
355
+ export {
356
+ Qe as default
357
+ };
@@ -0,0 +1,307 @@
1
+ import { reactive as X, ref as p, watchEffect as H, openBlock as r, createElementBlock as c, createVNode as _, unref as A, withCtx as b, Fragment as G, renderList as R, createElementVNode as e, computed as J, onMounted as K, createCommentVNode as $, Transition as U, createTextVNode as M, toDisplayString as S, withDirectives as Q, vShow as W, pushScopeId as Y, popScopeId as Z } from "vue";
2
+ import { a as L, F as ee, _ as te } from "./index-9128ade5.mjs";
3
+ import { S as ae } from "./Select-90d4b7c8.mjs";
4
+ import { V as se } from "./vue-draggable-next.esm-bundler-ff6e3f52.mjs";
5
+ import { _ as le } from "./UploadImageMultiple-ebcc51e6.mjs";
6
+ import { useRoute as oe } from "vue-router";
7
+ import { _ as ie } from "./_plugin-vue_export-helper-dad06003.mjs";
8
+ import "./Select.vue_vue_type_style_index_0_scoped_a78dbba1_lang-4ed993c7.mjs";
9
+ const ne = process.env.API_URL, V = L.create({ baseURL: ne, withCredentials: !0 }), g = X({
10
+ gallery: []
11
+ }), y = {
12
+ async fetchGallery(s, t) {
13
+ const n = [];
14
+ s && n.push(`page=${s}`), t && n.push(`limit=${t}`);
15
+ const l = `/api/gallery${n.length ? `?${n.join("&")}` : ""}`;
16
+ try {
17
+ const o = await V.get(l);
18
+ if (console.log(o), o && o.data)
19
+ return g.gallery = [...g.gallery, ...o.data], o.data;
20
+ } catch (o) {
21
+ throw console.error("Error fetching gallery:", o), o;
22
+ }
23
+ },
24
+ async createPhoto(s) {
25
+ try {
26
+ const t = await V.post("/api/gallery/create", s);
27
+ console.log(t.data), g.gallery = [...t.data, ...g.gallery];
28
+ } catch (t) {
29
+ console.error(t);
30
+ }
31
+ },
32
+ async updatePhoto(s) {
33
+ try {
34
+ const t = {
35
+ ...s,
36
+ categories: typeof s.categories == "string" ? s.categories.split(",").map((o) => o.trim()) : s.categories
37
+ }, n = await L.post("/api/gallery/update", t), l = g.gallery.findIndex((o) => o._id === s._id);
38
+ l !== -1 && (g.gallery[l] = n.data);
39
+ } catch (t) {
40
+ console.error(t);
41
+ }
42
+ },
43
+ async deletePhoto(s) {
44
+ try {
45
+ const t = await V.post(`/api/gallery/delete/${s}`), n = g.gallery.findIndex((l) => l._id === s);
46
+ n !== -1 && g.gallery.splice(n, 1);
47
+ } catch (t) {
48
+ console.error(t);
49
+ }
50
+ }
51
+ };
52
+ const re = { class: "pos-relative" }, ce = ["src"], de = ["onClick"], ue = {
53
+ __name: "EditImages",
54
+ props: {
55
+ images: Array
56
+ },
57
+ emits: ["update"],
58
+ setup(s, { emit: t }) {
59
+ const n = s, l = p([...n.images]);
60
+ H(() => {
61
+ l.value = [...n.images];
62
+ });
63
+ const o = () => {
64
+ t("update:images", l.value);
65
+ }, w = (u) => {
66
+ l.value = [...l.value, ...u], o();
67
+ }, k = (u) => {
68
+ l.value.splice(u, 1), o();
69
+ };
70
+ return (u, x) => (r(), c("div", null, [
71
+ _(le, {
72
+ "onUpdate:images": w,
73
+ uploadPath: "photos",
74
+ class: "mn-semi pd-small w-100 button bg-black t-white"
75
+ }),
76
+ _(A(se), {
77
+ class: "gap-small flex dragArea list-group w-full",
78
+ modelValue: l.value,
79
+ "onUpdate:modelValue": x[0] || (x[0] = (v) => l.value = v),
80
+ onChange: o
81
+ }, {
82
+ default: b(() => [
83
+ (r(!0), c(G, null, R(l.value, (v, P) => (r(), c("div", re, [
84
+ e("img", {
85
+ class: "i-extra radius-small o-hidden mn-thin",
86
+ src: (u.FILE_SERVER_URL || "") + v
87
+ }, null, 8, ce),
88
+ e("a", {
89
+ onClick: (h) => k(P),
90
+ class: "pos-absolute t-center radius-extra i-medium bg-red pos-t-0 pos-r-0"
91
+ }, "X", 8, de)
92
+ ]))), 256))
93
+ ]),
94
+ _: 1
95
+ }, 8, ["modelValue"])
96
+ ]));
97
+ }
98
+ };
99
+ const E = (s) => (Y("data-v-e82aa4af"), s = s(), Z(), s), me = { class: "pos-relative w-100" }, pe = { class: "w-100 o-hidden" }, ge = { class: "pd-medium flex-nowrap flex pd-t-thin pd-b-thin o-scroll" }, _e = ["data-id"], ve = ["src", "onClick"], he = {
100
+ key: 1,
101
+ class: "pd-small radius-small bg-white"
102
+ }, fe = ["src", "onClick"], ye = { class: "t-black p-small mn-small" }, be = /* @__PURE__ */ E(() => /* @__PURE__ */ e("span", { class: "uppercase t-transp" }, "Size", -1)), we = /* @__PURE__ */ E(() => /* @__PURE__ */ e("br", null, null, -1)), ke = { class: "pd-2px radius-big d-inline-block bg-grey" }, xe = { class: "t-black p-small mn-small uppe" }, Ce = /* @__PURE__ */ E(() => /* @__PURE__ */ e("span", { class: "uppercase t-transp" }, "Categories", -1)), Ie = /* @__PURE__ */ E(() => /* @__PURE__ */ e("br", null, null, -1)), $e = { class: "pd-2px radius-big d-inline-block bg-grey t-semi" }, Se = { class: "flex-nowrap flex" }, Ee = ["onClick"], Pe = { class: "modal pd-thin" }, ze = { class: "modal-content radius-big" }, Ue = { class: "" }, Ve = ["src"], Ge = {
103
+ key: 0,
104
+ class: "flex-v-center flex m modal pd-big"
105
+ }, Re = { class: "modal-content radius-small pd-medium bg-white" }, je = ["src"], Be = ["src"], Me = {
106
+ __name: "BackofficeGallery",
107
+ setup(s) {
108
+ oe();
109
+ const t = p(!0), n = p(null);
110
+ let l = 1;
111
+ const o = 10;
112
+ let w = p(null), k = p(!1);
113
+ const u = p([]), x = (d) => {
114
+ u.value = d;
115
+ }, v = J(() => B.value === "all" ? g.gallery : g.gallery.filter((d) => d.categories.includes(B.value))), P = async () => {
116
+ k.value = !0, await y.fetchGallery(l, o), k.value = !1;
117
+ }, h = p(null), a = p({
118
+ categories: "",
119
+ size: "",
120
+ image: !1
121
+ }), C = p(null), z = (d) => {
122
+ console.log(t.value), t.value ? N(d) : (h.value = "modal", a.value.image = d, j());
123
+ }, N = (d) => {
124
+ h.value = "edit-modal", a.value = d || {
125
+ categories: "",
126
+ size: "",
127
+ image: null
128
+ }, j();
129
+ }, f = () => {
130
+ a.value = {
131
+ categories: "",
132
+ size: "",
133
+ image: !1
134
+ }, C.value = null, D();
135
+ }, j = () => {
136
+ document.body.style.overflow = "hidden", document.documentElement.style.overflow = "hidden";
137
+ }, D = () => {
138
+ document.body.style.overflow = "", document.documentElement.style.overflow = "";
139
+ }, F = [
140
+ { name: "Small", value: "" },
141
+ { name: "Regular", value: "grid-item--width1 grid-item--height1" },
142
+ { name: "Medium", value: "grid-item--width2 grid-item--height2" },
143
+ { name: "Big", value: "grid-item--width3 grid-item--height3" }
144
+ ], O = async (d) => {
145
+ await y.deletePhoto(d);
146
+ }, T = async () => {
147
+ await y.updatePhoto(a.value), f();
148
+ }, q = async (d) => {
149
+ if (u.length < 1 || !a.value.categories || !a.value.size) {
150
+ console.error("All fields are required.");
151
+ return;
152
+ }
153
+ await y.createPhoto({
154
+ images: u.value,
155
+ size: a.value.size,
156
+ categories: typeof a.value.categories == "string" ? a.value.categories.split(",").map((m) => m.trim()) : a.value.categories
157
+ }), f();
158
+ };
159
+ let B = p("all");
160
+ return K(async () => {
161
+ await y.fetchGallery(l, o), typeof window < "u" && new IntersectionObserver((m) => {
162
+ m.some((i) => i.isIntersecting) && (l += 1, P());
163
+ }).observe(w.value);
164
+ }), (d, m) => (r(), c("div", me, [
165
+ e("div", pe, [
166
+ e("div", ge, [
167
+ t.value ? (r(), c("button", {
168
+ key: 0,
169
+ onClick: m[0] || (m[0] = (i) => z(null)),
170
+ class: "mn-r-small t-white t-black bg-second button-small button"
171
+ }, "Add photos +")) : $("", !0)
172
+ ])
173
+ ]),
174
+ e("div", {
175
+ ref_key: "grid",
176
+ ref: n,
177
+ class: "pd-medium cols-4 gap-thin"
178
+ }, [
179
+ (r(!0), c(G, null, R(A(v), (i, Ae) => (r(), c("div", {
180
+ key: i.id,
181
+ "data-id": i.id
182
+ }, [
183
+ _(U, {
184
+ name: "scaleIn",
185
+ mode: "in-out"
186
+ }, {
187
+ default: b(() => [
188
+ !t.value && n.value ? (r(), c("img", {
189
+ key: 0,
190
+ src: "https://thecommunephuket.com/photos/" + i.cover,
191
+ class: "w-100 h-100 o-hidden radius-medium object-fit-cover",
192
+ onClick: (I) => z(i.image)
193
+ }, null, 8, ve)) : (r(), c("div", he, [
194
+ M(S(i._id) + " ", 1),
195
+ e("img", {
196
+ src: "https://thecommunephuket.com/photos/" + i.cover,
197
+ class: "w-100 radius-small mn-small h-10r object-fit-cover",
198
+ onClick: (I) => z(i)
199
+ }, null, 8, fe),
200
+ e("p", ye, [
201
+ be,
202
+ we,
203
+ e("span", ke, S(i.size.name), 1)
204
+ ]),
205
+ e("p", xe, [
206
+ Ce,
207
+ Ie,
208
+ (r(!0), c(G, null, R(i.categories, (I) => (r(), c("span", $e, S(I), 1))), 256))
209
+ ]),
210
+ e("div", Se, [
211
+ e("button", {
212
+ class: "button-small w-100 button",
213
+ onClick: (I) => O(i._id)
214
+ }, "Delete", 8, Ee)
215
+ ])
216
+ ]))
217
+ ]),
218
+ _: 2
219
+ }, 1024)
220
+ ], 8, _e))), 128)),
221
+ e("div", {
222
+ ref_key: "sentinel",
223
+ ref: w,
224
+ class: "sentinel"
225
+ }, null, 512),
226
+ _(U, { name: "modal" }, {
227
+ default: b(() => [
228
+ Q(e("div", Pe, [
229
+ e("div", ze, [
230
+ e("div", Ue, [
231
+ e("span", {
232
+ class: "close",
233
+ onClick: f
234
+ }, "×"),
235
+ e("img", {
236
+ src: "https://thecommunephuket.com/photos/" + a.value.image
237
+ }, null, 8, Ve)
238
+ ])
239
+ ])
240
+ ], 512), [
241
+ [W, a.value.image !== !1 && h.value === "modal"]
242
+ ])
243
+ ]),
244
+ _: 1
245
+ }),
246
+ _(U, { name: "modal" }, {
247
+ default: b(() => [
248
+ a.value.image !== !1 && h.value === "edit-modal" ? (r(), c("div", Ge, [
249
+ e("div", Re, [
250
+ e("span", {
251
+ class: "close",
252
+ onClick: f
253
+ }, "×"),
254
+ typeof C.value == "string" ? (r(), c("img", {
255
+ key: 0,
256
+ src: C.value,
257
+ class: "radius-small w-100 mn-small h-20r object-fit-cover"
258
+ }, null, 8, je)) : $("", !0),
259
+ typeof C.value == "object" && a.value.image !== null ? (r(), c("img", {
260
+ key: 1,
261
+ class: "radius-small w-100 mn-small h-20r object-fit-cover",
262
+ src: "/photos/" + a.value.cover
263
+ }, null, 8, Be)) : $("", !0),
264
+ _(ae, {
265
+ options: F,
266
+ label: "Size",
267
+ select: a.value.size,
268
+ "onUpdate:select": m[1] || (m[1] = (i) => a.value.size = i),
269
+ placeholder: "Select Size",
270
+ class: "bg-grey pd-thin radius-small mn-thin t-black"
271
+ }, null, 8, ["select"]),
272
+ _(ee, {
273
+ field: a.value.categories,
274
+ "onUpdate:field": m[2] || (m[2] = (i) => a.value.categories = i),
275
+ type: "text",
276
+ label: "Categories",
277
+ placeholder: "Enter categories for image (comma separated)",
278
+ class: "bg-grey pd-thin radius-small mn-medium t-black"
279
+ }, null, 8, ["field"]),
280
+ _(ue, {
281
+ images: u.value,
282
+ "onUpdate:images": x,
283
+ uploadPath: "photos",
284
+ class: "mn-semi"
285
+ }, null, 8, ["images"]),
286
+ _(te, {
287
+ submit: a.value._id ? T : q,
288
+ callback: f,
289
+ class: "mn-thin"
290
+ }, {
291
+ default: b(() => [
292
+ M(S(a.value._id ? "Update" : "Create"), 1)
293
+ ]),
294
+ _: 1
295
+ }, 8, ["submit"])
296
+ ])
297
+ ])) : $("", !0)
298
+ ]),
299
+ _: 1
300
+ })
301
+ ], 512)
302
+ ]));
303
+ }
304
+ }, He = /* @__PURE__ */ ie(Me, [["__scopeId", "data-v-e82aa4af"]]);
305
+ export {
306
+ He as default
307
+ };