@nocobase/plugin-snapshot-field 0.18.0-alpha.9 → 0.19.0-alpha.10
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/SnapshotBlock/SnapshotBlockInitializers/SnapshotBlockInitializers.d.ts +1 -1
- package/dist/client/index.js +1 -1
- package/dist/externalVersion.js +4 -4
- package/dist/locale/ko_KR.json +14 -0
- package/dist/locale/zh-CN.json +1 -1
- package/dist/server/collections/collectionsHistory.d.ts +1 -2
- package/dist/server/collections/collectionsHistory.js +5 -5
- package/dist/server/collections/fieldsHistory.d.ts +1 -2
- package/dist/server/collections/fieldsHistory.js +5 -5
- package/dist/server/plugin.js +1 -3
- package/package.json +11 -6
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { SchemaInitializer } from '@nocobase/client';
|
|
2
|
-
export declare const snapshotBlockInitializers: SchemaInitializer
|
|
2
|
+
export declare const snapshotBlockInitializers: SchemaInitializer;
|
package/dist/client/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(n,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@nocobase/client"),require("react/jsx-runtime"),require("react"),require("antd"),require("@formily/react"),require("lodash"),require("react-i18next"),require("@ant-design/icons"),require("@formily/shared"),require("@formily/core")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","react/jsx-runtime","react","antd","@formily/react","lodash","react-i18next","@ant-design/icons","@formily/shared","@formily/core"],e):(n=typeof globalThis!="undefined"?globalThis:n||self,e(n["@nocobase/plugin-snapshot-field"]={},n["@nocobase/client"],n.jsxRuntime,n.react,n.antd,n["@formily/react"],n.lodash,n["react-i18next"],n["@ant-design/icons"],n["@formily/shared"],n["@formily/core"]))})(this,function(n,e,r,l,v,P,w,b,C,I,W){"use strict";var ae=Object.defineProperty,ce=Object.defineProperties;var le=Object.getOwnPropertyDescriptors;var M=Object.getOwnPropertySymbols;var H=Object.prototype.hasOwnProperty,G=Object.prototype.propertyIsEnumerable;var V=(n,e,r)=>e in n?ae(n,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[e]=r,m=(n,e)=>{for(var r in e||(e={}))H.call(e,r)&&V(n,r,e[r]);if(M)for(var r of M(e))G.call(e,r)&&V(n,r,e[r]);return n},x=(n,e)=>ce(n,le(e));var B=(n,e)=>{var r={};for(var l in n)H.call(n,l)&&e.indexOf(l)<0&&(r[l]=n[l]);if(n!=null&&M)for(var l of M(n))e.indexOf(l)<0&&G.call(n,l)&&(r[l]=n[l]);return r};var q=(n,e,r)=>new Promise((l,v)=>{var P=C=>{try{b(r.next(C))}catch(I){v(I)}},w=C=>{try{b(r.throw(C))}catch(I){v(I)}},b=C=>C.done?l(C.value):Promise.resolve(C.value).then(P,w);b((r=r.apply(n,e)).next())});const S="snapshot-field",{defaultProps:L}=e.interfacesProperties,T="appends",A="targetField",$=()=>{let o=e.useRecord();for(;o&&Object.keys(o.__parent).length>0;)o=o.__parent;return o};function J(){var s;const{getCollectionField:o}=e.useCollectionManager(),i=$(),a=P.useForm().values;return(s=o(`${i.name}.${a.targetField}`))==null?void 0:s.target}function R(o,i=[]){const{getCollection:a}=e.useCollectionManager(),s=[];return o.forEach(t=>{var c,d,u,f;if(["belongsTo","hasOne","hasMany","belongsToMany"].includes(t.type)){const g=i.filter(h=>`${h}.`.startsWith(`${t.name}.`));if(g.length){const h=a(t.target),k=g.filter(y=>y!==t.name).map(y=>y.replace(`${t.name}.`,"")).filter(y=>y);s.push({label:(d=(c=t.uiSchema)==null?void 0:c.title)!=null?d:t.name,value:t.name,children:R(h.fields,k)})}}else s.push({label:(f=(u=t.uiSchema)==null?void 0:u.title)!=null?f:t.name,value:t.name})}),s}const K={type:"void",title:"{{t('View record')}}","x-component":"RecordPicker.Viewer","x-component-props":{className:"nb-action-popup"},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},properties:{tab1:{type:"void",title:"{{t('Detail')}}","x-component":"Tabs.TabPane","x-designer":"Tabs.Designer","x-component-props":{},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"SnapshotBlockInitializers",properties:{}}}}}}}},z={name:"snapshot",type:"object",group:"advanced",title:`{{t('Snapshot', {ns: '${S}'})}}`,description:`{{t('When adding a new record, create a snapshot for its relational record and save in the current record. The snapshot is not updated when the record is subsequently updated.', {ns: '${S}'})}}`,default:{type:"snapshot",uiSchema:{"x-component":"SnapshotRecordPicker","x-component-props":{multiple:!0,fieldNames:{label:"id",value:"id"}}}},schemaInitialize(o,{field:i,readPretty:a,action:s,block:t}){o.properties={viewer:w.cloneDeep(K)}},initialize:o=>{},usePathOptions(o){const{appends:i=[],targetCollection:a}=o,{getCollection:s}=e.useCollectionManager(),{fields:t}=s(a),c=R(t,i);return[{label:`{{t('Snapshot data', { ns: '${S}' })}}`,value:"data",children:c}]},properties:x(m({},L),{[A]:{type:"string",title:`{{t('The association field to snapshot', {ns: '${S}'})}}`,required:!0,"x-decorator":"FormItem","x-component":"SnapshotOwnerCollectionFieldsSelect","x-disabled":"{{ !createOnly || isOverride }}","x-reactions":[{target:T,when:"{{$self.value != undefined}}",fulfill:{state:{visible:!0}},otherwise:{state:{visible:!1}}}]},[T]:{type:"string",title:`{{t("Snapshot the snapshot's association fields", {ns: "${S}"})}}`,"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{multiple:!0,useCollection:J},"x-reactions":[{dependencies:[A],when:"{{$deps[0]}}",fulfill:{run:"{{$self.setValue($self.value)}}"}}]}})},Q=()=>{const o=$(),{getCollection:i}=e.useCollectionManager(),a=i(o.name),s=e.useCompile();return a.fields.filter(t=>!!t.target&&!!t.interface).map(t=>{var c;return x(m({},t),{label:s((c=t.uiSchema)==null?void 0:c.title),value:t.name})})},U=o=>{const i=Q();return r.jsx(v.Select,m({popupMatchSelectWidth:!1,options:i},o))},O=o=>{const h=o,{formItemInitializers:i="ReadPrettyFormItemInitializers",actionInitializers:a="ReadPrettyFormActionInitializers",collection:s,association:t,resource:c,template:d}=h,u=B(h,["formItemInitializers","actionInitializers","collection","association","resource","template"]),f=c||t||s;return{type:"void","x-acl-action":`${f}:get`,"x-decorator":"SnapshotBlockProvider","x-decorator-props":m({resource:f,collection:s,association:t,readPretty:!0,action:"get",useParams:"{{ useParamsFromRecord }}"},u),"x-designer":"FormV2.ReadPrettyDesigner","x-component":"CardItem",properties:{[I.uid()]:{type:"void","x-component":"FormV2","x-read-pretty":!0,"x-component-props":{useProps:"{{ useFormBlockProps }}"},properties:{grid:d||{type:"void","x-component":"Grid","x-initializer":i,properties:{}}}}}}},X=()=>{const o=e.useSchemaInitializerItem(),F=o,{onCreateBlockSchema:i,componentType:a,createBlockSchema:s,icon:t=!0,targetCollection:c}=F,d=B(F,["onCreateBlockSchema","componentType","createBlockSchema","icon","targetCollection"]),{insert:u}=e.useSchemaInitializer(),{getTemplateSchemaByMode:f}=e.useSchemaTemplateManager(),g=c||e.useCollection(),h=e.useBlockAssociationContext(),{block:k}=e.useBlockRequestContext(),y=k!=="TableField"?o.actionInitializers||"ReadPrettyFormActionInitializers":null;return l.createElement(e.SchemaInitializerItem,x(m({icon:t&&r.jsx(C.FormOutlined,{})},d),{key:"snapshotDetail",onClick:ie=>q(this,[ie],function*({item:p}){if(p.template){const j=yield f(p);if(p.template.componentName==="ReadPrettyFormItem"){const E=O({actionInitializers:y,association:h,collection:g.name,action:"get",useSourceId:"{{ useSourceIdFromParentRecord }}",useParams:"{{ useParamsFromRecord }}",template:j});p.mode==="reference"&&(E["x-template-key"]=p.template.key),u(E)}else u(j)}else u(O({actionInitializers:y,association:h,collection:g.name,action:"get",useSourceId:"{{ useSourceIdFromParentRecord }}",useParams:"{{ useParamsFromRecord }}"}))}),items:e.useRecordCollectionDataSourceItems("ReadPrettyFormItem")}))},Y=o=>{var f;const{action:i,readPretty:a}=o,s=P.useField(),t=l.useMemo(()=>W.createForm({readPretty:a}),[]),{resource:c,service:d}=e.useBlockRequestContext(),u=l.useRef();return d.loading?r.jsx(v.Spin,{}):r.jsx(e.FormBlockContext.Provider,{value:{action:i,form:t,field:s,service:d,resource:c,updateAssociationValues:[],formBlockRef:u},children:a?r.jsx(e.RecordProvider,{record:(f=d==null?void 0:d.data)==null?void 0:f.data,children:r.jsx("div",{ref:u,children:o.children})}):r.jsx("div",{ref:u,children:o.children})})},Z=o=>{const i=P.useField(),a=e.useBlockResource(),s={loading:!1,data:{data:e.useRecord()}},t=l.useContext(e.BlockRequestContext);return r.jsx(e.BlockRequestContext.Provider,{value:{block:o.block,props:o,field:i,service:s,resource:a,__parent:t},children:o.children})},ee=o=>{const{collection:i,association:a}=o,s=e.useResource(o);return r.jsx(e.MaybeCollectionProvider,{collection:i,children:r.jsx(e.BlockAssociationContext.Provider,{value:a,children:r.jsx(e.BlockResourceContext.Provider,{value:s,children:r.jsx(Z,x(m({},o),{children:o.children}))})})})},oe=o=>{const i=e.useRecord(),{__tableName:a}=i,{getInheritCollections:s}=e.useCollectionManager(),t=s(a),{designable:c}=e.useDesignable();return!(!c&&a&&!t.includes(o.collection)&&a!==o.collection)&&r.jsx(ee,x(m({},o),{children:r.jsx(Y,m({},o))}))},te=o=>{var k,y,F;const{collectionName:i}=o,h=l.useContext(e.CollectionManagerContext),{collections:a}=h,s=B(h,["collections"]),t=(k=e.useHistoryCollectionsByNames([i]))==null?void 0:k[0],c=e.useHistoryCollectionsByNames((y=t==null?void 0:t.inherits)!=null?y:[]),d=e.useHistoryCollectionsByNames((F=t==null?void 0:t.fields.filter(p=>p.interface!=="snapshot").map(p=>p.target))!=null?F:[]),u=[t,...d,...c].filter(p=>p),g=[...a.filter(p=>!u.map(ie=>ie.name).includes(p.name)),...u];return r.jsx(e.CollectionManagerContext.Provider,{value:x(m({},s),{collections:g}),children:o.children})},N=o=>{const i=P.useFieldSchema(),{getField:a}=e.useCollection(),s=a(i.name);return r.jsx(te,{collectionName:s==null?void 0:s.targetCollection,children:r.jsx(e.ReadPrettyRecordPicker,m({},o))})},re=P.connect(N,P.mapReadPretty(N)),ne=o=>{const c=o,{value:i,onChange:a}=c,s=B(c,["value","onChange"]),t=x(m({},s),{value:i==null?void 0:i.data,onChange:d=>a({data:d})});return r.jsx(re,m({},t))},D=l.memo(o=>(l.useEffect(()=>{e.registerField(z.group,z.name,z)},[]),r.jsx(e.CollectionManagerProvider,{interfaces:{snapshot:z},children:r.jsx(e.CollectionHistoryProvider,{children:r.jsx(e.SchemaComponentOptions,{components:{SnapshotRecordPicker:ne,SnapshotBlockProvider:oe,SnapshotBlockInitializersDetailItem:X,SnapshotOwnerCollectionFieldsSelect:U},children:o.children})})})));D.displayName="SnapshotFieldProvider";const se=new e.SchemaInitializer({name:"SnapshotBlockInitializers",wrap:e.gridRowColWrap,title:`{{t("Add block", { ns: "${S}" })}}`,icon:"PlusOutlined",items:[{type:"itemGroup",title:'{{t("Current record blocks")}}',name:"currentRecordBlocks",children:[{name:"details",title:'{{t("Details")}}',Component:"SnapshotBlockInitializersDetailItem",actionInitializers:"CalendarFormActionInitializers"}]},{type:"itemGroup",title:'{{t("Other blocks")}}',name:"otherBlocks",children:[{name:"markdown",title:'{{t("Markdown")}}',Component:"MarkdownBlockInitializer"}]}]});class _ extends e.Plugin{load(){return q(this,null,function*(){this.app.use(D),this.app.schemaInitializerManager.add(se)})}}n.SnapshotFieldPlugin=_,n.default=_,Object.defineProperties(n,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
1
|
+
(function(n,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@nocobase/client"),require("react/jsx-runtime"),require("react"),require("antd"),require("@formily/react"),require("lodash"),require("react-i18next"),require("@ant-design/icons"),require("@formily/shared"),require("@formily/core")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","react/jsx-runtime","react","antd","@formily/react","lodash","react-i18next","@ant-design/icons","@formily/shared","@formily/core"],e):(n=typeof globalThis!="undefined"?globalThis:n||self,e(n["@nocobase/plugin-snapshot-field"]={},n["@nocobase/client"],n.jsxRuntime,n.react,n.antd,n["@formily/react"],n.lodash,n["react-i18next"],n["@ant-design/icons"],n["@formily/shared"],n["@formily/core"]))})(this,function(n,e,r,l,v,P,M,b,C,I,W){"use strict";var ae=Object.defineProperty,ce=Object.defineProperties;var le=Object.getOwnPropertyDescriptors;var w=Object.getOwnPropertySymbols;var H=Object.prototype.hasOwnProperty,G=Object.prototype.propertyIsEnumerable;var V=(n,e,r)=>e in n?ae(n,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[e]=r,m=(n,e)=>{for(var r in e||(e={}))H.call(e,r)&&V(n,r,e[r]);if(w)for(var r of w(e))G.call(e,r)&&V(n,r,e[r]);return n},x=(n,e)=>ce(n,le(e));var B=(n,e)=>{var r={};for(var l in n)H.call(n,l)&&e.indexOf(l)<0&&(r[l]=n[l]);if(n!=null&&w)for(var l of w(n))e.indexOf(l)<0&&G.call(n,l)&&(r[l]=n[l]);return r};var T=(n,e,r)=>new Promise((l,v)=>{var P=C=>{try{b(r.next(C))}catch(I){v(I)}},M=C=>{try{b(r.throw(C))}catch(I){v(I)}},b=C=>C.done?l(C.value):Promise.resolve(C.value).then(P,M);b((r=r.apply(n,e)).next())});const S="snapshot-field",{defaultProps:L}=e.interfacesProperties,q="appends",A="targetField",$=()=>{let o=e.useRecord();for(;o&&Object.keys(o.__parent).length>0;)o=o.__parent;return o};function J(){var s;const{getCollectionField:o}=e.useCollectionManager(),i=$(),a=P.useForm().values;return(s=o(`${i.name}.${a.targetField}`))==null?void 0:s.target}function R(o,i=[]){const{getCollection:a}=e.useCollectionManager(),s=[];return o.forEach(t=>{var c,d,u,f;if(["belongsTo","hasOne","hasMany","belongsToMany"].includes(t.type)){const g=i.filter(h=>`${h}.`.startsWith(`${t.name}.`));if(g.length){const h=a(t.target),k=g.filter(y=>y!==t.name).map(y=>y.replace(`${t.name}.`,"")).filter(y=>y);s.push({label:(d=(c=t.uiSchema)==null?void 0:c.title)!=null?d:t.name,value:t.name,children:R(h.fields,k)})}}else s.push({label:(f=(u=t.uiSchema)==null?void 0:u.title)!=null?f:t.name,value:t.name})}),s}const K={type:"void",title:"{{t('View record')}}","x-component":"RecordPicker.Viewer","x-component-props":{className:"nb-action-popup"},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},properties:{tab1:{type:"void",title:"{{t('Detail')}}","x-component":"Tabs.TabPane","x-designer":"Tabs.Designer","x-component-props":{},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"SnapshotBlockInitializers",properties:{}}}}}}}},z={name:"snapshot",type:"object",group:"advanced",title:`{{t('Snapshot', {ns: '${S}'})}}`,description:`{{t('When adding a new record, create a snapshot for its relational record and save in the new record. The snapshot will not be updated when the relational record is updated.', {ns: '${S}'})}}`,default:{type:"snapshot",uiSchema:{"x-component":"SnapshotRecordPicker","x-component-props":{multiple:!0,fieldNames:{label:"id",value:"id"}}}},schemaInitialize(o,{field:i,readPretty:a,action:s,block:t}){o.properties={viewer:M.cloneDeep(K)}},initialize:o=>{},usePathOptions(o){const{appends:i=[],targetCollection:a}=o,{getCollection:s}=e.useCollectionManager(),{fields:t}=s(a),c=R(t,i);return[{label:`{{t('Snapshot data', { ns: '${S}' })}}`,value:"data",children:c}]},properties:x(m({},L),{[A]:{type:"string",title:`{{t('The association field to snapshot', {ns: '${S}'})}}`,required:!0,"x-decorator":"FormItem","x-component":"SnapshotOwnerCollectionFieldsSelect","x-disabled":"{{ !createOnly || isOverride }}","x-reactions":[{target:q,when:"{{$self.value != undefined}}",fulfill:{state:{visible:!0}},otherwise:{state:{visible:!1}}}]},[q]:{type:"string",title:`{{t("Snapshot the snapshot's association fields", {ns: "${S}"})}}`,"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{multiple:!0,useCollection:J},"x-reactions":[{dependencies:[A],when:"{{$deps[0]}}",fulfill:{run:"{{$self.setValue($self.value)}}"}}]}})},Q=()=>{const o=$(),{getCollection:i}=e.useCollectionManager(),a=i(o.name),s=e.useCompile();return a.fields.filter(t=>!!t.target&&!!t.interface).map(t=>{var c;return x(m({},t),{label:s((c=t.uiSchema)==null?void 0:c.title),value:t.name})})},U=o=>{const i=Q();return r.jsx(v.Select,m({popupMatchSelectWidth:!1,options:i},o))},O=o=>{const h=o,{formItemInitializers:i="ReadPrettyFormItemInitializers",actionInitializers:a="ReadPrettyFormActionInitializers",collection:s,association:t,resource:c,template:d}=h,u=B(h,["formItemInitializers","actionInitializers","collection","association","resource","template"]),f=c||t||s;return{type:"void","x-acl-action":`${f}:get`,"x-decorator":"SnapshotBlockProvider","x-decorator-props":m({resource:f,collection:s,association:t,readPretty:!0,action:"get",useParams:"{{ useParamsFromRecord }}"},u),"x-designer":"FormV2.ReadPrettyDesigner","x-component":"CardItem",properties:{[I.uid()]:{type:"void","x-component":"FormV2","x-read-pretty":!0,"x-component-props":{useProps:"{{ useFormBlockProps }}"},properties:{grid:d||{type:"void","x-component":"Grid","x-initializer":i,properties:{}}}}}}},X=()=>{const o=e.useSchemaInitializerItem(),F=o,{onCreateBlockSchema:i,componentType:a,createBlockSchema:s,icon:t=!0,targetCollection:c}=F,d=B(F,["onCreateBlockSchema","componentType","createBlockSchema","icon","targetCollection"]),{insert:u}=e.useSchemaInitializer(),{getTemplateSchemaByMode:f}=e.useSchemaTemplateManager(),g=c||e.useCollection(),h=e.useBlockAssociationContext(),{block:k}=e.useBlockRequestContext(),y=k!=="TableField"?o.actionInitializers||"ReadPrettyFormActionInitializers":null;return l.createElement(e.SchemaInitializerItem,x(m({icon:t&&r.jsx(C.FormOutlined,{})},d),{key:"snapshotDetail",onClick:ie=>T(this,[ie],function*({item:p}){if(p.template){const j=yield f(p);if(p.template.componentName==="ReadPrettyFormItem"){const E=O({actionInitializers:y,association:h,collection:g.name,action:"get",useSourceId:"{{ useSourceIdFromParentRecord }}",useParams:"{{ useParamsFromRecord }}",template:j});p.mode==="reference"&&(E["x-template-key"]=p.template.key),u(E)}else u(j)}else u(O({actionInitializers:y,association:h,collection:g.name,action:"get",useSourceId:"{{ useSourceIdFromParentRecord }}",useParams:"{{ useParamsFromRecord }}"}))}),items:e.useRecordCollectionDataSourceItems("ReadPrettyFormItem")}))},Y=o=>{var f;const{action:i,readPretty:a}=o,s=P.useField(),t=l.useMemo(()=>W.createForm({readPretty:a}),[]),{resource:c,service:d}=e.useBlockRequestContext(),u=l.useRef();return d.loading?r.jsx(v.Spin,{}):r.jsx(e.FormBlockContext.Provider,{value:{action:i,form:t,field:s,service:d,resource:c,updateAssociationValues:[],formBlockRef:u},children:a?r.jsx(e.RecordProvider,{record:(f=d==null?void 0:d.data)==null?void 0:f.data,children:r.jsx("div",{ref:u,children:o.children})}):r.jsx("div",{ref:u,children:o.children})})},Z=o=>{const i=P.useField(),a=e.useBlockResource(),s={loading:!1,data:{data:e.useRecord()}},t=l.useContext(e.BlockRequestContext);return r.jsx(e.BlockRequestContext.Provider,{value:{block:o.block,props:o,field:i,service:s,resource:a,__parent:t},children:o.children})},ee=o=>{const{collection:i,association:a}=o,s=e.useResource(o);return r.jsx(e.MaybeCollectionProvider,{collection:i,children:r.jsx(e.BlockAssociationContext.Provider,{value:a,children:r.jsx(e.BlockResourceContext.Provider,{value:s,children:r.jsx(Z,x(m({},o),{children:o.children}))})})})},oe=o=>{const i=e.useRecord(),{__tableName:a}=i,{getInheritCollections:s}=e.useCollectionManager(),t=s(a),{designable:c}=e.useDesignable();return!(!c&&a&&!t.includes(o.collection)&&a!==o.collection)&&r.jsx(ee,x(m({},o),{children:r.jsx(Y,m({},o))}))},te=o=>{var k,y,F;const{collectionName:i}=o,h=l.useContext(e.CollectionManagerContext),{collections:a}=h,s=B(h,["collections"]),t=(k=e.useHistoryCollectionsByNames([i]))==null?void 0:k[0],c=e.useHistoryCollectionsByNames((y=t==null?void 0:t.inherits)!=null?y:[]),d=e.useHistoryCollectionsByNames((F=t==null?void 0:t.fields.filter(p=>p.interface!=="snapshot").map(p=>p.target))!=null?F:[]),u=[t,...d,...c].filter(p=>p),g=[...a.filter(p=>!u.map(ie=>ie.name).includes(p.name)),...u];return r.jsx(e.CollectionManagerContext.Provider,{value:x(m({},s),{collections:g}),children:o.children})},N=o=>{const i=P.useFieldSchema(),{getField:a}=e.useCollection(),s=a(i.name);return r.jsx(te,{collectionName:s==null?void 0:s.targetCollection,children:r.jsx(e.ReadPrettyRecordPicker,m({},o))})},re=P.connect(N,P.mapReadPretty(N)),ne=o=>{const c=o,{value:i,onChange:a}=c,s=B(c,["value","onChange"]),t=x(m({},s),{value:i==null?void 0:i.data,onChange:d=>a({data:d})});return r.jsx(re,m({},t))},D=l.memo(o=>(l.useEffect(()=>{e.registerField(z.group,z.name,z)},[]),r.jsx(e.CollectionManagerProvider,{interfaces:{snapshot:z},children:r.jsx(e.CollectionHistoryProvider,{children:r.jsx(e.SchemaComponentOptions,{components:{SnapshotRecordPicker:ne,SnapshotBlockProvider:oe,SnapshotBlockInitializersDetailItem:X,SnapshotOwnerCollectionFieldsSelect:U},children:o.children})})})));D.displayName="SnapshotFieldProvider";const se=new e.SchemaInitializer({name:"SnapshotBlockInitializers",wrap:e.gridRowColWrap,title:`{{t("Add block", { ns: "${S}" })}}`,icon:"PlusOutlined",items:[{type:"itemGroup",title:'{{t("Current record blocks")}}',name:"currentRecordBlocks",children:[{name:"details",title:'{{t("Details")}}',Component:"SnapshotBlockInitializersDetailItem",actionInitializers:"CalendarFormActionInitializers"}]},{type:"itemGroup",title:'{{t("Other blocks")}}',name:"otherBlocks",children:[{name:"markdown",title:'{{t("Markdown")}}',Component:"MarkdownBlockInitializer"}]}]});class _ extends e.Plugin{load(){return T(this,null,function*(){this.app.use(D),this.app.schemaInitializerManager.add(se)})}}n.SnapshotFieldPlugin=_,n.default=_,Object.defineProperties(n,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/externalVersion.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
"@nocobase/client": "0.
|
|
2
|
+
"@nocobase/client": "0.19.0-alpha.10",
|
|
3
3
|
"react": "18.2.0",
|
|
4
4
|
"@formily/react": "2.3.0",
|
|
5
5
|
"@formily/core": "2.3.0",
|
|
6
6
|
"lodash": "4.17.21",
|
|
7
|
-
"@nocobase/database": "0.
|
|
8
|
-
"@nocobase/server": "0.
|
|
9
|
-
"antd": "5.12.
|
|
7
|
+
"@nocobase/database": "0.19.0-alpha.10",
|
|
8
|
+
"@nocobase/server": "0.19.0-alpha.10",
|
|
9
|
+
"antd": "5.12.8",
|
|
10
10
|
"react-i18next": "11.18.6",
|
|
11
11
|
"@ant-design/icons": "5.2.6",
|
|
12
12
|
"@formily/shared": "2.3.0"
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Detail": "상세 정보",
|
|
3
|
+
"Snapshot": "스냅샷",
|
|
4
|
+
"Add block": "블록 추가",
|
|
5
|
+
"When adding a new record, create a snapshot for its relational record and save in the current record. The snapshot is not updated when the record is subsequently updated.":
|
|
6
|
+
"새로운 레코드를 추가할 때 해당 레코드의 관련 데이터에 대한 스냅샷을 생성하고 현재 레코드에 저장합니다. 레코드가 이후에 업데이트되어도 스냅샷은 업데이트되지 않습니다.",
|
|
7
|
+
"View record": "레코드 보기",
|
|
8
|
+
"Allow linking to multiple records": "다중 레코드에 연결 허용",
|
|
9
|
+
"The association field to snapshot": "스냅샷을 찍을 관련 필드",
|
|
10
|
+
"Snapshot the snapshot's association fields": "스냅샷의 관련 필드를 스냅샷으로 만듭니다.",
|
|
11
|
+
"Please select": "선택하세요",
|
|
12
|
+
"When a record is created, association data is backed up in a snapshot": "레코드가 생성되면 관련 데이터가 스냅샷에 백업됩니다.",
|
|
13
|
+
"Snapshot data": "스냅샷 데이터"
|
|
14
|
+
}
|
package/dist/locale/zh-CN.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"Detail": "详情",
|
|
3
3
|
"Snapshot": "快照",
|
|
4
4
|
"Add block": "创建区块",
|
|
5
|
-
"When adding a new record, create a snapshot for its relational record and save in the
|
|
5
|
+
"When adding a new record, create a snapshot for its relational record and save in the new record. The snapshot will not be updated when the relational record is updated.": "在添加数据时,为它的关系数据创建快照,并保存在当前的数据中。关系数据更新时,快照不会更新。",
|
|
6
6
|
"View record": "查看数据",
|
|
7
7
|
"Allow linking to multiple records": "允许关联多条记录",
|
|
8
8
|
"The association field to snapshot": "快照目标关系字段",
|
|
@@ -20,17 +20,17 @@ __export(collectionsHistory_exports, {
|
|
|
20
20
|
default: () => collectionsHistory_default
|
|
21
21
|
});
|
|
22
22
|
module.exports = __toCommonJS(collectionsHistory_exports);
|
|
23
|
-
var
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
var import_database = require("@nocobase/database");
|
|
24
|
+
var collectionsHistory_default = (0, import_database.defineCollection)({
|
|
25
|
+
dumpRules: "required",
|
|
26
26
|
name: "collectionsHistory",
|
|
27
|
-
title: "\u6570\u636E\u8868\u5386\u53F2",
|
|
28
27
|
sortable: "sort",
|
|
29
28
|
autoGenId: false,
|
|
30
29
|
model: "CollectionModel",
|
|
31
30
|
repository: "CollectionRepository",
|
|
32
31
|
timestamps: false,
|
|
33
32
|
filterTargetKey: "name",
|
|
33
|
+
shared: true,
|
|
34
34
|
fields: [
|
|
35
35
|
{
|
|
36
36
|
type: "uid",
|
|
@@ -74,4 +74,4 @@ var collectionsHistory_default = {
|
|
|
74
74
|
sortBy: "sort"
|
|
75
75
|
}
|
|
76
76
|
]
|
|
77
|
-
};
|
|
77
|
+
});
|
|
@@ -20,14 +20,14 @@ __export(fieldsHistory_exports, {
|
|
|
20
20
|
default: () => fieldsHistory_default
|
|
21
21
|
});
|
|
22
22
|
module.exports = __toCommonJS(fieldsHistory_exports);
|
|
23
|
-
var
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
var import_database = require("@nocobase/database");
|
|
24
|
+
var fieldsHistory_default = (0, import_database.defineCollection)({
|
|
25
|
+
dumpRules: "required",
|
|
26
26
|
name: "fieldsHistory",
|
|
27
|
-
title: '{{t("Fields history")}}',
|
|
28
27
|
autoGenId: false,
|
|
29
28
|
model: "FieldModel",
|
|
30
29
|
timestamps: false,
|
|
30
|
+
shared: true,
|
|
31
31
|
sortable: {
|
|
32
32
|
name: "sort",
|
|
33
33
|
scopeKey: "collectionName"
|
|
@@ -92,4 +92,4 @@ var fieldsHistory_default = {
|
|
|
92
92
|
defaultValue: {}
|
|
93
93
|
}
|
|
94
94
|
]
|
|
95
|
-
};
|
|
95
|
+
});
|
package/dist/server/plugin.js
CHANGED
|
@@ -89,9 +89,7 @@ class SnapshotFieldPlugin extends import_server.Plugin {
|
|
|
89
89
|
}
|
|
90
90
|
};
|
|
91
91
|
async load() {
|
|
92
|
-
await this.
|
|
93
|
-
directory: (0, import_path.resolve)(__dirname, "collections")
|
|
94
|
-
});
|
|
92
|
+
await this.importCollections((0, import_path.resolve)(__dirname, "collections"));
|
|
95
93
|
this.app.db.registerFieldTypes({
|
|
96
94
|
snapshot: import_snapshot_field.SnapshotField
|
|
97
95
|
});
|
package/package.json
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-snapshot-field",
|
|
3
|
-
"displayName": "
|
|
4
|
-
"displayName.zh-CN": "
|
|
5
|
-
"description": "",
|
|
6
|
-
"description.zh-CN": "",
|
|
7
|
-
"version": "0.
|
|
3
|
+
"displayName": "Collection field: Snapshot",
|
|
4
|
+
"displayName.zh-CN": "数据表字段:关系快照",
|
|
5
|
+
"description": "When adding a new record, create a snapshot for its relational record and save in the new record. The snapshot will not be updated when the relational record is updated.",
|
|
6
|
+
"description.zh-CN": "在添加数据时,为它的关系数据创建快照,并保存在当前的数据中。关系数据更新时,快照不会更新。",
|
|
7
|
+
"version": "0.19.0-alpha.10",
|
|
8
8
|
"license": "AGPL-3.0",
|
|
9
9
|
"main": "./dist/server/index.js",
|
|
10
|
+
"homepage": "https://docs.nocobase.com/plugins/snapshot-field",
|
|
11
|
+
"homepage.zh-CN": "https://docs-cn.nocobase.com/plugins/snapshot-field",
|
|
10
12
|
"devDependencies": {
|
|
11
13
|
"@ant-design/icons": "5.x",
|
|
12
14
|
"@formily/core": "2.x",
|
|
@@ -24,5 +26,8 @@
|
|
|
24
26
|
"@nocobase/test": "0.x",
|
|
25
27
|
"@nocobase/utils": "0.x"
|
|
26
28
|
},
|
|
27
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "d09d81eba67339da36bcec27939a85b35d180770",
|
|
30
|
+
"keywords": [
|
|
31
|
+
"Collection fields"
|
|
32
|
+
]
|
|
28
33
|
}
|