PageSourceSearch

https://defacto-observatoire.fr/webjars/wiki%3Axwiki/xwiki-platfor…/DisplayerXObjectProperty-CaZY6Yyt.js

js defacto-observatoire.fr collected 2026-10-02 05:33:01 UTC 4,692 bytes, 138 lines download raw bytes

1import { _ as l, B as p, d as y } from "./main-BueDL5c3.js";
2import { d as u } from "./displayerStatesMixin-BlpS49gT.js";
3import { l as f } from "./require-Dl4qyrU9.js";
4import { resolveComponent as h, createBlock as m, openBlock as g, withCtx as d, createElementVNode as c, normalizeClass as E } from "vue";
5function w(e, t) {
6  return new XWiki.Document(
7    XWiki.Model.resolve(e, XWiki.EntityType.DOCUMENT)
8  ).getURL(t);
9}
10function v(e, t) {
11  let r;
12  if (e.startsWith("doc."))
13    r = new XWiki.EntityReference(e.substring(4), XWiki.EntityType.OBJECT_PROPERTY);
14  else {
15    let n = new XWiki.EntityReference(t + "[0]", XWiki.EntityType.OBJECT);
16    r = new XWiki.EntityReference(e, XWiki.EntityType.OBJECT_PROPERTY, n);
17  }
18  return XWiki.Model.serialize(r);
19}
20async function b(e, t, r, n) {
21  const s = w(t, "get"), [o, i] = await f("xwiki-meta", "jquery");
22  return i.get(s, {
23    xpage: "display",
24    mode: e,
25    // TODO: handle the object index when provided
26    property: v(r, n),
27    type: r.startsWith("doc.") ? "document" : "object",
28    language: o.locale
29  }).catch((a) => {
30    throw new XWiki.widgets.Notification(
31      this.$t("livedata.displayer.xObjectProperty.failedToRetrieveField.errorMessage", [e]),
32      "error"
33    ), a;
34  });
35}
36function j(e, t, r) {
37  return b("edit", e, r, t);
38}
39const k = {
40  name: "displayer-xobject-property",
41  inject: ["logic", "jQuery"],
42  // Add the displayerMixin to get access to all the displayers methods and computed properties inside this component.
43  mixins: [y, u],
44  props: ["timestamp"],
45  components: { BaseDisplayer: p },
46  data() {
47    return {
48      editField: void 0
49    };
50  },
51  methods: {
52    /**
53     * Process the edit form content and send it to be saved.
54     */
55    applyEdit() {
56      if (!this.logic.getEntryId(this.entry))
57        new XWiki.widgets.Notification(
58          this.$t("livedata.displayer.xObjectProperty.missingDocumentName.errorMessage"),
59          "error"
60        );
61      else {
62        const t = this.jQuery;
63        t(document).trigger("xwiki:actions:beforeSave");
64        const r = t(this.$refs.xObjectPropertyEdit).find(":input").serializeArray(), n = this.data.query.source.className, s = {};
65        r.forEach((o) => {
66          var i = o.name;
67          i.startsWith(n) && (i = i.substring(n.length), i = i.replace(/^_\d+_/, "")), s[i] ? (Array.isArray(s[i]) || (s[i] = [s[i]]), s[i].push(o.value)) : s[i] = o.value;
68        }), this.logic.getEditBus().save(this.entry, this.propertyId, s);
69      }
70    },
71    /**
72     * Takes an update method and retrieves its content.
73     *
74     * @param {method} updateMethod the method dedicate to the update of a given aspect of the displayer. For instance,
75     *  the view or edit html content
76     * @returns {*} a `Promise` with the content of the updated view
77     */
78    update(e) {
79      this.isLoading = !0;
80      const t = this.logic.getEntryId(this.entry), r = this.data.query.source.className, n = this.propertyId;
81      return e(t, r, n);
82    },
83    /**
84     * Update the content of the editor slot.
85     */
86    updateEdit() {
87      this.update(j).then((e) => {
88        this.isLoading = !1, this.editField = e, this.$nextTick().then(() => {
89          const t = this.jQuery;
90          this.$refs.xObjectPropertyEdit && (t(document).trigger(
91            "xwiki:dom:updated",
92            { elements: [this.$refs.xObjectPropertyEdit] }
93          ), t(this.$refs.xObjectPropertyEdit).find(":input").filter(":visible").focus());
94        });
95      }).catch(() => {
96        this.isLoading = !1, this.isView = !0;
97      });
98    }
99  },
100  watch: {
101    // Refreshes the edit field when the view mode switched to edit.
102    isView: function(e) {
103      e || this.updateEdit();
104    }
105  }
106}, T = ["innerHTML"], x = ["innerHTML"];
107function O(e, t, r, n, s, o) {
108  const i = h("BaseDisplayer");
109  return g(), m(i, {
110    class: "displayer-xobject-property",
111    "property-id": e.propertyId,
112    entry: e.entry,
113    "is-view": e.isView,
114    "onUpdate:isView": t[0] || (t[0] = (a) => e.isView = a),
115    "is-loading": e.isLoading,
116    onSaveEdit: o.applyEdit
117  }, {
118    viewer: d(() => [
119      c("div", {
120        class: E(["html-wrapper", e.isLoading ? "disabled" : ""]),
121        innerHTML: e.sanitizeHtml(e.value),
122        ref: "xObjectPropertyView"
123      }, null, 10, T)
124    ]),
125    editor: d(() => [
126      c("div", {
127        innerHTML: e.sanitizeHtml(s.editField),
128        ref: "xObjectPropertyEdit"
129      }, null, 8, x)
130    ]),
131    _: 1
132  }, 8, ["property-id", "entry", "is-view", "is-loading", "onSaveEdit"]);
133}
134const $ = /* @__PURE__ */ l(k, [["render", O]]);
135export {
136  $ as default
137};
138//# sourceMappingURL=DisplayerXObjectProperty-CaZY6Yyt.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.