utopia-ui 3.0.0-alpha.215 → 3.0.0-alpha.217

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.
@@ -0,0 +1 @@
1
+ export declare const GratitudeControl: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export declare const AttestationForm: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export declare const EmojiPicker: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,3 @@
1
+ export declare const SelectUser: ({ userType }: {
2
+ userType: string;
3
+ }) => import("react/jsx-runtime").JSX.Element;
package/dist/index.js CHANGED
@@ -962,16 +962,16 @@ var DialogModal = function (_a) {
962
962
 
963
963
  function HeaderView(_a) {
964
964
  var _this = this;
965
- var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
966
- var item = _a.item, api = _a.api, editCallback = _a.editCallback, deleteCallback = _a.deleteCallback, setPositionCallback = _a.setPositionCallback, itemNameField = _a.itemNameField, itemSubnameField = _a.itemSubnameField, itemAvatarField = _a.itemAvatarField, loading = _a.loading, _m = _a.hideMenu, hideMenu = _m === void 0 ? false : _m, _o = _a.big, big = _o === void 0 ? false : _o, _p = _a.truncateSubname, truncateSubname = _p === void 0 ? true : _p, _q = _a.hideSubname, hideSubname = _q === void 0 ? false : _q, _r = _a.showAddress, showAddress = _r === void 0 ? false : _r;
967
- var _s = React.useState(false), modalOpen = _s[0], setModalOpen = _s[1];
965
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k;
966
+ var item = _a.item, api = _a.api, editCallback = _a.editCallback, deleteCallback = _a.deleteCallback, setPositionCallback = _a.setPositionCallback, itemNameField = _a.itemNameField, itemSubnameField = _a.itemSubnameField, itemAvatarField = _a.itemAvatarField, loading = _a.loading, _l = _a.hideMenu, hideMenu = _l === void 0 ? false : _l, _m = _a.big, big = _m === void 0 ? false : _m, _o = _a.truncateSubname, truncateSubname = _o === void 0 ? true : _o, _p = _a.hideSubname, hideSubname = _p === void 0 ? false : _p, _q = _a.showAddress, showAddress = _q === void 0 ? false : _q;
967
+ var _r = React.useState(false), modalOpen = _r[0], setModalOpen = _r[1];
968
968
  var hasUserPermission = useHasUserPermission();
969
969
  var navigate = useNavigate();
970
970
  var assetsApi = useAssetApi();
971
971
  var avatar = itemAvatarField && getValue(item, itemAvatarField) ? assetsApi.url + getValue(item, itemAvatarField) + "".concat(big ? "?width=160&heigth=160" : "?width=80&heigth=80") : ((_b = item.layer) === null || _b === void 0 ? void 0 : _b.itemAvatarField) && item && getValue(item, (_c = item.layer) === null || _c === void 0 ? void 0 : _c.itemAvatarField) && assetsApi.url + getValue(item, (_d = item.layer) === null || _d === void 0 ? void 0 : _d.itemAvatarField) + "".concat(big ? "?width=160&heigth=160" : "?width=80&heigth=80");
972
972
  var title = itemNameField ? getValue(item, itemNameField) : ((_e = item.layer) === null || _e === void 0 ? void 0 : _e.itemNameField) && item && getValue(item, (_f = item.layer) === null || _f === void 0 ? void 0 : _f.itemNameField);
973
973
  var subtitle = itemSubnameField ? getValue(item, itemSubnameField) : ((_g = item.layer) === null || _g === void 0 ? void 0 : _g.itemSubnameField) && item && getValue(item, (_h = item.layer) === null || _h === void 0 ? void 0 : _h.itemSubnameField);
974
- var _t = React.useState(""), address = _t[0]; _t[1];
974
+ var _s = React.useState(""), address = _s[0]; _s[1];
975
975
  var params = new URLSearchParams(window.location.search);
976
976
  var openDeleteModal = function (event) { return __awaiter(_this, void 0, void 0, function () {
977
977
  return __generator(this, function (_a) {
@@ -983,7 +983,7 @@ function HeaderView(_a) {
983
983
  return (jsxs(Fragment, { children: [jsxs("div", __assign({ className: 'tw-flex tw-flex-row' }, { children: [jsx("div", __assign({ className: "tw-grow tw-max-w-[calc(100%-60px)] }" }, { children: jsxs("div", __assign({ className: "flex items-center" }, { children: [avatar && (jsx("div", __assign({ className: "tw-avatar" }, { children: jsx("div", __assign({ className: "".concat(big ? "tw-w-20" : "tw-w-10", " tw-inline tw-items-center tw-justify-center overflow-hidden") }, { children: jsx("img", { className: "tw-w-full tw-h-full tw-object-cover tw-rounded-full", src: avatar, alt: item.name + " logo" }) })) }))), jsxs("div", __assign({ className: "".concat(avatar ? "tw-ml-2" : "", " tw-overflow-hidden") }, { children: [jsx("div", __assign({ className: "".concat(big ? "xl:tw-text-3xl tw-text-2xl" : "tw-text-xl", " tw-font-semibold tw-truncate") }, { children: title })), showAddress && address && !hideSubname && jsx("div", __assign({ className: "tw-text-xs tw-text-gray-500 ".concat(truncateSubname && "tw-truncate") }, { children: address })), subtitle && !hideSubname && jsx("div", __assign({ className: "tw-text-xs tw-text-gray-500 ".concat(truncateSubname && "tw-truncate") }, { children: subtitle }))] }))] })) })), jsx("div", __assign({ onClick: function (e) { return e.stopPropagation(); }, className: "".concat(big ? "tw-mt-5" : "tw-mt-1") }, { children: ((api === null || api === void 0 ? void 0 : api.deleteItem) || ((_k = (_j = item.layer) === null || _j === void 0 ? void 0 : _j.api) === null || _k === void 0 ? void 0 : _k.updateItem))
984
984
  && (hasUserPermission(api === null || api === void 0 ? void 0 : api.collectionName, "delete", item) || hasUserPermission(api === null || api === void 0 ? void 0 : api.collectionName, "update", item))
985
985
  && !hideMenu &&
986
- jsxs("div", __assign({ className: "tw-dropdown tw-dropdown-bottom" }, { children: [jsx("label", __assign({ tabIndex: 0, className: "tw-bg-base-100 tw-btn tw-m-1 tw-leading-3 tw-border-none tw-min-h-0 tw-h-6" }, { children: jsx("svg", __assign({ xmlns: "http://www.w3.org/2000/svg", className: "tw-h-5 tw-w-5", viewBox: "0 0 20 20", fill: "currentColor" }, { children: jsx("path", { d: "M10 6a2 2 0 110-4 2 2 0 010 4zM10 12a2 2 0 110-4 2 2 0 010 4zM10 18a2 2 0 110-4 2 2 0 010 4z" }) })) })), jsxs("ul", __assign({ tabIndex: 0, className: "tw-dropdown-content tw-menu tw-p-2 tw-shadow tw-bg-base-100 tw-rounded-box tw-z-1000" }, { children: [(((api === null || api === void 0 ? void 0 : api.updateItem) && hasUserPermission(api.collectionName, "update", item)) || ((_l = item.layer) === null || _l === void 0 ? void 0 : _l.customEditLink)) && editCallback && jsx("li", { children: jsx("a", __assign({ className: "!tw-text-base-content tw-cursor-pointer", onClick: function (e) { var _a; return ((_a = item.layer) === null || _a === void 0 ? void 0 : _a.customEditLink) ? navigate("".concat(item.layer.customEditLink).concat(item.layer.customEditParameter ? "/".concat(getValue(item, item.layer.customEditParameter)).concat(params && "?" + params) : "", " ")) : editCallback(e); } }, { children: jsx("svg", __assign({ xmlns: "http://www.w3.org/2000/svg", className: "tw-h-5 tw-w-5", viewBox: "0 0 20 20", fill: "currentColor" }, { children: jsx("path", { d: "M13.586 3.586a2 2 0 112.828 2.828l-.793.793-2.828-2.828.793-.793zM11.379 5.793L3 14.172V17h2.828l8.38-8.379-2.83-2.828z" }) })) })) }), (((api === null || api === void 0 ? void 0 : api.updateItem) && hasUserPermission(api.collectionName, "update", item))) && setPositionCallback && jsx("li", { children: jsx("a", __assign({ className: "!tw-text-base-content tw-cursor-pointer", onClick: setPositionCallback }, { children: jsx("svg", __assign({ stroke: "currentColor", fill: "currentColor", strokeWidth: "0", viewBox: "0 0 512 512", className: "tw-w-5 tw-h-5", xmlns: "http://www.w3.org/2000/svg" }, { children: jsx("path", { d: "M256 0c17.7 0 32 14.3 32 32V42.4c93.7 13.9 167.7 88 181.6 181.6H480c17.7 0 32 14.3 32 32s-14.3 32-32 32H469.6c-13.9 93.7-88 167.7-181.6 181.6V480c0 17.7-14.3 32-32 32s-32-14.3-32-32V469.6C130.3 455.7 56.3 381.7 42.4 288H32c-17.7 0-32-14.3-32-32s14.3-32 32-32H42.4C56.3 130.3 130.3 56.3 224 42.4V32c0-17.7 14.3-32 32-32zM107.4 288c12.5 58.3 58.4 104.1 116.6 116.6V384c0-17.7 14.3-32 32-32s32 14.3 32 32v20.6c58.3-12.5 104.1-58.4 116.6-116.6H384c-17.7 0-32-14.3-32-32s14.3-32 32-32h20.6C392.1 165.7 346.3 119.9 288 107.4V128c0 17.7-14.3 32-32 32s-32-14.3-32-32V107.4C165.7 119.9 119.9 165.7 107.4 224H128c17.7 0 32 14.3 32 32s-14.3 32-32 32H107.4zM256 224a32 32 0 1 1 0 64 32 32 0 1 1 0-64z" }) })) })) }), (api === null || api === void 0 ? void 0 : api.deleteItem) && hasUserPermission(api.collectionName, "delete", item) && deleteCallback && jsx("li", { children: jsx("a", __assign({ className: 'tw-cursor-pointer !tw-text-error', onClick: openDeleteModal }, { children: loading ? jsx("span", { className: "tw-loading tw-loading-spinner tw-loading-sm" })
986
+ jsxs("div", __assign({ className: "tw-dropdown tw-dropdown-bottom" }, { children: [jsx("label", __assign({ tabIndex: 0, className: "tw-bg-base-100 tw-btn tw-m-1 tw-leading-3 tw-border-none tw-min-h-0 tw-h-6" }, { children: jsx("svg", __assign({ xmlns: "http://www.w3.org/2000/svg", className: "tw-h-5 tw-w-5", viewBox: "0 0 20 20", fill: "currentColor" }, { children: jsx("path", { d: "M10 6a2 2 0 110-4 2 2 0 010 4zM10 12a2 2 0 110-4 2 2 0 010 4zM10 18a2 2 0 110-4 2 2 0 010 4z" }) })) })), jsxs("ul", __assign({ tabIndex: 0, className: "tw-dropdown-content tw-menu tw-p-2 tw-shadow tw-bg-base-100 tw-rounded-box tw-z-1000" }, { children: [(((api === null || api === void 0 ? void 0 : api.updateItem) && hasUserPermission(api.collectionName, "update", item))) && editCallback && jsx("li", { children: jsx("a", __assign({ className: "!tw-text-base-content tw-cursor-pointer", onClick: function (e) { var _a; return ((_a = item.layer) === null || _a === void 0 ? void 0 : _a.customEditLink) ? navigate("".concat(item.layer.customEditLink).concat(item.layer.customEditParameter ? "/".concat(getValue(item, item.layer.customEditParameter)).concat(params && "?" + params) : "", " ")) : editCallback(e); } }, { children: jsx("svg", __assign({ xmlns: "http://www.w3.org/2000/svg", className: "tw-h-5 tw-w-5", viewBox: "0 0 20 20", fill: "currentColor" }, { children: jsx("path", { d: "M13.586 3.586a2 2 0 112.828 2.828l-.793.793-2.828-2.828.793-.793zM11.379 5.793L3 14.172V17h2.828l8.38-8.379-2.83-2.828z" }) })) })) }), (((api === null || api === void 0 ? void 0 : api.updateItem) && hasUserPermission(api.collectionName, "update", item))) && setPositionCallback && jsx("li", { children: jsx("a", __assign({ className: "!tw-text-base-content tw-cursor-pointer", onClick: setPositionCallback }, { children: jsx("svg", __assign({ stroke: "currentColor", fill: "currentColor", strokeWidth: "0", viewBox: "0 0 512 512", className: "tw-w-5 tw-h-5", xmlns: "http://www.w3.org/2000/svg" }, { children: jsx("path", { d: "M256 0c17.7 0 32 14.3 32 32V42.4c93.7 13.9 167.7 88 181.6 181.6H480c17.7 0 32 14.3 32 32s-14.3 32-32 32H469.6c-13.9 93.7-88 167.7-181.6 181.6V480c0 17.7-14.3 32-32 32s-32-14.3-32-32V469.6C130.3 455.7 56.3 381.7 42.4 288H32c-17.7 0-32-14.3-32-32s14.3-32 32-32H42.4C56.3 130.3 130.3 56.3 224 42.4V32c0-17.7 14.3-32 32-32zM107.4 288c12.5 58.3 58.4 104.1 116.6 116.6V384c0-17.7 14.3-32 32-32s32 14.3 32 32v20.6c58.3-12.5 104.1-58.4 116.6-116.6H384c-17.7 0-32-14.3-32-32s14.3-32 32-32h20.6C392.1 165.7 346.3 119.9 288 107.4V128c0 17.7-14.3 32-32 32s-32-14.3-32-32V107.4C165.7 119.9 119.9 165.7 107.4 224H128c17.7 0 32 14.3 32 32s-14.3 32-32 32H107.4zM256 224a32 32 0 1 1 0 64 32 32 0 1 1 0-64z" }) })) })) }), (api === null || api === void 0 ? void 0 : api.deleteItem) && hasUserPermission(api.collectionName, "delete", item) && deleteCallback && jsx("li", { children: jsx("a", __assign({ className: 'tw-cursor-pointer !tw-text-error', onClick: openDeleteModal }, { children: loading ? jsx("span", { className: "tw-loading tw-loading-spinner tw-loading-sm" })
987
987
  :
988
988
  jsx("svg", __assign({ xmlns: "http://www.w3.org/2000/svg", className: "tw-h-5 tw-w-5", viewBox: "0 0 20 20", fill: "currentColor" }, { children: jsx("path", { fillRule: "evenodd", d: "M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z", clipRule: "evenodd" }) })) })) })] }))] })) }))] })), jsx(DialogModal, __assign({ isOpened: modalOpen, title: "Are you sure?", showCloseButton: false, onClose: function () { return (setModalOpen(false)); } }, { children: jsxs("div", __assign({ onClick: function (e) { return e.stopPropagation(); } }, { children: [jsxs("span", { children: ["Do you want to delete ", jsx("b", { children: item.name }), "?"] }), jsx("div", __assign({ className: "tw-grid" }, { children: jsxs("div", __assign({ className: "tw-flex tw-justify-between" }, { children: [jsx("label", __assign({ className: "tw-btn tw-mt-4 tw-btn-error", onClick: function (e) { deleteCallback(e); setModalOpen(false); } }, { children: "Yes" })), jsx("label", __assign({ className: "tw-btn tw-mt-4", onClick: function () { return setModalOpen(false); } }, { children: "No" }))] })) }))] })) }))] }));
989
989
  }
@@ -2361,6 +2361,8 @@ var addIcon = function (icon) {
2361
2361
  return '<svg class="liebevoll-jetzt-icon" fill="#fff" height="1.5em" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" viewBox="0 0 42 42"><path fill="#e52220" d="M32.554 33.551c0-.2.2-.5 0-.7-.2-.2-.1 0-.3-.1-.5-.2-1.2-.1-1.7.2-.7.3-1.7 1.5-1.3 2.4.2.3.5.6.8.8.5.3.8-.1 1.2-.4.4-.3.7-.5.9-1 .1-.1.8-1.2.4-1.2z"/> <path fill="#fff" d="M14.426 41.57c-1.512-.808-2.234-2.322-2.403-5.038-.104-1.671.136-3.65.844-6.962.497-2.327.545-2.56.81-3.95.236-1.234 3.381-10.767 4.237-12.842.688-1.667 3.022-6.084 3.379-6.394.158-.137.708-.948 1.22-1.802C24.243 1.704 25.935 0 27.065 0c1.134 0 2.303 1.066 2.763 2.521.274.864.133 2.528-.34 4.032-.551 1.754-2.928 6.42-3.994 7.84a37.025 37.025 0 0 0-1.753 2.622c-1.173 1.957-2.233 3.525-4.002 5.92-.831 1.126-1.628 2.306-1.77 2.621-.422.932-1.792 6.558-1.836 7.536-.023.496-.095 1.73-.16 2.742-.175 2.714.265 3.687 1.54 3.407.737-.162 1.569-.967 3.197-3.092 2.302-3.005 5.204-7.528 6.524-10.17.622-1.243 1.228-2.06 1.528-2.06.394 0 .46 1.003.131 1.975-.413 1.219-4.57 8.126-6.186 10.277-1.727 2.3-4.191 4.785-5.233 5.277-1.194.564-2.15.602-3.048.123zm6.76-23.631c2.714-4.414 5.248-9.115 5.42-10.052.027-.148.172-.553.322-.9.397-.915.872-2.532.997-3.386.077-.532.04-.833-.132-1.065-.232-.315-.259-.305-.918.33-1.692 1.632-4.116 7.08-6.488 14.581-.484 1.532-.88 2.855-.881 2.94-.002.255.192-.026 1.68-2.449z"/></svg>';
2362
2362
  case "group":
2363
2363
  return '<svg class="group-icon" stroke="#fff" fill="#fff" stroke-width="0" viewBox="0 0 20 20" aria-hidden="true" height="1.6em" width="1.6em" xmlns="http://www.w3.org/2000/svg"><path d="M10 9a3 3 0 1 0 0-6 3 3 0 0 0 0 6ZM6 8a2 2 0 1 1-4 0 2 2 0 0 1 4 0ZM1.49 15.326a.78.78 0 0 1-.358-.442 3 3 0 0 1 4.308-3.516 6.484 6.484 0 0 0-1.905 3.959c-.023.222-.014.442.025.654a4.97 4.97 0 0 1-2.07-.655ZM16.44 15.98a4.97 4.97 0 0 0 2.07-.654.78.78 0 0 0 .357-.442 3 3 0 0 0-4.308-3.517 6.484 6.484 0 0 1 1.907 3.96 2.32 2.32 0 0 1-.026.654ZM18 8a2 2 0 1 1-4 0 2 2 0 0 1 4 0ZM5.304 16.19a.844.844 0 0 1-.277-.71 5 5 0 0 1 9.947 0 .843.843 0 0 1-.277.71A6.975 6.975 0 0 1 10 18a6.974 6.974 0 0 1-4.696-1.81Z"></path></svg>';
2364
+ case "puzzle":
2365
+ return '<svg class="group-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#fff" width="1.6em" height="1.6em"><path d="M11.25 5.337c0-.355-.186-.676-.401-.959a1.647 1.647 0 0 1-.349-1.003c0-1.036 1.007-1.875 2.25-1.875S15 2.34 15 3.375c0 .369-.128.713-.349 1.003-.215.283-.401.604-.401.959 0 .332.278.598.61.578 1.91-.114 3.79-.342 5.632-.676a.75.75 0 0 1 .878.645 49.17 49.17 0 0 1 .376 5.452.657.657 0 0 1-.66.664c-.354 0-.675-.186-.958-.401a1.647 1.647 0 0 0-1.003-.349c-1.035 0-1.875 1.007-1.875 2.25s.84 2.25 1.875 2.25c.369 0 .713-.128 1.003-.349.283-.215.604-.401.959-.401.31 0 .557.262.534.571a48.774 48.774 0 0 1-.595 4.845.75.75 0 0 1-.61.61c-1.82.317-3.673.533-5.555.642a.58.58 0 0 1-.611-.581c0-.355.186-.676.401-.959.221-.29.349-.634.349-1.003 0-1.035-1.007-1.875-2.25-1.875s-2.25.84-2.25 1.875c0 .369.128.713.349 1.003.215.283.401.604.401.959a.641.641 0 0 1-.658.643 49.118 49.118 0 0 1-4.708-.36.75.75 0 0 1-.645-.878c.293-1.614.504-3.257.629-4.924A.53.53 0 0 0 5.337 15c-.355 0-.676.186-.959.401-.29.221-.634.349-1.003.349-1.036 0-1.875-1.007-1.875-2.25s.84-2.25 1.875-2.25c.369 0 .713.128 1.003.349.283.215.604.401.959.401a.656.656 0 0 0 .659-.663 47.703 47.703 0 0 0-.31-4.82.75.75 0 0 1 .83-.832c1.343.155 2.703.254 4.077.294a.64.64 0 0 0 .657-.642Z" /></svg>';
2364
2366
  default:
2365
2367
  return "";
2366
2368
  }
@@ -2858,35 +2860,40 @@ function usePermissionsManager(initialPermissions) {
2858
2860
  });
2859
2861
  }, []);
2860
2862
  var hasUserPermission = useCallback(function (collectionName, action, item, layer) {
2863
+ var evaluateCondition = function (condition) {
2864
+ var _a, _b, _c;
2865
+ if (((_a = condition.user_created) === null || _a === void 0 ? void 0 : _a._eq) === "$CURRENT_USER") {
2866
+ return ((_b = item === null || item === void 0 ? void 0 : item.user_created) === null || _b === void 0 ? void 0 : _b.id) === (user === null || user === void 0 ? void 0 : user.id);
2867
+ }
2868
+ if (((_c = condition.public_edit) === null || _c === void 0 ? void 0 : _c._eq) === true) {
2869
+ return (item === null || item === void 0 ? void 0 : item.public_edit) === true;
2870
+ }
2871
+ return false;
2872
+ };
2873
+ var evaluatePermissions = function (permissionConditions) {
2874
+ if (!permissionConditions || !permissionConditions._and) {
2875
+ return true;
2876
+ }
2877
+ return permissionConditions._and.every(function (andCondition) {
2878
+ return andCondition._or
2879
+ ? andCondition._or.some(function (orCondition) { return evaluateCondition(orCondition); })
2880
+ : evaluateCondition(andCondition);
2881
+ });
2882
+ };
2861
2883
  if (permissions.length === 0)
2862
2884
  return true;
2863
2885
  else if (user && user.role === adminRole)
2864
2886
  return true;
2865
2887
  else {
2866
2888
  return permissions.some(function (p) {
2867
- var _a, _b, _c;
2889
+ var _a;
2868
2890
  return p.action === action &&
2869
2891
  p.collection === collectionName &&
2870
- p.role === (user === null || user === void 0 ? void 0 : user.role) &&
2871
- (
2872
- // Wenn 'item' nicht gesetzt ist, ignorieren wir die Überprüfung von 'user_created'
2873
- !item || !p.permissions || !p.permissions._and ||
2874
- p.permissions._and.some(function (condition) {
2875
- var _a;
2876
- return condition.user_created &&
2877
- condition.user_created._eq === "$CURRENT_USER" &&
2878
- ((_a = item.user_created) === null || _a === void 0 ? void 0 : _a.id) === (user === null || user === void 0 ? void 0 : user.id);
2879
- }))
2880
- ||
2881
- ((layer === null || layer === void 0 ? void 0 : layer.public_edit_items) || ((_a = item === null || item === void 0 ? void 0 : item.layer) === null || _a === void 0 ? void 0 : _a.public_edit_items)) &&
2882
- (
2883
- // Wenn 'item' nicht gesetzt ist, ignorieren wir die Überprüfung von 'public_edit'
2884
- !item ||
2885
- ((_c = (_b = p.permissions) === null || _b === void 0 ? void 0 : _b._and) === null || _c === void 0 ? void 0 : _c.some(function (condition) {
2886
- return condition.public_edit &&
2887
- condition.public_edit._eq == true &&
2888
- item.public_edit == true;
2889
- })));
2892
+ ((p.role === (user === null || user === void 0 ? void 0 : user.role) &&
2893
+ (!item || evaluatePermissions(p.permissions))) ||
2894
+ (p.role == null &&
2895
+ (((layer === null || layer === void 0 ? void 0 : layer.public_edit_items) || ((_a = item === null || item === void 0 ? void 0 : item.layer) === null || _a === void 0 ? void 0 : _a.public_edit_items)) &&
2896
+ (!item || evaluatePermissions(p.permissions)))));
2890
2897
  });
2891
2898
  }
2892
2899
  }, [permissions, user]);
@@ -3519,7 +3526,6 @@ function ItemFormPopup(props) {
3519
3526
  return [3 /*break*/, 13];
3520
3527
  case 5:
3521
3528
  item = items.find(function (i) { var _a, _b; return ((_a = i.user_created) === null || _a === void 0 ? void 0 : _a.id) === (user === null || user === void 0 ? void 0 : user.id) && ((_b = i.layer) === null || _b === void 0 ? void 0 : _b.itemType.name) === props.layer.itemType.name; });
3522
- console.log(item);
3523
3529
  uuid = crypto.randomUUID();
3524
3530
  success = false;
3525
3531
  _g.label = 6;
@@ -4354,22 +4360,27 @@ var onUpdateItem = function (state, item, tags, addTag, setLoading, navigate, up
4354
4360
  changedItem = {};
4355
4361
  offer_updates = [];
4356
4362
  //check for new offers
4357
- (_a = state.offers) === null || _a === void 0 ? void 0 : _a.map(function (o) {
4358
- var _a;
4359
- var existingOffer = (_a = item === null || item === void 0 ? void 0 : item.offers) === null || _a === void 0 ? void 0 : _a.find(function (t) { return t.tags_id === o.id; });
4360
- existingOffer && offer_updates.push(existingOffer.id);
4361
- if (!existingOffer && !tags.some(function (t) { return t.id === o.id; }))
4362
- addTag(__assign(__assign({}, o), { offer_or_need: true }));
4363
- !existingOffer && offer_updates.push({ items_id: item === null || item === void 0 ? void 0 : item.id, tags_id: o.id });
4364
- });
4363
+ return [4 /*yield*/, ((_a = state.offers) === null || _a === void 0 ? void 0 : _a.map(function (o) {
4364
+ var _a;
4365
+ var existingOffer = (_a = item === null || item === void 0 ? void 0 : item.offers) === null || _a === void 0 ? void 0 : _a.find(function (t) { return t.tags_id === o.id; });
4366
+ existingOffer && offer_updates.push(existingOffer.id);
4367
+ if (!existingOffer && !tags.some(function (t) { return t.id === o.id; }))
4368
+ addTag(__assign(__assign({}, o), { offer_or_need: true }));
4369
+ !existingOffer && offer_updates.push({ items_id: item === null || item === void 0 ? void 0 : item.id, tags_id: o.id });
4370
+ }))];
4371
+ case 1:
4372
+ //check for new offers
4373
+ _m.sent();
4365
4374
  needs_updates = [];
4366
- (_b = state.needs) === null || _b === void 0 ? void 0 : _b.map(function (n) {
4367
- var _a;
4368
- var existingNeed = (_a = item === null || item === void 0 ? void 0 : item.needs) === null || _a === void 0 ? void 0 : _a.find(function (t) { return t.tags_id === n.id; });
4369
- existingNeed && needs_updates.push(existingNeed.id);
4370
- !existingNeed && needs_updates.push({ items_id: item === null || item === void 0 ? void 0 : item.id, tags_id: n.id });
4371
- !existingNeed && !tags.some(function (t) { return t.id === n.id; }) && addTag(__assign(__assign({}, n), { offer_or_need: true }));
4372
- });
4375
+ return [4 /*yield*/, ((_b = state.needs) === null || _b === void 0 ? void 0 : _b.map(function (n) {
4376
+ var _a;
4377
+ var existingNeed = (_a = item === null || item === void 0 ? void 0 : item.needs) === null || _a === void 0 ? void 0 : _a.find(function (t) { return t.tags_id === n.id; });
4378
+ existingNeed && needs_updates.push(existingNeed.id);
4379
+ !existingNeed && needs_updates.push({ items_id: item === null || item === void 0 ? void 0 : item.id, tags_id: n.id });
4380
+ !existingNeed && !tags.some(function (t) { return t.id === n.id; }) && addTag(__assign(__assign({}, n), { offer_or_need: true }));
4381
+ }))];
4382
+ case 2:
4383
+ _m.sent();
4373
4384
  // update profile item in current state
4374
4385
  changedItem = __assign(__assign(__assign(__assign(__assign({ id: state.id, group_type: state.groupType, status: state.status, name: state.name, subname: state.subname, text: state.text, color: state.color, position: item.position, contact: state.contact, telephone: state.telephone }, state.markerIcon && { markerIcon: state.markerIcon }), { next_appointment: state.nextAppointment }), state.image.length > 10 && { image: state.image }), state.offers.length > 0 && { offers: offer_updates }), state.needs.length > 0 && { needs: needs_updates });
4375
4386
  offers_state = [];
@@ -4377,12 +4388,12 @@ var onUpdateItem = function (state, item, tags, addTag, setLoading, navigate, up
4377
4388
  return [4 /*yield*/, state.offers.map(function (o) {
4378
4389
  offers_state.push({ items_id: item === null || item === void 0 ? void 0 : item.id, tags_id: o.id });
4379
4390
  })];
4380
- case 1:
4391
+ case 3:
4381
4392
  _m.sent();
4382
4393
  return [4 /*yield*/, state.needs.map(function (n) {
4383
4394
  needs_state.push({ items_id: item === null || item === void 0 ? void 0 : item.id, tags_id: n.id });
4384
4395
  })];
4385
- case 2:
4396
+ case 4:
4386
4397
  _m.sent();
4387
4398
  changedItem = __assign(__assign({}, changedItem), { offers: offers_state, needs: needs_state });
4388
4399
  (_c = state.text.toLocaleLowerCase().match(hashTagRegex)) === null || _c === void 0 ? void 0 : _c.map(function (tag) {
@@ -4935,6 +4946,12 @@ function ProfileForm(_a) {
4935
4946
  var layer = layers.find(function (l) { return l.itemType.name == userType; });
4936
4947
  !item && setItem({ id: crypto.randomUUID(), name: user ? user.first_name : "", text: "", layer: layer, new: true });
4937
4948
  }, [items]);
4949
+ useEffect(function () {
4950
+ console.log(state.offers);
4951
+ console.log(state.needs);
4952
+ console.log(state.id);
4953
+ console.log(item);
4954
+ }, [state]);
4938
4955
  useEffect(function () {
4939
4956
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
4940
4957
  var newColor = ((_a = item.layer) === null || _a === void 0 ? void 0 : _a.itemColorField) && getValue(item, (_b = item.layer) === null || _b === void 0 ? void 0 : _b.itemColorField)