@nocobase/plugin-kanban 1.0.0-alpha.11 → 1.0.0-alpha.13
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 +3 -3
- package/package.json +2 -2
package/dist/client/index.js
CHANGED
|
@@ -308,4 +308,4 @@ Error generating stack: `+i.message+`
|
|
|
308
308
|
color: #8c8c8c;
|
|
309
309
|
fontweight: normal;
|
|
310
310
|
}
|
|
311
|
-
`,Qs=D.memo(J.RecursionField);Qs.displayName="MemorizedRecursionField";const aI=J.observer(()=>{const{t:e}=oI(),r=I.useCollection(),{setDisableCardDrag:n,cardViewerSchema:t,card:o,cardField:i,columnIndex:a,cardIndex:l}=D.useContext(Vs),u=I.useCollectionParentRecordData(),s=J.useFieldSchema(),[f,c]=D.useState(!1),d=D.useCallback(g=>{const y=g.target;g.currentTarget.contains(y)&&c(!0),g.stopPropagation()},[]),p=D.useMemo(()=>({cursor:"pointer",overflow:"hidden"}),[]),h=D.useCallback(()=>{n(!0)},[]),S=D.useCallback(()=>{n(!1)},[]),C=D.useMemo(()=>{var g,y;return{openMode:((g=s["x-component-props"])==null?void 0:g.openMode)||"drawer",openSize:(y=s["x-component-props"])==null?void 0:y.openSize,visible:f,setVisible:c}},[s,f]),m=D.useMemo(()=>i.address.concat(`${a}.cards.${l}`),[i,a,l]),v=D.useMemo(()=>i.address.concat(`${a}.cardViewer.${l}`),[i,a,l]);return x.jsxs(x.Fragment,{children:[x.jsx(qe.Card,{onClick:d,bordered:!1,hoverable:!0,style:p,className:iI,children:x.jsx(I.DndContext,{onDragStart:h,onDragEnd:S,children:x.jsx(Fr.FormLayout,{layout:"vertical",children:x.jsx(Qs,{basePath:m,schema:s,onlyRenderProperties:!0})})})}),t&&x.jsx(I.ActionContextProvider,{value:C,children:x.jsx(I.RecordProvider,{record:o,parent:u,children:x.jsx(I.DeclareVariable,{name:"$nPopupRecord",title:e("Current popup record"),value:o,collection:r,children:x.jsx(Qs,{basePath:v,schema:t,onlyRenderProperties:!0})})})})]})},{displayName:"KanbanCard"}),Xg=e=>(e["x-read-pretty"]=!0,{type:"void","x-component":"Grid.Row",properties:{[No.uid()]:{type:"void","x-component":"Grid.Col",properties:{[e.name||No.uid()]:e}}}}),lI=()=>{const{designable:e}=I.useDesignable(),{render:r}=I.useSchemaInitializerRender("kanban:configureItemFields");return e?x.jsx("div",{className:"general-schema-designer",children:x.jsx("div",{className:"general-schema-designer-icons",children:x.jsx(qe.Space,{size:2,align:"center",children:r()})})}):null},Jg=new I.CompatibleSchemaInitializer({name:"KanbanCardInitializers",wrap:Xg,useInsert(){const e=J.useFieldSchema(),{t:r}=un.useTranslation(),n=I.useAPIClient(),{refresh:t}=I.useDesignable();return o=>{const i=e.reduceProperties((l,u)=>u["x-component"]==="Grid"?u:l,null);if(!i)return;const a=I.createDesignable({t:r,api:n,refresh:t,current:i});a.loadAPIClientEvents(),a.insertBeforeEnd(o)}},Component:e=>{const{getAriaLabel:r}=I.useGetAriaLabelOfDesigner();return x.jsx(La.MenuOutlined,$(F({},e),{role:"button","aria-label":r("schema-initializer"),style:{cursor:"pointer",fontSize:12}}))},items:[{type:"itemGroup",title:'{{t("Display fields")}}',name:"displayFields",useChildren:I.useFormItemInitializerFields},{type:"itemGroup",divider:!0,title:'{{t("Display association fields")}}',name:"displayAssociationFields",hideIfNoChildren:!0,useChildren(){return I.useAssociatedFormItemInitializerFields({readPretty:!0,block:"Kanban"})}},{name:"divider",type:"divider"},{name:"openMode",Component:I.SchemaInitializerOpenModeSchemaItems}]}),uI=new I.CompatibleSchemaInitializer({name:"kanban:configureItemFields",wrap:Xg,useInsert(){const e=J.useFieldSchema(),{t:r}=un.useTranslation(),n=I.useAPIClient(),{refresh:t}=I.useDesignable();return o=>{const i=e.reduceProperties((l,u)=>u["x-component"]==="Grid"?u:l,null);if(!i)return;const a=I.createDesignable({t:r,api:n,refresh:t,current:i});a.loadAPIClientEvents(),a.insertBeforeEnd(o)}},Component:e=>{const{getAriaLabel:r}=I.useGetAriaLabelOfDesigner();return x.jsx(La.MenuOutlined,$(F({},e),{role:"button","aria-label":r("schema-initializer"),style:{cursor:"pointer",fontSize:12}}))},items:[{type:"itemGroup",title:'{{t("Display fields")}}',name:"displayFields",useChildren:I.useFormItemInitializerFields},{type:"itemGroup",divider:!0,title:'{{t("Display association fields")}}',name:"displayAssociationFields",hideIfNoChildren:!0,useChildren(){return I.useAssociatedFormItemInitializerFields({readPretty:!0,block:"Kanban"})}},{name:"divider",type:"divider"},{name:"openMode",Component:I.SchemaInitializerOpenModeSchemaItems}]},Jg),sI=J.observer(e=>e.children,{displayName:"KanbanCardViewer"}),cI=()=>{const{name:e,title:r}=I.useCollection_deprecated(),n=I.useSchemaTemplate();return x.jsx(I.GeneralSchemaDesigner,{schemaSettings:"blockSettings:kanban",template:n,title:r||e})},dI=new I.SchemaSettings({name:"blockSettings:kanban",items:[{name:"title",Component:I.SchemaSettingsBlockTitleItem},{name:"dataScope",Component:I.SchemaSettingsDataScope,useComponentProps(){var a,l;const{name:e}=I.useCollection_deprecated(),r=J.useFieldSchema(),{form:n}=I.useFormBlockContext(),t=J.useField(),{service:o}=Pa(),{dn:i}=I.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=I.removeNullCondition(u);const s=t.decoratorProps.params||{};s.filter=u,t.decoratorProps.params=s,r["x-decorator-props"].params=s,o.run($(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:"fixedBlock",Component:I.FixedBlockDesignerItem},{name:"template",Component:I.SchemaSettingsTemplate,useComponentProps(){const{name:e}=I.useCollection_deprecated();return{componentName:"Kanban",collectionName:e}}},{name:"divider",type:"divider"},{name:"remove",type:"remove",componentProps:{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}]}),Zg=new I.CompatibleSchemaInitializer({name:"KanbanActionInitializers",title:"{{t('Configure actions')}}",icon:"SettingOutlined",style:{marginLeft:8},items:[{type:"itemGroup",title:"{{t('Enable actions')}}",name:"enableActions",children:[{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(){const e=I.useCollection_deprecated();return e.template!=="view"||(e==null?void 0:e.writableView)}}]}]}),fI=new I.CompatibleSchemaInitializer({name:"kanban:configureActions",title:"{{t('Configure actions')}}",icon:"SettingOutlined",style:{marginLeft:8},items:[{type:"itemGroup",title:"{{t('Enable actions')}}",name:"enableActions",children:[{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(){const e=I.useCollection_deprecated();return e.template!=="view"||(e==null?void 0:e.writableView)}}]}]},Zg),em=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:{}},[No.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},pI=e=>{const m=e,{sortFields:r,collectionFields:n,groupField:t,collectionName:o,dataSource:i}=m,a=Ma(m,["sortFields","collectionFields","groupField","collectionName","dataSource"]),l=J.useField(),u=I.useCompile(),s=I.useAPIClient(),{t:f}=un.useTranslation(),{theme:c}=I.useGlobalTheme(),d=D.useContext(J.SchemaOptionsContext),p=n==null?void 0:n.filter(v=>v.interface==="integer"),h=({scopeKey:v})=>{var w;const g=v&&n.find(b=>b.name===v),y=v&&u((w=g.uiSchema)==null?void 0:w.title);return x.jsxs("span",{style:{color:"rgba(0, 0, 0, 0.25)"},children:["(",y?f("Grouped sorting based on",{ns:ft})+`「${y}」`:f("Global sorting",{ns:ft}),")"]})},S=()=>hr(this,null,function*(){var y;const v=yield I.FormDialog(f("Create sort field"),()=>x.jsx(I.SchemaComponentOptions,{scope:d.scope,components:F({},d.components),children:x.jsx(Fr.FormLayout,{layout:"vertical",children:x.jsx(I.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_${No.uid()}`}}),{data:g}=yield s.resource("collections.fields",o).create({values:F({type:"sort",interface:"sort"},v)});l.dataSource=l.dataSource.concat([$(F({},g.data),{value:g.data.name,label:u((y=g.data.uiSchema)==null?void 0:y.title)})]),l.value=g.data.name}),C=()=>hr(this,null,function*(){var w;const v=yield I.FormDialog(f("Create sort field"),()=>x.jsx(I.SchemaComponentOptions,{scope:d.scope,components:F({},d.components),children:x.jsx(Fr.FormLayout,{layout:"vertical",children:x.jsx(I.SchemaComponent,{schema:{properties:{field:{type:"string",title:f("Convert the following integer fields to sorting fields",{ns:ft}),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)}),y=g.data;l.dataSource=l.dataSource.concat([$(F({},y),{value:y.name,label:u((w=y.uiSchema)==null?void 0:w.title)})]),l.value=y.name});return x.jsxs(qe.Space.Compact,{style:{width:"100%"},children:[x.jsx(I.Select,$(F({options:r},a),{disabled:!t,optionRender:({label:v,data:g})=>x.jsxs(qe.Space,{children:[x.jsx("span",{children:v}),x.jsx(h,{scopeKey:g.scopeKey})]})})),x.jsx(qe.Button,{disabled:!t,onClick:i==="main"?S:C,children:f("Add new")})]})},rm=({item:e,sortFields:r,collectionFields:n,fields:t,options:o,api:i})=>{const a=J.useForm(),{t:l}=un.useTranslation();return x.jsx(I.APIClientProvider,{apiClient:i,children:x.jsx(I.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(I.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:ft}),required:!0,description:l("Used for sorting kanban cards, only sorting fields corresponding to grouping fields can be selected",{ns:ft}),"x-component":pI,"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 $(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}}"}}}]}}}})})})})},vI=({filterCollections:e,onlyCurrentDataSource:r,hideSearch:n,createBlockSchema:t,showAssociationFields:o})=>{const i=I.useSchemaInitializerItem(),{createKanbanBlock:a}=nm();return x.jsx(I.DataBlockInitializer,$(F({},i),{componentType:"Calendar",icon:x.jsx(La.FormOutlined,{}),onCreateBlockSchema:l=>hr(this,null,function*(){if(t)return t(l);a(l)}),onlyCurrentDataSource:r,hideSearch:n,filter:e,showAssociationFields:o}))},nm=()=>{const{insert:e}=I.useSchemaInitializer(),{t:r}=un.useTranslation(),{getCollectionFields:n}=I.useCollectionManager_deprecated(),t=D.useContext(J.SchemaOptionsContext),{theme:o}=I.useGlobalTheme(),i=I.useAPIClient();return{createKanbanBlock:u=>hr(this,[u],function*({item:l}){var p,h;console.log(l);const s=n(l.name,l.dataSource),f=(p=s==null?void 0:s.filter(S=>["select","radioGroup"].includes(S.interface)))==null?void 0:p.map(S=>{var C;return{label:(C=S==null?void 0:S.uiSchema)==null?void 0:C.title,value:S.name,uiSchema:$(F({},S.uiSchema),{name:S.name})}}),c=(h=s==null?void 0:s.filter(S=>["sort"].includes(S.interface)))==null?void 0:h.map(S=>{var C;return{label:(C=S==null?void 0:S.uiSchema)==null?void 0:C.title,value:S.name,scopeKey:S.scopeKey,uiSchema:$(F({},S.uiSchema),{name:S.name})}}),d=yield I.FormDialog(r("Create kanban block"),x.jsx(rm,{item:l,sortFields:c,collectionFields:s,fields:f,options:t,api:i}),o).open({initialValues:{}});e(em({sortField:d.dragSortBy,groupField:d.groupField.value,collectionName:l.name,dataSource:l.dataSource,params:{sort:[d.dragSortBy]}}))})}};function gI(){const{insert:e}=I.useSchemaInitializer(),{t:r}=un.useTranslation(),n=D.useContext(J.SchemaOptionsContext),{theme:t}=I.useGlobalTheme(),{getCollectionFields:o}=I.useCollectionManager_deprecated(),i=I.useAPIClient();return{createAssociationKanbanBlock:u=>hr(this,[u],function*({item:l}){var h,S;console.log(l);const s=l.associationField,f=o(l.name,l.dataSource),c=(h=f==null?void 0:f.filter(C=>["select","radioGroup"].includes(C.interface)))==null?void 0:h.map(C=>{var m;return{label:(m=C==null?void 0:C.uiSchema)==null?void 0:m.title,value:C.name,uiSchema:$(F({},C.uiSchema),{name:C.name})}}),d=(S=f==null?void 0:f.filter(C=>["sort"].includes(C.interface)))==null?void 0:S.map(C=>{var m;return{label:(m=C==null?void 0:C.uiSchema)==null?void 0:m.title,value:C.name,scopeKey:C.scopeKey,uiSchema:$(F({},C.uiSchema),{name:C.name})}}),p=yield I.FormDialog(r("Create kanban block"),x.jsx(rm,{item:l,sortFields:d,collectionFields:f,fields:c,options:n,api:i}),t).open({initialValues:{}});e(em({sortField:p.dragSortBy,groupField:p.groupField.value,association:`${s.collectionName}.${s.name}`,dataSource:l.dataSource,params:{sort:[p.dragSortBy]}}))})}}In.Card=aI,In.CardAdder=I.Action,In.CardViewer=sI,In.Card.Designer=lI,In.Designer=cI;const mI=In,tm=D.memo(e=>x.jsx(I.SchemaComponentOptions,{components:{Kanban:In,KanbanBlockProvider:TE,KanbanV2:mI,KanbanBlockInitializer:vI},scope:{useKanbanBlockProps:ME},children:e.children}));tm.displayName="KanbanPluginProvider";class hI extends I.Plugin{load(){return hr(this,null,function*(){this.app.use(tm),this.app.schemaInitializerManager.add(Jg),this.app.schemaInitializerManager.add(uI),this.app.schemaInitializerManager.add(Zg),this.app.schemaInitializerManager.add(fI),this.app.schemaSettingsManager.add(dI);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}=gI(),{createKanbanBlock:t}=nm();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}}})})}}j.default=hI,Object.defineProperties(j,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
311
|
+
`,Qs=D.memo(J.RecursionField);Qs.displayName="MemorizedRecursionField";const aI=J.observer(()=>{const{t:e}=oI(),r=I.useCollection(),{setDisableCardDrag:n,cardViewerSchema:t,card:o,cardField:i,columnIndex:a,cardIndex:l}=D.useContext(Vs),u=I.useCollectionParentRecordData(),s=J.useFieldSchema(),[f,c]=D.useState(!1),d=D.useCallback(g=>{const y=g.target;g.currentTarget.contains(y)&&c(!0),g.stopPropagation()},[]),p=D.useMemo(()=>({cursor:"pointer",overflow:"hidden"}),[]),h=D.useCallback(()=>{n(!0)},[]),S=D.useCallback(()=>{n(!1)},[]),C=D.useMemo(()=>{var g,y;return{openMode:((g=s["x-component-props"])==null?void 0:g.openMode)||"drawer",openSize:(y=s["x-component-props"])==null?void 0:y.openSize,visible:f,setVisible:c}},[s,f]),m=D.useMemo(()=>i.address.concat(`${a}.cards.${l}`),[i,a,l]),v=D.useMemo(()=>i.address.concat(`${a}.cardViewer.${l}`),[i,a,l]);return x.jsxs(x.Fragment,{children:[x.jsx(qe.Card,{onClick:d,bordered:!1,hoverable:!0,style:p,className:iI,children:x.jsx(I.DndContext,{onDragStart:h,onDragEnd:S,children:x.jsx(Fr.FormLayout,{layout:"vertical",children:x.jsx(Qs,{basePath:m,schema:s,onlyRenderProperties:!0})})})}),t&&x.jsx(I.ActionContextProvider,{value:C,children:x.jsx(I.RecordProvider,{record:o,parent:u,children:x.jsx(I.DeclareVariable,{name:"$nPopupRecord",title:e("Current popup record"),value:o,collection:r,children:x.jsx(Qs,{basePath:v,schema:t,onlyRenderProperties:!0})})})})]})},{displayName:"KanbanCard"}),Xg=e=>(e["x-read-pretty"]=!0,{type:"void","x-component":"Grid.Row",properties:{[No.uid()]:{type:"void","x-component":"Grid.Col",properties:{[e.name||No.uid()]:e}}}}),lI=()=>{const{designable:e}=I.useDesignable(),{render:r}=I.useSchemaInitializerRender("kanban:configureItemFields");return e?x.jsx("div",{className:"general-schema-designer",children:x.jsx("div",{className:"general-schema-designer-icons",children:x.jsx(qe.Space,{size:2,align:"center",children:r()})})}):null},Jg=new I.CompatibleSchemaInitializer({name:"KanbanCardInitializers",wrap:Xg,useInsert(){const e=J.useFieldSchema(),{t:r}=un.useTranslation(),n=I.useAPIClient(),{refresh:t}=I.useDesignable();return o=>{const i=e.reduceProperties((l,u)=>u["x-component"]==="Grid"?u:l,null);if(!i)return;const a=I.createDesignable({t:r,api:n,refresh:t,current:i});a.loadAPIClientEvents(),a.insertBeforeEnd(o)}},Component:e=>{const{getAriaLabel:r}=I.useGetAriaLabelOfDesigner();return x.jsx(La.MenuOutlined,$(F({},e),{role:"button","aria-label":r("schema-initializer"),style:{cursor:"pointer",fontSize:12}}))},items:[{type:"itemGroup",title:'{{t("Display fields")}}',name:"displayFields",useChildren:I.useFormItemInitializerFields},{type:"itemGroup",divider:!0,title:'{{t("Display association fields")}}',name:"displayAssociationFields",hideIfNoChildren:!0,useChildren(){return I.useAssociatedFormItemInitializerFields({readPretty:!0,block:"Kanban"})}},{name:"divider",type:"divider"},{name:"openMode",Component:I.SchemaInitializerOpenModeSchemaItems}]}),uI=new I.CompatibleSchemaInitializer({name:"kanban:configureItemFields",wrap:Xg,useInsert(){const e=J.useFieldSchema(),{t:r}=un.useTranslation(),n=I.useAPIClient(),{refresh:t}=I.useDesignable();return o=>{const i=e.reduceProperties((l,u)=>u["x-component"]==="Grid"?u:l,null);if(!i)return;const a=I.createDesignable({t:r,api:n,refresh:t,current:i});a.loadAPIClientEvents(),a.insertBeforeEnd(o)}},Component:e=>{const{getAriaLabel:r}=I.useGetAriaLabelOfDesigner();return x.jsx(La.MenuOutlined,$(F({},e),{role:"button","aria-label":r("schema-initializer"),style:{cursor:"pointer",fontSize:12}}))},items:[{type:"itemGroup",title:'{{t("Display fields")}}',name:"displayFields",useChildren:I.useFormItemInitializerFields},{type:"itemGroup",divider:!0,title:'{{t("Display association fields")}}',name:"displayAssociationFields",hideIfNoChildren:!0,useChildren(){return I.useAssociatedFormItemInitializerFields({readPretty:!0,block:"Kanban"})}},{name:"divider",type:"divider"},{name:"openMode",Component:I.SchemaInitializerOpenModeSchemaItems}]},Jg),sI=J.observer(e=>e.children,{displayName:"KanbanCardViewer"}),cI=()=>{const{name:e,title:r}=I.useCollection_deprecated(),n=I.useSchemaTemplate();return x.jsx(I.GeneralSchemaDesigner,{schemaSettings:"blockSettings:kanban",template:n,title:r||e})},dI=new I.SchemaSettings({name:"blockSettings:kanban",items:[{name:"title",Component:I.SchemaSettingsBlockTitleItem},{name:"dataScope",Component:I.SchemaSettingsDataScope,useComponentProps(){var a,l;const{name:e}=I.useCollection_deprecated(),r=J.useFieldSchema(),{form:n}=I.useFormBlockContext(),t=J.useField(),{service:o}=Pa(),{dn:i}=I.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=I.removeNullCondition(u);const s=t.decoratorProps.params||{};s.filter=u,t.decoratorProps.params=s,r["x-decorator-props"].params=s,o.run($(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:"fixedBlock",Component:I.FixedBlockDesignerItem},{name:"template",Component:I.SchemaSettingsTemplate,useComponentProps(){const{name:e}=I.useCollection_deprecated();return{componentName:"Kanban",collectionName:e}}},{name:"divider",type:"divider"},{name:"remove",type:"remove",componentProps:{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}]}),Zg=new I.CompatibleSchemaInitializer({name:"KanbanActionInitializers",title:"{{t('Configure actions')}}",icon:"SettingOutlined",style:{marginLeft:8},items:[{type:"itemGroup",title:"{{t('Enable actions')}}",name:"enableActions",children:[{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(){const e=I.useCollection_deprecated();return e.template!=="view"||(e==null?void 0:e.writableView)}}]}]}),fI=new I.CompatibleSchemaInitializer({name:"kanban:configureActions",title:"{{t('Configure actions')}}",icon:"SettingOutlined",style:{marginLeft:8},items:[{type:"itemGroup",title:"{{t('Enable actions')}}",name:"enableActions",children:[{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(){const e=I.useCollection_deprecated();return e.template!=="view"||(e==null?void 0:e.writableView)}}]}]},Zg),em=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:{}},[No.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},pI=e=>{const m=e,{sortFields:r,collectionFields:n,groupField:t,collectionName:o,dataSource:i}=m,a=Ma(m,["sortFields","collectionFields","groupField","collectionName","dataSource"]),l=J.useField(),u=I.useCompile(),s=I.useAPIClient(),{t:f}=un.useTranslation(),{theme:c}=I.useGlobalTheme(),d=D.useContext(J.SchemaOptionsContext),p=n==null?void 0:n.filter(v=>v.interface==="integer"),h=({scopeKey:v})=>{var w;const g=v&&n.find(b=>b.name===v),y=v&&u((w=g==null?void 0:g.uiSchema)==null?void 0:w.title);return x.jsxs("span",{style:{color:"rgba(0, 0, 0, 0.25)"},children:["(",y?f("Grouped sorting based on",{ns:ft})+`「${y}」`:f("Global sorting",{ns:ft}),")"]})},S=()=>hr(this,null,function*(){var y;const v=yield I.FormDialog(f("Create sort field"),()=>x.jsx(I.SchemaComponentOptions,{scope:d.scope,components:F({},d.components),children:x.jsx(Fr.FormLayout,{layout:"vertical",children:x.jsx(I.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_${No.uid()}`}}),{data:g}=yield s.resource("collections.fields",o).create({values:F({type:"sort",interface:"sort"},v)});l.dataSource=l.dataSource.concat([$(F({},g.data),{value:g.data.name,label:u((y=g.data.uiSchema)==null?void 0:y.title)})]),l.value=g.data.name}),C=()=>hr(this,null,function*(){var w;const v=yield I.FormDialog(f("Create sort field"),()=>x.jsx(I.SchemaComponentOptions,{scope:d.scope,components:F({},d.components),children:x.jsx(Fr.FormLayout,{layout:"vertical",children:x.jsx(I.SchemaComponent,{schema:{properties:{field:{type:"string",title:f("Convert the following integer fields to sorting fields",{ns:ft}),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)}),y=g.data;l.dataSource=l.dataSource.concat([$(F({},y),{value:y.name,label:u((w=y.uiSchema)==null?void 0:w.title)})]),l.value=y.name});return x.jsxs(qe.Space.Compact,{style:{width:"100%"},children:[x.jsx(I.Select,$(F({options:r},a),{disabled:!t,optionRender:({label:v,data:g})=>x.jsxs(qe.Space,{children:[x.jsx("span",{children:v}),x.jsx(h,{scopeKey:g.scopeKey})]})})),x.jsx(qe.Button,{disabled:!t,onClick:i==="main"?S:C,children:f("Add new")})]})},rm=({item:e,sortFields:r,collectionFields:n,fields:t,options:o,api:i})=>{const a=J.useForm(),{t:l}=un.useTranslation();return x.jsx(I.APIClientProvider,{apiClient:i,children:x.jsx(I.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(I.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:ft}),required:!0,description:l("Used for sorting kanban cards, only sorting fields corresponding to grouping fields can be selected",{ns:ft}),"x-component":pI,"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 $(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}}"}}}]}}}})})})})},vI=({filterCollections:e,onlyCurrentDataSource:r,hideSearch:n,createBlockSchema:t,showAssociationFields:o})=>{const i=I.useSchemaInitializerItem(),{createKanbanBlock:a}=nm();return x.jsx(I.DataBlockInitializer,$(F({},i),{componentType:"Calendar",icon:x.jsx(La.FormOutlined,{}),onCreateBlockSchema:l=>hr(this,null,function*(){if(t)return t(l);a(l)}),onlyCurrentDataSource:r,hideSearch:n,filter:e,showAssociationFields:o}))},nm=()=>{const{insert:e}=I.useSchemaInitializer(),{t:r}=un.useTranslation(),{getCollectionFields:n}=I.useCollectionManager_deprecated(),t=D.useContext(J.SchemaOptionsContext),{theme:o}=I.useGlobalTheme(),i=I.useAPIClient();return{createKanbanBlock:u=>hr(this,[u],function*({item:l}){var p,h;console.log(l);const s=n(l.name,l.dataSource),f=(p=s==null?void 0:s.filter(S=>["select","radioGroup"].includes(S.interface)))==null?void 0:p.map(S=>{var C;return{label:(C=S==null?void 0:S.uiSchema)==null?void 0:C.title,value:S.name,uiSchema:$(F({},S.uiSchema),{name:S.name})}}),c=(h=s==null?void 0:s.filter(S=>["sort"].includes(S.interface)))==null?void 0:h.map(S=>{var C;return{label:(C=S==null?void 0:S.uiSchema)==null?void 0:C.title,value:S.name,scopeKey:S.scopeKey,uiSchema:$(F({},S.uiSchema),{name:S.name})}}),d=yield I.FormDialog(r("Create kanban block"),x.jsx(rm,{item:l,sortFields:c,collectionFields:s,fields:f,options:t,api:i}),o).open({initialValues:{}});e(em({sortField:d.dragSortBy,groupField:d.groupField.value,collectionName:l.name,dataSource:l.dataSource,params:{sort:[d.dragSortBy]}}))})}};function gI(){const{insert:e}=I.useSchemaInitializer(),{t:r}=un.useTranslation(),n=D.useContext(J.SchemaOptionsContext),{theme:t}=I.useGlobalTheme(),{getCollectionFields:o}=I.useCollectionManager_deprecated(),i=I.useAPIClient();return{createAssociationKanbanBlock:u=>hr(this,[u],function*({item:l}){var h,S;console.log(l);const s=l.associationField,f=o(l.name,l.dataSource),c=(h=f==null?void 0:f.filter(C=>["select","radioGroup"].includes(C.interface)))==null?void 0:h.map(C=>{var m;return{label:(m=C==null?void 0:C.uiSchema)==null?void 0:m.title,value:C.name,uiSchema:$(F({},C.uiSchema),{name:C.name})}}),d=(S=f==null?void 0:f.filter(C=>["sort"].includes(C.interface)))==null?void 0:S.map(C=>{var m;return{label:(m=C==null?void 0:C.uiSchema)==null?void 0:m.title,value:C.name,scopeKey:C.scopeKey,uiSchema:$(F({},C.uiSchema),{name:C.name})}}),p=yield I.FormDialog(r("Create kanban block"),x.jsx(rm,{item:l,sortFields:d,collectionFields:f,fields:c,options:n,api:i}),t).open({initialValues:{}});e(em({sortField:p.dragSortBy,groupField:p.groupField.value,association:`${s.collectionName}.${s.name}`,dataSource:l.dataSource,params:{sort:[p.dragSortBy]}}))})}}In.Card=aI,In.CardAdder=I.Action,In.CardViewer=sI,In.Card.Designer=lI,In.Designer=cI;const mI=In,tm=D.memo(e=>x.jsx(I.SchemaComponentOptions,{components:{Kanban:In,KanbanBlockProvider:TE,KanbanV2:mI,KanbanBlockInitializer:vI},scope:{useKanbanBlockProps:ME},children:e.children}));tm.displayName="KanbanPluginProvider";class hI extends I.Plugin{load(){return hr(this,null,function*(){this.app.use(tm),this.app.schemaInitializerManager.add(Jg),this.app.schemaInitializerManager.add(uI),this.app.schemaInitializerManager.add(Zg),this.app.schemaInitializerManager.add(fI),this.app.schemaSettingsManager.add(dI);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}=gI(),{createKanbanBlock:t}=nm();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}}})})}}j.default=hI,Object.defineProperties(j,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/externalVersion.js
CHANGED
|
@@ -11,7 +11,7 @@ module.exports = {
|
|
|
11
11
|
"@ant-design/icons": "5.2.6",
|
|
12
12
|
"@formily/react": "2.3.0",
|
|
13
13
|
"@formily/shared": "2.3.0",
|
|
14
|
-
"@nocobase/client": "1.0.0-alpha.
|
|
14
|
+
"@nocobase/client": "1.0.0-alpha.13",
|
|
15
15
|
"antd": "5.12.8",
|
|
16
16
|
"react": "18.2.0",
|
|
17
17
|
"react-i18next": "11.18.6",
|
|
@@ -19,7 +19,7 @@ module.exports = {
|
|
|
19
19
|
"@formily/antd-v5": "1.1.9",
|
|
20
20
|
"@formily/core": "2.3.0",
|
|
21
21
|
"lodash": "4.17.21",
|
|
22
|
-
"@nocobase/server": "1.0.0-alpha.
|
|
23
|
-
"@nocobase/test": "1.0.0-alpha.
|
|
22
|
+
"@nocobase/server": "1.0.0-alpha.13",
|
|
23
|
+
"@nocobase/test": "1.0.0-alpha.13",
|
|
24
24
|
"antd-style": "3.4.5"
|
|
25
25
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-kanban",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.13",
|
|
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
|
"dependencies": {
|
|
18
18
|
"react-intersection-observer": "^9.8.1"
|
|
19
19
|
},
|
|
20
|
-
"gitHead": "
|
|
20
|
+
"gitHead": "bd97adef70762a6691b5b58ca6572672a8cdf838",
|
|
21
21
|
"keywords": [
|
|
22
22
|
"Blocks"
|
|
23
23
|
]
|