@webx-ui/module-recipes 0.1.12 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,37 +1,37 @@
1
- import { reorderItems as Ue, useAdmin as oe, useDates as Be, useTranslate as ne, useErrorText as Te, provideRelationOwner as Le, provideRecordAddress as Oe, WxScreenHead as He, WxScreen as Fe, WxSaveState as Ke, WxDate as Ge, WxListScreen as Je, WxRowMenu as je, WxAddressNote as Qe, categoryRoutes as Re } from "@webx-ui/module-admin";
2
- import { provide as Xe, inject as Ye, defineComponent as ce, computed as f, ref as x, watch as le, onMounted as Ve, onBeforeUnmount as ze, openBlock as v, createElementBlock as N, Fragment as te, createVNode as h, unref as e, withCtx as d, createTextVNode as _, toDisplayString as w, createBlock as k, createCommentVNode as q, renderList as Ie, normalizeClass as ke, createElementVNode as E, useTemplateRef as Ze, nextTick as et, isRef as tt, withKeys as at, resolveDynamicComponent as it, mergeProps as rt } from "vue";
3
- import { useRoute as Ne, useRouter as qe, onBeforeRouteLeave as st } from "vue-router";
4
- import { useLocales as nt, localizedValue as lt, confirm as Y, WxSkeleton as ue, WxCard as ot, WxBadge as Z, WxBreadcrumb as ut, WxBreadcrumbItem as We, WxAlert as Ae, WxButton as ee, WxActionBar as ct, toast as $, WxEmpty as De, WxText as dt, useModal as pt, WxDialog as vt, WxFormItem as ht, WxInput as Me, WxSpace as ft, createModal as yt, WxIcon as xe, WxSelect as _e, WxSortableList as mt, WxTooltip as gt } from "@webx-ui/core";
5
- const Se = "recipes";
6
- function de(l) {
7
- const n = `${l.apiPath}/${Se}`, y = (t) => t.data;
1
+ import { reorderItems as Ue, useAdmin as oe, useDates as Be, useTranslate as se, useErrorText as $e, useEditing as Le, provideRelationOwner as He, provideRecordAddress as Fe, WxScreenHead as Ke, WxEditingAlerts as Je, WxScreen as Ge, WxSaveState as je, WxDate as Qe, WxDrafts as Xe, WxListScreen as Ye, WxRowMenu as Ze, WxAddressNote as et, categoryRoutes as Se } from "@webx-ui/module-admin";
2
+ import { provide as tt, inject as at, defineComponent as he, computed as f, ref as _, watch as ne, onMounted as Ne, onBeforeUnmount as ze, openBlock as p, createElementBlock as q, Fragment as ee, createVNode as y, unref as e, withCtx as v, createTextVNode as $, toDisplayString as x, createBlock as k, createCommentVNode as D, createElementVNode as A, renderList as qe, normalizeClass as Te, useTemplateRef as it, nextTick as rt, isRef as st, withKeys as nt, resolveDynamicComponent as lt, mergeProps as ot } from "vue";
3
+ import { useRoute as Ae, useRouter as De, onBeforeRouteLeave as ut } from "vue-router";
4
+ import { useLocales as ct, localizedValue as dt, confirm as ae, WxSkeleton as ve, WxCard as pt, WxBadge as Z, WxBreadcrumb as vt, WxBreadcrumbItem as Ve, WxActionBar as ht, WxButton as le, toast as S, WxEmpty as Ee, WxText as ft, useModal as yt, WxDialog as mt, WxFormItem as bt, WxInput as Pe, WxSpace as gt, createModal as wt, WxIcon as _e, WxSelect as ke, WxSortableList as xt, WxTooltip as _t, WxAlert as kt } from "@webx-ui/core";
5
+ const Ce = "recipes";
6
+ function fe(u) {
7
+ const l = `${u.apiPath}/${Ce}`, m = (t) => t.data;
8
8
  return {
9
9
  list: (t = {}) => {
10
- const u = new URLSearchParams();
11
- return t.q && u.set("q", t.q), t.category != null && u.set("category", String(t.category)), t.nutrient != null && u.set("nutrient", String(t.nutrient)), t.service != null && u.set("service", String(t.service)), t.status && u.set("status", t.status), t.trashed && u.set("trashed", "1"), l.http.get(u.size > 0 ? `${n}?${u}` : n);
10
+ const o = new URLSearchParams();
11
+ return t.q && o.set("q", t.q), t.category != null && o.set("category", String(t.category)), t.nutrient != null && o.set("nutrient", String(t.nutrient)), t.service != null && o.set("service", String(t.service)), t.status && o.set("status", t.status), t.trashed && o.set("trashed", "1"), u.http.get(o.size > 0 ? `${l}?${o}` : l);
12
12
  },
13
- get: (t) => l.http.get(`${n}/${t}`).then(y),
14
- create: (t) => l.http.post(n, t).then(y),
15
- save: (t, u) => l.http.put(`${n}/${t}`, u).then(y),
16
- discard: (t) => l.http.post(`${n}/${t}/discard`, {}).then(y),
17
- publish: (t) => l.http.post(`${n}/${t}/publish`, {}).then(y),
18
- unpublish: (t) => l.http.post(`${n}/${t}/unpublish`, {}).then(y),
19
- remove: (t) => l.http.delete(`${n}/${t}`).then(() => {
13
+ get: (t) => u.http.get(`${l}/${t}`).then(m),
14
+ create: (t) => u.http.post(l, t).then(m),
15
+ save: (t, o) => u.http.put(`${l}/${t}`, o).then(m),
16
+ discard: (t) => u.http.post(`${l}/${t}/discard`, {}).then(m),
17
+ publish: (t, o) => u.http.post(`${l}/${t}/publish`, o ? { revision: o } : {}).then(m),
18
+ unpublish: (t) => u.http.post(`${l}/${t}/unpublish`, {}).then(m),
19
+ remove: (t) => u.http.delete(`${l}/${t}`).then(() => {
20
20
  }),
21
- restore: (t) => l.http.post(`${n}/${t}/restore`, {}).then(y),
22
- versions: (t) => l.http.get(`${n}/${t}/versions`).then(y),
23
- restoreVersion: (t, u) => l.http.post(`${n}/${t}/versions/${u}/restore`, {}).then(y),
24
- reorder: (t) => Ue(l, Se, t, null)
21
+ restore: (t) => u.http.post(`${l}/${t}/restore`, {}).then(m),
22
+ versions: (t) => u.http.get(`${l}/${t}/versions`).then(m),
23
+ restoreVersion: (t, o) => u.http.post(`${l}/${t}/versions/${o}/restore`, {}).then(m),
24
+ reorder: (t) => Ue(u, Ce, t, null)
25
25
  };
26
26
  }
27
- const Ee = /* @__PURE__ */ Symbol("wx-recipe-editor");
28
- function bt(l) {
29
- Xe(Ee, l);
27
+ const Me = /* @__PURE__ */ Symbol("wx-recipe-editor");
28
+ function Tt(u) {
29
+ tt(Me, u);
30
30
  }
31
- function wt() {
32
- return Ye(Ee, null);
31
+ function $t() {
32
+ return at(Me, null);
33
33
  }
34
- const xt = {
34
+ const Rt = {
35
35
  module: {
36
36
  group: "Recipes",
37
37
  recipes: "Recipes",
@@ -151,245 +151,270 @@ const xt = {
151
151
  saved: "Saved.",
152
152
  "field-title": "Title"
153
153
  }
154
- }, Ce = /* @__PURE__ */ new WeakSet();
155
- function pe() {
154
+ }, Ie = /* @__PURE__ */ new WeakSet();
155
+ function ye() {
156
156
  try {
157
- const { i18n: l } = oe();
158
- Ce.has(l) || (l.defaults("webx-recipes", xt), Ce.add(l));
157
+ const { i18n: u } = oe();
158
+ Ie.has(u) || (u.defaults("webx-recipes", Rt), Ie.add(u));
159
159
  } catch {
160
160
  }
161
161
  }
162
- const _t = 1200, kt = /* @__PURE__ */ ce({
162
+ const Wt = 1200, St = /* @__PURE__ */ he({
163
163
  __name: "RecipeEditorPage",
164
164
  props: {
165
165
  base: { default: "/recipes" }
166
166
  },
167
- setup(l) {
168
- const n = l, y = oe(), t = de(y), u = Ne(), A = qe(), i = nt(), S = Be();
169
- pe();
170
- const r = ne("webx-recipes"), b = ne("webx-admin"), T = Te(), B = f(() => Number(u.params.id)), z = f(() => n.base), o = x(null), g = x({}), m = x(""), P = x(null), L = x(null), O = x(!0), U = x(!1), V = x(!1), J = x({}), I = x(null), H = x(""), D = f(() => y.can("recipes.manage")), ve = f(() => !D.value || V.value), F = f(() => JSON.stringify(g.value)), R = f(() => H.value !== "" && F.value !== H.value), ie = f(() => U.value ? "saving" : R.value ? "unsaved" : "saved"), j = f(() => {
171
- const s = g.value.title;
172
- return lt(s, i.active.value, o.value?.title ?? "");
173
- }), re = f(() => {
174
- const s = o.value;
175
- return !s || s.status !== "published" && s.status !== "modified" ? "" : r("recipe.live-since", { date: S.short(s.published_at) });
167
+ setup(u) {
168
+ const l = u, m = oe(), t = fe(m), o = Ae(), E = De(), i = ct(), V = Be();
169
+ ye();
170
+ const r = se("webx-recipes"), g = se("webx-admin"), R = $e(), P = f(() => Number(o.params.id)), N = f(() => l.base), n = _(null), b = _({}), h = _(""), M = _(null), B = _(null), F = _(!0), O = _(!1), I = _(!1), j = _({}), Q = _(""), z = f(() => m.can("recipes.manage")), T = Le({
171
+ entity: "recipes",
172
+ id: () => n.value?.id,
173
+ values: b,
174
+ revision: h,
175
+ read: async () => {
176
+ const s = await t.get(P.value);
177
+ return { values: s.values, revision: s.revision };
178
+ },
179
+ adopt: (s) => {
180
+ Q.value = JSON.stringify(s.values);
181
+ },
182
+ // Published or restored by somebody else: the badge and the address follow, and the form
183
+ // stays as it is.
184
+ refresh: () => be(),
185
+ restore: async () => {
186
+ n.value && await t.restore(n.value.id);
187
+ },
188
+ canWrite: () => z.value,
189
+ busy: () => O.value || G !== void 0,
190
+ screen: "recipes.form"
191
+ }), K = T.conflict, me = f(() => !z.value || I.value), U = f(() => JSON.stringify(b.value)), C = f(() => Q.value !== "" && U.value !== Q.value), ie = f(() => O.value ? "saving" : C.value ? "unsaved" : "saved"), X = f(() => {
192
+ const s = b.value.title;
193
+ return dt(s, i.active.value, n.value?.title ?? "");
194
+ }), ue = f(() => {
195
+ const s = n.value;
196
+ return !s || s.status !== "published" && s.status !== "modified" ? "" : r("recipe.live-since", { date: V.short(s.published_at) });
176
197
  });
177
- Le({ type: "recipe", id: f(() => o.value?.id ?? null) }), Oe({
178
- values: g,
179
- prefix: P,
180
- path: f(() => o.value?.path),
198
+ He({ type: "recipe", id: f(() => n.value?.id ?? null) }), Fe({
199
+ values: b,
200
+ prefix: M,
201
+ path: f(() => n.value?.path),
181
202
  moving: () => r("recipe.address-moving")
182
- }), bt({ recipe: o, canManage: D.value, reload: () => K(!0) });
183
- function se(s) {
184
- o.value = s.recipe, g.value = s.values, m.value = s.revision, P.value = s.prefix, L.value = s.preview_url, H.value = JSON.stringify(s.values), I.value = null;
203
+ }), Tt({ recipe: n, canManage: z.value, reload: () => J(!0) });
204
+ function ce(s) {
205
+ n.value = s.recipe, b.value = s.values, h.value = s.revision, M.value = s.prefix, B.value = s.preview_url, Q.value = JSON.stringify(s.values), T.opened(s.values), K.value = null;
185
206
  }
186
- async function K(s = !1) {
187
- s || (O.value = !0);
207
+ async function J(s = !1) {
208
+ s || (F.value = !0);
188
209
  try {
189
- se(await t.get(B.value));
190
- } catch (W) {
191
- $.danger(T(W)), A.push(z.value);
210
+ ce(await t.get(P.value));
211
+ } catch (w) {
212
+ S.danger(R(w)), E.push(N.value);
192
213
  } finally {
193
- O.value = !1;
214
+ F.value = !1;
215
+ }
216
+ }
217
+ async function be() {
218
+ try {
219
+ const s = await t.get(P.value);
220
+ n.value = s.recipe, M.value = s.prefix, B.value = s.preview_url;
221
+ } catch {
194
222
  }
195
223
  }
196
- let Q;
197
- function he() {
198
- !D.value || I.value || !R.value || (clearTimeout(Q), Q = setTimeout(() => {
199
- M();
200
- }, _t));
224
+ let Y;
225
+ function ge() {
226
+ !z.value || K.value || !C.value || T.stopped.value || (clearTimeout(Y), Y = setTimeout(() => {
227
+ H();
228
+ }, Wt));
201
229
  }
202
- function fe() {
203
- !D.value || I.value || !R.value || U.value || (clearTimeout(Q), M());
230
+ function te() {
231
+ !z.value || K.value || !C.value || O.value || T.stopped.value || (clearTimeout(Y), H());
204
232
  }
205
- let X;
206
- async function M() {
207
- for (; X; ) {
208
- const { carried: C, done: G } = X;
209
- if (await G, !R.value || I.value || F.value === C) return;
233
+ let G;
234
+ async function H() {
235
+ for (; G; ) {
236
+ const { carried: W, done: L } = G;
237
+ if (await L, !C.value || K.value || U.value === W) return;
210
238
  }
211
- const s = F.value, W = ye();
212
- X = { carried: s, done: W };
239
+ const s = U.value, w = we();
240
+ G = { carried: s, done: w };
213
241
  try {
214
- await W;
242
+ await w;
215
243
  } finally {
216
- X?.done === W && (X = void 0);
244
+ G?.done === w && (G = void 0);
217
245
  }
218
246
  }
219
- async function ye() {
220
- if (!o.value || !D.value) return;
221
- clearTimeout(Q);
222
- const s = F.value, W = g.value;
223
- U.value = !0, J.value = {};
247
+ async function we() {
248
+ if (!n.value || !z.value) return;
249
+ clearTimeout(Y);
250
+ const s = U.value, w = b.value;
251
+ O.value = !0, j.value = {};
224
252
  try {
225
- const C = await t.save(o.value.id, { values: W, revision: m.value });
226
- o.value = C.recipe, m.value = C.revision, P.value = C.prefix, L.value = C.preview_url, I.value = null, F.value === s && (H.value = s);
227
- } catch (C) {
228
- const G = C;
229
- G.status === 409 && G.body?.data ? I.value = G.body : G.body?.errors ? (J.value = G.body.errors, $.danger(r("recipe.save-failed"))) : $.danger(T(C));
253
+ const W = await t.save(n.value.id, { values: w, revision: h.value });
254
+ n.value = W.recipe, h.value = W.revision, M.value = W.prefix, B.value = W.preview_url, K.value = null, U.value === s && (Q.value = s), T.opened(w);
255
+ } catch (W) {
256
+ const L = W;
257
+ if (L.status === 409 && L.body?.data) {
258
+ const pe = L.body.data;
259
+ T.refused({
260
+ values: pe.values,
261
+ revision: pe.revision,
262
+ changed: L.body.changed
263
+ }) && (n.value = pe.recipe, H());
264
+ } else L.body?.errors ? (j.value = L.body.errors, S.danger(r("recipe.save-failed"))) : await T.failed(W) || S.danger(R(W));
230
265
  } finally {
231
- U.value = !1;
266
+ O.value = !1;
232
267
  }
233
268
  }
234
- async function me() {
235
- await Y({
236
- title: r("recipe.conflict-theirs-title"),
237
- message: r("recipe.conflict-theirs-text"),
238
- confirmText: r("recipe.conflict-theirs"),
239
- cancelText: r("panel.cancel"),
240
- tone: "danger"
241
- }) && await K(!0);
242
- }
243
- async function ge() {
244
- const s = I.value;
245
- s && (m.value = s.data.revision, I.value = null, await M());
269
+ async function xe() {
270
+ await J(!0);
246
271
  }
247
- async function be() {
248
- if (!(!o.value || !await Y({
249
- title: b("editor.discard-title"),
250
- message: b("editor.discard-text"),
272
+ async function a() {
273
+ if (!(!n.value || !await ae({
274
+ title: g("editor.discard-title"),
275
+ message: g("editor.discard-text"),
251
276
  confirmText: r("recipe.discard"),
252
277
  // Not «Cancel»: beside «Discard changes» the two read as the same word.
253
- cancelText: b("editor.keep-changes"),
278
+ cancelText: g("editor.keep-changes"),
254
279
  tone: "danger"
255
280
  }))) {
256
- V.value = !0;
281
+ I.value = !0;
257
282
  try {
258
- se(await t.discard(o.value.id)), $.success(r("recipe.discarded"));
259
- } catch (W) {
260
- $.danger(T(W));
283
+ ce(await t.discard(n.value.id)), S.success(r("recipe.discarded"));
284
+ } catch (w) {
285
+ S.danger(R(w));
261
286
  } finally {
262
- V.value = !1;
287
+ I.value = !1;
263
288
  }
264
289
  }
265
290
  }
266
- async function a() {
267
- if (R.value && await M(), I.value || R.value) return;
268
- const s = o.value;
291
+ async function d() {
292
+ if (C.value && await H(), K.value || C.value || !n.value) return;
293
+ const s = await T.beforePublish();
269
294
  if (!s) return;
270
- const W = s.next_path ?? s.path, C = s.next_path != null && s.path !== null ? ` ${b("editor.publish-moves", { old: `/${s.path}` })}` : "";
271
- if (await Y({
272
- title: r("recipe.publish-title", { title: j.value || s.title }),
273
- message: W === null ? r("recipe.publish-nowhere") : r("recipe.publish-text", { address: `/${W}` }) + C,
295
+ const w = n.value, W = w.next_path ?? w.path, L = w.next_path != null && w.path !== null ? ` ${g("editor.publish-moves", { old: `/${w.path}` })}` : "";
296
+ if (s.asked || await ae({
297
+ title: r("recipe.publish-title", { title: X.value || w.title }),
298
+ message: W === null ? r("recipe.publish-nowhere") : r("recipe.publish-text", { address: `/${W}` }) + L,
274
299
  confirmText: r("panel.publish"),
275
300
  cancelText: r("panel.cancel")
276
301
  })) {
277
- V.value = !0;
302
+ I.value = !0;
278
303
  try {
279
- await t.publish(s.id), await K(!0), $.success(r("panel.published"));
280
- } catch (Pe) {
281
- $.danger(T(Pe));
304
+ await t.publish(w.id, s.revision), await J(!0), S.success(r("panel.published"));
305
+ } catch (We) {
306
+ await T.failed(We) || S.danger(R(We));
282
307
  } finally {
283
- V.value = !1;
308
+ I.value = !1;
284
309
  }
285
310
  }
286
311
  }
287
- async function p() {
288
- const s = o.value;
289
- if (!(!s || !await Y({
290
- title: b("editor.unpublish-title"),
291
- message: b("editor.unpublish-text"),
292
- confirmText: b("editor.unpublish"),
293
- cancelText: b("editor.keep-published")
312
+ async function c() {
313
+ const s = n.value;
314
+ if (!(!s || !await ae({
315
+ title: g("editor.unpublish-title"),
316
+ message: g("editor.unpublish-text"),
317
+ confirmText: g("editor.unpublish"),
318
+ cancelText: g("editor.keep-published")
294
319
  }))) {
295
- V.value = !0;
320
+ I.value = !0;
296
321
  try {
297
- await t.unpublish(s.id), await K(!0), $.success(b("editor.unpublished"));
298
- } catch (C) {
299
- $.danger(T(C));
322
+ await t.unpublish(s.id), await J(!0), S.success(g("editor.unpublished"));
323
+ } catch (W) {
324
+ S.danger(R(W));
300
325
  } finally {
301
- V.value = !1;
326
+ I.value = !1;
302
327
  }
303
328
  }
304
329
  }
305
- function c() {
306
- const s = o.value?.status;
330
+ function re() {
331
+ const s = n.value?.status;
307
332
  return s === "published" || s === "modified" ? "success" : "default";
308
333
  }
309
- function ae(s) {
310
- R.value && s.preventDefault();
334
+ function de(s) {
335
+ C.value && s.preventDefault();
311
336
  }
312
- le(F, he), le(B, () => {
313
- K();
314
- }), Ve(() => {
315
- K(), window.addEventListener("beforeunload", ae);
337
+ ne(U, ge), ne(P, () => {
338
+ J();
339
+ }), Ne(() => {
340
+ J(), window.addEventListener("beforeunload", de);
316
341
  }), ze(() => {
317
- clearTimeout(Q), window.removeEventListener("beforeunload", ae);
318
- }), st(async () => !R.value || !D.value || (await M(), !R.value) ? !0 : await Y({
342
+ clearTimeout(Y), window.removeEventListener("beforeunload", de);
343
+ }), ut(async () => !C.value || !z.value || (await H(), !C.value) ? !0 : await ae({
319
344
  title: r("recipe.leave-title"),
320
345
  message: r("recipe.leave-text"),
321
346
  confirmText: r("recipe.leave"),
322
347
  cancelText: r("panel.cancel"),
323
348
  tone: "danger"
324
349
  }));
325
- const we = f(() => {
350
+ const Oe = f(() => {
326
351
  const s = [];
327
- return L.value && s.push({ key: "preview", label: r("recipe.preview"), icon: "eye", href: L.value }), o.value?.url && o.value.status !== "draft" && s.push({
352
+ return B.value && s.push({ key: "preview", label: r("recipe.preview"), icon: "eye", href: B.value }), n.value?.url && n.value.status !== "draft" && s.push({
328
353
  key: "site",
329
354
  label: r("panel.open-on-site"),
330
355
  icon: "link",
331
- href: o.value.url
332
- }), D.value && (o.value?.status === "published" || o.value?.status === "modified") && s.push({
356
+ href: n.value.url
357
+ }), z.value && (n.value?.status === "published" || n.value?.status === "modified") && s.push({
333
358
  key: "unpublish",
334
- label: b("editor.unpublish"),
359
+ label: g("editor.unpublish"),
335
360
  icon: "eye-off",
336
361
  run: () => {
337
- p();
362
+ c();
338
363
  }
339
- }), o.value?.status === "modified" && s.push({
364
+ }), n.value?.status === "modified" && s.push({
340
365
  key: "discard",
341
366
  label: r("recipe.discard"),
342
367
  icon: "refresh",
343
368
  danger: !0,
344
369
  menu: !0,
345
370
  run: () => {
346
- be();
371
+ a();
347
372
  }
348
373
  }), s;
349
374
  });
350
- return (s, W) => (v(), N("div", {
375
+ return (s, w) => (p(), q("div", {
351
376
  class: "wx-recipe-editor",
352
- onFocusout: fe
377
+ onFocusout: te
353
378
  }, [
354
- O.value || !o.value ? (v(), N(te, { key: 0 }, [
355
- h(e(ue), {
379
+ F.value || !n.value ? (p(), q(ee, { key: 0 }, [
380
+ y(e(ve), {
356
381
  class: "wx-recipe-editor__ghost",
357
382
  title: "",
358
383
  rows: 1
359
384
  }),
360
- h(e(ot), null, {
361
- default: d(() => [
362
- h(e(ue), { rows: 8 })
385
+ y(e(pt), null, {
386
+ default: v(() => [
387
+ y(e(ve), { rows: 8 })
363
388
  ]),
364
389
  _: 1
365
390
  })
366
- ], 64)) : (v(), N(te, { key: 1 }, [
367
- h(e(He), {
391
+ ], 64)) : (p(), q(ee, { key: 1 }, [
392
+ y(e(Ke), {
368
393
  divider: "",
369
- back: z.value,
394
+ back: N.value,
370
395
  "back-label": e(r)("module.recipes"),
371
- title: j.value || e(r)("recipe.untitled"),
372
- subtitle: re.value,
373
- actions: we.value
396
+ title: X.value || e(r)("recipe.untitled"),
397
+ subtitle: ue.value,
398
+ actions: Oe.value
374
399
  }, {
375
- trail: d(() => [
376
- h(e(ut), {
400
+ trail: v(() => [
401
+ y(e(vt), {
377
402
  size: "sm",
378
403
  label: e(r)("recipe.trail")
379
404
  }, {
380
- default: d(() => [
381
- h(e(We), {
405
+ default: v(() => [
406
+ y(e(Ve), {
382
407
  as: "router-link",
383
- to: z.value
408
+ to: N.value
384
409
  }, {
385
- default: d(() => [
386
- _(w(e(r)("module.recipes")), 1)
410
+ default: v(() => [
411
+ $(x(e(r)("module.recipes")), 1)
387
412
  ]),
388
413
  _: 1
389
414
  }, 8, ["to"]),
390
- h(e(We), { current: "" }, {
391
- default: d(() => [
392
- _(w(j.value || e(r)("recipe.untitled")), 1)
415
+ y(e(Ve), { current: "" }, {
416
+ default: v(() => [
417
+ $(x(X.value || e(r)("recipe.untitled")), 1)
393
418
  ]),
394
419
  _: 1
395
420
  })
@@ -397,257 +422,247 @@ const _t = 1200, kt = /* @__PURE__ */ ce({
397
422
  _: 1
398
423
  }, 8, ["label"])
399
424
  ]),
400
- "title-after": d(() => [
401
- h(e(Z), {
402
- type: c(),
425
+ "title-after": v(() => [
426
+ y(e(Z), {
427
+ type: re(),
403
428
  dot: ""
404
429
  }, {
405
- default: d(() => [
406
- _(w(e(r)(`panel.status-${o.value.status}`)), 1)
430
+ default: v(() => [
431
+ $(x(e(r)(`panel.status-${n.value.status}`)), 1)
407
432
  ]),
408
433
  _: 1
409
434
  }, 8, ["type"]),
410
- o.value.status === "modified" ? (v(), k(e(Z), {
435
+ n.value.status === "modified" ? (p(), k(e(Z), {
411
436
  key: 0,
412
437
  type: "primary",
413
438
  round: ""
414
439
  }, {
415
- default: d(() => [
416
- _(w(e(r)("panel.edits")), 1)
440
+ default: v(() => [
441
+ $(x(e(r)("panel.edits")), 1)
417
442
  ]),
418
443
  _: 1
419
- })) : q("", !0)
444
+ })) : D("", !0)
420
445
  ]),
421
446
  _: 1
422
447
  }, 8, ["back", "back-label", "title", "subtitle", "actions"]),
423
- I.value ? (v(), k(e(Ae), {
424
- key: 0,
425
- type: "warning",
426
- title: e(r)("recipe.conflict-title"),
427
- description: I.value.message
428
- }, {
429
- actions: d(() => [
430
- h(e(ee), {
431
- size: "sm",
432
- variant: "outline",
433
- onClick: me
434
- }, {
435
- default: d(() => [
436
- _(w(e(r)("recipe.conflict-theirs")), 1)
437
- ]),
438
- _: 1
439
- }),
440
- h(e(ee), {
441
- size: "sm",
442
- type: "primary",
443
- onClick: ge
444
- }, {
445
- default: d(() => [
446
- _(w(e(r)("recipe.conflict-mine")), 1)
447
- ]),
448
- _: 1
449
- })
450
- ]),
451
- _: 1
452
- }, 8, ["title", "description"])) : q("", !0),
453
- h(e(Fe), {
454
- modelValue: g.value,
455
- "onUpdate:modelValue": W[0] || (W[0] = (C) => g.value = C),
448
+ y(e(Je), {
449
+ editing: e(T),
450
+ onSave: H,
451
+ onTheirs: xe
452
+ }, null, 8, ["editing"]),
453
+ y(e(Ge), {
454
+ modelValue: b.value,
455
+ "onUpdate:modelValue": w[0] || (w[0] = (W) => b.value = W),
456
456
  name: "recipes.form",
457
- errors: J.value,
458
- disabled: ve.value
457
+ errors: j.value,
458
+ disabled: me.value
459
459
  }, null, 8, ["modelValue", "errors", "disabled"]),
460
- D.value ? (v(), k(e(ct), { key: 1 }, {
461
- state: d(() => [
462
- h(e(Ke), { state: ie.value }, null, 8, ["state"])
460
+ z.value ? (p(), k(e(ht), { key: 0 }, {
461
+ state: v(() => [
462
+ e(T).stopped.value ? D("", !0) : (p(), k(e(je), {
463
+ key: 0,
464
+ state: ie.value
465
+ }, null, 8, ["state"]))
463
466
  ]),
464
- default: d(() => [
465
- h(e(ee), {
467
+ default: v(() => [
468
+ y(e(le), {
466
469
  variant: "outline",
467
- loading: U.value,
468
- disabled: !R.value,
469
- onClick: M
470
+ loading: O.value,
471
+ disabled: !C.value || e(T).stopped.value,
472
+ title: e(T).blocked.value,
473
+ onClick: H
470
474
  }, {
471
- default: d(() => [
472
- _(w(e(r)("recipe.save")), 1)
475
+ default: v(() => [
476
+ $(x(e(r)("recipe.save")), 1)
473
477
  ]),
474
478
  _: 1
475
- }, 8, ["loading", "disabled"]),
476
- h(e(ee), {
479
+ }, 8, ["loading", "disabled", "title"]),
480
+ y(e(le), {
477
481
  type: "primary",
478
- loading: V.value,
479
- disabled: o.value.status === "published" && !R.value,
480
- onClick: a
482
+ loading: I.value,
483
+ disabled: e(T).stopped.value || n.value.status === "published" && !C.value,
484
+ title: e(T).blocked.value,
485
+ onClick: d
481
486
  }, {
482
- default: d(() => [
483
- _(w(e(r)("panel.publish")), 1)
487
+ default: v(() => [
488
+ $(x(e(r)("panel.publish")), 1)
484
489
  ]),
485
490
  _: 1
486
- }, 8, ["loading", "disabled"])
491
+ }, 8, ["loading", "disabled", "title"])
487
492
  ]),
488
493
  _: 1
489
- })) : q("", !0)
494
+ })) : D("", !0)
490
495
  ], 64))
491
496
  ], 32));
492
497
  }
493
- }), $e = (l, n) => {
494
- const y = l.__vccOpts || l;
495
- for (const [t, u] of n)
496
- y[t] = u;
497
- return y;
498
- }, Tt = /* @__PURE__ */ $e(kt, [["__scopeId", "data-v-77110321"]]), $t = { class: "wx-recipe-history" }, Rt = { class: "wx-recipe-history__number" }, Wt = { class: "wx-recipe-history__who" }, St = /* @__PURE__ */ ce({
498
+ }), Re = (u, l) => {
499
+ const m = u.__vccOpts || u;
500
+ for (const [t, o] of l)
501
+ m[t] = o;
502
+ return m;
503
+ }, Vt = /* @__PURE__ */ Re(St, [["__scopeId", "data-v-253e5134"]]), Ct = { class: "wx-recipe-history-tab" }, It = { class: "wx-recipe-history" }, Nt = { class: "wx-recipe-history__number" }, zt = { class: "wx-recipe-history__who" }, qt = /* @__PURE__ */ he({
499
504
  name: "WxRecipeHistory",
500
505
  __name: "RecipeHistory",
501
- setup(l) {
502
- const n = oe(), y = de(n), t = wt();
503
- pe();
504
- const u = ne("webx-recipes"), A = Te(), i = x(null), S = x(!1), r = f(() => t?.recipe.value ?? null), b = f(() => t?.canManage ?? !1), T = f(
506
+ setup(u) {
507
+ const l = oe(), m = fe(l), t = $t();
508
+ ye();
509
+ const o = se("webx-recipes"), E = $e(), i = _(null), V = _(!1), r = f(() => t?.recipe.value ?? null), g = f(() => t?.canManage ?? !1), R = f(
505
510
  () => r.value?.status === "published" || r.value?.status === "modified" ? i.value?.[0]?.number ?? null : null
506
511
  );
507
- async function B() {
508
- const o = r.value;
509
- if (o)
512
+ async function P() {
513
+ const n = r.value;
514
+ if (n)
510
515
  try {
511
- i.value = await y.versions(o.id);
512
- } catch (g) {
513
- i.value = [], $.danger(A(g));
516
+ i.value = await m.versions(n.id);
517
+ } catch (b) {
518
+ i.value = [], S.danger(E(b));
514
519
  }
515
520
  }
516
- async function z(o) {
517
- const g = r.value;
518
- if (!(!g || !await Y({
519
- title: u("recipe.restore-title", { number: o.number }),
520
- message: u("recipe.restore-text"),
521
- confirmText: u("recipe.restore-version"),
522
- cancelText: u("panel.cancel")
521
+ async function N(n) {
522
+ const b = r.value;
523
+ if (!(!b || !await ae({
524
+ title: o("recipe.restore-title", { number: n.number }),
525
+ message: o("recipe.restore-text"),
526
+ confirmText: o("recipe.restore-version"),
527
+ cancelText: o("panel.cancel")
523
528
  }))) {
524
- S.value = !0;
529
+ V.value = !0;
525
530
  try {
526
- await y.restoreVersion(g.id, o.number), await t?.reload(), $.success(u("recipe.restored-version", { number: o.number }));
527
- } catch (P) {
528
- $.danger(A(P));
531
+ await m.restoreVersion(b.id, n.number), await t?.reload(), S.success(o("recipe.restored-version", { number: n.number }));
532
+ } catch (M) {
533
+ S.danger(E(M));
529
534
  } finally {
530
- S.value = !1;
535
+ V.value = !1;
531
536
  }
532
537
  }
533
538
  }
534
- return le(
539
+ return ne(
535
540
  () => [r.value?.id, r.value?.published_at, r.value?.updated_at],
536
541
  () => {
537
- B();
542
+ P();
538
543
  },
539
544
  { immediate: !0 }
540
- ), (o, g) => (v(), N("div", $t, [
541
- i.value === null ? (v(), k(e(ue), {
542
- key: 0,
543
- class: "wx-recipe-history__ghost",
544
- rows: 3
545
- })) : i.value.length === 0 ? (v(), k(e(De), {
546
- key: 1,
547
- description: e(u)("recipe.history-empty")
548
- }, null, 8, ["description"])) : (v(!0), N(te, { key: 2 }, Ie(i.value, (m) => (v(), N("div", {
549
- key: m.number,
550
- class: ke(["wx-recipe-history__row", { "is-live": m.number === T.value }])
551
- }, [
552
- E("code", Rt, w(e(u)("recipe.version", { number: m.number })), 1),
553
- E("div", Wt, [
554
- m.created_at ? (v(), k(e(Ge), {
545
+ ), (n, b) => (p(), q("div", Ct, [
546
+ A("div", It, [
547
+ i.value === null ? (p(), k(e(ve), {
548
+ key: 0,
549
+ class: "wx-recipe-history__ghost",
550
+ rows: 3
551
+ })) : i.value.length === 0 ? (p(), k(e(Ee), {
552
+ key: 1,
553
+ description: e(o)("recipe.history-empty")
554
+ }, null, 8, ["description"])) : (p(!0), q(ee, { key: 2 }, qe(i.value, (h) => (p(), q("div", {
555
+ key: h.number,
556
+ class: Te(["wx-recipe-history__row", { "is-live": h.number === R.value }])
557
+ }, [
558
+ A("code", Nt, x(e(o)("recipe.version", { number: h.number })), 1),
559
+ A("div", zt, [
560
+ h.created_at ? (p(), k(e(Qe), {
561
+ key: 0,
562
+ value: h.created_at,
563
+ size: "md",
564
+ tone: "default"
565
+ }, null, 8, ["value"])) : D("", !0),
566
+ y(e(ft), {
567
+ size: "sm",
568
+ tone: "muted"
569
+ }, {
570
+ default: v(() => [
571
+ $(x(h.author ?? e(o)(`recipe.source-${h.source}`)) + " ", 1),
572
+ h.comment ? (p(), q(ee, { key: 0 }, [
573
+ $(" · " + x(h.comment), 1)
574
+ ], 64)) : D("", !0)
575
+ ]),
576
+ _: 2
577
+ }, 1024)
578
+ ]),
579
+ h.number === R.value ? (p(), k(e(Z), {
555
580
  key: 0,
556
- value: m.created_at,
557
- size: "md",
558
- tone: "default"
559
- }, null, 8, ["value"])) : q("", !0),
560
- h(e(dt), {
581
+ type: "success",
582
+ dot: ""
583
+ }, {
584
+ default: v(() => [
585
+ $(x(e(o)("recipe.version-live")), 1)
586
+ ]),
587
+ _: 1
588
+ })) : D("", !0),
589
+ g.value && h.number !== R.value ? (p(), k(e(le), {
590
+ key: 1,
561
591
  size: "sm",
562
- tone: "muted"
592
+ variant: "outline",
593
+ loading: V.value,
594
+ onClick: (M) => N(h)
563
595
  }, {
564
- default: d(() => [
565
- _(w(m.author ?? e(u)(`recipe.source-${m.source}`)) + " ", 1),
566
- m.comment ? (v(), N(te, { key: 0 }, [
567
- _(" · " + w(m.comment), 1)
568
- ], 64)) : q("", !0)
596
+ default: v(() => [
597
+ $(x(e(o)("recipe.restore-version")), 1)
569
598
  ]),
570
- _: 2
571
- }, 1024)
572
- ]),
573
- m.number === T.value ? (v(), k(e(Z), {
574
- key: 0,
575
- type: "success",
576
- dot: ""
577
- }, {
578
- default: d(() => [
579
- _(w(e(u)("recipe.version-live")), 1)
580
- ]),
581
- _: 1
582
- })) : q("", !0),
583
- b.value && m.number !== T.value ? (v(), k(e(ee), {
584
- key: 1,
585
- size: "sm",
586
- variant: "outline",
587
- loading: S.value,
588
- onClick: (P) => z(m)
589
- }, {
590
- default: d(() => [
591
- _(w(e(u)("recipe.restore-version")), 1)
592
- ]),
593
- _: 1
594
- }, 8, ["loading", "onClick"])) : q("", !0)
595
- ], 2))), 128))
599
+ _: 1
600
+ }, 8, ["loading", "onClick"])) : D("", !0)
601
+ ], 2))), 128))
602
+ ]),
603
+ y(e(Xe), {
604
+ id: r.value?.id,
605
+ entity: "recipes",
606
+ screen: "recipes.form",
607
+ "can-restore": g.value,
608
+ stamp: [r.value?.published_at, r.value?.updated_at],
609
+ onRestored: b[0] || (b[0] = (h) => e(t)?.reload())
610
+ }, null, 8, ["id", "can-restore", "stamp"])
596
611
  ]));
597
612
  }
598
- }), Ct = /* @__PURE__ */ $e(St, [["__scopeId", "data-v-dcd71040"]]);
599
- function Vt(l, n) {
600
- if (l == null || l <= 0) return "";
601
- const y = Math.floor(l / 60), t = l % 60;
602
- return y === 0 ? n("panel.minutes", { count: t }) : t === 0 ? n("panel.hours", { hours: y }) : n("panel.hours-minutes", { hours: y, minutes: t });
613
+ }), At = /* @__PURE__ */ Re(qt, [["__scopeId", "data-v-23c74649"]]);
614
+ function Dt(u, l) {
615
+ if (u == null || u <= 0) return "";
616
+ const m = Math.floor(u / 60), t = u % 60;
617
+ return m === 0 ? l("panel.minutes", { count: t }) : t === 0 ? l("panel.hours", { hours: m }) : l("panel.hours-minutes", { hours: m, minutes: t });
603
618
  }
604
- const zt = /* @__PURE__ */ ce({
619
+ const Et = /* @__PURE__ */ he({
605
620
  __name: "RecipeCreateDialog",
606
- setup(l) {
607
- const { open: n, resolve: y, dismiss: t } = pt(), u = oe(), A = de(u);
608
- pe();
609
- const i = ne("webx-recipes"), S = x(""), r = x(!1), b = x({}), T = Ze("field");
610
- Ve(async () => {
611
- await et(), T.value?.querySelector("input")?.focus();
621
+ setup(u) {
622
+ const { open: l, resolve: m, dismiss: t } = yt(), o = oe(), E = fe(o);
623
+ ye();
624
+ const i = se("webx-recipes"), V = _(""), r = _(!1), g = _({}), R = it("field");
625
+ Ne(async () => {
626
+ await rt(), R.value?.querySelector("input")?.focus();
612
627
  });
613
- async function B() {
614
- if (!(S.value.trim() === "" || r.value)) {
615
- r.value = !0, b.value = {};
628
+ async function P() {
629
+ if (!(V.value.trim() === "" || r.value)) {
630
+ r.value = !0, g.value = {};
616
631
  try {
617
- y((await A.create({ title: S.value.trim() })).recipe);
618
- } catch (z) {
619
- b.value = z.body?.errors ?? {};
632
+ m((await E.create({ title: V.value.trim() })).recipe);
633
+ } catch (N) {
634
+ g.value = N.body?.errors ?? {};
620
635
  } finally {
621
636
  r.value = !1;
622
637
  }
623
638
  }
624
639
  }
625
- return (z, o) => (v(), k(e(vt), {
626
- open: e(n),
627
- "onUpdate:open": o[2] || (o[2] = (g) => tt(n) ? n.value = g : null),
640
+ return (N, n) => (p(), k(e(mt), {
641
+ open: e(l),
642
+ "onUpdate:open": n[2] || (n[2] = (b) => st(l) ? l.value = b : null),
628
643
  title: e(i)("panel.new-title"),
629
644
  width: 440
630
645
  }, {
631
- footer: d(() => [
632
- h(e(ft), { size: "sm" }, {
633
- default: d(() => [
634
- h(e(ee), {
646
+ footer: v(() => [
647
+ y(e(gt), { size: "sm" }, {
648
+ default: v(() => [
649
+ y(e(le), {
635
650
  variant: "outline",
636
- onClick: o[1] || (o[1] = (g) => e(t)())
651
+ onClick: n[1] || (n[1] = (b) => e(t)())
637
652
  }, {
638
- default: d(() => [
639
- _(w(e(i)("panel.cancel")), 1)
653
+ default: v(() => [
654
+ $(x(e(i)("panel.cancel")), 1)
640
655
  ]),
641
656
  _: 1
642
657
  }),
643
- h(e(ee), {
658
+ y(e(le), {
644
659
  type: "primary",
645
660
  loading: r.value,
646
- disabled: S.value.trim() === "",
647
- onClick: B
661
+ disabled: V.value.trim() === "",
662
+ onClick: P
648
663
  }, {
649
- default: d(() => [
650
- _(w(e(i)("panel.create")), 1)
664
+ default: v(() => [
665
+ $(x(e(i)("panel.create")), 1)
651
666
  ]),
652
667
  _: 1
653
668
  }, 8, ["loading", "disabled"])
@@ -655,22 +670,22 @@ const zt = /* @__PURE__ */ ce({
655
670
  _: 1
656
671
  })
657
672
  ]),
658
- default: d(() => [
659
- h(e(ht), {
673
+ default: v(() => [
674
+ y(e(bt), {
660
675
  label: e(i)("panel.field-title"),
661
- error: b.value.title?.[0] ?? b.value.slug?.[0],
676
+ error: g.value.title?.[0] ?? g.value.slug?.[0],
662
677
  required: ""
663
678
  }, {
664
- default: d(() => [
665
- E("div", {
679
+ default: v(() => [
680
+ A("div", {
666
681
  ref_key: "field",
667
- ref: T
682
+ ref: R
668
683
  }, [
669
- h(e(Me), {
670
- modelValue: S.value,
671
- "onUpdate:modelValue": o[0] || (o[0] = (g) => S.value = g),
684
+ y(e(Pe), {
685
+ modelValue: V.value,
686
+ "onUpdate:modelValue": n[0] || (n[0] = (b) => V.value = b),
672
687
  "aria-label": e(i)("panel.field-title"),
673
- onKeyup: at(B, ["enter"])
688
+ onKeyup: nt(P, ["enter"])
674
689
  }, null, 8, ["modelValue", "aria-label"])
675
690
  ], 512)
676
691
  ]),
@@ -680,388 +695,388 @@ const zt = /* @__PURE__ */ ce({
680
695
  _: 1
681
696
  }, 8, ["open", "title"]));
682
697
  }
683
- }), It = { class: "wx-recipes" }, Nt = { class: "wx-recipes__bar" }, qt = ["src"], At = { class: "wx-recipe-row__name" }, Dt = { class: "wx-recipe-row__title" }, Mt = { class: "wx-recipe-row__address" }, Et = { class: "wx-recipe-row__facts" }, Pt = { class: "wx-recipe-row__chips" }, Ut = { class: "wx-recipe-row__state" }, Bt = {
698
+ }), Pt = { class: "wx-recipes" }, Mt = { class: "wx-recipes__bar" }, Ot = ["src"], Ut = { class: "wx-recipe-row__name" }, Bt = { class: "wx-recipe-row__title" }, Lt = { class: "wx-recipe-row__address" }, Ht = { class: "wx-recipe-row__facts" }, Ft = { class: "wx-recipe-row__chips" }, Kt = { class: "wx-recipe-row__state" }, Jt = {
684
699
  key: 0,
685
700
  class: "wx-recipe-row__time"
686
- }, Lt = /* @__PURE__ */ ce({
701
+ }, Gt = /* @__PURE__ */ he({
687
702
  __name: "RecipesPage",
688
703
  props: {
689
704
  base: { default: "/recipes" }
690
705
  },
691
- setup(l) {
692
- const n = l, y = oe(), t = de(y), u = Ne(), A = qe();
693
- pe();
694
- const i = ne("webx-recipes"), S = Te(), r = x([]), b = x({ categories: [], nutrients: [], services: null }), T = x(!0), B = yt(zt), z = f(() => y.can("recipes.manage")), o = f(
695
- () => y.state.manifest?.modules.find((a) => a.id === "recipes")?.title ?? i("module.recipes")
696
- ), g = f({
697
- get: () => typeof u.query.view == "string" ? u.query.view : "",
706
+ setup(u) {
707
+ const l = u, m = oe(), t = fe(m), o = Ae(), E = De();
708
+ ye();
709
+ const i = se("webx-recipes"), V = $e(), r = _([]), g = _({ categories: [], nutrients: [], services: null }), R = _(!0), P = wt(Et), N = f(() => m.can("recipes.manage")), n = f(
710
+ () => m.state.manifest?.modules.find((a) => a.id === "recipes")?.title ?? i("module.recipes")
711
+ ), b = f({
712
+ get: () => typeof o.query.view == "string" ? o.query.view : "",
698
713
  set: (a) => {
699
- A.replace({
700
- query: { ...u.query, view: a === "" ? void 0 : String(a) }
714
+ E.replace({
715
+ query: { ...o.query, view: a === "" ? void 0 : String(a) }
701
716
  });
702
717
  }
703
- }), m = f(() => g.value === "trashed");
704
- function P(a) {
705
- const p = u.query[a];
706
- return typeof p == "string" && p !== "" && Number(p) || null;
718
+ }), h = f(() => b.value === "trashed");
719
+ function M(a) {
720
+ const d = o.query[a];
721
+ return typeof d == "string" && d !== "" && Number(d) || null;
707
722
  }
708
- const L = f(() => P("category")), O = f(() => P("nutrient")), U = f(() => P("service")), V = f(() => typeof u.query.q == "string" ? u.query.q : ""), J = x(V.value), I = f(() => [
723
+ const B = f(() => M("category")), F = f(() => M("nutrient")), O = f(() => M("service")), I = f(() => typeof o.query.q == "string" ? o.query.q : ""), j = _(I.value), Q = f(() => [
709
724
  { value: "", label: i("panel.view-all") },
710
725
  { value: "published", label: i("panel.view-published") },
711
726
  { value: "draft", label: i("panel.view-draft") },
712
727
  { value: "unpublished", label: i("panel.view-unpublished") },
713
728
  { value: "trashed", label: i("panel.bin"), icon: "trash" }
714
- ]), H = f(
715
- () => g.value === "" && V.value.trim() === "" && L.value === null && O.value === null && U.value === null
716
- ), D = f(() => z.value && H.value), ve = f(() => i(H.value ? "panel.order-all" : "panel.order-locked")), F = f(() => V.value !== "" ? i("panel.empty-search") : m.value ? i("panel.empty-bin") : i("panel.empty"));
717
- async function R() {
718
- T.value = !0;
729
+ ]), z = f(
730
+ () => b.value === "" && I.value.trim() === "" && B.value === null && F.value === null && O.value === null
731
+ ), T = f(() => N.value && z.value), K = f(() => i(z.value ? "panel.order-all" : "panel.order-locked")), me = f(() => I.value !== "" ? i("panel.empty-search") : h.value ? i("panel.empty-bin") : i("panel.empty"));
732
+ async function U() {
733
+ R.value = !0;
719
734
  try {
720
735
  const a = await t.list({
721
- q: V.value,
722
- category: L.value,
723
- nutrient: O.value,
724
- service: U.value,
725
- status: m.value ? "" : g.value,
726
- trashed: m.value
736
+ q: I.value,
737
+ category: B.value,
738
+ nutrient: F.value,
739
+ service: O.value,
740
+ status: h.value ? "" : b.value,
741
+ trashed: h.value
727
742
  });
728
- r.value = a.data, b.value = a.filters;
743
+ r.value = a.data, g.value = a.filters;
729
744
  } catch (a) {
730
- $.danger(S(a));
745
+ S.danger(V(a));
731
746
  } finally {
732
- T.value = !1;
747
+ R.value = !1;
733
748
  }
734
749
  }
735
- le(
736
- () => [g.value, L.value, O.value, U.value, V.value],
750
+ ne(
751
+ () => [b.value, B.value, F.value, O.value, I.value],
737
752
  () => {
738
- R();
753
+ U();
739
754
  }
740
- ), R();
741
- let ie;
742
- le(J, (a) => {
743
- clearTimeout(ie), ie = setTimeout(() => {
744
- A.replace({ query: { ...u.query, q: a.trim() === "" ? void 0 : a } });
755
+ ), U();
756
+ let C;
757
+ ne(j, (a) => {
758
+ clearTimeout(C), C = setTimeout(() => {
759
+ E.replace({ query: { ...o.query, q: a.trim() === "" ? void 0 : a } });
745
760
  }, 300);
746
- }), ze(() => clearTimeout(ie));
747
- function j(a, p) {
748
- A.replace({
749
- query: { ...u.query, [a]: typeof p == "number" ? String(p) : void 0 }
761
+ }), ze(() => clearTimeout(C));
762
+ function ie(a, d) {
763
+ E.replace({
764
+ query: { ...o.query, [a]: typeof d == "number" ? String(d) : void 0 }
750
765
  });
751
766
  }
752
- const re = (a) => (a ?? []).map((p) => ({ value: p.id, label: p.title }));
753
- function se(a) {
754
- A.push({ path: `${n.base}/${a.id}`, query: { ...u.query } });
767
+ const X = (a) => (a ?? []).map((d) => ({ value: d.id, label: d.title }));
768
+ function ue(a) {
769
+ E.push({ path: `${l.base}/${a.id}`, query: { ...o.query } });
755
770
  }
756
- async function K() {
757
- const a = await B({});
758
- a && se(a);
771
+ async function ce() {
772
+ const a = await P({});
773
+ a && ue(a);
759
774
  }
760
- async function Q() {
775
+ async function J() {
761
776
  try {
762
777
  await t.reorder(r.value.map((a) => a.id));
763
778
  } catch (a) {
764
- $.danger(S(a, i("panel.reorder-failed"))), await R();
779
+ S.danger(V(a, i("panel.reorder-failed"))), await U();
765
780
  }
766
781
  }
767
- function he(a) {
768
- if (!z.value) return [];
769
- if (m.value)
782
+ function be(a) {
783
+ if (!N.value) return [];
784
+ if (h.value)
770
785
  return [
771
786
  {
772
787
  key: "restore",
773
788
  icon: "refresh",
774
789
  label: i("panel.restore"),
775
790
  run: () => {
776
- X(a);
791
+ ge(a);
777
792
  }
778
793
  }
779
794
  ];
780
- const p = [
781
- { key: "open", icon: "edit", label: i("panel.open"), run: () => se(a) }
795
+ const d = [
796
+ { key: "open", icon: "edit", label: i("panel.open"), run: () => ue(a) }
782
797
  ];
783
- return a.url && a.status !== "draft" && p.push({
798
+ return a.url && a.status !== "draft" && d.push({
784
799
  key: "site",
785
800
  icon: "external-link",
786
801
  label: i("panel.open-on-site"),
787
802
  href: a.url
788
- }), a.url && p.push({
803
+ }), a.url && d.push({
789
804
  key: "copy",
790
805
  icon: "copy",
791
806
  label: i("panel.copy-address"),
792
807
  run: () => {
793
- ye(a);
808
+ G(a);
794
809
  }
795
- }), p.push(
810
+ }), d.push(
796
811
  a.status === "published" || a.status === "modified" ? {
797
812
  key: "unpublish",
798
813
  icon: "eye-off",
799
814
  label: i("panel.unpublish"),
800
815
  run: () => {
801
- M(() => t.unpublish(a.id), i("panel.unpublished-done"));
816
+ te(() => t.unpublish(a.id), i("panel.unpublished-done"));
802
817
  }
803
818
  } : {
804
819
  key: "publish",
805
820
  icon: "upload",
806
821
  label: i("panel.publish"),
807
822
  run: () => {
808
- M(() => t.publish(a.id), i("panel.published"));
823
+ te(() => t.publish(a.id), i("panel.published"));
809
824
  }
810
825
  }
811
- ), p.push({
826
+ ), d.push({
812
827
  key: "delete",
813
828
  icon: "trash",
814
829
  label: i("panel.delete"),
815
830
  danger: !0,
816
831
  run: () => {
817
- fe(a);
832
+ Y(a);
818
833
  }
819
- }), p;
834
+ }), d;
820
835
  }
821
- async function fe(a) {
822
- await Y({
836
+ async function Y(a) {
837
+ await ae({
823
838
  title: i("panel.delete-title", { title: a.title }),
824
839
  message: i("panel.delete-text"),
825
840
  confirmText: i("panel.delete"),
826
841
  cancelText: i("panel.cancel"),
827
842
  tone: "danger"
828
- }) && await M(() => t.remove(a.id), i("panel.deleted"));
843
+ }) && await te(() => t.remove(a.id), i("panel.deleted"));
829
844
  }
830
- async function X(a) {
831
- await M(() => t.restore(a.id), i("panel.restored"));
845
+ async function ge(a) {
846
+ await te(() => t.restore(a.id), i("panel.restored"));
832
847
  }
833
- async function M(a, p) {
848
+ async function te(a, d) {
834
849
  try {
835
- await a(), $.success(p);
850
+ await a(), S.success(d);
836
851
  } catch (c) {
837
- $.danger(S(c));
852
+ S.danger(V(c));
838
853
  } finally {
839
- await R();
854
+ await U();
840
855
  }
841
856
  }
842
- async function ye(a) {
857
+ async function G(a) {
843
858
  if (a.url)
844
859
  try {
845
- await navigator.clipboard.writeText(a.url), $.success(i("panel.address-copied"));
860
+ await navigator.clipboard.writeText(a.url), S.success(i("panel.address-copied"));
846
861
  } catch {
847
862
  }
848
863
  }
849
- function me(a) {
864
+ function H(a) {
850
865
  return a === "published" || a === "modified" ? "success" : "default";
851
866
  }
852
- function ge(a) {
853
- return m.value ? "—" : a.path === null ? i("panel.no-address") : `/${a.path}`;
867
+ function we(a) {
868
+ return h.value ? "—" : a.path === null ? i("panel.no-address") : `/${a.path}`;
854
869
  }
855
- const be = f(
856
- () => z.value ? [{ key: "new", label: i("panel.new"), icon: "plus", primary: !0, run: () => {
857
- K();
870
+ const xe = f(
871
+ () => N.value ? [{ key: "new", label: i("panel.new"), icon: "plus", primary: !0, run: () => {
872
+ ce();
858
873
  } }] : []
859
874
  );
860
- return (a, p) => (v(), N("div", It, [
861
- h(e(Je), {
862
- view: g.value,
863
- "onUpdate:view": p[5] || (p[5] = (c) => g.value = c),
864
- title: o.value,
865
- views: I.value,
866
- actions: be.value,
875
+ return (a, d) => (p(), q("div", Pt, [
876
+ y(e(Ye), {
877
+ view: b.value,
878
+ "onUpdate:view": d[5] || (d[5] = (c) => b.value = c),
879
+ title: n.value,
880
+ views: Q.value,
881
+ actions: xe.value,
867
882
  padding: "sm"
868
883
  }, {
869
- default: d(() => [
870
- E("div", Nt, [
871
- h(e(Me), {
872
- modelValue: J.value,
873
- "onUpdate:modelValue": p[0] || (p[0] = (c) => J.value = c),
884
+ default: v(() => [
885
+ A("div", Mt, [
886
+ y(e(Pe), {
887
+ modelValue: j.value,
888
+ "onUpdate:modelValue": d[0] || (d[0] = (c) => j.value = c),
874
889
  class: "wx-recipes__search",
875
890
  size: "sm",
876
891
  clearable: "",
877
892
  placeholder: e(i)("panel.search"),
878
893
  "aria-label": e(i)("panel.search")
879
894
  }, {
880
- prefix: d(() => [
881
- h(e(xe), {
895
+ prefix: v(() => [
896
+ y(e(_e), {
882
897
  name: "search",
883
898
  size: "sm"
884
899
  })
885
900
  ]),
886
901
  _: 1
887
902
  }, 8, ["modelValue", "placeholder", "aria-label"]),
888
- h(e(_e), {
889
- "model-value": L.value,
890
- options: re(b.value.categories),
903
+ y(e(ke), {
904
+ "model-value": B.value,
905
+ options: X(g.value.categories),
891
906
  placeholder: e(i)("panel.any-category"),
892
907
  "aria-label": e(i)("panel.filter-category"),
893
908
  clearable: "",
894
909
  size: "sm",
895
- "onUpdate:modelValue": p[1] || (p[1] = (c) => j("category", c))
910
+ "onUpdate:modelValue": d[1] || (d[1] = (c) => ie("category", c))
896
911
  }, null, 8, ["model-value", "options", "placeholder", "aria-label"]),
897
- h(e(_e), {
898
- "model-value": O.value,
899
- options: re(b.value.nutrients),
912
+ y(e(ke), {
913
+ "model-value": F.value,
914
+ options: X(g.value.nutrients),
900
915
  placeholder: e(i)("panel.any-nutrient"),
901
916
  "aria-label": e(i)("panel.filter-nutrient"),
902
917
  clearable: "",
903
918
  size: "sm",
904
- "onUpdate:modelValue": p[2] || (p[2] = (c) => j("nutrient", c))
919
+ "onUpdate:modelValue": d[2] || (d[2] = (c) => ie("nutrient", c))
905
920
  }, null, 8, ["model-value", "options", "placeholder", "aria-label"]),
906
- b.value.services !== null ? (v(), k(e(_e), {
921
+ g.value.services !== null ? (p(), k(e(ke), {
907
922
  key: 0,
908
- "model-value": U.value,
909
- options: re(b.value.services),
923
+ "model-value": O.value,
924
+ options: X(g.value.services),
910
925
  placeholder: e(i)("panel.any-service"),
911
926
  "aria-label": e(i)("panel.filter-service"),
912
927
  clearable: "",
913
928
  size: "sm",
914
- "onUpdate:modelValue": p[3] || (p[3] = (c) => j("service", c))
915
- }, null, 8, ["model-value", "options", "placeholder", "aria-label"])) : q("", !0)
929
+ "onUpdate:modelValue": d[3] || (d[3] = (c) => ie("service", c))
930
+ }, null, 8, ["model-value", "options", "placeholder", "aria-label"])) : D("", !0)
916
931
  ]),
917
- T.value && r.value.length === 0 ? (v(), k(e(ue), {
932
+ R.value && r.value.length === 0 ? (p(), k(e(ve), {
918
933
  key: 0,
919
934
  class: "wx-recipes__loading",
920
935
  rows: 5
921
- })) : r.value.length === 0 ? (v(), k(e(De), {
936
+ })) : r.value.length === 0 ? (p(), k(e(Ee), {
922
937
  key: 1,
923
- title: F.value,
924
- description: H.value ? e(i)("panel.empty-help") : void 0
925
- }, null, 8, ["title", "description"])) : (v(), N(te, { key: 2 }, [
926
- h(e(mt), {
938
+ title: me.value,
939
+ description: z.value ? e(i)("panel.empty-help") : void 0
940
+ }, null, 8, ["title", "description"])) : (p(), q(ee, { key: 2 }, [
941
+ y(e(xt), {
927
942
  modelValue: r.value,
928
- "onUpdate:modelValue": p[4] || (p[4] = (c) => r.value = c),
929
- class: ke(["wx-recipes__list", { "is-loading": T.value }]),
943
+ "onUpdate:modelValue": d[4] || (d[4] = (c) => r.value = c),
944
+ class: Te(["wx-recipes__list", { "is-loading": R.value }]),
930
945
  plain: "",
931
946
  "item-key": "id",
932
- handle: D.value ? "grip" : "row",
947
+ handle: T.value ? "grip" : "row",
933
948
  "item-label": (c) => c.title,
934
- disabled: !D.value,
935
- onMove: Q
949
+ disabled: !T.value,
950
+ onMove: J
936
951
  }, {
937
- default: d(({ item: c }) => [
938
- (v(), k(it(m.value ? "div" : "router-link"), rt({ class: "wx-recipe-row" }, m.value ? {} : { to: { path: `${n.base}/${c.id}`, query: e(u).query } }), {
939
- default: d(() => [
940
- E("span", {
941
- class: ke(["wx-recipe-row__cover", { "is-empty": !c.cover?.thumb }])
952
+ default: v(({ item: c }) => [
953
+ (p(), k(lt(h.value ? "div" : "router-link"), ot({ class: "wx-recipe-row" }, h.value ? {} : { to: { path: `${l.base}/${c.id}`, query: e(o).query } }), {
954
+ default: v(() => [
955
+ A("span", {
956
+ class: Te(["wx-recipe-row__cover", { "is-empty": !c.cover?.thumb }])
942
957
  }, [
943
- c.cover?.thumb ? (v(), N("img", {
958
+ c.cover?.thumb ? (p(), q("img", {
944
959
  key: 0,
945
960
  src: c.cover.thumb,
946
961
  alt: "",
947
962
  loading: "lazy"
948
- }, null, 8, qt)) : (v(), k(e(xe), {
963
+ }, null, 8, Ot)) : (p(), k(e(_e), {
949
964
  key: 1,
950
965
  name: "image",
951
966
  size: "sm"
952
967
  }))
953
968
  ], 2),
954
- E("span", At, [
955
- E("span", Dt, w(c.title), 1),
956
- E("span", Mt, [
957
- _(w(ge(c)), 1),
958
- m.value ? q("", !0) : (v(), k(e(Qe), {
969
+ A("span", Ut, [
970
+ A("span", Bt, x(c.title), 1),
971
+ A("span", Lt, [
972
+ $(x(we(c)), 1),
973
+ h.value ? D("", !0) : (p(), k(e(et), {
959
974
  key: 0,
960
975
  locale: c.address_locale
961
976
  }, null, 8, ["locale"]))
962
977
  ])
963
978
  ]),
964
- E("span", Et, [
965
- E("span", Pt, [
966
- (v(!0), N(te, null, Ie(c.categories, (ae, we) => (v(), N(te, {
967
- key: ae.id
979
+ A("span", Ht, [
980
+ A("span", Ft, [
981
+ (p(!0), q(ee, null, qe(c.categories, (re, de) => (p(), q(ee, {
982
+ key: re.id
968
983
  }, [
969
- we === 0 ? (v(), k(e(gt), {
984
+ de === 0 ? (p(), k(e(_t), {
970
985
  key: 0,
971
986
  content: e(i)("panel.main-category")
972
987
  }, {
973
- default: d(() => [
974
- h(e(Z), {
988
+ default: v(() => [
989
+ y(e(Z), {
975
990
  size: "sm",
976
991
  round: "",
977
992
  type: "primary"
978
993
  }, {
979
- default: d(() => [
980
- _(w(ae.title), 1)
994
+ default: v(() => [
995
+ $(x(re.title), 1)
981
996
  ]),
982
997
  _: 2
983
998
  }, 1024)
984
999
  ]),
985
1000
  _: 2
986
- }, 1032, ["content"])) : (v(), k(e(Z), {
1001
+ }, 1032, ["content"])) : (p(), k(e(Z), {
987
1002
  key: 1,
988
1003
  size: "sm",
989
1004
  round: ""
990
1005
  }, {
991
- default: d(() => [
992
- _(w(ae.title), 1)
1006
+ default: v(() => [
1007
+ $(x(re.title), 1)
993
1008
  ]),
994
1009
  _: 2
995
1010
  }, 1024))
996
1011
  ], 64))), 128))
997
1012
  ]),
998
- E("span", Ut, [
999
- c.minutes ? (v(), N("span", Bt, [
1000
- h(e(xe), {
1013
+ A("span", Kt, [
1014
+ c.minutes ? (p(), q("span", Jt, [
1015
+ y(e(_e), {
1001
1016
  name: "clock",
1002
1017
  size: "sm"
1003
1018
  }),
1004
- _(w(e(Vt)(c.minutes, e(i))), 1)
1005
- ])) : q("", !0),
1006
- h(e(Z), {
1007
- type: me(c.status),
1019
+ $(x(e(Dt)(c.minutes, e(i))), 1)
1020
+ ])) : D("", !0),
1021
+ y(e(Z), {
1022
+ type: H(c.status),
1008
1023
  dot: "",
1009
1024
  size: "sm"
1010
1025
  }, {
1011
- default: d(() => [
1012
- _(w(e(i)(`panel.status-${c.status}`)), 1)
1026
+ default: v(() => [
1027
+ $(x(e(i)(`panel.status-${c.status}`)), 1)
1013
1028
  ]),
1014
1029
  _: 2
1015
1030
  }, 1032, ["type"]),
1016
- c.status === "modified" ? (v(), k(e(Z), {
1031
+ c.status === "modified" ? (p(), k(e(Z), {
1017
1032
  key: 1,
1018
1033
  type: "primary",
1019
1034
  size: "sm",
1020
1035
  round: ""
1021
1036
  }, {
1022
- default: d(() => [
1023
- _(w(e(i)("panel.edits")), 1)
1037
+ default: v(() => [
1038
+ $(x(e(i)("panel.edits")), 1)
1024
1039
  ]),
1025
1040
  _: 1
1026
- })) : q("", !0)
1041
+ })) : D("", !0)
1027
1042
  ])
1028
1043
  ])
1029
1044
  ]),
1030
1045
  _: 2
1031
1046
  }, 1040))
1032
1047
  ]),
1033
- actions: d(({ item: c }) => [
1034
- h(e(je), {
1035
- actions: he(c),
1048
+ actions: v(({ item: c }) => [
1049
+ y(e(Ze), {
1050
+ actions: be(c),
1036
1051
  label: c.title
1037
1052
  }, null, 8, ["actions", "label"])
1038
1053
  ]),
1039
1054
  _: 1
1040
1055
  }, 8, ["modelValue", "class", "handle", "item-label", "disabled"]),
1041
- z.value && !m.value ? (v(), k(e(Ae), {
1056
+ N.value && !h.value ? (p(), k(e(kt), {
1042
1057
  key: 0,
1043
1058
  class: "wx-recipes__note",
1044
1059
  type: "info",
1045
- description: ve.value
1046
- }, null, 8, ["description"])) : q("", !0)
1060
+ description: K.value
1061
+ }, null, 8, ["description"])) : D("", !0)
1047
1062
  ], 64))
1048
1063
  ]),
1049
1064
  _: 1
1050
1065
  }, 8, ["view", "title", "views", "actions"])
1051
1066
  ]));
1052
1067
  }
1053
- }), Ot = /* @__PURE__ */ $e(Lt, [["__scopeId", "data-v-27e46b1b"]]);
1054
- function Ht(l = "/recipes") {
1068
+ }), jt = /* @__PURE__ */ Re(Gt, [["__scopeId", "data-v-27e46b1b"]]);
1069
+ function Qt(u = "/recipes") {
1055
1070
  return {
1056
1071
  api: "recipes/categories",
1057
- path: `${l}/categories`,
1072
+ path: `${u}/categories`,
1058
1073
  name: "webx.recipes.categories",
1059
1074
  module: "recipe-categories",
1060
1075
  screen: "recipes.category-form",
1061
1076
  manage: "recipes.categories.manage",
1062
1077
  count: "recipes_count",
1063
1078
  // A category has no order of its own inside it (decision 4): the link shows what is in it.
1064
- items: (n) => ({ path: l, query: { category: String(n) } }),
1079
+ items: (l) => ({ path: u, query: { category: String(l) } }),
1065
1080
  words: {
1066
1081
  new: "webx-recipes::category.new",
1067
1082
  empty: "webx-recipes::category.empty",
@@ -1081,16 +1096,16 @@ function Ht(l = "/recipes") {
1081
1096
  }
1082
1097
  };
1083
1098
  }
1084
- function Ft(l = "/recipes") {
1099
+ function Xt(u = "/recipes") {
1085
1100
  return {
1086
1101
  api: "recipes/nutrients",
1087
- path: `${l}/nutrients`,
1102
+ path: `${u}/nutrients`,
1088
1103
  name: "webx.recipes.nutrients",
1089
1104
  module: "recipe-nutrients",
1090
1105
  screen: "recipes.nutrient-form",
1091
1106
  manage: "recipes.categories.manage",
1092
1107
  count: "recipes_count",
1093
- items: (n) => ({ path: l, query: { nutrient: String(n) } }),
1108
+ items: (l) => ({ path: u, query: { nutrient: String(l) } }),
1094
1109
  words: {
1095
1110
  new: "webx-recipes::nutrient.new",
1096
1111
  empty: "webx-recipes::nutrient.empty",
@@ -1107,19 +1122,19 @@ function Ft(l = "/recipes") {
1107
1122
  }
1108
1123
  };
1109
1124
  }
1110
- function Qt(l = {}) {
1111
- const n = l.path ?? "/recipes";
1125
+ function aa(u = {}) {
1126
+ const l = u.path ?? "/recipes";
1112
1127
  return [
1113
1128
  {
1114
1129
  id: "recipes",
1115
- path: n,
1130
+ path: l,
1116
1131
  routes: [
1117
- { path: n, name: "webx.recipes", component: Ot, props: { base: n } },
1132
+ { path: l, name: "webx.recipes", component: jt, props: { base: l } },
1118
1133
  {
1119
- path: `${n}/:id(\\d+)`,
1134
+ path: `${l}/:id(\\d+)`,
1120
1135
  name: "webx.recipes.edit",
1121
- component: Tt,
1122
- props: { base: n }
1136
+ component: Vt,
1137
+ props: { base: l }
1123
1138
  }
1124
1139
  ],
1125
1140
  /*
@@ -1127,35 +1142,35 @@ function Qt(l = {}) {
1127
1142
  * panel's (`wx-slug`, `wx-categories`, `wx-relations`, `wx-gallery`, `wx-rich-text`).
1128
1143
  */
1129
1144
  types: {
1130
- "wx-recipe-history": { component: Ct, kind: "display" }
1145
+ "wx-recipe-history": { component: At, kind: "display" }
1131
1146
  }
1132
1147
  },
1133
1148
  {
1134
1149
  id: "recipe-categories",
1135
- path: `${n}/categories`,
1136
- routes: Re(Ht(n))
1150
+ path: `${l}/categories`,
1151
+ routes: Se(Qt(l))
1137
1152
  },
1138
1153
  {
1139
1154
  id: "recipe-nutrients",
1140
- path: `${n}/nutrients`,
1141
- routes: Re(Ft(n))
1155
+ path: `${l}/nutrients`,
1156
+ routes: Se(Xt(l))
1142
1157
  }
1143
1158
  ];
1144
1159
  }
1145
1160
  export {
1146
- Se as RECIPES_API,
1147
- zt as WxRecipeCreateDialog,
1148
- Tt as WxRecipeEditorPage,
1149
- Ct as WxRecipeHistory,
1150
- Ot as WxRecipesPage,
1151
- de as createRecipesApi,
1152
- Vt as formatMinutes,
1153
- bt as provideRecipeEditor,
1154
- Ht as recipeCategoriesOptions,
1155
- Ee as recipeEditorKey,
1156
- Ft as recipeNutrientsOptions,
1157
- Qt as recipes,
1158
- xt as recipesMessages,
1159
- wt as useRecipeEditor
1161
+ Ce as RECIPES_API,
1162
+ Et as WxRecipeCreateDialog,
1163
+ Vt as WxRecipeEditorPage,
1164
+ At as WxRecipeHistory,
1165
+ jt as WxRecipesPage,
1166
+ fe as createRecipesApi,
1167
+ Dt as formatMinutes,
1168
+ Tt as provideRecipeEditor,
1169
+ Qt as recipeCategoriesOptions,
1170
+ Me as recipeEditorKey,
1171
+ Xt as recipeNutrientsOptions,
1172
+ aa as recipes,
1173
+ Rt as recipesMessages,
1174
+ $t as useRecipeEditor
1160
1175
  };
1161
1176
  //# sourceMappingURL=index.js.map