|
1 | 1 | import * as React from 'react';
|
2 |
| -import { Form, Input, Checkbox, Row } from 'antd'; |
| 2 | +import { Form, Input, Checkbox, Modal, Tabs } from 'antd'; |
3 | 3 | import FormItem from 'antd/lib/form/FormItem';
|
4 | 4 |
|
| 5 | +import CheckboxGroup from 'antd/lib/checkbox/Group'; |
| 6 | +import { GetAllPermissionsOutput } from 'src/services/role/dto/getAllPermissionsOutput'; |
| 7 | +import { L } from 'src/lib/abpUtility'; |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | +const TabPane = Tabs.TabPane; |
5 | 12 | class CreateOrUpdateRoles extends React.Component<any> {
|
6 | 13 | constructor(props: any) {
|
7 | 14 | super(props);
|
8 |
| - |
9 |
| - } |
10 |
| -state = { |
11 |
| - confirmDirty: false, |
12 |
| -} |
13 |
| - compareToFirstPassword = (rule:any, value:any, callback:any) => { |
14 |
| - const form = this.props.form; |
15 |
| - if (value && value !== form.getFieldValue('password')) { |
16 |
| - callback('Two passwords that you enter is inconsistent!'); |
17 |
| - } else { |
18 |
| - callback(); |
19 |
| - } |
20 | 15 | }
|
21 | 16 |
|
22 |
| - validateToNextPassword = (rule:any, value:any, callback:any) => { |
23 |
| - const form = this.props.form; |
24 |
| - if (value && this.state.confirmDirty) { |
25 |
| - form.validateFields(['confirm'], { force: true }); |
26 |
| - } |
27 |
| - callback(); |
28 |
| - } |
| 17 | + state = { |
| 18 | + confirmDirty: false, |
| 19 | + }; |
| 20 | + |
29 | 21 | render() {
|
| 22 | + debugger; |
| 23 | + const { permission } = this.props; |
| 24 | + debugger; |
| 25 | + const options = permission.map((x: GetAllPermissionsOutput) => { |
| 26 | + var test = { label: x.displayName, value: x.name }; |
| 27 | + return test; |
| 28 | + }); |
| 29 | + |
30 | 30 | const formItemLayout = {
|
31 | 31 | labelCol: {
|
32 | 32 | xs: { span: 6 },
|
@@ -64,41 +64,38 @@ state = {
|
64 | 64 | },
|
65 | 65 | };
|
66 | 66 | const { getFieldDecorator } = this.props.form;
|
67 |
| - return ( |
68 |
| - |
69 |
| - <Row> |
70 |
| - <FormItem label={'Role Name'} {...formItemLayout}> |
71 |
| - {getFieldDecorator('roleName', { |
72 |
| - rules: [{ required: true, message: 'Please input your name!' }], |
73 |
| - })( |
74 |
| - <Input />)} |
75 |
| - </FormItem> |
76 |
| - <FormItem label={'Display Name'} {...formItemLayout}> |
77 |
| - {getFieldDecorator('displayName', { |
78 |
| - rules: [{ required: true, message: 'Please input your surname!' }], |
79 |
| - })( |
80 |
| - <Input />)} |
81 |
| - </FormItem> |
82 |
| - <FormItem label={'Role Description'} {...formItemLayout}> |
83 |
| - {getFieldDecorator('roleDescription', { |
84 |
| - rules: [{ required: true, message: 'Please input your username!' }], |
85 |
| - })( |
86 |
| - <Input />)} |
87 |
| - </FormItem> |
88 |
| - |
89 |
| - <FormItem label={'isActive'} {...tailFormItemLayout}> |
90 |
| - |
91 |
| - {getFieldDecorator('password(repeat)', { |
92 |
| - rules: [{ required: true, message: 'Please input your username!' }], |
93 |
| - })( |
94 |
| - |
95 |
| - <Checkbox > |
96 |
| - Aktif |
97 |
| - </Checkbox>)} |
98 |
| - </FormItem> |
99 |
| - |
100 |
| - </Row> |
101 |
| - ) |
| 67 | + return <Modal |
| 68 | + visible={this.props.visible} |
| 69 | + cancelText={L('Cancel')} |
| 70 | + okText={L('OK')} |
| 71 | + onCancel={this.props.onCancel} |
| 72 | + title={L('Role')} |
| 73 | + onOk={this.props.onOk}> |
| 74 | + <Tabs defaultActiveKey={'Role'} size={'small'} tabBarGutter={64}> |
| 75 | + <TabPane tab={L('RoleDetails')} key={'role'}> |
| 76 | + <FormItem label={L('RoleName')} {...formItemLayout}> |
| 77 | + {getFieldDecorator('name', { rules: [{ required: true, message: 'Please input your name!' }] })(<Input />)} |
| 78 | + </FormItem> |
| 79 | + <FormItem label={L('DisplayName')} {...formItemLayout}> |
| 80 | + {getFieldDecorator('displayName', { rules: [{ required: true, message: 'Please input your surname!' }] })(<Input />)} |
| 81 | + </FormItem> |
| 82 | + <FormItem label={L('Description')} {...formItemLayout}> |
| 83 | + {getFieldDecorator('description', { rules: [{ required: true, message: 'Please input your username!' }] })(<Input />)} |
| 84 | + </FormItem> |
| 85 | + <FormItem label={L('IsActive')} {...tailFormItemLayout}> |
| 86 | + {getFieldDecorator('isStatic', { |
| 87 | + rules: [{ required: true, message: 'Please input your username!' }], |
| 88 | + valuePropName: 'checked', |
| 89 | + })(<Checkbox>Aktif</Checkbox>)} |
| 90 | + </FormItem> |
| 91 | + </TabPane> |
| 92 | + <TabPane tab={L('RolePermission')} key={'permission'}> |
| 93 | + <FormItem {...tailFormItemLayout}> |
| 94 | + {getFieldDecorator('permissions', { valuePropName: 'value' })(<CheckboxGroup options={options} />)} |
| 95 | + </FormItem> |
| 96 | + </TabPane> |
| 97 | + </Tabs> |
| 98 | + </Modal>; |
102 | 99 | }
|
103 | 100 | }
|
104 | 101 |
|
|
0 commit comments