@nocobase/plugin-ui-templates 2.3.0-beta.2 → 2.3.0-beta.21
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/client/{285.4bc78a19e0774a30.js → 285.5eb4562bd2428b91.js} +1 -1
- package/dist/client/643.d86c7387b9a113e5.js +10 -0
- package/dist/client/934.0cc4e03a5a8aad6a.js +10 -0
- package/dist/client/index.js +1 -1
- package/dist/client-v2/643.46972cb394c1cae2.js +10 -0
- package/dist/client-v2/index.js +1 -1
- package/dist/externalVersion.js +8 -8
- package/package.json +2 -2
- package/dist/client/643.047c34d491bb5ac0.js +0 -10
- package/dist/client/934.5dd36051e3d71be1.js +0 -10
- package/dist/client-v2/643.df78038aa6e1b397.js +0 -10
package/dist/externalVersion.js
CHANGED
|
@@ -8,16 +8,16 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
|
-
"@nocobase/client": "2.3.0-beta.
|
|
12
|
-
"@nocobase/flow-engine": "2.3.0-beta.
|
|
11
|
+
"@nocobase/client": "2.3.0-beta.21",
|
|
12
|
+
"@nocobase/flow-engine": "2.3.0-beta.21",
|
|
13
13
|
"react": "18.2.0",
|
|
14
14
|
"antd": "5.24.2",
|
|
15
15
|
"@ant-design/icons": "5.6.1",
|
|
16
16
|
"lodash": "4.18.1",
|
|
17
|
-
"@nocobase/client-v2": "2.3.0-beta.
|
|
18
|
-
"@nocobase/server": "2.3.0-beta.
|
|
19
|
-
"@nocobase/plugin-flow-engine": "2.3.0-beta.
|
|
20
|
-
"@nocobase/utils": "2.3.0-beta.
|
|
21
|
-
"@nocobase/database": "2.3.0-beta.
|
|
22
|
-
"@nocobase/actions": "2.3.0-beta.
|
|
17
|
+
"@nocobase/client-v2": "2.3.0-beta.21",
|
|
18
|
+
"@nocobase/server": "2.3.0-beta.21",
|
|
19
|
+
"@nocobase/plugin-flow-engine": "2.3.0-beta.21",
|
|
20
|
+
"@nocobase/utils": "2.3.0-beta.21",
|
|
21
|
+
"@nocobase/database": "2.3.0-beta.21",
|
|
22
|
+
"@nocobase/actions": "2.3.0-beta.21"
|
|
23
23
|
};
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"displayName.zh-CN": "UI 模板",
|
|
5
5
|
"description": "Provides block templates and popup templates for UI reuse.",
|
|
6
6
|
"description.zh-CN": "提供区块模板和弹窗模板复用的能力。",
|
|
7
|
-
"version": "2.3.0-beta.
|
|
7
|
+
"version": "2.3.0-beta.21",
|
|
8
8
|
"license": "Apache-2.0",
|
|
9
9
|
"main": "./dist/server/index.js",
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
"block",
|
|
34
34
|
"popup"
|
|
35
35
|
],
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "a2bdd27cc7bc8ced9ad395b3a7468fc1850eef4a"
|
|
37
37
|
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
"use strict";(self.webpackChunk_nocobase_plugin_ui_templates=self.webpackChunk_nocobase_plugin_ui_templates||[]).push([["643"],{126:function(e,t,n){n.d(t,{Y4:function(){return M},tD:function(){return O}});var r=n(375),a=n(485),i=n(694),l=n(59),u=n(155),o=n.n(u),c=n(488),s=n(912);function p(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function m(e,t,n,r,a,i,l){try{var u=e[i](l),o=u.value}catch(e){n(e);return}u.done?t(o):Promise.resolve(o).then(r,a)}function f(e){return function(){var t=this,n=arguments;return new Promise(function(r,a){var i=e.apply(t,n);function l(e){m(i,r,a,l,u,"next",e)}function u(e){m(i,r,a,l,u,"throw",e)}l(void 0)})}}function d(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,a=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var i=[],l=!0,u=!1;try{for(a=a.call(e);!(l=(n=a.next()).done)&&(i.push(n.value),!t||i.length!==t);l=!0);}catch(e){u=!0,r=e}finally{try{l||null==a.return||a.return()}finally{if(u)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return p(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return p(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function y(e,t){var n,r,a,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},l=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(l,"next",{value:o(0)}),u(l,"throw",{value:o(1)}),u(l,"return",{value:o(2)}),"function"==typeof Symbol&&u(l,Symbol.iterator,{value:function(){return this}}),l;function o(u){return function(o){var c=[u,o];if(n)throw TypeError("Generator is already executing.");for(;l&&(l=0,c[0]&&(i=0)),i;)try{if(n=1,r&&(a=2&c[0]?r.return:c[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,c[1])).done)return a;switch(r=0,a&&(c=[2&c[0],a.value]),c[0]){case 0:case 1:a=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(a=(a=i.trys).length>0&&a[a.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!a||c[1]>a[0]&&c[1]<a[3])){i.label=c[1];break}if(6===c[0]&&i.label<a[1]){i.label=a[1],a=c;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(c);break}a[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],r=0}finally{n=a=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}var h="flowModelTemplates",b={display:"inline-block",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",verticalAlign:"bottom",whiteSpace:"nowrap"},v={whiteSpace:"pre-wrap",wordBreak:"break-word"},g=["name","description","targetUid","useModel","dataSourceKey","collectionName","associationName","filterByTk","sourceId"],w={name:h,filterTargetKey:"uid",fields:[{type:"string",name:"name",title:"Template name",interface:"input",uiSchema:{type:"string","x-component":"Input"}},{type:"text",name:"description",title:"Template description",interface:"textarea",uiSchema:{type:"string","x-component":"Input.TextArea"}},{type:"string",name:"targetUid",title:"targetUid",interface:"input",uiSchema:{type:"string","x-component":"Input"}},{type:"string",name:"useModel",title:"useModel",interface:"input",uiSchema:{type:"string","x-component":"Input"}},{type:"string",name:"dataSourceKey",title:"dataSourceKey",interface:"input",uiSchema:{type:"string","x-component":"Input"}},{type:"string",name:"collectionName",title:"collectionName",interface:"input",uiSchema:{type:"string","x-component":"Input"}},{type:"string",name:"associationName",title:"associationName",interface:"input",uiSchema:{type:"string","x-component":"Input"}},{type:"string",name:"filterByTk",title:"filterByTk",interface:"input",uiSchema:{type:"string","x-component":"Input"}},{type:"string",name:"sourceId",title:"sourceId",interface:"input",uiSchema:{type:"string","x-component":"Input"}}]},S=function(e){var t,n,r,a,i=null==e||null==(t=e.getDataSource)?void 0:t.call(e,"main");if(i){var l=null==(n=i.getCollection)?void 0:n.call(i,h);return l||(null==(r=i.addCollection)||r.call(i,w),null==(a=i.getCollection)?void 0:a.call(i,h))}},E=function(e,t){var n="popup"===e?{type:"popup"}:{$or:[{type:{$ne:"popup"}},{type:{$empty:!0}}]};return t&&0!==Object.keys(t).length?{$and:[n,t]}:n},T=function(e){return(e.usageCount||0)>0},k=function(e){return null==e?"":String(e)},x=function(e,t){var n;return(null!=(n=Error)&&"u">typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](e):e instanceof n)?e.message:k(e)||t},C=function(e){var t=k(e.value),n=l.theme.useToken().token,r=(0,u.useRef)(null),a=d((0,u.useState)(!1),2),i=a[0],c=a[1];(0,u.useEffect)(function(){c(!1)},[t]);var s=(0,u.useCallback)(function(){var e=r.current;return!!e&&e.scrollWidth>e.clientWidth},[]),p=(0,u.useCallback)(function(e){e?c(s()):c(!1)},[s]);if(!t)return null;var m=o().createElement("span",{ref:r,style:b},t);return o().createElement(l.Popover,{content:o().createElement(l.Typography.Text,{style:v},t),open:i,onOpenChange:p,styles:{body:{maxHeight:n.screenSM,maxWidth:n.screenSM,overflow:"auto"}}},m)},I=function(e){var t=e.record,n=e.resource,r=e.onSubmitted,i=(0,c.kj)(),s=l.App.useApp().message,p=d(l.Form.useForm(),1)[0],m=d((0,u.useState)(!1),2),h=m[0],b=m[1];(0,u.useEffect)(function(){p.setFieldsValue({name:t.name||"",description:t.description||""})},[p,t]);var v=(0,u.useCallback)(function(){return f(function(){var e;return y(this,function(a){switch(a.label){case 0:return[4,p.validateFields()];case 1:e=a.sent(),b(!0),a.label=2;case 2:var l;return a.trys.push([2,,5,6]),[4,(l={resource:n,record:{uid:t.uid},values:e},f(function(){return y(this,function(e){switch(e.label){case 0:return[4,l.resource.update({filterByTk:l.record.uid,values:{name:l.values.name,description:l.values.description}})];case 1:return e.sent(),[2]}})})())];case 3:return a.sent(),[4,r()];case 4:return a.sent(),s.success(i("Saved")),[3,6];case 5:return b(!1),[7];case 6:return[2]}})})()},[p,s,r,t.uid,n,i]);return o().createElement(a.DrawerFormLayout,{title:i("Edit template"),onSubmit:v,submitting:h,submitText:i("Submit"),cancelText:i("Cancel")},o().createElement(l.Form,{form:p,layout:"vertical"},o().createElement(l.Form.Item,{name:"name",label:i("Template name"),rules:[{required:!0,message:i("Template name is required")}]},o().createElement(l.Input,null)),o().createElement(l.Form.Item,{name:"description",label:i("Template description")},o().createElement(l.Input.TextArea,{rows:4}))))},A=function(e){var t,n=e.templateType,p=(0,c.kj)(),m=(0,i.useFlowContext)(),h=(0,a.useApp)(),b=l.App.useApp(),v=b.modal,w=b.message,k=l.theme.useToken().token,A=(0,u.useMemo)(function(){return m.api.resource("flowModelTemplates")},[m.api]),F=null!=(t=S(h.dataSourceManager))?t:S(m.dataSourceManager),M=d((0,u.useState)([]),2),O=M[0],j=M[1],B=d((0,u.useState)(0),2),_=B[0],D=B[1],N=d((0,u.useState)(1),2),z=N[0],K=N[1],P=d((0,u.useState)(a.DEFAULT_PAGE_SIZE),2),U=P[0],$=P[1],R=d((0,u.useState)(),2),W=R[0],L=R[1],q=d((0,u.useState)(!1),2),G=q[0],H=q[1],V=(0,u.useCallback)(function(){return f(function(){var e;return y(this,function(t){switch(t.label){case 0:var r;return[4,A.list({page:(r={templateType:n,page:z,pageSize:U,filter:W}).page,pageSize:r.pageSize,sort:"-createdAt",filter:E(r.templateType,r.filter)})];case 1:return e=t.sent(),[2,(0,s.RN)(e)]}})})()},[W,z,U,A,n]),Y=(0,u.useCallback)(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){return!0};return f(function(){var t,n,r;return y(this,function(a){switch(a.label){case 0:H(!0),a.label=1;case 1:return a.trys.push([1,3,4,5]),[4,V()];case 2:if(n=a.sent(),!e())return[2];return j(n.rows),D(null!=(t=n.count)?t:n.rows.length),[3,5];case 3:return r=a.sent(),e()&&w.error(x(r,p("Operation failed"))),[3,5];case 4:return e()&&H(!1),[7];case 5:return[2]}})})()},[V,w,p]),Z=(0,u.useCallback)(function(){return f(function(){return y(this,function(e){switch(e.label){case 0:return[4,Y()];case 1:return e.sent(),[2]}})})()},[Y]);(0,u.useEffect)(function(){var e=!0;return Y(function(){return e}),function(){e=!1}},[Y]);var J=(0,u.useCallback)(function(e){L(e),K(1)},[]),Q=(0,u.useCallback)(function(e,t){if(t!==U){$(t),K(1);return}K(e)},[U]),X=(0,u.useCallback)(function(e){m.viewer.drawer({width:"50%",closable:!0,content:function(){return o().createElement(I,{record:e,resource:A,onSubmitted:Z})}})},[m.viewer,Z,A]),ee=(0,u.useCallback)(function(e){T(e)?w.warning(p("Template is in use and cannot be deleted")):v.confirm({title:p("Delete template"),content:p("Are you sure you want to delete this item? This action cannot be undone."),onOk:function(){return f(function(){return y(this,function(t){switch(t.label){case 0:var n;return[4,(n={resource:A,record:e},f(function(){return y(this,function(e){switch(e.label){case 0:return[4,n.resource.destroy({filterByTk:n.record.uid})];case 1:return e.sent(),[2]}})})())];case 1:return t.sent(),[4,Z()];case 2:return t.sent(),w.success(p("Deleted")),[2]}})})()}})},[Z,w,v,A,p]),et=(0,u.useMemo)(function(){return[{title:p("Template name"),dataIndex:"name",width:300,ellipsis:{showTitle:!1},render:function(e){return o().createElement(C,{value:e})}},{title:p("Template description"),dataIndex:"description",width:420,ellipsis:{showTitle:!1},render:function(e){return o().createElement(C,{value:e})}},{title:p("Data source"),dataIndex:"dataSourceKey",width:160,ellipsis:{showTitle:!1},render:function(e){return o().createElement(C,{value:e})}},{title:p("Collection"),dataIndex:"collectionName",width:180,ellipsis:{showTitle:!1},render:function(e){return o().createElement(C,{value:e})}},{title:p("Usage count"),dataIndex:"usageCount",width:140,render:function(e){return e||0}},{title:p("Actions"),key:"actions",width:180,render:function(e,t){var n=T(t);return o().createElement(l.Space,null,o().createElement(l.Button,{type:"link",size:"small",icon:o().createElement(r.EditOutlined,null),onClick:function(){return X(t)}},p("Edit")),o().createElement(l.Tooltip,{title:n?p("Template is in use and cannot be deleted"):void 0},o().createElement(l.Button,{type:"link",size:"small",danger:!0,disabled:n,icon:o().createElement(r.DeleteOutlined,null),onClick:function(){return ee(t)}},p("Delete"))))}}]},[ee,X,p]);return o().createElement(l.Card,{variant:"borderless"},o().createElement(l.Flex,{justify:"space-between",align:"center",style:{marginBottom:k.margin}},o().createElement(l.Flex,{align:"center",gap:k.marginSM},o().createElement(a.CollectionFilter,{collection:F,filterableFieldNames:g,onChange:J,t:p})),o().createElement(l.Button,{icon:o().createElement(r.ReloadOutlined,null),onClick:Z},p("Refresh"))),o().createElement(a.Table,{rowKey:"uid",loading:G,columns:et,dataSource:O,tableLayout:"fixed",scroll:{x:1380},pagination:{current:z,pageSize:U,total:_,onChange:Q}}))},F=function(e){var t=e.templateType;return o().createElement(a.ExtendCollectionsProvider,{collections:[w]},o().createElement(A,{templateType:t}))},M=function(){return o().createElement(F,{templateType:"block"})},O=function(){return o().createElement(F,{templateType:"popup"})}}}]);
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
"use strict";(self.webpackChunk_nocobase_plugin_ui_templates=self.webpackChunk_nocobase_plugin_ui_templates||[]).push([["934"],{869:function(t,e,r){r.r(e),r.d(e,{ReferenceFormGridModel:function(){return E}});var n=r(155),i=r.n(n),o=r(694),a=r(401),l=r(488),u=r(277);function s(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function c(t,e,r,n,i,o,a){try{var l=t[o](a),u=l.value}catch(t){r(t);return}l.done?e(u):Promise.resolve(u).then(n,i)}function d(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var o=t.apply(e,r);function a(t){c(o,n,i,a,l,"next",t)}function l(t){c(o,n,i,a,l,"throw",t)}a(void 0)})}}function f(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function v(t,e,r){return(v="u">typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=h(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(r||t):i.value}})(t,e,r||t)}function h(t){return(h=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function g(t,e){return null!=e&&"u">typeof Symbol&&e[Symbol.hasInstance]?!!e[Symbol.hasInstance](t):t instanceof e}function p(t,e){if(e&&("object"===m(e)||"function"==typeof e))return e;if(void 0===t)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function y(t,e){return(y=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function b(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r,n,i=null==t?null:"u">typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=i){var o=[],a=!0,l=!1;try{for(i=i.call(t);!(a=(r=i.next()).done)&&(o.push(r.value),!e||o.length!==e);a=!0);}catch(t){l=!0,n=t}finally{try{a||null==i.return||i.return()}finally{if(l)throw n}}return o}}(t,e)||function(t,e){if(t){if("string"==typeof t)return s(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if("Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return s(t,e)}}(t,e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function m(t){return t&&"u">typeof Symbol&&t.constructor===Symbol?"symbol":typeof t}function _(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(_=function(){return!!t})()}function S(t,e){var r,n,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(a,"next",{value:u(0)}),l(a,"throw",{value:u(1)}),l(a,"return",{value:u(2)}),"function"==typeof Symbol&&l(a,Symbol.iterator,{value:function(){return this}}),a;function u(l){return function(u){var s=[l,u];if(r)throw TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=(i=o.trys).length>0&&i[i.length-1])&&(6===s[0]||2===s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=e.call(t,o)}catch(t){s=[6,t],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}}var w="referenceSettings",P=Symbol.for("nocobase.refGridHostBridge"),E=function(t){var e;if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");function r(t){if(!(this instanceof r))throw TypeError("Cannot call a class as a function");e=r,n=[t],e=h(e),f(i=p(this,_()?Reflect.construct(e,n||[],h(this).constructor):e.apply(this,n)),"_scopedEngine",void 0),f(i,"_targetRoot",void 0),f(i,"_targetGrid",void 0),f(i,"_resolvedTargetUid",void 0),f(i,"_invalidTargetUid",void 0);var e,n,i,o=new Set(["mapSubModels","filterSubModels","findSubModel","hasSubModel"]),a=new Proxy(i,{get:function(t,e){var r=t._targetGrid;if(r){if("subModels"===e)return r.subModels;if("string"==typeof e&&o.has(e)){var n=Reflect.get(r,e,r);return"function"==typeof n?n.bind(r):n}}if(e in t){var i=Reflect.get(t,e,t);return"function"==typeof i&&"constructor"!==e?i.bind(t):i}if(r){var a=Reflect.get(r,e,r);if("function"==typeof a&&"constructor"!==e)return a.bind(r);if(void 0!==a)return a}},has:function(t,e){if(e in t)return!0;var r=t._targetGrid;return!!r&&e in r},ownKeys:function(t){var e=new Set(Reflect.ownKeys(t)),r=t._targetGrid;if(r){var n=!0,i=!1,o=void 0;try{for(var a,l=Reflect.ownKeys(r)[Symbol.iterator]();!(n=(a=l.next()).done);n=!0){var u=a.value;e.add(u)}}catch(t){i=!0,o=t}finally{try{n||null==l.return||l.return()}finally{if(i)throw o}}}return Array.from(e)},getOwnPropertyDescriptor:function(t,e){var r=Reflect.getOwnPropertyDescriptor(t,e);if(r)return r;var n=t._targetGrid;if(n)return Object.getOwnPropertyDescriptor(n,e)||void 0}});return p(i,a)}return r.prototype=Object.create(t&&t.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),t&&y(r,t),e=[{key:"_syncHostResourceAppends",value:function(t,e){if(t.addAppends){var r=new Set,n=function(t){var e,n="string"==typeof t?t.trim():"";if(n){r.add(n);var i=null==(e=n.split(".")[0])?void 0:e.trim();i&&r.add(i)}},i=function(t){var e=null==(s=t.getStepParams)?void 0:s.call(t,"fieldSettings","init");e&&(n(e.fieldPath),n(e.associationPathName));var r=t.subModels||{},a=!0,l=!1,u=void 0;try{for(var s,c,d=Object.values(r)[Symbol.iterator]();!(a=(c=d.next()).done);a=!0){var f=c.value;Array.isArray(f)?f.forEach(function(t){return g(t,o.FlowModel)&&i(t)}):g(f,o.FlowModel)&&i(f)}}catch(t){l=!0,u=t}finally{try{a||null==d.return||d.return()}finally{if(l)throw u}}};if(i(e),0!==r.size){var a=!0,l=!1,u=void 0;try{for(var s,c=r[Symbol.iterator]();!(a=(s=c.next()).done);a=!0){var d,f=s.value;null==(d=t.addAppends)||d.call(t,f)}}catch(t){l=!0,u=t}finally{try{a||null==c.return||c.return()}finally{if(l)throw u}}}}}},{key:"_ensureScopedEngine",value:function(){return this._scopedEngine=(0,u.Ob)(this.flowEngine,this._scopedEngine),this._scopedEngine}},{key:"_getTargetSettings",value:function(){var t=this.getStepParams(w,"useTemplate");if(t&&(void 0===t?"undefined":m(t))==="object"){var e=String(t.templateUid||"").trim(),r=String(t.targetUid||"").trim();if(e&&r)return{templateUid:e,templateName:String(t.templateName||"").trim()||void 0,targetUid:r,targetPath:String(t.targetPath||"").trim()||void 0}}}},{key:"_syncHostExtraTitle",value:function(t){var e,r,n,i,a=this.parent;if(a){var u=(null==a?void 0:a.isFork)&&a.master||a,s=[a];if(u&&u!==a&&g(u,o.FlowModel)&&s.push(u),null==u||null==(r=u.forks)||null==(e=r.forEach)||e.call(r,function(t){return g(t,o.FlowModel)&&s.push(t)}),!t)return void s.forEach(function(t){return t.setExtraTitle("")});var c=a.context.t("Reference template",{ns:[l.CU,"client"],nsMode:"fallback"}),d=a.context.t("(Fields only)",{ns:[l.CU,"client"],nsMode:"fallback"}),f=(null==(n=t.templateName)?void 0:n.trim())||(null==(i=t.templateUid)?void 0:i.trim())||"",v=f?"".concat(c,": ").concat(f," ").concat(d):"".concat(c," ").concat(d);s.forEach(function(t){return t.setExtraTitle(v.trim())})}}},{key:"addSubModel",value:function(t,e){if(!this._targetGrid)throw Error("[block-reference] Target grid is not resolved yet.");return this._targetGrid.addSubModel(t,e)}},{key:"setSubModel",value:function(t,e){if(!this._targetGrid)throw Error("[block-reference] Target grid is not resolved yet.");return this._targetGrid.setSubModel(t,e)}},{key:"getStepParams",value:function(t,e){if(!t||t===w||!this._targetGrid)return v(h(r.prototype),"getStepParams",this).call(this,t,e);if(e){var n,i,o,a,l=this._targetGrid.getStepParams(t,e);return void 0!==l?l:null==(a=this._targetRoot)||null==(o=a.getStepParams)?void 0:o.call(a,t,e)}var u=this._targetGrid.getStepParams(t),s=null==(i=this._targetRoot)||null==(n=i.getStepParams)?void 0:n.call(i,t);return s&&(void 0===s?"undefined":m(s))==="object"?function(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable}))),n.forEach(function(e){f(t,e,r[e])})}return t}({},s,u||{}):u}},{key:"setStepParams",value:function(t,e,n){if("string"==typeof t)return t!==w&&this._targetGrid?"string"==typeof e&&void 0!==n?void this._targetGrid.setStepParams(t,e,n):void((void 0===e?"undefined":m(e))==="object"&&null!==e&&this._targetGrid.setStepParams(t,e)):void v(h(r.prototype),"setStepParams",this).call(this,t,e,n);if((void 0===t?"undefined":m(t))==="object"&&null!==t){var i={},o={},a=!0,l=!1,u=void 0;try{for(var s,c=Object.entries(t)[Symbol.iterator]();!(a=(s=c.next()).done);a=!0){var d=b(s.value,2),f=d[0],g=d[1];f!==w&&this._targetGrid?o[f]=g:i[f]=g}}catch(t){l=!0,u=t}finally{try{a||null==c.return||c.return()}finally{if(l)throw u}}Object.keys(i).length>0&&v(h(r.prototype),"setStepParams",this).call(this,i),Object.keys(o).length>0&&this._targetGrid&&this._targetGrid.setStepParams(o)}}},{key:"saveStepParams",value:function(){var t=this,e=this;return d(function(){var n,i,o,a,l,u,s,c,d;return S(this,function(f){switch(f.label){case 0:if(this._targetGrid)return[3,2];return[4,this.dispatchEvent("beforeRender")];case 1:f.sent(),f.label=2;case 2:if(this._targetGrid&&this.stepParams){n=!0,i=!1,o=void 0;try{for(a=Object.entries(this.stepParams)[Symbol.iterator]();!(n=(l=a.next()).done);n=!0)s=(u=b(l.value,2))[0],c=u[1],s!==w&&(void 0===c?"undefined":m(c))==="object"&&null!==c&&(this._targetGrid.setStepParams(s,c),delete this.stepParams[s])}catch(t){i=!0,o=t}finally{try{n||null==a.return||a.return()}finally{if(i)throw o}}}return[4,v(h(r.prototype),"saveStepParams",t).call(e)];case 3:if(d=f.sent(),!this._targetGrid)return[3,5];return[4,this._targetGrid.saveStepParams()];case 4:f.sent(),f.label=5;case 5:return[2,d]}})}).call(this)}},{key:"onDispatchEventStart",value:function(t){return d(function(){var e,r,n,i,l,s,c,f,v,h,p,y,b;return S(this,function(m){switch(m.label){case 0:if(e=this,"beforeRender"!==t)return[2];if(!(n=this._getTargetSettings()))return this._syncHostExtraTitle(void 0),this._targetRoot=void 0,this._targetGrid=void 0,this._resolvedTargetUid=void 0,this._invalidTargetUid=void 0,[2];if(this._syncHostExtraTitle(n),"subModels.grid"!==(i=(null==(r=n.targetPath)?void 0:r.trim())||"subModels.grid"))throw Error("[block-reference] Only 'subModels.grid' is supported for ReferenceFormGridModel (got '".concat(i,"')."));if(this._resolvedTargetUid===n.targetUid&&this._targetGrid)return this._invalidTargetUid=void 0,[2];return l=this._ensureScopedEngine(),s=this.parent,(0,u.YT)(l,(null==s?void 0:s.context)||this.context),c=n.targetUid,f=this._targetGrid,v=this._resolvedTargetUid,h=this._invalidTargetUid,this._invalidTargetUid=void 0,[4,(p=function(){return d(function(){var t,e,r,u,d,f,v;return S(this,function(h){switch(h.label){case 0:return[4,l.loadModel({uid:c})];case 1:if(!(e=h.sent())||(e.setParent(s),r={hostUid:null==s?void 0:s.uid,hostUse:null==s?void 0:s.use,ref:{templateUid:n.templateUid,templateName:n.templateName,targetUid:c,targetPath:i,mountSubKey:"grid",mode:"reference"}},e.context.defineProperty(a.v,{value:r}),g(u=null==(t=e.subModels)?void 0:t.grid,o.FlowModel)&&(d=u),f=null==d?void 0:d.context,d&&(null==s?void 0:s.context)&&!(null==f?void 0:f[P])&&((v=new o.FlowContext).defineProperty("engine",{value:l}),v.addDelegate(s.context),d.context.addDelegate(v),d.context[P]=!0),!d))return[2,void 0];return s&&this._syncHostResourceAppends(s,d),[2,{root:e,grid:d}]}})}).call(e)})()];case 1:if(y=m.sent())return[3,4];return[4,new Promise(function(t){return setTimeout(t,50)})];case 2:if(m.sent(),(null==(b=this._getTargetSettings())?void 0:b.targetUid)!==c)return[2];return[4,p()];case 3:y=m.sent(),m.label=4;case 4:if(!y)return this._targetRoot=void 0,this._targetGrid=void 0,this._resolvedTargetUid=void 0,this._invalidTargetUid=c,(f||v||h!==c)&&this.rerender(),[2];return this._targetRoot=y.root,this._targetGrid=y.grid,this._resolvedTargetUid=c,this._invalidTargetUid=void 0,(f!==y.grid||v!==c||h)&&this.rerender(),[2]}})}).call(this)}},{key:"clearForks",value:function(){try{this._syncHostExtraTitle(void 0),(0,u.KC)(this._scopedEngine)}finally{this._scopedEngine=void 0}v(h(r.prototype),"clearForks",this).call(this)}},{key:"destroy",value:function(){var t=this,e=this;return d(function(){return S(this,function(n){switch(n.label){case 0:try{(0,u.KC)(this._scopedEngine)}finally{this._scopedEngine=void 0}return[4,v(h(r.prototype),"destroy",t).call(e)];case 1:return[2,n.sent()]}})}).call(this)}},{key:"render",value:function(){var t=this._getTargetSettings();if(!t)return(0,u.Qj)(this,"unconfigured");var e=this._targetGrid;if(!e)return this._invalidTargetUid===t.targetUid?(0,u.Qj)(this,"invalid"):(0,u.Qj)(this,"resolving");var r=this._ensureScopedEngine();return i().createElement(u.vx,{engine:r,model:e})}}],function(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}(r.prototype,e),r}(o.FlowModel);E.define({hide:!0})},277:function(t,e,r){r.d(e,{KC:function(){return c},Ob:function(){return u},Qj:function(){return f},YT:function(){return s},vx:function(){return h}});var n=r(155),i=r.n(n),o=r(59),a=r(694),l=r(488);function u(t,e){return null!=e?e:(0,a.createBlockScopedEngine)(t)}function s(t,e){(null==t?void 0:t.context)&&e&&t.context.defineProperty("view",{cache:!1,get:function(){return e.view}})}function c(t){var e;null==t||null==(e=t.unlinkFromStack)||e.call(t)}function d(t,e){var r=null==t?void 0:t.translate;return"function"!=typeof r?e:r(e,{ns:[l.CU,"client"]})||e}function f(t,e){return"unconfigured"===e?i().createElement(o.Card,null,i().createElement(o.Empty,{image:o.Empty.PRESENTED_IMAGE_SIMPLE,description:d(t,"Please configure target block")})):"resolving"===e?i().createElement(o.Card,null,i().createElement(o.Skeleton,{active:!0,title:!1,paragraph:{rows:3}})):i().createElement(o.Card,null,i().createElement(o.Result,{status:"error",subTitle:d(t,"Target block is invalid")}))}var v=function(t){var e=t.engine,r=t.model,n=(0,a.useFlowViewContext)(),o=i().useMemo(function(){var t,r=new a.FlowContext;return r.defineProperty("engine",{value:e}),r.addDelegate(e.context),n&&(null!=(t=a.FlowContext)&&"u">typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](n):n instanceof t)&&r.addDelegate(n),r},[e,n]);return i().createElement(a.FlowViewContextProvider,{context:o},i().createElement(a.FlowModelRenderer,{key:r.uid,model:r,showFlowSettings:!1,showErrorFallback:!0}))},h=function(t){var e=t.engine,r=t.model;return i().createElement(a.FlowEngineProvider,{engine:e},i().createElement(v,{engine:e,model:r}))}},401:function(t,e,r){r.d(e,{v:function(){return n}});var n="__subModelReferenceHost"}}]);
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
"use strict";(self.webpackChunk_nocobase_plugin_ui_templates_client_v2=self.webpackChunk_nocobase_plugin_ui_templates_client_v2||[]).push([["643"],{126:function(e,t,n){n.d(t,{Y4:function(){return _},tD:function(){return M}});var r=n(375),a=n(485),i=n(694),l=n(59),u=n(155),o=n.n(u),c=n(488),s=n(912);function p(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function m(e,t,n,r,a,i,l){try{var u=e[i](l),o=u.value}catch(e){n(e);return}u.done?t(o):Promise.resolve(o).then(r,a)}function f(e){return function(){var t=this,n=arguments;return new Promise(function(r,a){var i=e.apply(t,n);function l(e){m(i,r,a,l,u,"next",e)}function u(e){m(i,r,a,l,u,"throw",e)}l(void 0)})}}function d(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,a=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var i=[],l=!0,u=!1;try{for(a=a.call(e);!(l=(n=a.next()).done)&&(i.push(n.value),!t||i.length!==t);l=!0);}catch(e){u=!0,r=e}finally{try{l||null==a.return||a.return()}finally{if(u)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return p(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return p(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function y(e,t){var n,r,a,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},l=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(l,"next",{value:o(0)}),u(l,"throw",{value:o(1)}),u(l,"return",{value:o(2)}),"function"==typeof Symbol&&u(l,Symbol.iterator,{value:function(){return this}}),l;function o(u){return function(o){var c=[u,o];if(n)throw TypeError("Generator is already executing.");for(;l&&(l=0,c[0]&&(i=0)),i;)try{if(n=1,r&&(a=2&c[0]?r.return:c[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,c[1])).done)return a;switch(r=0,a&&(c=[2&c[0],a.value]),c[0]){case 0:case 1:a=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(a=(a=i.trys).length>0&&a[a.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!a||c[1]>a[0]&&c[1]<a[3])){i.label=c[1];break}if(6===c[0]&&i.label<a[1]){i.label=a[1],a=c;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(c);break}a[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],r=0}finally{n=a=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}var h="flowModelTemplates",b={display:"inline-block",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",verticalAlign:"bottom",whiteSpace:"nowrap"},v={whiteSpace:"pre-wrap",wordBreak:"break-word"},g=["name","description","targetUid","useModel","dataSourceKey","collectionName","associationName","filterByTk","sourceId"],w={name:h,filterTargetKey:"uid",fields:[{type:"string",name:"name",title:"Template name",interface:"input",uiSchema:{type:"string","x-component":"Input"}},{type:"text",name:"description",title:"Template description",interface:"textarea",uiSchema:{type:"string","x-component":"Input.TextArea"}},{type:"string",name:"targetUid",title:"targetUid",interface:"input",uiSchema:{type:"string","x-component":"Input"}},{type:"string",name:"useModel",title:"useModel",interface:"input",uiSchema:{type:"string","x-component":"Input"}},{type:"string",name:"dataSourceKey",title:"dataSourceKey",interface:"input",uiSchema:{type:"string","x-component":"Input"}},{type:"string",name:"collectionName",title:"collectionName",interface:"input",uiSchema:{type:"string","x-component":"Input"}},{type:"string",name:"associationName",title:"associationName",interface:"input",uiSchema:{type:"string","x-component":"Input"}},{type:"string",name:"filterByTk",title:"filterByTk",interface:"input",uiSchema:{type:"string","x-component":"Input"}},{type:"string",name:"sourceId",title:"sourceId",interface:"input",uiSchema:{type:"string","x-component":"Input"}}]},S=function(e){var t,n,r,a,i=null==e||null==(t=e.getDataSource)?void 0:t.call(e,"main");if(i){var l=null==(n=i.getCollection)?void 0:n.call(i,h);return l||(null==(r=i.addCollection)||r.call(i,w),null==(a=i.getCollection)?void 0:a.call(i,h))}},E=function(e,t){var n="popup"===e?{type:"popup"}:{$or:[{type:{$ne:"popup"}},{type:{$empty:!0}}]};return t&&0!==Object.keys(t).length?{$and:[n,t]}:n},T=function(e){return(e.usageCount||0)>0},k=function(e){return null==e?"":String(e)},x=function(e,t){var n;return(null!=(n=Error)&&"u">typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](e):e instanceof n)?e.message:k(e)||t},C=function(e){var t=k(e.value),n=l.theme.useToken().token,r=(0,u.useRef)(null),a=d((0,u.useState)(!1),2),i=a[0],c=a[1];(0,u.useEffect)(function(){c(!1)},[t]);var s=(0,u.useCallback)(function(){var e=r.current;return!!e&&e.scrollWidth>e.clientWidth},[]),p=(0,u.useCallback)(function(e){e?c(s()):c(!1)},[s]);if(!t)return null;var m=o().createElement("span",{ref:r,style:b},t);return o().createElement(l.Popover,{content:o().createElement(l.Typography.Text,{style:v},t),open:i,onOpenChange:p,styles:{body:{maxHeight:n.screenSM,maxWidth:n.screenSM,overflow:"auto"}}},m)},I=function(e){var t=e.record,n=e.resource,r=e.onSubmitted,i=(0,c.kj)(),s=l.App.useApp().message,p=d(l.Form.useForm(),1)[0],m=d((0,u.useState)(!1),2),h=m[0],b=m[1];(0,u.useEffect)(function(){p.setFieldsValue({name:t.name||"",description:t.description||""})},[p,t]);var v=(0,u.useCallback)(function(){return f(function(){var e;return y(this,function(a){switch(a.label){case 0:return[4,p.validateFields()];case 1:e=a.sent(),b(!0),a.label=2;case 2:var l;return a.trys.push([2,,5,6]),[4,(l={resource:n,record:{uid:t.uid},values:e},f(function(){return y(this,function(e){switch(e.label){case 0:return[4,l.resource.update({filterByTk:l.record.uid,values:{name:l.values.name,description:l.values.description}})];case 1:return e.sent(),[2]}})})())];case 3:return a.sent(),[4,r()];case 4:return a.sent(),s.success(i("Saved")),[3,6];case 5:return b(!1),[7];case 6:return[2]}})})()},[p,s,r,t.uid,n,i]);return o().createElement(a.DrawerFormLayout,{title:i("Edit template"),onSubmit:v,submitting:h,submitText:i("Submit"),cancelText:i("Cancel")},o().createElement(l.Form,{form:p,layout:"vertical"},o().createElement(l.Form.Item,{name:"name",label:i("Template name"),rules:[{required:!0,message:i("Template name is required")}]},o().createElement(l.Input,null)),o().createElement(l.Form.Item,{name:"description",label:i("Template description")},o().createElement(l.Input.TextArea,{rows:4}))))},A=function(e){var t,n=e.templateType,p=(0,c.kj)(),m=(0,i.useFlowContext)(),h=(0,a.useApp)(),b=l.App.useApp(),v=b.modal,w=b.message,k=l.theme.useToken().token,A=(0,u.useMemo)(function(){return m.api.resource("flowModelTemplates")},[m.api]),F=null!=(t=S(h.dataSourceManager))?t:S(m.dataSourceManager),_=d((0,u.useState)([]),2),M=_[0],O=_[1],j=d((0,u.useState)(0),2),B=j[0],D=j[1],N=d((0,u.useState)(1),2),z=N[0],K=N[1],P=d((0,u.useState)(a.DEFAULT_PAGE_SIZE),2),U=P[0],$=P[1],R=d((0,u.useState)(),2),W=R[0],L=R[1],q=d((0,u.useState)(!1),2),G=q[0],H=q[1],V=(0,u.useCallback)(function(){return f(function(){var e;return y(this,function(t){switch(t.label){case 0:var r;return[4,A.list({page:(r={templateType:n,page:z,pageSize:U,filter:W}).page,pageSize:r.pageSize,sort:"-createdAt",filter:E(r.templateType,r.filter)})];case 1:return e=t.sent(),[2,(0,s.RN)(e)]}})})()},[W,z,U,A,n]),Y=(0,u.useCallback)(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){return!0};return f(function(){var t,n,r;return y(this,function(a){switch(a.label){case 0:H(!0),a.label=1;case 1:return a.trys.push([1,3,4,5]),[4,V()];case 2:if(n=a.sent(),!e())return[2];return O(n.rows),D(null!=(t=n.count)?t:n.rows.length),[3,5];case 3:return r=a.sent(),e()&&w.error(x(r,p("Operation failed"))),[3,5];case 4:return e()&&H(!1),[7];case 5:return[2]}})})()},[V,w,p]),Z=(0,u.useCallback)(function(){return f(function(){return y(this,function(e){switch(e.label){case 0:return[4,Y()];case 1:return e.sent(),[2]}})})()},[Y]);(0,u.useEffect)(function(){var e=!0;return Y(function(){return e}),function(){e=!1}},[Y]);var J=(0,u.useCallback)(function(e){L(e),K(1)},[]),Q=(0,u.useCallback)(function(e,t){if(t!==U){$(t),K(1);return}K(e)},[U]),X=(0,u.useCallback)(function(e){m.viewer.drawer({width:"50%",closable:!0,content:function(){return o().createElement(I,{record:e,resource:A,onSubmitted:Z})}})},[m.viewer,Z,A]),ee=(0,u.useCallback)(function(e){T(e)?w.warning(p("Template is in use and cannot be deleted")):v.confirm({title:p("Delete template"),content:p("Are you sure you want to delete this item? This action cannot be undone."),onOk:function(){return f(function(){return y(this,function(t){switch(t.label){case 0:var n;return[4,(n={resource:A,record:e},f(function(){return y(this,function(e){switch(e.label){case 0:return[4,n.resource.destroy({filterByTk:n.record.uid})];case 1:return e.sent(),[2]}})})())];case 1:return t.sent(),[4,Z()];case 2:return t.sent(),w.success(p("Deleted")),[2]}})})()}})},[Z,w,v,A,p]),et=(0,u.useMemo)(function(){return[{title:p("Template name"),dataIndex:"name",width:300,ellipsis:{showTitle:!1},render:function(e){return o().createElement(C,{value:e})}},{title:p("Template description"),dataIndex:"description",width:420,ellipsis:{showTitle:!1},render:function(e){return o().createElement(C,{value:e})}},{title:p("Data source"),dataIndex:"dataSourceKey",width:160,ellipsis:{showTitle:!1},render:function(e){return o().createElement(C,{value:e})}},{title:p("Collection"),dataIndex:"collectionName",width:180,ellipsis:{showTitle:!1},render:function(e){return o().createElement(C,{value:e})}},{title:p("Usage count"),dataIndex:"usageCount",width:140,render:function(e){return e||0}},{title:p("Actions"),key:"actions",width:180,render:function(e,t){var n=T(t);return o().createElement(l.Space,null,o().createElement(l.Button,{type:"link",size:"small",icon:o().createElement(r.EditOutlined,null),onClick:function(){return X(t)}},p("Edit")),o().createElement(l.Tooltip,{title:n?p("Template is in use and cannot be deleted"):void 0},o().createElement(l.Button,{type:"link",size:"small",danger:!0,disabled:n,icon:o().createElement(r.DeleteOutlined,null),onClick:function(){return ee(t)}},p("Delete"))))}}]},[ee,X,p]);return o().createElement(l.Card,{variant:"borderless"},o().createElement(l.Flex,{justify:"space-between",align:"center",style:{marginBottom:k.margin}},o().createElement(l.Flex,{align:"center",gap:k.marginSM},o().createElement(a.CollectionFilter,{collection:F,filterableFieldNames:g,onChange:J,t:p})),o().createElement(l.Button,{icon:o().createElement(r.ReloadOutlined,null),onClick:Z},p("Refresh"))),o().createElement(a.Table,{rowKey:"uid",loading:G,columns:et,dataSource:M,tableLayout:"fixed",scroll:{x:1380},pagination:{current:z,pageSize:U,total:B,onChange:Q}}))},F=function(e){var t=e.templateType;return o().createElement(a.ExtendCollectionsProvider,{collections:[w]},o().createElement(A,{templateType:t}))},_=function(){return o().createElement(F,{templateType:"block"})},M=function(){return o().createElement(F,{templateType:"popup"})}}}]);
|