@tachybase/module-user 1.6.32 → 1.6.34
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 +2 -2
- package/dist/externalVersion.js +2 -2
- package/package.json +4 -4
package/dist/client/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
(function(a,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@tachybase/client"),require("@tachybase/module-acl/client"),require("react/jsx-runtime"),require("react"),require("@tachybase/schema"),require("antd"),require("react-i18next"),require("@tego/client")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","@tachybase/module-acl/client","react/jsx-runtime","react","@tachybase/schema","antd","react-i18next","@tego/client"],e):(a=typeof globalThis!="undefined"?globalThis:a||self,e(a["@tachybase/module-user"]={},a["@tachybase/client"],a["@tachybase/module-acl"],a.jsxRuntime,a.react,a["@tachybase/schema"],a.antd,a["react-i18next"],a["@tego/client"]))})(this,function(a,e,i,r,d,x,y,w,h){"use strict";var xe=Object.defineProperty,ye=Object.defineProperties;var Ce=Object.getOwnPropertyDescriptors;var P=Object.getOwnPropertySymbols;var M=Object.prototype.hasOwnProperty,q=Object.prototype.propertyIsEnumerable;var E=(a,e,i)=>e in a?xe(a,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):a[e]=i,f=(a,e)=>{for(var i in e||(e={}))M.call(e,i)&&E(a,i,e[i]);if(P)for(var i of P(e))q.call(e,i)&&E(a,i,e[i]);return a},b=(a,e)=>ye(a,Ce(e));var N=(a,e)=>{var i={};for(var r in a)M.call(a,r)&&e.indexOf(r)<0&&(i[r]=a[r]);if(a!=null&&P)for(var r of P(a))e.indexOf(r)<0&&q.call(a,r)&&(i[r]=a[r]);return i};var F=(a,e,i)=>new Promise((r,d)=>{var x=h=>{try{w(i.next(h))}catch(C){d(C)}},y=h=>{try{w(i.throw(h))}catch(C){d(C)}},w=h=>h.done?r(h.value):Promise.resolve(h.value).then(x,y);w((i=i.apply(a,e)).next())});function C(){return w.useTranslation(["user","core"],{nsMode:"fallback"})}const S={name:"users",fields:[{name:"id",type:"bigInt",autoIncrement:!0,primaryKey:!0,allowNull:!1,uiSchema:{type:"number",title:'{{t("ID")}}',"x-component":"InputNumber","x-read-pretty":!0},interface:"id"},{interface:"input",type:"string",name:"nickname",uiSchema:{type:"string",title:'{{t("Nickname")}}',"x-component":"Input"}},{interface:"input",type:"string",name:"username",unique:!0,uiSchema:{type:"string",title:'{{t("Username")}}',"x-component":"Input","x-validator":{username:!0},required:!0}},{interface:"email",type:"string",name:"email",unique:!0,uiSchema:{type:"string",title:'{{t("Email")}}',"x-component":"Input","x-validator":"email",required:!0}},{interface:"phone",type:"string",name:"phone",unique:!0,uiSchema:{type:"string",title:'{{t("Phone")}}',"x-component":"Input","x-validator":"phone",required:!0}},{interface:"password",type:"password",name:"password",hidden:!0,uiSchema:{type:"string",title:'{{t("Password")}}',"x-component":"Password"}},{interface:"m2m",type:"belongsToMany",name:"roles",target:"roles",foreignKey:"userId",otherKey:"roleName",onDelete:"CASCADE",sourceKey:"id",targetKey:"name",through:"rolesUsers",uiSchema:{type:"array",title:'{{t("Roles")}}',"x-component":"AssociationField","x-component-props":{multiple:!0,fieldNames:{label:"title",value:"name"}}}},{interface:"m2o",type:"belongsTo",name:"statusInfo",target:"userStatuses",foreignKey:"status",targetKey:"key",uiSchema:{type:"object",title:'{{t("Status")}}',"x-component":"AssociationField","x-component-props":{fieldNames:{label:"title",value:"key"}}}},{interface:"m2o",type:"belongsTo",name:"previousStatusInfo",target:"userStatuses",foreignKey:"previousStatus",targetKey:"key",uiSchema:{type:"object",title:'{{t("Previous Status")}}',"x-component":"AssociationField","x-component-props":{fieldNames:{label:"title",value:"key"}}}},{interface:"datetime",type:"date",name:"statusExpireAt",uiSchema:{type:"datetime",title:'{{t("Status Expire At")}}',"x-component":"DatePicker","x-component-props":{showTime:!0}}},{interface:"select",type:"string",name:"previousStatus",uiSchema:{type:"string",title:'{{t("Previous Status")}}',"x-component":"Select","x-component-props":{fieldNames:{label:"title",value:"key"}}}},{interface:"textarea",type:"text",name:"statusReason",uiSchema:{type:"string",title:'{{t("Status Reason")}}',"x-component":"Input.TextArea"}}]},K={type:"void",properties:{block1:{type:"void","x-decorator":"TableBlockProvider","x-component":"CardItem","x-decorator-props":{collection:S,action:"list",params:{pageSize:50,appends:["roles","statusInfo","previousStatusInfo"]}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action","x-use-component-props":"useBulkDestroyActionProps","x-component-props":{confirm:{title:"{{t('Delete users')}}",content:"{{t('Are you sure you want to delete it?')}}"},icon:"DeleteOutlined"}},create:{type:"void","x-action":"create","x-acl-action":"create",title:"{{t('Add new')}}","x-component":"Action","x-decorator":"ACLActionProvider","x-component-props":{openMode:"drawer",type:"primary",component:"CreateRecordAction",icon:"PlusOutlined"},"x-align":"right","x-acl-action-props":{skipScopeCheck:!0},properties:{drawer:{type:"void",title:'{{ t("Add user") }}',"x-component":"Action.Container","x-component-props":{className:"tb-action-popup"},properties:{body:{type:"void","x-acl-action-props":{skipScopeCheck:!0},"x-acl-action":"users:create","x-decorator":"FormBlockProvider","x-use-decorator-props":"useCreateFormBlockDecoratorProps","x-decorator-props":{dataSource:"main",collection:S},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useCreateFormBlockProps",properties:{actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:24}},properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-use-component-props":"useCreateActionProps","x-component-props":{type:"primary",htmlType:"submit"},"x-action-settings":{assignedValues:{},triggerWorkflows:[],pageMode:!1}}}},nickname:{"x-component":"CollectionField","x-decorator":"FormItem"},username:{"x-component":"CollectionField","x-decorator":"FormItem"},email:{title:'{{t("Email")}}',"x-component":"Input","x-validator":"email","x-decorator":"FormItem",required:!1},phone:{title:'{{t("Phone")}}',"x-component":"Input","x-validator":"phone","x-decorator":"FormItem","x-component-props":{autocomplete:"off"},required:!1},password:{"x-component":"CollectionField","x-decorator":"FormItem","x-component-props":{autocomplete:"new-password"},required:!0},roles:{"x-component":"CollectionField","x-collection-field":"users.roles","x-decorator":"FormItem"},statusInfo:{"x-component":"CollectionField","x-collection-field":"users.statusInfo","x-decorator":"FormItem",required:!0},statusExpireAt:{"x-component":"CollectionField","x-collection-field":"users.statusExpireAt","x-decorator":"FormItem"},statusReason:{"x-component":"CollectionField","x-collection-field":"users.statusReason","x-decorator":"FormItem"}}}}}}}}}}},table:{type:"array","x-uid":"input","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{column1:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{nickname:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},column2:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{username:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column3:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{email:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column4:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:'{{t("Roles")}}',properties:{roles:{type:"array","x-component":"UserRolesField"}}},column4_5:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:'{{t("Status")}}',properties:{statusInfo:{type:"object","x-component":"UserStatusField"}}},column5:{type:"void",title:'{{t("Actions")}}',"x-component":"TableV2.Column",properties:{actions:{type:"void","x-component":"Space",properties:{update:{type:"void",title:'{{t("Edit profile")}}',"x-acl-action-props":{skipScopeCheck:!1},"x-acl-action":"users:update","x-decorator":"FormBlockProvider","x-use-decorator-props":"useEditFormBlockDecoratorProps","x-decorator-props":{action:"get",dataSource:"main",collection:"users",params:{appends:["statusInfo","previousStatusInfo"]}},"x-component":"Action.Link","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"FormV2","x-use-decorator-props":"useEditFormBlockProps",title:'{{t("Edit profile")}}',properties:{actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:24}},properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-use-component-props":"useUpdateActionProps","x-component-props":{type:"primary"}}}},nickname:{"x-component":"CollectionField","x-decorator":"FormItem"},username:{"x-component":"CollectionField","x-decorator":"FormItem"},email:{title:'{{t("Email")}}',"x-component":"Input","x-validator":"email","x-decorator":"FormItem",required:!1},phone:{title:'{{t("Phone")}}',"x-component":"Input","x-validator":"phone","x-decorator":"FormItem",required:!1},roles:{"x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"users.roles"},statusInfo:{"x-component":"CollectionField","x-collection-field":"users.statusInfo","x-decorator":"FormItem",required:!0},statusExpireAt:{"x-component":"CollectionField","x-collection-field":"users.statusExpireAt","x-decorator":"FormItem"},previousStatusInfo:{"x-component":"CollectionField","x-collection-field":"users.previousStatusInfo","x-decorator":"FormItem","x-disabled":!0},statusReason:{"x-component":"CollectionField","x-collection-field":"users.statusReason","x-decorator":"FormItem"}}}}},changePassword:{type:"void",title:'{{ t("Change password") }}',"x-action":"update","x-component":"Action.Link","x-component-props":{openMode:"drawer"},"x-decorator":"ACLActionProvider",properties:{drawer:{type:"void",title:'{{ t("Change password") }}',"x-component":"Action.Container","x-component-props":{className:"tb-action-popup"},properties:{card:{type:"void","x-acl-action-props":{skipScopeCheck:!1},"x-acl-action":"users:update","x-decorator":"FormBlockProvider","x-use-decorator-props":"useEditFormBlockDecoratorProps","x-decorator-props":{action:"get",dataSource:"main",collection:S,params:{append:["password"]}},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useEditFormBlockProps",properties:{actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:24}},properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-use-component-props":"useUpdateActionProps","x-component-props":{type:"primary"}}}},password:{"x-component":"CollectionField","x-component-props":{component:"PasswordField"},"x-decorator":"FormItem",required:!0}}}}}}}}},delete:{type:"void",title:'{{ t("Delete") }}',"x-acl-action":"users:destroy","x-action":"destroy","x-decorator":"ACLActionProvider","x-component":"Action.Link","x-use-component-props":"useDestroyActionProps","x-component-props":{confirm:{title:"{{t('Delete')}}",content:"{{t('Are you sure you want to delete it?')}}"}}}}}}}}}}}}},O=()=>({type:"void",properties:{[x.uid()]:{type:"void","x-decorator":"RoleUsersTableBlockProvider","x-component":"CardItem","x-use-decorator-props":"useRoleUsersServiceProps",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{[x.uid()]:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},actions:{type:"void","x-component":"Space",properties:{remove:{type:"void",title:'{{t("Remove")}}',"x-component":"Action","x-use-component-props":"useBulkRemoveUsers","x-component-props":{icon:"MinusOutlined",confirm:{title:"{{t('Remove')}}",content:"{{t('Are you sure you want to remove these users?')}}"},style:{marginRight:8}}},create:{type:"void",title:'{{t("Add users")}}',"x-component":"Action","x-component-props":{type:"primary",icon:"PlusOutlined"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"FormV2",title:'{{t("Add users")}}',properties:{resource:{type:"void","x-decorator":"TableBlockProvider","x-component":"CardItem","x-use-decorator-props":"useRoleUsersProps",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',default:{$and:[{username:{$includes:""}},{nickname:{$includes:""}}]},"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-use-component-props":"useAddRoleUsers","x-component-props":{type:"primary",htmlType:"submit"}}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{username:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{username:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},nickname:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{nickname:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},phone:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{phone:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},email:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{email:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}}}}}}}}}}}}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{username:{type:"void",title:'{{t("Username")}}',"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{username:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},nickname:{type:"void",title:'{{t("Nickname")}}',"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{nickname:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{t("Actions")}}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{remove:{type:"void",title:'{{ t("Remove") }}',"x-component":"Action.Link","x-use-component-props":"useRemoveUser","x-component-props":{confirm:{title:"{{t('Remove user')}}",content:"{{t('Are you sure you want to remove it?')}}"}}}}}}}}}}}}}),j=()=>{var s,p;const o=d.useContext(e.CollectionContext),t=e.useFilterFieldOptions(o.fields),{service:n}=e.useTableBlockContext();return e.useFilterFieldProps({options:t,params:((p=(s=n.state)==null?void 0:s.params)==null?void 0:p[0])||n.params,service:n})},R=()=>{const o=e.useAPIClient(),{role:t}=d.useContext(i.RolesManagerContext),n=e.useCollectionRecordData(),{service:s}=e.useTableBlockContext();return{onClick(){return F(this,null,function*(){yield o.resource("roles.users",t==null?void 0:t.name).remove({values:[n.id]}),s==null||s.refresh()})}}},L=()=>{const{t:o}=C(),{message:t}=y.App.useApp(),n=e.useAPIClient(),{service:s,field:p}=e.useTableBlockContext(),{role:m}=d.useContext(i.RolesManagerContext);return{onClick(){return F(this,null,function*(){var u;const l=(u=p==null?void 0:p.data)==null?void 0:u.selectedRowKeys;if(!(l!=null&&l.length)){t.warning(o("Please select users"));return}yield n.resource("roles.users",m==null?void 0:m.name).remove({values:l}),p.data.selectedRowKeys=[],s==null||s.refresh()})}}},$=()=>{const{t:o}=C(),{role:t}=d.useContext(i.RolesManagerContext),{message:n}=y.App.useApp(),s=e.useAPIClient(),{setVisible:p}=e.useActionContext(),{field:m}=e.useTableBlockContext(),{__parent:c}=e.useBlockRequestContext();return{onClick(){return F(this,null,function*(){var g,v;const u=(g=m==null?void 0:m.data)==null?void 0:g.selectedRowKeys;if(!(u!=null&&u.length)){n.warning(o("Please select users"));return}yield s.resource("roles.users",t==null?void 0:t.name).add({values:u}),m.data.selectedRowKeys=[],p(!1),(v=c==null?void 0:c.props)==null||v.service.refresh()})}}},H=o=>{const{role:t}=d.useContext(i.RolesManagerContext);return b(f({},o),{collection:S,action:"listExcludeRole",params:{roleName:t==null?void 0:t.name}})},W=o=>{const{role:t}=d.useContext(i.RolesManagerContext),n=e.useRequest({resource:"roles.users",resourceOf:t==null?void 0:t.name,action:"list"},{ready:!!t});return b(f({},o),{service:n,collection:S,params:{pageSize:50}})},z=e.withDynamicSchemaProps(o=>{const D=o,{showIndex:t,dragSort:n,rowKey:s,fieldNames:p,collection:m,service:c}=D,l=N(D,["showIndex","dragSort","rowKey","fieldNames","collection","service"]),u=x.useField(),{role:g}=d.useContext(i.RolesManagerContext),v=e.useTableBlockParams(o);d.useEffect(()=>{c.run()},[g]);const A=x.useFieldSchema(),{treeTable:k}=(A==null?void 0:A["x-decorator-props"])||{},[V,me]=d.useState(!!p);let B="children";if(m!=null&&m.tree&&k!==!1){const U=m.fields.find(de=>de.treeChildren);U&&(B=U.name),v.tree=!0}const ue=d.useMemo(()=>x.createForm(),[k]);return r.jsx(e.SchemaComponentOptions,{scope:{treeTable:k},children:r.jsx(x.FormContext.Provider,{value:ue,children:r.jsx(e.BlockProvider,b(f({name:o.name||"table"},o),{params:v,runWhenParamsChanged:!0,children:r.jsx(e.FixedBlockWrapper,{children:r.jsx(e.TableBlockContext.Provider,{value:b(f({},l),{field:u,service:c,params:v,showIndex:t,dragSort:n,rowKey:s,expandFlag:V,childrenColumnName:B,setExpandFlag:()=>me(!V)}),children:r.jsx(e.RenderChildrenWithAssociationFilter,f({},o))})})}))})})}),G=()=>{const{t:o}=C(),{role:t}=d.useContext(i.RolesManagerContext),n=d.useMemo(()=>O(),[t]);return r.jsx(e.ExtendCollectionsProvider,{collections:[S],children:r.jsx(e.SchemaComponent,{schema:n,components:{RoleUsersTableBlockProvider:z},scope:{useBulkRemoveUsers:L,useRemoveUser:R,useAddRoleUsers:$,useRoleUsersProps:H,useFilterActionProps:j,useRoleUsersServiceProps:W,t:o}})})},_=()=>{var g,v,A,k;const o=e.useCurrentUserContext(),t=e.useApp().pluginManager,n=t.get("@tachybase/plugin-otp"),s=t.get("@tachybase/plugin-auth-sms"),p=!!n&&!!s,m=((v=(g=o==null?void 0:o.data)==null?void 0:g.data)==null?void 0:v.password)!==null,c=(k=(A=o==null?void 0:o.data)==null?void 0:A.data)==null?void 0:k.phone,{t:l}=e.useTranslation(),u=c?l("Send verification code to phone: {{phoneNumber}}",{phoneNumber:c}):l("Please fill in your mobile phone number in your personal information first");return r.jsx(e.SchemaComponent,{schema:Q,scope:{useSaveCurrentUserValues:J,oldPassword:m,codeDescription:u,phoneNumber:c,smsVerifyEnabled:p},components:{VerificationCode:e.VerificationCode}})},J=()=>{var c,l;const o=x.useForm(),t=e.useAPIClient(),{message:n}=y.App.useApp(),{t:s}=e.useTranslation(),p=e.useCurrentUserContext(),m=((l=(c=p==null?void 0:p.data)==null?void 0:c.data)==null?void 0:l.password)===null;return{run(){return F(this,null,function*(){yield o.submit(),(yield t.resource("auth").changePassword({values:o.values})).status===200&&(n.success(s("Edited successfully")),m&&p.mutate({data:b(f({},p.data.data),{password:""})})),yield o.reset()})}}},Q={type:"object",properties:{[h.uid()]:{type:"void","x-component":"CardItem","x-decorator":"Form",title:'{{t("Change password")}}',properties:{action:{type:"void",properties:{submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",style:{left:"96%"},useAction:"{{ useSaveCurrentUserValues }}"}}}},verifyMethod:{type:"string",required:!0,title:'{{t("Verify method")}}',enum:[{label:'{{t("Use old password")}}',value:"password"},{label:'{{t("Use verification code")}}',value:"code"}],"x-component":"Radio.Group","x-decorator":"FormItem","x-reactions":[{dependencies:[".phoneExist",".oldPasswordExist"],fulfill:{state:{hidden:"{{ !($deps[0] && $deps[1] && smsVerifyEnabled) }}",value:"{{ undefined }}"}}}]},phoneExist:{type:"boolean",default:"{{ !!phoneNumber }}","x-hidden":!0},phone:{type:"string",title:'{{t("Phone")}}',default:"{{ phoneNumber }}","x-component":"Input","x-validator":"phone","x-decorator":"FormItem","x-hidden":!0},code:{type:"string",title:'{{t("Verification code")}}',description:"{{codeDescription}}","x-component":"VerificationCode","x-component-props":{actionType:"auth:changePassword",targetFieldName:"phone"},required:!0,"x-decorator":"FormItem","x-reactions":[{dependencies:[".verifyMethod",".phoneExist"],fulfill:{state:{hidden:`{{
|
|
1
|
+
(function(a,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@tachybase/client"),require("@tachybase/module-acl/client"),require("react/jsx-runtime"),require("react"),require("@tachybase/schema"),require("antd"),require("react-i18next"),require("@tego/client")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","@tachybase/module-acl/client","react/jsx-runtime","react","@tachybase/schema","antd","react-i18next","@tego/client"],e):(a=typeof globalThis!="undefined"?globalThis:a||self,e(a["@tachybase/module-user"]={},a["@tachybase/client"],a["@tachybase/module-acl"],a.jsxRuntime,a.react,a["@tachybase/schema"],a.antd,a["react-i18next"],a["@tego/client"]))})(this,function(a,e,p,r,d,x,y,P,h){"use strict";var xe=Object.defineProperty,ye=Object.defineProperties;var Ce=Object.getOwnPropertyDescriptors;var w=Object.getOwnPropertySymbols;var M=Object.prototype.hasOwnProperty,q=Object.prototype.propertyIsEnumerable;var E=(a,e,p)=>e in a?xe(a,e,{enumerable:!0,configurable:!0,writable:!0,value:p}):a[e]=p,f=(a,e)=>{for(var p in e||(e={}))M.call(e,p)&&E(a,p,e[p]);if(w)for(var p of w(e))q.call(e,p)&&E(a,p,e[p]);return a},b=(a,e)=>ye(a,Ce(e));var N=(a,e)=>{var p={};for(var r in a)M.call(a,r)&&e.indexOf(r)<0&&(p[r]=a[r]);if(a!=null&&w)for(var r of w(a))e.indexOf(r)<0&&q.call(a,r)&&(p[r]=a[r]);return p};var F=(a,e,p)=>new Promise((r,d)=>{var x=h=>{try{P(p.next(h))}catch(C){d(C)}},y=h=>{try{P(p.throw(h))}catch(C){d(C)}},P=h=>h.done?r(h.value):Promise.resolve(h.value).then(x,y);P((p=p.apply(a,e)).next())});function C(){return P.useTranslation(["user","core"],{nsMode:"fallback"})}const S={name:"users",fields:[{name:"id",type:"bigInt",autoIncrement:!0,primaryKey:!0,allowNull:!1,uiSchema:{type:"number",title:'{{t("ID")}}',"x-component":"InputNumber","x-read-pretty":!0},interface:"id"},{interface:"input",type:"string",name:"nickname",uiSchema:{type:"string",title:'{{t("Nickname")}}',"x-component":"Input"}},{interface:"input",type:"string",name:"username",unique:!0,uiSchema:{type:"string",title:'{{t("Username")}}',"x-component":"Input","x-validator":{username:!0},required:!0}},{interface:"email",type:"string",name:"email",unique:!0,uiSchema:{type:"string",title:'{{t("Email")}}',"x-component":"Input","x-validator":"email",required:!0}},{interface:"phone",type:"string",name:"phone",unique:!0,uiSchema:{type:"string",title:'{{t("Phone")}}',"x-component":"Input","x-validator":"phone",required:!0}},{interface:"password",type:"password",name:"password",hidden:!0,uiSchema:{type:"string",title:'{{t("Password")}}',"x-component":"Password"}},{interface:"m2m",type:"belongsToMany",name:"roles",target:"roles",foreignKey:"userId",otherKey:"roleName",onDelete:"CASCADE",sourceKey:"id",targetKey:"name",through:"rolesUsers",uiSchema:{type:"array",title:'{{t("Roles")}}',"x-component":"AssociationField","x-component-props":{multiple:!0,fieldNames:{label:"title",value:"name"}}}},{interface:"m2o",type:"belongsTo",name:"statusInfo",target:"userStatuses",foreignKey:"status",targetKey:"key",uiSchema:{type:"object",title:'{{t("Status")}}',"x-component":"AssociationField","x-component-props":{fieldNames:{label:"title",value:"key"}}}},{interface:"m2o",type:"belongsTo",name:"previousStatusInfo",target:"userStatuses",foreignKey:"previousStatus",targetKey:"key",uiSchema:{type:"object",title:'{{t("Previous Status")}}',"x-component":"AssociationField","x-component-props":{fieldNames:{label:"title",value:"key"}}}},{interface:"datetime",type:"date",name:"statusExpireAt",uiSchema:{type:"datetime",title:'{{t("Status Expire At")}}',"x-component":"DatePicker","x-component-props":{showTime:!0}}},{interface:"select",type:"string",name:"previousStatus",uiSchema:{type:"string",title:'{{t("Previous Status")}}',"x-component":"Select","x-component-props":{fieldNames:{label:"title",value:"key"}}}},{interface:"textarea",type:"text",name:"statusReason",uiSchema:{type:"string",title:'{{t("Status Reason")}}',"x-component":"Input.TextArea"}}]},K={type:"void",properties:{block1:{type:"void","x-decorator":"TableBlockProvider","x-component":"CardItem","x-decorator-props":{collection:S,action:"list",params:{pageSize:50,appends:["roles","statusInfo","previousStatusInfo"]}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action","x-use-component-props":"useBulkDestroyActionProps","x-component-props":{confirm:{title:"{{t('Delete users')}}",content:"{{t('Are you sure you want to delete it?')}}"},icon:"DeleteOutlined"}},create:{type:"void","x-action":"create","x-acl-action":"create",title:"{{t('Add new')}}","x-component":"Action","x-decorator":"ACLActionProvider","x-component-props":{openMode:"drawer",type:"primary",component:"CreateRecordAction",icon:"PlusOutlined"},"x-align":"right","x-acl-action-props":{skipScopeCheck:!0},properties:{drawer:{type:"void",title:'{{ t("Add user") }}',"x-component":"Action.Container","x-component-props":{className:"tb-action-popup"},properties:{body:{type:"void","x-acl-action-props":{skipScopeCheck:!0},"x-acl-action":"users:create","x-decorator":"FormBlockProvider","x-use-decorator-props":"useCreateFormBlockDecoratorProps","x-decorator-props":{dataSource:"main",collection:S},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useCreateFormBlockProps",properties:{actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:24}},properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-use-component-props":"useCreateActionProps","x-component-props":{type:"primary",htmlType:"submit"},"x-action-settings":{assignedValues:{},triggerWorkflows:[],pageMode:!1}}}},nickname:{"x-component":"CollectionField","x-decorator":"FormItem"},username:{"x-component":"CollectionField","x-decorator":"FormItem"},email:{title:'{{t("Email")}}',"x-component":"Input","x-validator":"email","x-decorator":"FormItem",required:!1},phone:{title:'{{t("Phone")}}',"x-component":"Input","x-validator":"phone","x-decorator":"FormItem","x-component-props":{autocomplete:"off"},required:!1},password:{"x-component":"CollectionField","x-decorator":"FormItem","x-component-props":{autocomplete:"new-password"},required:!0},roles:{"x-component":"CollectionField","x-collection-field":"users.roles","x-decorator":"FormItem"},statusInfo:{"x-component":"CollectionField","x-collection-field":"users.statusInfo","x-decorator":"FormItem",required:!0},statusExpireAt:{"x-component":"CollectionField","x-collection-field":"users.statusExpireAt","x-decorator":"FormItem"},statusReason:{"x-component":"CollectionField","x-collection-field":"users.statusReason","x-decorator":"FormItem"}}}}}}}}}}},table:{type:"array","x-uid":"input","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{column1:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{nickname:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},column2:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{username:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column3:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{email:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column4:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:'{{t("Roles")}}',properties:{roles:{type:"array","x-component":"UserRolesField"}}},column4_5:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:'{{t("Status")}}',properties:{statusInfo:{type:"object","x-component":"UserStatusField"}}},column5:{type:"void",title:'{{t("Actions")}}',"x-component":"TableV2.Column",properties:{actions:{type:"void","x-component":"Space",properties:{update:{type:"void",title:'{{t("Edit profile")}}',"x-acl-action-props":{skipScopeCheck:!1},"x-acl-action":"users:update","x-decorator":"FormBlockProvider","x-use-decorator-props":"useEditFormBlockDecoratorProps","x-decorator-props":{action:"get",dataSource:"main",collection:"users",params:{appends:["statusInfo","previousStatusInfo"]}},"x-component":"Action.Link","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"FormV2","x-use-decorator-props":"useEditFormBlockProps",title:'{{t("Edit profile")}}',properties:{actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:24}},properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-use-component-props":"useUpdateActionProps","x-component-props":{type:"primary"}}}},nickname:{"x-component":"CollectionField","x-decorator":"FormItem"},username:{"x-component":"CollectionField","x-decorator":"FormItem"},email:{title:'{{t("Email")}}',"x-component":"Input","x-validator":"email","x-decorator":"FormItem",required:!1},phone:{title:'{{t("Phone")}}',"x-component":"Input","x-validator":"phone","x-decorator":"FormItem",required:!1},roles:{"x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"users.roles"},statusInfo:{"x-component":"CollectionField","x-collection-field":"users.statusInfo","x-decorator":"FormItem",required:!0},statusExpireAt:{"x-component":"CollectionField","x-collection-field":"users.statusExpireAt","x-decorator":"FormItem"},previousStatusInfo:{"x-component":"CollectionField","x-collection-field":"users.previousStatusInfo","x-decorator":"FormItem","x-disabled":!0},statusReason:{"x-component":"CollectionField","x-collection-field":"users.statusReason","x-decorator":"FormItem"}}}}},changePassword:{type:"void",title:'{{ t("Change password") }}',"x-action":"update","x-component":"Action.Link","x-component-props":{openMode:"drawer"},"x-decorator":"ACLActionProvider",properties:{drawer:{type:"void",title:'{{ t("Change password") }}',"x-component":"Action.Container","x-component-props":{className:"tb-action-popup"},properties:{card:{type:"void","x-acl-action-props":{skipScopeCheck:!1},"x-acl-action":"users:update","x-decorator":"FormBlockProvider","x-use-decorator-props":"useEditFormBlockDecoratorProps","x-decorator-props":{action:"get",dataSource:"main",collection:S,params:{append:["password"]}},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useEditFormBlockProps",properties:{actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:24}},properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-use-component-props":"useUpdateActionProps","x-component-props":{type:"primary"}}}},password:{"x-component":"CollectionField","x-component-props":{component:"PasswordField"},"x-decorator":"FormItem",required:!0}}}}}}}}},delete:{type:"void",title:'{{ t("Delete") }}',"x-acl-action":"users:destroy","x-action":"destroy","x-decorator":"ACLActionProvider","x-component":"Action.Link","x-use-component-props":"useDestroyActionProps","x-component-props":{confirm:{title:"{{t('Delete')}}",content:"{{t('Are you sure you want to delete it?')}}"}}}}}}}}}}}}},O=()=>({type:"void",properties:{[x.uid()]:{type:"void","x-decorator":"RoleUsersTableBlockProvider","x-component":"CardItem","x-use-decorator-props":"useRoleUsersServiceProps",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{[x.uid()]:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},actions:{type:"void","x-component":"Space",properties:{remove:{type:"void",title:'{{t("Remove")}}',"x-component":"Action","x-use-component-props":"useBulkRemoveUsers","x-component-props":{icon:"MinusOutlined",confirm:{title:"{{t('Remove')}}",content:"{{t('Are you sure you want to remove these users?')}}"},style:{marginRight:8}}},create:{type:"void",title:'{{t("Add users")}}',"x-component":"Action","x-component-props":{type:"primary",icon:"PlusOutlined"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"FormV2",title:'{{t("Add users")}}',properties:{resource:{type:"void","x-decorator":"TableBlockProvider","x-component":"CardItem","x-use-decorator-props":"useRoleUsersProps",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',default:{$and:[{username:{$includes:""}},{nickname:{$includes:""}}]},"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-use-component-props":"useAddRoleUsers","x-component-props":{type:"primary",htmlType:"submit"}}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{username:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{username:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},nickname:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{nickname:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},phone:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{phone:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},email:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{email:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}}}}}}}}}}}}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{username:{type:"void",title:'{{t("Username")}}',"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{username:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},nickname:{type:"void",title:'{{t("Nickname")}}',"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{nickname:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{t("Actions")}}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{remove:{type:"void",title:'{{ t("Remove") }}',"x-component":"Action.Link","x-use-component-props":"useRemoveUser","x-component-props":{confirm:{title:"{{t('Remove user')}}",content:"{{t('Are you sure you want to remove it?')}}"}}}}}}}}}}}}}),j=()=>{var s,i;const o=d.useContext(e.CollectionContext),t=e.useFilterFieldOptions(o.fields),{service:n}=e.useTableBlockContext();return e.useFilterFieldProps({options:t,params:((i=(s=n.state)==null?void 0:s.params)==null?void 0:i[0])||n.params,service:n})},R=()=>{const o=e.useAPIClient(),{role:t}=d.useContext(p.RolesManagerContext),n=e.useCollectionRecordData(),{service:s}=e.useTableBlockContext();return{onClick(){return F(this,null,function*(){yield o.resource("roles.users",t==null?void 0:t.name).remove({values:[n.id]}),s==null||s.refresh()})}}},L=()=>{const{t:o}=C(),{message:t}=y.App.useApp(),n=e.useAPIClient(),{service:s,field:i}=e.useTableBlockContext(),{role:m}=d.useContext(p.RolesManagerContext);return{onClick(){return F(this,null,function*(){var u;const l=(u=i==null?void 0:i.data)==null?void 0:u.selectedRowKeys;if(!(l!=null&&l.length)){t.warning(o("Please select users"));return}yield n.resource("roles.users",m==null?void 0:m.name).remove({values:l}),i.data.selectedRowKeys=[],s==null||s.refresh()})}}},$=()=>{const{t:o}=C(),{role:t}=d.useContext(p.RolesManagerContext),{message:n}=y.App.useApp(),s=e.useAPIClient(),{setVisible:i}=e.useActionContext(),{field:m}=e.useTableBlockContext(),{__parent:c}=e.useBlockRequestContext();return{onClick(){return F(this,null,function*(){var g,v;const u=(g=m==null?void 0:m.data)==null?void 0:g.selectedRowKeys;if(!(u!=null&&u.length)){n.warning(o("Please select users"));return}yield s.resource("roles.users",t==null?void 0:t.name).add({values:u}),m.data.selectedRowKeys=[],i(!1),(v=c==null?void 0:c.props)==null||v.service.refresh()})}}},H=o=>{const{role:t}=d.useContext(p.RolesManagerContext);return b(f({},o),{collection:S,action:"listExcludeRole",params:{roleName:t==null?void 0:t.name}})},W=o=>{const{role:t}=d.useContext(p.RolesManagerContext),n=e.useRequest({resource:"roles.users",resourceOf:t==null?void 0:t.name,action:"list"},{ready:!!t});return b(f({},o),{service:n,collection:S,params:{pageSize:50}})},z=e.withDynamicSchemaProps(o=>{const D=o,{showIndex:t,dragSort:n,rowKey:s,fieldNames:i,collection:m,service:c}=D,l=N(D,["showIndex","dragSort","rowKey","fieldNames","collection","service"]),u=x.useField(),{role:g}=d.useContext(p.RolesManagerContext),v=e.useTableBlockParams(o);d.useEffect(()=>{c.run()},[g]);const A=x.useFieldSchema(),{treeTable:k}=(A==null?void 0:A["x-decorator-props"])||{},[V,me]=d.useState(!!i);let B="children";if(m!=null&&m.tree&&k!==!1){const U=m.fields.find(de=>de.treeChildren);U&&(B=U.name),v.tree=!0}const ue=d.useMemo(()=>x.createForm(),[k]);return r.jsx(e.SchemaComponentOptions,{scope:{treeTable:k},children:r.jsx(x.FormContext.Provider,{value:ue,children:r.jsx(e.BlockProvider,b(f({name:o.name||"table"},o),{params:v,runWhenParamsChanged:!0,children:r.jsx(e.FixedBlockWrapper,{children:r.jsx(e.TableBlockContext.Provider,{value:b(f({},l),{field:u,service:c,params:v,showIndex:t,dragSort:n,rowKey:s,expandFlag:V,childrenColumnName:B,setExpandFlag:()=>me(!V)}),children:r.jsx(e.RenderChildrenWithAssociationFilter,f({},o))})})}))})})}),G=()=>{const{t:o}=C(),{role:t}=d.useContext(p.RolesManagerContext),n=d.useMemo(()=>O(),[t]);return r.jsx(e.ExtendCollectionsProvider,{collections:[S],children:r.jsx(e.SchemaComponent,{schema:n,components:{RoleUsersTableBlockProvider:z},scope:{useBulkRemoveUsers:L,useRemoveUser:R,useAddRoleUsers:$,useRoleUsersProps:H,useFilterActionProps:j,useRoleUsersServiceProps:W,t:o}})})},_=()=>{var g,v,A,k;const o=e.useCurrentUserContext(),t=e.useApp().pluginManager,n=t.get("@tachybase/plugin-otp"),s=t.get("@tachybase/plugin-auth-sms"),i=!!n&&!!s,m=((v=(g=o==null?void 0:o.data)==null?void 0:g.data)==null?void 0:v.hasPassword)===!0,c=(k=(A=o==null?void 0:o.data)==null?void 0:A.data)==null?void 0:k.phone,{t:l}=e.useTranslation(),u=c?l("Send verification code to phone: {{phoneNumber}}",{phoneNumber:c}):l("Please fill in your mobile phone number in your personal information first");return r.jsx(e.SchemaComponent,{schema:Q,scope:{useSaveCurrentUserValues:J,oldPassword:m,codeDescription:u,phoneNumber:c,smsVerifyEnabled:i},components:{VerificationCode:e.VerificationCode}})},J=()=>{var c,l;const o=x.useForm(),t=e.useAPIClient(),{message:n}=y.App.useApp(),{t:s}=e.useTranslation(),i=e.useCurrentUserContext(),m=((l=(c=i==null?void 0:i.data)==null?void 0:c.data)==null?void 0:l.hasPassword)!==!0;return{run(){return F(this,null,function*(){yield o.submit(),(yield t.resource("auth").changePassword({values:o.values})).status===200&&(n.success(s("Edited successfully")),m&&i.mutate({data:b(f({},i.data.data),{hasPassword:!0})})),yield o.reset()})}}},Q={type:"object",properties:{[h.uid()]:{type:"void","x-component":"CardItem","x-decorator":"Form",title:'{{t("Change password")}}',properties:{action:{type:"void",properties:{submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",style:{left:"96%"},useAction:"{{ useSaveCurrentUserValues }}"}}}},verifyMethod:{type:"string",required:!0,title:'{{t("Verify method")}}',enum:[{label:'{{t("Use old password")}}',value:"password"},{label:'{{t("Use verification code")}}',value:"code"}],"x-component":"Radio.Group","x-decorator":"FormItem","x-reactions":[{dependencies:[".phoneExist",".oldPasswordExist"],fulfill:{state:{hidden:"{{ !($deps[0] && $deps[1] && smsVerifyEnabled) }}",value:"{{ undefined }}"}}}]},phoneExist:{type:"boolean",default:"{{ !!phoneNumber }}","x-hidden":!0},phone:{type:"string",title:'{{t("Phone")}}',default:"{{ phoneNumber }}","x-component":"Input","x-validator":"phone","x-decorator":"FormItem","x-hidden":!0},code:{type:"string",title:'{{t("Verification code")}}',description:"{{codeDescription}}","x-component":"VerificationCode","x-component-props":{actionType:"auth:changePassword",targetFieldName:"phone"},required:!0,"x-decorator":"FormItem","x-reactions":[{dependencies:[".verifyMethod",".phoneExist"],fulfill:{state:{hidden:`{{
|
|
2
2
|
!$deps[1] ||
|
|
3
3
|
!smsVerifyEnabled ||
|
|
4
4
|
($deps[0] !== 'code' && $deps[0] !== undefined) // 有 verifyMethod 但未选 code
|
|
5
5
|
}}`}}}]},oldPasswordExist:{type:"boolean",default:"{{ oldPassword }}","x-hidden":!0},oldPassword:{type:"string",title:'{{t("Old password")}}',required:!0,"x-component":"Password","x-decorator":"FormItem","x-reactions":[{dependencies:[".verifyMethod",".oldPasswordExist"],fulfill:{state:{hidden:`{{
|
|
6
6
|
!$deps[1] ||
|
|
7
7
|
(smsVerifyEnabled && $deps[0] !== 'password' && $deps[0] !== undefined)
|
|
8
|
-
}}`}}}]},newPassword:{type:"string",title:'{{t("New password")}}',required:!0,"x-component":"Password","x-decorator":"FormItem","x-component-props":{checkStrength:!0,style:{}},"x-reactions":[{dependencies:[".confirmPassword"],fulfill:{state:{selfErrors:'{{$deps[0] && $self.value && $self.value !== $deps[0] ? t("Password mismatch") : ""}}'}}}]},confirmPassword:{type:"string",required:!0,title:'{{t("Confirm password")}}',"x-component":"Password","x-decorator":"FormItem","x-component-props":{checkStrength:!0,style:{}},"x-reactions":[{dependencies:[".newPassword"],fulfill:{state:{selfErrors:'{{$deps[0] && $self.value && $self.value !== $deps[0] ? t("Password mismatch") : ""}}'}}}]}}}}},X=()=>{const o=e.useApp().pluginManager,t=o.get("@tachybase/plugin-otp"),n=o.get("@tachybase/plugin-auth-sms"),s=!!t&&!!n;return r.jsx(e.SchemaComponent,{schema:ee,scope:{useCurrentUserValues:Y,useSaveCurrentUserValues:Z,smsVerifyEnabled:s},components:{VerificationCode:e.VerificationCode}})},Y=o=>{const t=e.useCurrentUserContext();return e.useRequest(()=>Promise.resolve(t.data),o)},Z=()=>{const o=e.useCurrentUserContext(),t=x.useForm(),n=e.useAPIClient(),{message:s}=y.App.useApp(),{t:p}=e.useTranslation();return{run(){return F(this,null,function*(){var u;const c=yield t.submit();(yield n.resource("users").updateProfile({values:c})).status===200&&s.success(p("Edited successfully")),o.mutate({data:f(f({},(u=o==null?void 0:o.data)==null?void 0:u.data),c)})})}}},ee={type:"object",properties:{[h.uid()]:{type:"void","x-component":"CardItem","x-decorator":"Form","x-decorator-props":{useValues:"{{useCurrentUserValues}}"},title:'{{t("Edit profile")}}',properties:{action:{type:"void",properties:{submit:{title:"Submit","x-component":"Action","x-component-props":{type:"primary",style:{left:"96%"},useAction:"{{ useSaveCurrentUserValues }}"}}}},nickname:{type:"string",title:"{{t('Nickname')}}","x-decorator":"FormItem","x-component":"Input"},username:{type:"string",title:'{{t("Username")}}',"x-decorator":"FormItem","x-component":"Input","x-validator":{username:!0},required:!0},email:{type:"string",title:'{{t("Email")}}',"x-decorator":"FormItem","x-component":"Input","x-validator":"email"},phone:{type:"string",title:'{{t("Phone")}}',"x-decorator":"FormItem","x-component":"Input","x-validator":"phone"},code:{type:"string",title:'{{t("Verification code")}}',"x-component":"VerificationCode","x-component-props":{actionType:"users:updateProfile",targetFieldName:"phone"},required:!0,"x-decorator":"FormItem","x-reactions":[{dependencies:[".phone"],fulfill:{state:{hidden:"{{ $deps[0] === $form.initialValues?.phone || !smsVerifyEnabled}}"}}}]}}}}},te=(o=10)=>{const t="ABCDEFGHIJKLMNOPQRSTUVWXYZ",n="abcdefghijklmnopqrstuvwxyz",s="0123456789",p="!#$%^&*-_+=",m=t+n+s+p,c=new Uint32Array(o);crypto.getRandomValues(c);let l="";l+=t.charAt(c[0]%t.length),l+=n.charAt(c[1]%n.length),l+=s.charAt(c[2]%s.length),l+=p.charAt(c[3]%p.length);for(let u=4;u<o;u++){const g=c[u]%m.length;l+=m.charAt(g)}return l=l[0]+l.slice(1).split("").sort(()=>Math.random()-.5).join(""),l},oe=()=>{const{t:o}=C(),t=x.useField(),[n,s]=d.useState(!1),p=e.useActionContext();return d.useEffect(()=>{p.visible||t.reset()},[t,p.visible]),r.jsxs(y.Row,{gutter:10,children:[r.jsx(y.Col,{span:18,children:r.jsx(e.Password,{checkStrength:!0,visibilityToggle:{visible:n,onVisibleChange:s},value:t.value,onChange:m=>t.setValue(m.target.value),autoComplete:"off"})}),r.jsx(y.Col,{span:4,children:r.jsx(y.Button,{onClick:()=>{t.setValue(te()),s(!0)},children:o("Random password")})})]})},re=()=>{const{t:o}=C();return(x.useField().value||[]).map(n=>r.jsx(y.Tag,{children:x.Schema.compile(n.title,{t:o})},n.name))},T=()=>{const o=e.useRecord();e.useCollectionField();const t=e.useCompile(),n=x.useFieldSchema();let s=o==null?void 0:o.statusInfo;if(!s&&(n!=null&&n.name)&&(s=o==null?void 0:o[n.name]),!s)return r.jsx("span",{children:"-"});const p=t(s.title||s.key);return r.jsx(y.Tag,{color:s.color||"default",children:p})},ne=()=>{const{t:o}=C(),t=e.useSchemaComponentContext();return r.jsx(e.SchemaComponentContext.Provider,{value:b(f({},t),{designable:!1}),children:r.jsx(e.SchemaComponent,{schema:K,scope:{t:o},components:{UserRolesField:re,PasswordField:oe,UserStatusField:T}})})},se={type:"void",properties:{userStatusHistoriesBlock:{type:"void","x-decorator":"TableBlockProvider","x-component":"CardItem","x-decorator-props":{collection:{name:"userStatusHistories",fields:[{name:"id",type:"bigInt",primaryKey:!0,uiSchema:{type:"number",title:'{{t("ID")}}',"x-component":"InputNumber","x-read-pretty":!0}},{interface:"m2o",type:"belongsTo",name:"user",target:"users",foreignKey:"userId",uiSchema:{type:"object",title:'{{t("User")}}',"x-component":"AssociationField","x-component-props":{fieldNames:{label:"nickname",value:"id"}}}},{interface:"m2o",type:"belongsTo",name:"fromStatusInfo",target:"userStatuses",foreignKey:"fromStatus",targetKey:"key",uiSchema:{type:"object",title:'{{t("From Status")}}',"x-component":"AssociationField","x-component-props":{fieldNames:{label:"title",value:"key"}}}},{interface:"m2o",type:"belongsTo",name:"toStatusInfo",target:"userStatuses",foreignKey:"toStatus",targetKey:"key",uiSchema:{type:"object",title:'{{t("To Status")}}',"x-component":"AssociationField","x-component-props":{fieldNames:{label:"title",value:"key"}}}},{interface:"input",type:"string",name:"fromStatus",uiSchema:{type:"string",title:'{{t("From Status")}}',"x-component":"Input","x-read-pretty":!0}},{interface:"input",type:"string",name:"toStatus",uiSchema:{type:"string",title:'{{t("To Status")}}',"x-component":"Input","x-read-pretty":!0}},{interface:"textarea",type:"text",name:"reason",uiSchema:{type:"string",title:'{{t("Reason")}}',"x-component":"Input.TextArea","x-read-pretty":!0}},{interface:"select",type:"string",name:"operationType",uiSchema:{type:"string",title:'{{t("Operation Type")}}',"x-component":"Select",enum:[{label:'{{t("Manual")}}',value:"manual"},{label:'{{t("Auto")}}',value:"auto"},{label:'{{t("System")}}',value:"system"}],"x-read-pretty":!0}},{interface:"datetime",type:"date",name:"expireAt",uiSchema:{type:"string",title:'{{t("Expire At")}}',"x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0}},{interface:"m2o",type:"belongsTo",name:"createdBy",target:"users",foreignKey:"createdById",uiSchema:{type:"object",title:'{{t("Created By")}}',"x-component":"AssociationField","x-component-props":{fieldNames:{label:"nickname",value:"id"}}}},{interface:"createdAt",type:"date",name:"createdAt",uiSchema:{type:"datetime",title:'{{t("Created At")}}',"x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0}}]},action:"list",params:{pageSize:50,sort:["-createdAt"],appends:["user","createdBy","fromStatusInfo","toStatusInfo"]}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"}}},table:{type:"array","x-uid":"userStatusHistoriesTable","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id"},properties:{column1:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:'{{t("User")}}',properties:{user:{type:"object","x-component":"UserNicknameField"}}},column2:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:'{{t("From Status")}}',properties:{fromStatusInfo:{type:"object","x-component":"UserStatusField"}}},column3:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:'{{t("To Status")}}',properties:{toStatusInfo:{type:"object","x-component":"UserStatusField"}}},column4:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{reason:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column5:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{operationType:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column6:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{expireAt:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column7:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:'{{t("Created By")}}',properties:{createdBy:{type:"object","x-component":"UserNicknameField"}}},column8:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{createdAt:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}}}}}}}},ae=x.observer(()=>{const o=x.useField(),t=o==null?void 0:o.value;return t!=null&&t.nickname?r.jsx("span",{children:t.nickname}):t!=null&&t.username?r.jsx("span",{children:t.username}):(t==null?void 0:t.id)!==void 0?r.jsx("span",{children:t.id}):r.jsx("span",{children:"-"})},{displayName:"UserNicknameField"}),pe=()=>{const{t:o}=C(),t=e.useSchemaComponentContext();return r.jsx(e.SchemaComponentContext.Provider,{value:b(f({},t),{designable:!1}),children:r.jsx(e.SchemaComponent,{schema:se,scope:{t:o},components:{UserStatusField:T,UserNicknameField:ae}})})},I={name:"userStatuses",fields:[{name:"key",type:"string",primaryKey:!0,allowNull:!1,unique:!0,uiSchema:{type:"string",title:'{{t("Status Key")}}',"x-component":"Input",required:!0}},{name:"title",type:"string",allowNull:!1,uiSchema:{type:"string",title:'{{t("Status Title")}}',"x-component":"Input",required:!0}},{name:"color",type:"string",uiSchema:{type:"string",title:'{{t("Color")}}',"x-component":"ColorPicker"}},{name:"allowLogin",type:"boolean",defaultValue:!0,uiSchema:{type:"boolean",title:'{{t("Allow Login")}}',"x-component":"Checkbox"}},{name:"loginErrorMessage",type:"text",uiSchema:{type:"string",title:'{{t("Login Error Message")}}',"x-component":"Input.TextArea"}},{name:"isSystemDefined",type:"boolean",defaultValue:!1,uiSchema:{type:"boolean",title:'{{t("System Defined")}}',"x-component":"Checkbox","x-read-pretty":!0}},{name:"sort",type:"integer",defaultValue:0,uiSchema:{type:"number",title:'{{t("Sort")}}',"x-component":"InputNumber"}},{name:"packageName",type:"string",uiSchema:{type:"string",title:'{{t("Package Name")}}',"x-component":"Input","x-read-pretty":!0}},{name:"description",type:"text",uiSchema:{type:"string",title:'{{t("Description")}}',"x-component":"Input.TextArea"}}]},ie={type:"void",properties:{userStatusesBlock:{type:"void","x-decorator":"TableBlockProvider","x-component":"CardItem","x-decorator-props":{collection:I,action:"list",params:{pageSize:50,sort:["sort"]}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action","x-use-component-props":"useBulkDestroyActionProps","x-component-props":{confirm:{title:"{{t('Delete statuses')}}",content:"{{t('Are you sure you want to delete it?')}}"},icon:"DeleteOutlined"}},create:{type:"void","x-action":"create","x-acl-action":"create",title:"{{t('Add new')}}","x-component":"Action","x-decorator":"ACLActionProvider","x-component-props":{openMode:"drawer",type:"primary",component:"CreateRecordAction",icon:"PlusOutlined"},"x-align":"right","x-acl-action-props":{skipScopeCheck:!0},properties:{drawer:{type:"void",title:'{{ t("Add status") }}',"x-component":"Action.Container","x-component-props":{className:"tb-action-popup"},properties:{body:{type:"void","x-acl-action-props":{skipScopeCheck:!0},"x-acl-action":"userStatuses:create","x-decorator":"FormBlockProvider","x-use-decorator-props":"useCreateFormBlockDecoratorProps","x-decorator-props":{dataSource:"main",collection:I},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useCreateFormBlockProps",properties:{actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:24}},properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-use-component-props":"useCreateActionProps","x-component-props":{type:"primary",htmlType:"submit"},"x-action-settings":{assignedValues:{},triggerWorkflows:[],pageMode:!1}}}},key:{"x-component":"CollectionField","x-decorator":"FormItem",required:!0},title:{"x-component":"CollectionField","x-decorator":"FormItem",required:!0},color:{"x-component":"CollectionField","x-decorator":"FormItem"},allowLogin:{"x-component":"CollectionField","x-decorator":"FormItem"},loginErrorMessage:{"x-component":"CollectionField","x-decorator":"FormItem"},sort:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"}}}}}}}}}}},table:{type:"array","x-uid":"userStatusesTable","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"key",rowSelection:{type:"checkbox"}},properties:{column1:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{key:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column2:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column3:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{color:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column4:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{allowLogin:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0}}},column5:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{isSystemDefined:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0}}},column6:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{sort:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},column7:{type:"void",title:'{{t("Actions")}}',"x-component":"TableV2.Column",properties:{actions:{type:"void","x-component":"Space",properties:{update:{type:"void",title:'{{t("Edit")}}',"x-acl-action-props":{skipScopeCheck:!1},"x-acl-action":"userStatuses:update","x-decorator":"FormBlockProvider","x-use-decorator-props":"useEditFormBlockDecoratorProps","x-decorator-props":{action:"get",dataSource:"main",collection:"userStatuses"},"x-component":"Action.Link","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"FormV2","x-use-decorator-props":"useEditFormBlockProps",title:'{{t("Edit status")}}',properties:{actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:24}},properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-use-component-props":"useUpdateActionProps","x-component-props":{type:"primary"}}}},key:{"x-component":"CollectionField","x-decorator":"FormItem","x-disabled":!0},title:{"x-component":"CollectionField","x-decorator":"FormItem",required:!0},color:{"x-component":"CollectionField","x-decorator":"FormItem"},allowLogin:{"x-component":"CollectionField","x-decorator":"FormItem"},loginErrorMessage:{"x-component":"CollectionField","x-decorator":"FormItem"},sort:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"}}}}},delete:{type:"void",title:'{{ t("Delete") }}',"x-acl-action":"userStatuses:destroy","x-action":"destroy","x-decorator":"ACLActionProvider","x-component":"Action.Link","x-use-component-props":"useDestroyActionProps","x-component-props":{confirm:{title:"{{t('Delete')}}",content:"{{t('Are you sure you want to delete it?')}}"}}}}}}}}}}}}},ce=()=>{const{t:o}=C(),t=e.useSchemaComponentContext();return r.jsx(e.SchemaComponentContext.Provider,{value:b(f({},t),{designable:!1}),children:r.jsx(e.SchemaComponent,{schema:ie,scope:{t:o}})})};class le extends e.Plugin{load(){return F(this,null,function*(){this.app.systemSettingsManager.add("id-auth.users",{title:e.tval("Users"),icon:"UserOutlined",Component:ne,aclSnippet:"pm.users"}),this.app.systemSettingsManager.add("id-auth.user-statuses",{title:e.tval("User Statuses"),icon:"TagOutlined",Component:ce,aclSnippet:"pm.users.statuses",sort:8}),this.app.systemSettingsManager.add("id-auth.user-status-histories",{title:e.tval("User Status Histories"),icon:"HistoryOutlined",Component:pe,aclSnippet:"pm.users.statuses",sort:9}),this.userSettingsManager.add("user-change-password",{icon:"LockOutlined",title:e.tval("Change password"),Component:_}),this.userSettingsManager.add("user-profile",{icon:"UserOutlined",title:e.tval("Edit profile"),Component:X}),this.app.pm.get(i).rolesManager.add("users",{title:e.tval("Users"),Component:G})})}}a.default=le,Object.defineProperties(a,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
8
|
+
}}`}}}]},newPassword:{type:"string",title:'{{t("New password")}}',required:!0,"x-component":"Password","x-decorator":"FormItem","x-component-props":{checkStrength:!0,style:{}},"x-reactions":[{dependencies:[".confirmPassword"],fulfill:{state:{selfErrors:'{{$deps[0] && $self.value && $self.value !== $deps[0] ? t("Password mismatch") : ""}}'}}}]},confirmPassword:{type:"string",required:!0,title:'{{t("Confirm password")}}',"x-component":"Password","x-decorator":"FormItem","x-component-props":{checkStrength:!0,style:{}},"x-reactions":[{dependencies:[".newPassword"],fulfill:{state:{selfErrors:'{{$deps[0] && $self.value && $self.value !== $deps[0] ? t("Password mismatch") : ""}}'}}}]}}}}},X=()=>{const o=e.useApp().pluginManager,t=o.get("@tachybase/plugin-otp"),n=o.get("@tachybase/plugin-auth-sms"),s=!!t&&!!n;return r.jsx(e.SchemaComponent,{schema:ee,scope:{useCurrentUserValues:Y,useSaveCurrentUserValues:Z,smsVerifyEnabled:s},components:{VerificationCode:e.VerificationCode}})},Y=o=>{const t=e.useCurrentUserContext();return e.useRequest(()=>Promise.resolve(t.data),o)},Z=()=>{const o=e.useCurrentUserContext(),t=x.useForm(),n=e.useAPIClient(),{message:s}=y.App.useApp(),{t:i}=e.useTranslation();return{run(){return F(this,null,function*(){var u;const c=yield t.submit();(yield n.resource("users").updateProfile({values:c})).status===200&&s.success(i("Edited successfully")),o.mutate({data:f(f({},(u=o==null?void 0:o.data)==null?void 0:u.data),c)})})}}},ee={type:"object",properties:{[h.uid()]:{type:"void","x-component":"CardItem","x-decorator":"Form","x-decorator-props":{useValues:"{{useCurrentUserValues}}"},title:'{{t("Edit profile")}}',properties:{action:{type:"void",properties:{submit:{title:"Submit","x-component":"Action","x-component-props":{type:"primary",style:{left:"96%"},useAction:"{{ useSaveCurrentUserValues }}"}}}},nickname:{type:"string",title:"{{t('Nickname')}}","x-decorator":"FormItem","x-component":"Input"},username:{type:"string",title:'{{t("Username")}}',"x-decorator":"FormItem","x-component":"Input","x-validator":{username:!0},required:!0},email:{type:"string",title:'{{t("Email")}}',"x-decorator":"FormItem","x-component":"Input","x-validator":"email"},phone:{type:"string",title:'{{t("Phone")}}',"x-decorator":"FormItem","x-component":"Input","x-validator":"phone"},code:{type:"string",title:'{{t("Verification code")}}',"x-component":"VerificationCode","x-component-props":{actionType:"users:updateProfile",targetFieldName:"phone"},required:!0,"x-decorator":"FormItem","x-reactions":[{dependencies:[".phone"],fulfill:{state:{hidden:"{{ $deps[0] === $form.initialValues?.phone || !smsVerifyEnabled}}"}}}]}}}}},te=(o=10)=>{const t="ABCDEFGHIJKLMNOPQRSTUVWXYZ",n="abcdefghijklmnopqrstuvwxyz",s="0123456789",i="!#$%^&*-_+=",m=t+n+s+i,c=new Uint32Array(o);crypto.getRandomValues(c);let l="";l+=t.charAt(c[0]%t.length),l+=n.charAt(c[1]%n.length),l+=s.charAt(c[2]%s.length),l+=i.charAt(c[3]%i.length);for(let u=4;u<o;u++){const g=c[u]%m.length;l+=m.charAt(g)}return l=l[0]+l.slice(1).split("").sort(()=>Math.random()-.5).join(""),l},oe=()=>{const{t:o}=C(),t=x.useField(),[n,s]=d.useState(!1),i=e.useActionContext();return d.useEffect(()=>{i.visible||t.reset()},[t,i.visible]),r.jsxs(y.Row,{gutter:10,children:[r.jsx(y.Col,{span:18,children:r.jsx(e.Password,{checkStrength:!0,visibilityToggle:{visible:n,onVisibleChange:s},value:t.value,onChange:m=>t.setValue(m.target.value),autoComplete:"off"})}),r.jsx(y.Col,{span:4,children:r.jsx(y.Button,{onClick:()=>{t.setValue(te()),s(!0)},children:o("Random password")})})]})},re=()=>{const{t:o}=C();return(x.useField().value||[]).map(n=>r.jsx(y.Tag,{children:x.Schema.compile(n.title,{t:o})},n.name))},T=()=>{const o=e.useRecord();e.useCollectionField();const t=e.useCompile(),n=x.useFieldSchema();let s=o==null?void 0:o.statusInfo;if(!s&&(n!=null&&n.name)&&(s=o==null?void 0:o[n.name]),!s)return r.jsx("span",{children:"-"});const i=t(s.title||s.key);return r.jsx(y.Tag,{color:s.color||"default",children:i})},ne=()=>{const{t:o}=C(),t=e.useSchemaComponentContext();return r.jsx(e.SchemaComponentContext.Provider,{value:b(f({},t),{designable:!1}),children:r.jsx(e.SchemaComponent,{schema:K,scope:{t:o},components:{UserRolesField:re,PasswordField:oe,UserStatusField:T}})})},se={type:"void",properties:{userStatusHistoriesBlock:{type:"void","x-decorator":"TableBlockProvider","x-component":"CardItem","x-decorator-props":{collection:{name:"userStatusHistories",fields:[{name:"id",type:"bigInt",primaryKey:!0,uiSchema:{type:"number",title:'{{t("ID")}}',"x-component":"InputNumber","x-read-pretty":!0}},{interface:"m2o",type:"belongsTo",name:"user",target:"users",foreignKey:"userId",uiSchema:{type:"object",title:'{{t("User")}}',"x-component":"AssociationField","x-component-props":{fieldNames:{label:"nickname",value:"id"}}}},{interface:"m2o",type:"belongsTo",name:"fromStatusInfo",target:"userStatuses",foreignKey:"fromStatus",targetKey:"key",uiSchema:{type:"object",title:'{{t("From Status")}}',"x-component":"AssociationField","x-component-props":{fieldNames:{label:"title",value:"key"}}}},{interface:"m2o",type:"belongsTo",name:"toStatusInfo",target:"userStatuses",foreignKey:"toStatus",targetKey:"key",uiSchema:{type:"object",title:'{{t("To Status")}}',"x-component":"AssociationField","x-component-props":{fieldNames:{label:"title",value:"key"}}}},{interface:"input",type:"string",name:"fromStatus",uiSchema:{type:"string",title:'{{t("From Status")}}',"x-component":"Input","x-read-pretty":!0}},{interface:"input",type:"string",name:"toStatus",uiSchema:{type:"string",title:'{{t("To Status")}}',"x-component":"Input","x-read-pretty":!0}},{interface:"textarea",type:"text",name:"reason",uiSchema:{type:"string",title:'{{t("Reason")}}',"x-component":"Input.TextArea","x-read-pretty":!0}},{interface:"select",type:"string",name:"operationType",uiSchema:{type:"string",title:'{{t("Operation Type")}}',"x-component":"Select",enum:[{label:'{{t("Manual")}}',value:"manual"},{label:'{{t("Auto")}}',value:"auto"},{label:'{{t("System")}}',value:"system"}],"x-read-pretty":!0}},{interface:"datetime",type:"date",name:"expireAt",uiSchema:{type:"string",title:'{{t("Expire At")}}',"x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0}},{interface:"m2o",type:"belongsTo",name:"createdBy",target:"users",foreignKey:"createdById",uiSchema:{type:"object",title:'{{t("Created By")}}',"x-component":"AssociationField","x-component-props":{fieldNames:{label:"nickname",value:"id"}}}},{interface:"createdAt",type:"date",name:"createdAt",uiSchema:{type:"datetime",title:'{{t("Created At")}}',"x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0}}]},action:"list",params:{pageSize:50,sort:["-createdAt"],appends:["user","createdBy","fromStatusInfo","toStatusInfo"]}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"}}},table:{type:"array","x-uid":"userStatusHistoriesTable","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id"},properties:{column1:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:'{{t("User")}}',properties:{user:{type:"object","x-component":"UserNicknameField"}}},column2:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:'{{t("From Status")}}',properties:{fromStatusInfo:{type:"object","x-component":"UserStatusField"}}},column3:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:'{{t("To Status")}}',properties:{toStatusInfo:{type:"object","x-component":"UserStatusField"}}},column4:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{reason:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column5:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{operationType:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column6:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{expireAt:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column7:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:'{{t("Created By")}}',properties:{createdBy:{type:"object","x-component":"UserNicknameField"}}},column8:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{createdAt:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}}}}}}}},ae=x.observer(()=>{const o=x.useField(),t=o==null?void 0:o.value;return t!=null&&t.nickname?r.jsx("span",{children:t.nickname}):t!=null&&t.username?r.jsx("span",{children:t.username}):(t==null?void 0:t.id)!==void 0?r.jsx("span",{children:t.id}):r.jsx("span",{children:"-"})},{displayName:"UserNicknameField"}),ie=()=>{const{t:o}=C(),t=e.useSchemaComponentContext();return r.jsx(e.SchemaComponentContext.Provider,{value:b(f({},t),{designable:!1}),children:r.jsx(e.SchemaComponent,{schema:se,scope:{t:o},components:{UserStatusField:T,UserNicknameField:ae}})})},I={name:"userStatuses",fields:[{name:"key",type:"string",primaryKey:!0,allowNull:!1,unique:!0,uiSchema:{type:"string",title:'{{t("Status Key")}}',"x-component":"Input",required:!0}},{name:"title",type:"string",allowNull:!1,uiSchema:{type:"string",title:'{{t("Status Title")}}',"x-component":"Input",required:!0}},{name:"color",type:"string",uiSchema:{type:"string",title:'{{t("Color")}}',"x-component":"ColorPicker"}},{name:"allowLogin",type:"boolean",defaultValue:!0,uiSchema:{type:"boolean",title:'{{t("Allow Login")}}',"x-component":"Checkbox"}},{name:"loginErrorMessage",type:"text",uiSchema:{type:"string",title:'{{t("Login Error Message")}}',"x-component":"Input.TextArea"}},{name:"isSystemDefined",type:"boolean",defaultValue:!1,uiSchema:{type:"boolean",title:'{{t("System Defined")}}',"x-component":"Checkbox","x-read-pretty":!0}},{name:"sort",type:"integer",defaultValue:0,uiSchema:{type:"number",title:'{{t("Sort")}}',"x-component":"InputNumber"}},{name:"packageName",type:"string",uiSchema:{type:"string",title:'{{t("Package Name")}}',"x-component":"Input","x-read-pretty":!0}},{name:"description",type:"text",uiSchema:{type:"string",title:'{{t("Description")}}',"x-component":"Input.TextArea"}}]},pe={type:"void",properties:{userStatusesBlock:{type:"void","x-decorator":"TableBlockProvider","x-component":"CardItem","x-decorator-props":{collection:I,action:"list",params:{pageSize:50,sort:["sort"]}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action","x-use-component-props":"useBulkDestroyActionProps","x-component-props":{confirm:{title:"{{t('Delete statuses')}}",content:"{{t('Are you sure you want to delete it?')}}"},icon:"DeleteOutlined"}},create:{type:"void","x-action":"create","x-acl-action":"create",title:"{{t('Add new')}}","x-component":"Action","x-decorator":"ACLActionProvider","x-component-props":{openMode:"drawer",type:"primary",component:"CreateRecordAction",icon:"PlusOutlined"},"x-align":"right","x-acl-action-props":{skipScopeCheck:!0},properties:{drawer:{type:"void",title:'{{ t("Add status") }}',"x-component":"Action.Container","x-component-props":{className:"tb-action-popup"},properties:{body:{type:"void","x-acl-action-props":{skipScopeCheck:!0},"x-acl-action":"userStatuses:create","x-decorator":"FormBlockProvider","x-use-decorator-props":"useCreateFormBlockDecoratorProps","x-decorator-props":{dataSource:"main",collection:I},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useCreateFormBlockProps",properties:{actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:24}},properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-use-component-props":"useCreateActionProps","x-component-props":{type:"primary",htmlType:"submit"},"x-action-settings":{assignedValues:{},triggerWorkflows:[],pageMode:!1}}}},key:{"x-component":"CollectionField","x-decorator":"FormItem",required:!0},title:{"x-component":"CollectionField","x-decorator":"FormItem",required:!0},color:{"x-component":"CollectionField","x-decorator":"FormItem"},allowLogin:{"x-component":"CollectionField","x-decorator":"FormItem"},loginErrorMessage:{"x-component":"CollectionField","x-decorator":"FormItem"},sort:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"}}}}}}}}}}},table:{type:"array","x-uid":"userStatusesTable","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"key",rowSelection:{type:"checkbox"}},properties:{column1:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{key:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column2:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column3:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{color:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column4:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{allowLogin:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0}}},column5:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{isSystemDefined:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0}}},column6:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{sort:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},column7:{type:"void",title:'{{t("Actions")}}',"x-component":"TableV2.Column",properties:{actions:{type:"void","x-component":"Space",properties:{update:{type:"void",title:'{{t("Edit")}}',"x-acl-action-props":{skipScopeCheck:!1},"x-acl-action":"userStatuses:update","x-decorator":"FormBlockProvider","x-use-decorator-props":"useEditFormBlockDecoratorProps","x-decorator-props":{action:"get",dataSource:"main",collection:"userStatuses"},"x-component":"Action.Link","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"FormV2","x-use-decorator-props":"useEditFormBlockProps",title:'{{t("Edit status")}}',properties:{actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:24}},properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-use-component-props":"useUpdateActionProps","x-component-props":{type:"primary"}}}},key:{"x-component":"CollectionField","x-decorator":"FormItem","x-disabled":!0},title:{"x-component":"CollectionField","x-decorator":"FormItem",required:!0},color:{"x-component":"CollectionField","x-decorator":"FormItem"},allowLogin:{"x-component":"CollectionField","x-decorator":"FormItem"},loginErrorMessage:{"x-component":"CollectionField","x-decorator":"FormItem"},sort:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"}}}}},delete:{type:"void",title:'{{ t("Delete") }}',"x-acl-action":"userStatuses:destroy","x-action":"destroy","x-decorator":"ACLActionProvider","x-component":"Action.Link","x-use-component-props":"useDestroyActionProps","x-component-props":{confirm:{title:"{{t('Delete')}}",content:"{{t('Are you sure you want to delete it?')}}"}}}}}}}}}}}}},ce=()=>{const{t:o}=C(),t=e.useSchemaComponentContext();return r.jsx(e.SchemaComponentContext.Provider,{value:b(f({},t),{designable:!1}),children:r.jsx(e.SchemaComponent,{schema:pe,scope:{t:o}})})};class le extends e.Plugin{load(){return F(this,null,function*(){this.app.systemSettingsManager.add("id-auth.users",{title:e.tval("Users"),icon:"UserOutlined",Component:ne,aclSnippet:"pm.users"}),this.app.systemSettingsManager.add("id-auth.user-statuses",{title:e.tval("User Statuses"),icon:"TagOutlined",Component:ce,aclSnippet:"pm.users.statuses",sort:8}),this.app.systemSettingsManager.add("id-auth.user-status-histories",{title:e.tval("User Status Histories"),icon:"HistoryOutlined",Component:ie,aclSnippet:"pm.users.statuses",sort:9}),this.userSettingsManager.add("user-change-password",{icon:"LockOutlined",title:e.tval("Change password"),Component:_}),this.userSettingsManager.add("user-profile",{icon:"UserOutlined",title:e.tval("Edit profile"),Component:X}),this.app.pm.get(p).rolesManager.add("users",{title:e.tval("Users"),Component:G})})}}a.default=le,Object.defineProperties(a,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/externalVersion.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
"react": "18.3.1",
|
|
3
|
-
"@tachybase/client": "1.6.
|
|
3
|
+
"@tachybase/client": "1.6.34",
|
|
4
4
|
"@tachybase/schema": "1.6.17",
|
|
5
5
|
"antd": "5.22.5",
|
|
6
|
-
"@tachybase/module-acl": "1.6.
|
|
6
|
+
"@tachybase/module-acl": "1.6.34",
|
|
7
7
|
"@tego/client": "1.6.17",
|
|
8
8
|
"react-i18next": "16.2.1",
|
|
9
9
|
"@tego/server": "1.6.17"
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tachybase/module-user",
|
|
3
3
|
"displayName": "Users",
|
|
4
|
-
"version": "1.6.
|
|
4
|
+
"version": "1.6.34",
|
|
5
5
|
"description": "Provides basic user model, as well as created by and updated by fields.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"Users & permissions"
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
"antd": "5.22.5",
|
|
28
28
|
"jsonwebtoken": "^8.5.1",
|
|
29
29
|
"react-i18next": "16.2.1",
|
|
30
|
-
"@tachybase/
|
|
31
|
-
"@tachybase/
|
|
32
|
-
"@tachybase/module-auth": "1.6.
|
|
30
|
+
"@tachybase/client": "1.6.34",
|
|
31
|
+
"@tachybase/module-acl": "1.6.34",
|
|
32
|
+
"@tachybase/module-auth": "1.6.34"
|
|
33
33
|
},
|
|
34
34
|
"description.zh-CN": "提供了基础的用户模型,以及创建人和最后更新人字段。",
|
|
35
35
|
"displayName.zh-CN": "用户",
|