@nocobase/plugin-kanban 1.4.0-beta.9 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/index.js +1 -1
- package/dist/externalVersion.js +4 -4
- package/package.json +2 -2
package/dist/client/index.js
CHANGED
|
@@ -306,4 +306,4 @@ Error generating stack: `+i.message+`
|
|
|
306
306
|
// color: #8c8c8c;
|
|
307
307
|
// fontweight: normal;
|
|
308
308
|
// }
|
|
309
|
-
`,Bs=D.memo(J.RecursionField);Bs.displayName="MemorizedRecursionField";const ab=()=>{var C;const e=P.useCollection(),{setDisableCardDrag:r}=D.useContext(As)||{},n=J.useFieldSchema(),{openPopup:t,getPopupSchemaFromSchema:o}=P.usePopupUtils(),i=P.useCollectionRecordData(),a=o(n)||lb(n),[l,u]=D.useState(!1),{isPopupVisibleControlledByURL:s}=P.usePopupSettings(),f=D.useCallback(b=>{const E=b.target;b.currentTarget.contains(E)&&(s()?t({popupUidUsedInURL:a==null?void 0:a["x-uid"]}):u(!0)),b.stopPropagation()},[t,a]),c=D.useMemo(()=>({cursor:"pointer",overflow:"hidden"}),[]),d=D.useMemo(()=>Ug.createForm({values:i}),[i]),p=D.useCallback(()=>{r==null||r(!0)},[r]),h=D.useCallback(()=>{r==null||r(!1)},[r]),y=D.useMemo(()=>({type:"void",properties:{drawer:a}}),[a]),w=(C=P.getCardItemSchema)==null?void 0:C.call(P,n),{layout:m="vertical",labelAlign:v="left",labelWidth:g=120,labelWrap:S=!0}=(w==null?void 0:w["x-component-props"])||{};return x.jsxs(x.Fragment,{children:[x.jsx(Re.Card,{onClick:f,bordered:!1,hoverable:!0,style:c,className:ib,children:x.jsx(P.DndContext,{onDragStart:p,onDragEnd:h,children:x.jsx(Fr.FormLayout,{layout:m,labelAlign:v,labelWidth:m==="horizontal"?g:null,labelWrap:S,children:x.jsx(P.FormProvider,{form:d,children:x.jsx(Bs,{schema:n,onlyRenderProperties:!0})})})})}),x.jsx(P.PopupContextProvider,{visible:l,setVisible:u,children:x.jsx(P.VariablePopupRecordProvider,{recordData:i,collection:e,children:x.jsx(Bs,{schema:y})})})]})};function lb(e){var n,t,o,i;return(i=(o=(t=(n=e.parent)==null?void 0:n.properties)==null?void 0:t.cardViewer)==null?void 0:o.properties)!=null&&i.drawer?e.parent.properties.cardViewer.properties.drawer:Eg(e["x-uid"],e.root).parent.properties.cardViewer.properties.drawer}function Eg(e,r,n={value:null}){return n=n||{value:null},r.mapProperties(t=>{t["x-uid"]===e?n.value=t:Eg(e,t,n)}),n.value}const ub=e=>(e["x-read-pretty"]=!0,{type:"void","x-component":"Grid.Row",properties:{[Po.uid()]:{type:"void","x-component":"Grid.Col",properties:{[e.name||Po.uid()]:e}}}}),sb=()=>{const{designable:e}=P.useDesignable(),{render:r}=P.useSchemaInitializerRender("kanban:configureItemFields");return e?x.jsx("div",{className:"general-schema-designer",children:x.jsx("div",{className:"general-schema-designer-icons",children:x.jsx(Re.Space,{size:2,align:"center",children:r()})})}):null},Pg={wrap:ub,useInsert(){const e=J.useFieldSchema(),{t:r}=Pn.useTranslation(),n=P.useAPIClient(),{refresh:t}=P.useDesignable();return o=>{const i=e.reduceProperties((l,u)=>u["x-component"]==="Grid"?u:l,null);if(!i)return;const a=P.createDesignable({t:r,api:n,refresh:t,current:i});a.loadAPIClientEvents(),a.insertBeforeEnd(o)}},Component:e=>{const{getAriaLabel:r}=P.useGetAriaLabelOfDesigner();return x.jsx(Gs.MenuOutlined,G(F({},e),{role:"button","aria-label":r("schema-initializer"),style:{cursor:"pointer",fontSize:12}}))},items:[{type:"itemGroup",title:'{{t("Display fields")}}',name:"displayFields",useChildren:P.useFormItemInitializerFields},{type:"itemGroup",divider:!0,title:'{{t("Display association fields")}}',name:"displayAssociationFields",hideIfNoChildren:!0,useChildren(){return P.useAssociatedFormItemInitializerFields({readPretty:!0,block:"Kanban"})}},{name:"divider",type:"divider"},{name:"openMode",Component:P.SchemaInitializerOpenModeSchemaItems,useComponentProps(){const{hideOpenMode:e}=P.useOpenModeContext();return{openMode:!e,openSize:!e}}}]},Ig=new P.CompatibleSchemaInitializer(F({name:"KanbanCardInitializers"},Pg)),cb=new P.CompatibleSchemaInitializer(F({name:"kanban:configureItemFields"},Pg),Ig),db=J.observer(e=>e.children,{displayName:"KanbanCardViewer"}),fb=()=>{const{name:e,title:r}=P.useCollection_deprecated(),n=P.useSchemaTemplate();return x.jsx(P.GeneralSchemaDesigner,{schemaSettings:"blockSettings:kanban",template:n,title:r||e})},pb=new P.SchemaSettings({name:"blockSettings:kanban",items:[{name:"title",Component:P.SchemaSettingsBlockTitleItem},{name:"setTheBlockHeight",Component:P.SchemaSettingsBlockHeightItem},{name:"dataScope",Component:P.SchemaSettingsDataScope,useComponentProps(){var a,l;const{name:e}=P.useCollection_deprecated(),r=J.useFieldSchema(),{form:n}=P.useFormBlockContext(),t=J.useField(),{service:o}=ya(),{dn:i}=P.useDesignable();return{collectionName:e,defaultFilter:((l=(a=r==null?void 0:r["x-decorator-props"])==null?void 0:a.params)==null?void 0:l.filter)||{},form:n,onSubmit:({filter:u})=>{var f;u=P.removeNullCondition(u);const s=t.decoratorProps.params||{};s.filter=u,t.decoratorProps.params=s,r["x-decorator-props"].params=s,o.run(G(F({},(f=o.params)==null?void 0:f[0]),{filter:u})),i.emit("patch",{schema:{"x-uid":r["x-uid"],"x-decorator-props":r["x-decorator-props"]}})}}}},{name:"template",Component:P.SchemaSettingsTemplate,useComponentProps(){const{name:e}=P.useCollection(),{componentNamePrefix:r}=P.useBlockTemplateContext();return{componentName:`${r}Kanban`,collectionName:e}}},{name:"allowDragAndDrop",type:"switch",useComponentProps:()=>{var o;const e=J.useField(),r=J.useFieldSchema(),{t:n}=Pn.useTranslation(),{dn:t}=P.useDesignable();return{title:n("Enable drag and drop sorting"),checked:((o=e.componentProps)==null?void 0:o.dragSort)!==!1,onChange:i=>ur(this,null,function*(){e.componentProps=e.componentProps||{},e.componentProps.dragSort=i,r["x-component-props"]=r["x-component-props"]||{},r["x-component-props"].dragSort=i,t.emit("patch",{schema:{"x-uid":r["x-uid"],"x-component-props":r["x-component-props"]}})})}}},{name:"setBlockLayout",Component:P.SchemaSettingsLayoutItem},{name:"divider",type:"divider"},{name:"remove",type:"remove",componentProps:{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}]}),kg={title:"{{t('Configure actions')}}",icon:"SettingOutlined",style:{marginLeft:8},items:[{name:"filter",title:"{{t('Filter')}}",Component:"FilterActionInitializer",schema:{"x-align":"left"}},{name:"addNew",title:"{{t('Add new')}}",Component:"CreateActionInitializer",schema:{"x-align":"right","x-decorator":"ACLActionProvider","x-acl-action-props":{skipScopeCheck:!0}},useVisible:()=>P.useActionAvailable("create")},{name:"customRequest",title:'{{t("Custom request")}}',Component:"CustomRequestInitializer",schema:{"x-action":"customize:table:request:global"}}]},Ng=new P.CompatibleSchemaInitializer(F({name:"KanbanActionInitializers"},kg)),vb=new P.CompatibleSchemaInitializer(F({name:"kanban:configureActions"},kg),Ng),xo="kanban",gb=e=>{const m=e,{sortFields:r,collectionFields:n,groupField:t,collectionName:o,dataSource:i}=m,a=Ea(m,["sortFields","collectionFields","groupField","collectionName","dataSource"]),l=J.useField(),u=P.useCompile(),s=P.useAPIClient(),{t:f}=Pn.useTranslation(),{theme:c}=P.useGlobalTheme(),d=D.useContext(J.SchemaOptionsContext),p=n==null?void 0:n.filter(v=>v.interface==="integer"),h=({scopeKey:v})=>{var C;const g=v&&n.find(b=>b.name===v),S=v&&u((C=g==null?void 0:g.uiSchema)==null?void 0:C.title);return x.jsxs("span",{style:{color:"rgba(0, 0, 0, 0.25)"},children:["(",S?f("Grouped sorting based on",{ns:xo})+`「${S}」`:f("Global sorting",{ns:xo}),")"]})},y=()=>ur(this,null,function*(){var S;const v=yield P.FormDialog(f("Create sort field"),()=>x.jsx(P.SchemaComponentOptions,{scope:d.scope,components:F({},d.components),children:x.jsx(Fr.FormLayout,{layout:"vertical",children:x.jsx(P.SchemaComponent,{schema:{properties:{"uiSchema.title":{type:"string",title:'{{t("Field display name")}}',required:!0,"x-decorator":"FormItem","x-component":"Input"},name:{type:"string",title:'{{t("Field name")}}',required:!0,"x-decorator":"FormItem","x-component":"Input","x-validator":"uid",description:"{{t('Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.')}}"},scopeKey:{type:"string",title:'{{t("Grouped sorting")}}',default:t.value,"x-disabled":!0,"x-decorator":"FormItem","x-component":"Select",enum:[t]}}}})})}),c).open({initialValues:{name:`f_${Po.uid()}`}}),{data:g}=yield s.resource("collections.fields",o).create({values:F({type:"sort",interface:"sort"},v)});l.dataSource=l.dataSource.concat([G(F({},g.data),{value:g.data.name,label:u((S=g.data.uiSchema)==null?void 0:S.title)})]),l.value=g.data.name}),w=()=>ur(this,null,function*(){var C;const v=yield P.FormDialog(f("Create sort field"),()=>x.jsx(P.SchemaComponentOptions,{scope:d.scope,components:F({},d.components),children:x.jsx(Fr.FormLayout,{layout:"vertical",children:x.jsx(P.SchemaComponent,{schema:{properties:{field:{type:"string",title:f("Convert the following integer fields to sorting fields",{ns:xo}),required:!0,"x-decorator":"FormItem","x-component":"Select",enum:p.map(b=>{var E;return{value:b.name,label:u(((E=b.uiSchema)==null?void 0:E.title)||b.name)}})},scopeKey:{type:"string",title:'{{t("Grouped sorting")}}',default:t.value,"x-disabled":!0,"x-decorator":"FormItem","x-component":"Select",enum:[t]}}}})})}),c).open({initialValues:{}}),{data:g}=yield s.request({url:`dataSourcesCollections/${i}.${o}/fields:update?filterByTk=${v.field}`,method:"post",data:F({type:"sort",interface:"sort"},v)}),S=g.data;l.dataSource=l.dataSource.concat([G(F({},S),{value:S.name,label:u((C=S.uiSchema)==null?void 0:C.title)})]),l.value=S.name});return x.jsxs(Re.Space.Compact,{style:{width:"100%"},children:[x.jsx(P.Select,G(F({options:r},a),{disabled:!t,optionRender:({label:v,data:g})=>x.jsxs(Re.Space,{children:[x.jsx("span",{children:v}),x.jsx(h,{scopeKey:g.scopeKey})]})})),x.jsx(Re.Button,{disabled:!t,onClick:i==="main"?y:w,children:f("Add new")})]})},Ag=e=>{const{collectionName:r,groupField:n,sortField:t,dataSource:o,params:i,association:a}=e,l={type:"void","x-acl-action":`${a||r}:list`,"x-decorator":"KanbanBlockProvider","x-decorator-props":{collection:r,dataSource:o,action:"list",groupField:n,sortField:t,params:F({paginate:!1},i)},"x-toolbar":"BlockSchemaToolbar","x-settings":"blockSettings:kanban","x-component":"CardItem",properties:{actions:{type:"void","x-initializer":"kanban:configureActions","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--nb-spacing)"}},properties:{}},[Po.uid()]:{type:"array","x-component":"Kanban","x-use-component-props":"useKanbanBlockProps",properties:{card:{type:"void","x-read-pretty":!0,"x-label-disabled":!0,"x-decorator":"BlockItem","x-component":"Kanban.Card","x-component-props":{openMode:"drawer"},"x-designer":"Kanban.Card.Designer",properties:{grid:{type:"void","x-component":"Grid","x-component-props":{dndContext:!1}}}},cardViewer:{type:"void",title:'{{ t("View") }}',"x-designer":"Action.Designer","x-component":"Kanban.CardViewer","x-action":"view","x-component-props":{openMode:"drawer"},properties:{drawer:{type:"void",title:'{{ t("View record") }}',"x-component":"Action.Container","x-component-props":{className:"nb-action-popup"},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"popup:addTab",properties:{tab1:{type:"void",title:'{{t("Details")}}',"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer","x-component-props":{},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"popup:common:addBlock",properties:{}}}}}}}}}}}}}};return a&&(l["x-decorator-props"].association=a),l},Og=({item:e,sortFields:r,collectionFields:n,fields:t,options:o,api:i})=>{const a=J.useForm(),{t:l}=Pn.useTranslation();return x.jsx(P.APIClientProvider,{apiClient:i,children:x.jsx(P.SchemaComponentOptions,{scope:F({},o==null?void 0:o.scope),components:F({},o==null?void 0:o.components),children:x.jsx(Fr.FormLayout,{layout:"vertical",children:x.jsx(P.SchemaComponent,{schema:{properties:{groupField:{title:l("Grouping field"),enum:t,required:!0,description:l("Single select and radio fields can be used as the grouping field"),"x-component":"Select","x-component-props":{objectValue:!0,fieldNames:{label:"label",value:"value"},onChange:()=>{a.setValuesIn("dragSortBy",null)}},"x-decorator":"FormItem"},dragSortBy:{title:l("Sorting field",{ns:xo}),required:!0,description:l("Used for sorting kanban cards, only sorting fields corresponding to grouping fields can be selected",{ns:xo}),"x-component":gb,"x-component-props":{objectValue:!0,fieldNames:{label:"label",value:"value"},sortFields:r},"x-decorator":"FormItem","x-reactions":[u=>{var s;u.dataSource=r.map(f=>{var c,d;return G(F({},f),{disabled:f.scopeKey!==((d=(c=u.form.values)==null?void 0:c.groupField)==null?void 0:d.value)})}),u.groupField=(s=u.form.values)==null?void 0:s.groupField,u.setComponentProps({dataSource:e.dataSource,collectionName:e.collectionName||e.name,collectionFields:n,sortFields:r})},{dependencies:[".groupField"],fulfill:{schema:{"x-component-props":"{{$form.values}}"}}}]}}}})})})})},mb=({filterCollections:e,onlyCurrentDataSource:r,hideSearch:n,createBlockSchema:t,showAssociationFields:o})=>{const i=P.useSchemaInitializerItem(),{createKanbanBlock:a}=Tg();return x.jsx(P.DataBlockInitializer,G(F({},i),{componentType:"Kanban",icon:x.jsx(Gs.FormOutlined,{}),onCreateBlockSchema:l=>ur(this,null,function*(){if(t)return t(l);a(l)}),onlyCurrentDataSource:r,hideSearch:n,filter:e,showAssociationFields:o}))},Tg=()=>{const{insert:e}=P.useSchemaInitializer(),{t:r}=Pn.useTranslation(),{getCollectionFields:n}=P.useCollectionManager_deprecated(),t=D.useContext(J.SchemaOptionsContext),{theme:o}=P.useGlobalTheme(),i=P.useAPIClient();return{createKanbanBlock:u=>ur(this,[u],function*({item:l}){var p,h;const s=n(l.name,l.dataSource),f=(p=s==null?void 0:s.filter(y=>["select","radioGroup"].includes(y.interface)))==null?void 0:p.map(y=>{var w;return{label:(w=y==null?void 0:y.uiSchema)==null?void 0:w.title,value:y.name,uiSchema:G(F({},y.uiSchema),{name:y.name})}}),c=(h=s==null?void 0:s.filter(y=>["sort"].includes(y.interface)))==null?void 0:h.map(y=>{var w;return{label:(w=y==null?void 0:y.uiSchema)==null?void 0:w.title,value:y.name,scopeKey:y.scopeKey,uiSchema:G(F({},y.uiSchema),{name:y.name})}}),d=yield P.FormDialog(r("Create kanban block"),x.jsx(Og,{item:l,sortFields:c,collectionFields:s,fields:f,options:t,api:i}),o).open({initialValues:{}});e(Ag({sortField:d.dragSortBy,groupField:d.groupField.value,collectionName:l.name,dataSource:l.dataSource,params:{sort:[d.dragSortBy]}}))})}};function hb(){const{insert:e}=P.useSchemaInitializer(),{t:r}=Pn.useTranslation(),n=D.useContext(J.SchemaOptionsContext),{theme:t}=P.useGlobalTheme(),{getCollectionFields:o}=P.useCollectionManager_deprecated(),i=P.useAPIClient();return{createAssociationKanbanBlock:u=>ur(this,[u],function*({item:l}){var h,y;console.log(l);const s=l.associationField,f=o(l.name,l.dataSource),c=(h=f==null?void 0:f.filter(w=>["select","radioGroup"].includes(w.interface)))==null?void 0:h.map(w=>{var m;return{label:(m=w==null?void 0:w.uiSchema)==null?void 0:m.title,value:w.name,uiSchema:G(F({},w.uiSchema),{name:w.name})}}),d=(y=f==null?void 0:f.filter(w=>["sort"].includes(w.interface)))==null?void 0:y.map(w=>{var m;return{label:(m=w==null?void 0:w.uiSchema)==null?void 0:m.title,value:w.name,scopeKey:w.scopeKey,uiSchema:G(F({},w.uiSchema),{name:w.name})}}),p=yield P.FormDialog(r("Create kanban block"),x.jsx(Og,{item:l,sortFields:d,collectionFields:f,fields:c,options:n,api:i}),t).open({initialValues:{}});e(Ag({sortField:p.dragSortBy,groupField:p.groupField.value,association:`${s.collectionName}.${s.name}`,dataSource:l.dataSource,params:{sort:[p.dragSortBy]}}))})}}En.Card=ab,En.CardAdder=P.Action,En.CardViewer=db,En.Card.Designer=sb,En.Designer=fb;const yb=En,Bg=D.memo(e=>x.jsx(P.SchemaComponentOptions,{components:{Kanban:En,KanbanBlockProvider:OC,KanbanV2:yb,KanbanBlockInitializer:mb},scope:{useKanbanBlockProps:BC},children:e.children}));Bg.displayName="KanbanPluginProvider";class Sb extends P.Plugin{load(){return ur(this,null,function*(){this.app.use(Bg),this.app.schemaInitializerManager.add(Ig),this.app.schemaInitializerManager.add(cb),this.app.schemaInitializerManager.add(Ng),this.app.schemaInitializerManager.add(vb),this.app.schemaSettingsManager.add(pb);const r=this.app.schemaInitializerManager.get("page:addBlock");r==null||r.add("dataBlocks.kanban",{title:'{{t("Kanban")}}',Component:"KanbanBlockInitializer"}),this.app.schemaInitializerManager.addItem("popup:common:addBlock","dataBlocks.kanban",{title:'{{t("Kanban")}}',Component:"KanbanBlockInitializer",useComponentProps(){const{createAssociationKanbanBlock:n}=hb(),{createKanbanBlock:t}=Tg();return{onlyCurrentDataSource:!0,filterCollections({associationField:o}){return o?["hasMany","belongsToMany"].includes(o.type):!1},createBlockSchema:({item:o,fromOthersInPopup:i})=>{if(i)return t({item:o});n({item:o})},showAssociationFields:!0,hideSearch:!0}}})})}}$.default=Sb,Object.defineProperties($,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
309
|
+
`,Bs=D.memo(J.RecursionField);Bs.displayName="MemorizedRecursionField";const ab=()=>{var C;const e=P.useCollection(),{setDisableCardDrag:r}=D.useContext(As)||{},n=J.useFieldSchema(),{openPopup:t,getPopupSchemaFromSchema:o}=P.usePopupUtils(),i=P.useCollectionRecordData(),a=o(n)||lb(n),[l,u]=D.useState(!1),{isPopupVisibleControlledByURL:s}=P.usePopupSettings(),f=D.useCallback(b=>{const E=b.target;b.currentTarget.contains(E)&&(s()?t({popupUidUsedInURL:a==null?void 0:a["x-uid"]}):u(!0)),b.stopPropagation()},[t,a]),c=D.useMemo(()=>({cursor:"pointer",overflow:"hidden"}),[]),d=D.useMemo(()=>Ug.createForm({values:i}),[i]),p=D.useCallback(()=>{r==null||r(!0)},[r]),h=D.useCallback(()=>{r==null||r(!1)},[r]),y=D.useMemo(()=>({type:"void",properties:{drawer:a}}),[a]),w=(C=P.getCardItemSchema)==null?void 0:C.call(P,n),{layout:m="vertical",labelAlign:v="left",labelWidth:g=120,labelWrap:S=!0}=(w==null?void 0:w["x-component-props"])||{};return x.jsxs(x.Fragment,{children:[x.jsx(Re.Card,{onClick:f,bordered:!1,hoverable:!0,style:c,className:ib,children:x.jsx(P.DndContext,{onDragStart:p,onDragEnd:h,children:x.jsx(Fr.FormLayout,{layout:m,labelAlign:v,labelWidth:m==="horizontal"?g:null,labelWrap:S,children:x.jsx(P.FormProvider,{form:d,children:x.jsx(Bs,{schema:n,onlyRenderProperties:!0})})})})}),x.jsx(P.PopupContextProvider,{visible:l,setVisible:u,children:x.jsx(P.VariablePopupRecordProvider,{recordData:i,collection:e,children:x.jsx(Bs,{schema:y})})})]})};function lb(e){var n,t,o,i;return(i=(o=(t=(n=e.parent)==null?void 0:n.properties)==null?void 0:t.cardViewer)==null?void 0:o.properties)!=null&&i.drawer?e.parent.properties.cardViewer.properties.drawer:Eg(e["x-uid"],e.root).parent.properties.cardViewer.properties.drawer}function Eg(e,r,n={value:null}){return n=n||{value:null},r.mapProperties(t=>{t["x-uid"]===e?n.value=t:Eg(e,t,n)}),n.value}const ub=e=>(e["x-read-pretty"]=!0,{type:"void","x-component":"Grid.Row",properties:{[Po.uid()]:{type:"void","x-component":"Grid.Col",properties:{[e.name||Po.uid()]:e}}}}),sb=()=>{const{designable:e}=P.useDesignable(),{render:r}=P.useSchemaInitializerRender("kanban:configureItemFields");return e?x.jsx("div",{className:"general-schema-designer",children:x.jsx("div",{className:"general-schema-designer-icons",children:x.jsx(Re.Space,{size:2,align:"center",children:r()})})}):null},Pg={wrap:ub,useInsert(){const e=J.useFieldSchema(),{t:r}=Pn.useTranslation(),n=P.useAPIClient(),{refresh:t}=P.useDesignable();return o=>{const i=e.reduceProperties((l,u)=>u["x-component"]==="Grid"?u:l,null);if(!i)return;const a=P.createDesignable({t:r,api:n,refresh:t,current:i});a.loadAPIClientEvents(),a.insertBeforeEnd(o)}},Component:e=>{const{getAriaLabel:r}=P.useGetAriaLabelOfDesigner();return x.jsx(Gs.MenuOutlined,G(F({},e),{role:"button","aria-label":r("schema-initializer"),style:{cursor:"pointer",fontSize:12}}))},items:[{type:"itemGroup",title:'{{t("Display fields")}}',name:"displayFields",useChildren:P.useFormItemInitializerFields},{type:"itemGroup",divider:!0,title:'{{t("Display association fields")}}',name:"displayAssociationFields",hideIfNoChildren:!0,useChildren(){return P.useAssociatedFormItemInitializerFields({readPretty:!0,block:"Kanban"})}},{name:"divider",type:"divider"},{name:"openMode",Component:P.SchemaInitializerOpenModeSchemaItems,useComponentProps(){const{hideOpenMode:e}=P.useOpenModeContext();return{openMode:!e,openSize:!e}}}]},Ig=new P.CompatibleSchemaInitializer(F({name:"KanbanCardInitializers"},Pg)),cb=new P.CompatibleSchemaInitializer(F({name:"kanban:configureItemFields"},Pg),Ig),db=J.observer(e=>e.children,{displayName:"KanbanCardViewer"}),fb=()=>{const{name:e,title:r}=P.useCollection_deprecated(),n=P.useSchemaTemplate();return x.jsx(P.GeneralSchemaDesigner,{schemaSettings:"blockSettings:kanban",template:n,title:r||e})},pb=new P.SchemaSettings({name:"blockSettings:kanban",items:[{name:"title",Component:P.SchemaSettingsBlockTitleItem},{name:"setTheBlockHeight",Component:P.SchemaSettingsBlockHeightItem},{name:"dataScope",Component:P.SchemaSettingsDataScope,useComponentProps(){var a,l;const{name:e}=P.useCollection_deprecated(),r=J.useFieldSchema(),{form:n}=P.useFormBlockContext(),t=J.useField(),{service:o}=ya(),{dn:i}=P.useDesignable();return{collectionName:e,defaultFilter:((l=(a=r==null?void 0:r["x-decorator-props"])==null?void 0:a.params)==null?void 0:l.filter)||{},form:n,onSubmit:({filter:u})=>{var f;u=P.removeNullCondition(u);const s=t.decoratorProps.params||{};s.filter=u,t.decoratorProps.params=s,r["x-decorator-props"].params=s,o.run(G(F({},(f=o.params)==null?void 0:f[0]),{filter:u})),i.emit("patch",{schema:{"x-uid":r["x-uid"],"x-decorator-props":r["x-decorator-props"]}})}}}},{name:"template",Component:P.SchemaSettingsTemplate,useComponentProps(){const{name:e}=P.useCollection(),{componentNamePrefix:r}=P.useBlockTemplateContext();return{componentName:`${r}Kanban`,collectionName:e}}},{name:"allowDragAndDrop",type:"switch",useComponentProps:()=>{var o;const e=J.useField(),r=J.useFieldSchema(),{t:n}=Pn.useTranslation(),{dn:t}=P.useDesignable();return{title:n("Enable drag and drop sorting"),checked:((o=e.componentProps)==null?void 0:o.dragSort)!==!1,onChange:i=>ur(this,null,function*(){e.componentProps=e.componentProps||{},e.componentProps.dragSort=i,r["x-component-props"]=r["x-component-props"]||{},r["x-component-props"].dragSort=i,t.emit("patch",{schema:{"x-uid":r["x-uid"],"x-component-props":r["x-component-props"]}})})}}},{name:"setBlockLayout",Component:P.SchemaSettingsLayoutItem},{name:"divider",type:"divider"},{name:"remove",type:"remove",componentProps:{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}]}),kg={title:"{{t('Configure actions')}}",icon:"SettingOutlined",style:{marginLeft:8},items:[{name:"filter",title:"{{t('Filter')}}",Component:"FilterActionInitializer",schema:{"x-align":"left"}},{name:"addNew",title:"{{t('Add new')}}",Component:"CreateActionInitializer",schema:{"x-align":"right","x-decorator":"ACLActionProvider","x-acl-action-props":{skipScopeCheck:!0}},useVisible:()=>P.useActionAvailable("create")},{name:"customRequest",title:'{{t("Custom request")}}',Component:"CustomRequestInitializer",schema:{"x-action":"customize:table:request:global"}}]},Ng=new P.CompatibleSchemaInitializer(F({name:"KanbanActionInitializers"},kg)),vb=new P.CompatibleSchemaInitializer(F({name:"kanban:configureActions"},kg),Ng),xo="kanban",gb=e=>{const m=e,{sortFields:r,collectionFields:n,groupField:t,collectionName:o,dataSource:i}=m,a=Ea(m,["sortFields","collectionFields","groupField","collectionName","dataSource"]),l=J.useField(),u=P.useCompile(),s=P.useAPIClient(),{t:f}=Pn.useTranslation(),{theme:c}=P.useGlobalTheme(),d=D.useContext(J.SchemaOptionsContext),p=n==null?void 0:n.filter(v=>v.interface==="integer"),h=({scopeKey:v})=>{var C;const g=v&&n.find(b=>b.name===v),S=v&&u((C=g==null?void 0:g.uiSchema)==null?void 0:C.title);return x.jsxs("span",{style:{color:"rgba(0, 0, 0, 0.25)"},children:["(",S?f("Grouped sorting based on",{ns:xo})+`「${S}」`:f("Global sorting",{ns:xo}),")"]})},y=()=>ur(this,null,function*(){var S;const v=yield P.FormDialog(f("Create sort field"),()=>x.jsx(P.SchemaComponentOptions,{scope:d.scope,components:F({},d.components),children:x.jsx(Fr.FormLayout,{layout:"vertical",children:x.jsx(P.SchemaComponent,{schema:{properties:{"uiSchema.title":{type:"string",title:'{{t("Field display name")}}',required:!0,"x-decorator":"FormItem","x-component":"Input"},name:{type:"string",title:'{{t("Field name")}}',required:!0,"x-decorator":"FormItem","x-component":"Input","x-validator":"uid",description:"{{t('Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.')}}"},scopeKey:{type:"string",title:'{{t("Grouped sorting")}}',default:t.value,"x-disabled":!0,"x-decorator":"FormItem","x-component":"Select",enum:[t]}}}})})}),c).open({initialValues:{name:`f_${Po.uid()}`}}),{data:g}=yield s.resource("collections.fields",o).create({values:F({type:"sort",interface:"sort"},v)});l.dataSource=l.dataSource.concat([G(F({},g.data),{value:g.data.name,label:u((S=g.data.uiSchema)==null?void 0:S.title)})]),l.value=g.data.name}),w=()=>ur(this,null,function*(){var C;const v=yield P.FormDialog(f("Create sort field"),()=>x.jsx(P.SchemaComponentOptions,{scope:d.scope,components:F({},d.components),children:x.jsx(Fr.FormLayout,{layout:"vertical",children:x.jsx(P.SchemaComponent,{schema:{properties:{field:{type:"string",title:f("Convert the following integer fields to sorting fields",{ns:xo}),required:!0,"x-decorator":"FormItem","x-component":"Select",enum:p.map(b=>{var E;return{value:b.name,label:u(((E=b.uiSchema)==null?void 0:E.title)||b.name)}})},scopeKey:{type:"string",title:'{{t("Grouped sorting")}}',default:t.value,"x-disabled":!0,"x-decorator":"FormItem","x-component":"Select",enum:[t]}}}})})}),c).open({initialValues:{}}),{data:g}=yield s.request({url:`dataSourcesCollections/${i}.${o}/fields:update?filterByTk=${v.field}`,method:"post",data:F({type:"sort",interface:"sort"},v)}),S=g.data;l.dataSource=l.dataSource.concat([G(F({},S),{value:S.name,label:u((C=S.uiSchema)==null?void 0:C.title)})]),l.value=S.name});return x.jsxs(Re.Space.Compact,{style:{width:"100%"},children:[x.jsx(P.Select,G(F({options:r},a),{disabled:!t,optionRender:({label:v,data:g})=>x.jsxs(Re.Space,{children:[x.jsx("span",{children:v}),x.jsx(h,{scopeKey:g.scopeKey})]})})),x.jsx(Re.Button,{disabled:!t,onClick:i==="main"?y:w,children:f("Add new")})]})},Ag=e=>{const{collectionName:r,groupField:n,sortField:t,dataSource:o,params:i,association:a}=e,l={type:"void","x-acl-action":`${a||r}:list`,"x-decorator":"KanbanBlockProvider","x-decorator-props":{collection:r,dataSource:o,action:"list",groupField:n,sortField:t,params:F({paginate:!1},i)},"x-toolbar":"BlockSchemaToolbar","x-settings":"blockSettings:kanban","x-component":"CardItem",properties:{actions:{type:"void","x-initializer":"kanban:configureActions","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--nb-spacing)"}},properties:{}},[Po.uid()]:{type:"array","x-component":"Kanban","x-use-component-props":"useKanbanBlockProps",properties:{card:{type:"void","x-read-pretty":!0,"x-label-disabled":!0,"x-decorator":"BlockItem","x-component":"Kanban.Card","x-component-props":{openMode:"drawer"},"x-designer":"Kanban.Card.Designer",properties:{grid:{type:"void","x-component":"Grid","x-component-props":{dndContext:!1}}}},cardViewer:{type:"void",title:'{{ t("View") }}',"x-designer":"Action.Designer","x-component":"Kanban.CardViewer","x-action":"view","x-component-props":{openMode:"drawer"},properties:{drawer:{type:"void",title:'{{ t("View record") }}',"x-component":"Action.Container","x-component-props":{className:"nb-action-popup"},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"popup:addTab",properties:{tab1:{type:"void",title:'{{t("Details")}}',"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer","x-component-props":{},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"popup:common:addBlock",properties:{}}}}}}}}}}}}}};return a&&(l["x-decorator-props"].association=a),l},Og=({item:e,sortFields:r,collectionFields:n,fields:t,options:o,api:i})=>{const a=J.useForm(),{t:l}=Pn.useTranslation();return x.jsx(P.APIClientProvider,{apiClient:i,children:x.jsx(P.SchemaComponentOptions,{scope:F({},o==null?void 0:o.scope),components:F({},o==null?void 0:o.components),children:x.jsx(Fr.FormLayout,{layout:"vertical",children:x.jsx(P.SchemaComponent,{schema:{properties:{groupField:{title:l("Grouping field"),enum:t,required:!0,description:l("Single select and radio fields can be used as the grouping field"),"x-component":"Select","x-component-props":{objectValue:!0,fieldNames:{label:"label",value:"value"},onChange:()=>{a.setValuesIn("dragSortBy",null)}},"x-decorator":"FormItem"},dragSortBy:{title:l("Sorting field",{ns:xo}),required:!0,description:l("Used for sorting kanban cards, only sorting fields corresponding to grouping fields can be selected",{ns:xo}),"x-component":gb,"x-component-props":{objectValue:!0,fieldNames:{label:"label",value:"value"},sortFields:r},"x-decorator":"FormItem","x-reactions":[u=>{var s;u.dataSource=r.map(f=>{var c,d;return G(F({},f),{disabled:f.scopeKey!==((d=(c=u.form.values)==null?void 0:c.groupField)==null?void 0:d.value)})}),u.groupField=(s=u.form.values)==null?void 0:s.groupField,u.setComponentProps({dataSource:e.dataSource,collectionName:e.collectionName||e.name,collectionFields:n,sortFields:r})},{dependencies:[".groupField"],fulfill:{schema:{"x-component-props":"{{$form.values}}"}}}]}}}})})})})},mb=({filterCollections:e,onlyCurrentDataSource:r,hideSearch:n,createBlockSchema:t,showAssociationFields:o})=>{const i=P.useSchemaInitializerItem(),{createKanbanBlock:a}=Tg();return x.jsx(P.DataBlockInitializer,G(F({},i),{componentType:"Kanban",icon:x.jsx(Gs.ProjectOutlined,{}),onCreateBlockSchema:l=>ur(this,null,function*(){if(t)return t(l);a(l)}),onlyCurrentDataSource:r,hideSearch:n,filter:e,showAssociationFields:o}))},Tg=()=>{const{insert:e}=P.useSchemaInitializer(),{t:r}=Pn.useTranslation(),{getCollectionFields:n}=P.useCollectionManager_deprecated(),t=D.useContext(J.SchemaOptionsContext),{theme:o}=P.useGlobalTheme(),i=P.useAPIClient();return{createKanbanBlock:u=>ur(this,[u],function*({item:l}){var p,h;const s=n(l.name,l.dataSource),f=(p=s==null?void 0:s.filter(y=>["select","radioGroup"].includes(y.interface)))==null?void 0:p.map(y=>{var w;return{label:(w=y==null?void 0:y.uiSchema)==null?void 0:w.title,value:y.name,uiSchema:G(F({},y.uiSchema),{name:y.name})}}),c=(h=s==null?void 0:s.filter(y=>["sort"].includes(y.interface)))==null?void 0:h.map(y=>{var w;return{label:(w=y==null?void 0:y.uiSchema)==null?void 0:w.title,value:y.name,scopeKey:y.scopeKey,uiSchema:G(F({},y.uiSchema),{name:y.name})}}),d=yield P.FormDialog(r("Create kanban block"),x.jsx(Og,{item:l,sortFields:c,collectionFields:s,fields:f,options:t,api:i}),o).open({initialValues:{}});e(Ag({sortField:d.dragSortBy,groupField:d.groupField.value,collectionName:l.name,dataSource:l.dataSource,params:{sort:[d.dragSortBy]}}))})}};function hb(){const{insert:e}=P.useSchemaInitializer(),{t:r}=Pn.useTranslation(),n=D.useContext(J.SchemaOptionsContext),{theme:t}=P.useGlobalTheme(),{getCollectionFields:o}=P.useCollectionManager_deprecated(),i=P.useAPIClient();return{createAssociationKanbanBlock:u=>ur(this,[u],function*({item:l}){var h,y;console.log(l);const s=l.associationField,f=o(l.name,l.dataSource),c=(h=f==null?void 0:f.filter(w=>["select","radioGroup"].includes(w.interface)))==null?void 0:h.map(w=>{var m;return{label:(m=w==null?void 0:w.uiSchema)==null?void 0:m.title,value:w.name,uiSchema:G(F({},w.uiSchema),{name:w.name})}}),d=(y=f==null?void 0:f.filter(w=>["sort"].includes(w.interface)))==null?void 0:y.map(w=>{var m;return{label:(m=w==null?void 0:w.uiSchema)==null?void 0:m.title,value:w.name,scopeKey:w.scopeKey,uiSchema:G(F({},w.uiSchema),{name:w.name})}}),p=yield P.FormDialog(r("Create kanban block"),x.jsx(Og,{item:l,sortFields:d,collectionFields:f,fields:c,options:n,api:i}),t).open({initialValues:{}});e(Ag({sortField:p.dragSortBy,groupField:p.groupField.value,association:`${s.collectionName}.${s.name}`,dataSource:l.dataSource,params:{sort:[p.dragSortBy]}}))})}}En.Card=ab,En.CardAdder=P.Action,En.CardViewer=db,En.Card.Designer=sb,En.Designer=fb;const yb=En,Bg=D.memo(e=>x.jsx(P.SchemaComponentOptions,{components:{Kanban:En,KanbanBlockProvider:OC,KanbanV2:yb,KanbanBlockInitializer:mb},scope:{useKanbanBlockProps:BC},children:e.children}));Bg.displayName="KanbanPluginProvider";class Sb extends P.Plugin{load(){return ur(this,null,function*(){this.app.use(Bg),this.app.schemaInitializerManager.add(Ig),this.app.schemaInitializerManager.add(cb),this.app.schemaInitializerManager.add(Ng),this.app.schemaInitializerManager.add(vb),this.app.schemaSettingsManager.add(pb);const r=this.app.schemaInitializerManager.get("page:addBlock");r==null||r.add("dataBlocks.kanban",{title:'{{t("Kanban")}}',Component:"KanbanBlockInitializer"}),this.app.schemaInitializerManager.addItem("popup:common:addBlock","dataBlocks.kanban",{title:'{{t("Kanban")}}',Component:"KanbanBlockInitializer",useComponentProps(){const{createAssociationKanbanBlock:n}=hb(),{createKanbanBlock:t}=Tg();return{onlyCurrentDataSource:!0,filterCollections({associationField:o}){return o?["hasMany","belongsToMany"].includes(o.type):!1},createBlockSchema:({item:o,fromOthersInPopup:i})=>{if(i)return t({item:o});n({item:o})},showAssociationFields:!0,hideSearch:!0}}})})}}$.default=Sb,Object.defineProperties($,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/externalVersion.js
CHANGED
|
@@ -11,16 +11,16 @@ module.exports = {
|
|
|
11
11
|
"@ant-design/icons": "5.2.6",
|
|
12
12
|
"@formily/react": "2.3.0",
|
|
13
13
|
"@formily/shared": "2.3.2",
|
|
14
|
-
"@nocobase/client": "1.4.
|
|
14
|
+
"@nocobase/client": "1.4.1",
|
|
15
15
|
"antd": "5.12.8",
|
|
16
16
|
"react": "18.2.0",
|
|
17
17
|
"react-i18next": "11.18.6",
|
|
18
18
|
"@emotion/css": "11.13.0",
|
|
19
19
|
"@formily/antd-v5": "1.1.9",
|
|
20
20
|
"@formily/core": "2.3.0",
|
|
21
|
-
"@nocobase/utils": "1.4.
|
|
21
|
+
"@nocobase/utils": "1.4.1",
|
|
22
22
|
"lodash": "4.17.21",
|
|
23
|
-
"@nocobase/server": "1.4.
|
|
24
|
-
"@nocobase/test": "1.4.
|
|
23
|
+
"@nocobase/server": "1.4.1",
|
|
24
|
+
"@nocobase/test": "1.4.1",
|
|
25
25
|
"antd-style": "3.7.1"
|
|
26
26
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-kanban",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"main": "dist/server/index.js",
|
|
5
5
|
"homepage": "https://docs.nocobase.com/handbook/block-kanban",
|
|
6
6
|
"homepage.zh-CN": "https://docs-cn.nocobase.com/handbook/block-kanban",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"react-intersection-observer": "^9.8.1"
|
|
19
19
|
},
|
|
20
|
-
"gitHead": "
|
|
20
|
+
"gitHead": "db321e5213768ee9e357fbb55fc7120e2e308d6e",
|
|
21
21
|
"keywords": [
|
|
22
22
|
"Blocks"
|
|
23
23
|
]
|