-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
permissions, tvorenie permissions, formulár pre role
- Loading branch information
Showing
22 changed files
with
593 additions
and
22 deletions.
There are no files selected for viewing
151 changes: 151 additions & 0 deletions
151
src/priv/Components/Modules/Core/Settings/FormUserRoles.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
import React, { Component } from 'react'; | ||
import { deepObjectMerge, getUrlParam } from 'adios/Helper'; | ||
import Form, { FormProps, FormState } from 'adios/Form'; | ||
import InputTags2 from 'adios/Inputs/Tags2'; | ||
import InputTable from 'adios/Inputs/Table'; | ||
import FormInput from 'adios/FormInput'; | ||
import TableRolePermissions from './TableRolePermissions'; | ||
|
||
interface FormUserRolesProps extends FormProps {} | ||
|
||
interface FormUserRolesState extends FormState {} | ||
|
||
export default class FormUserRoles<P, S> extends Form<FormUserRolesProps,FormUserRolesState> { | ||
static defaultProps: any = { | ||
...Form.defaultProps, | ||
model: 'CeremonyCrmApp/Modules/Core/Settings/Models/UserRoles', | ||
}; | ||
|
||
props: FormUserRolesProps; | ||
state: FormUserRolesState; | ||
|
||
constructor(props: FormUserRolesProps) { | ||
super(props); | ||
this.state = this.getStateFromProps(props); | ||
} | ||
|
||
getStateFromProps(props: FormUserRolesProps) { | ||
return { | ||
...super.getStateFromProps(props), | ||
}; | ||
} | ||
|
||
/* normalizeRecord(record) { | ||
return record; | ||
} */ | ||
|
||
renderHeaderLeft(): JSX.Element { | ||
return <> | ||
{this.state.isInlineEditing ? this.renderSaveButton() : this.renderEditButton()} | ||
</>; | ||
} | ||
|
||
renderHeaderRight(): JSX.Element { | ||
return <> | ||
{this.state.isInlineEditing ? this.renderDeleteButton() : null} | ||
{this.props.showInModal ? this.renderCloseButton() : null} | ||
</>; | ||
} | ||
|
||
renderTitle(): JSX.Element { | ||
if (getUrlParam('recordId') == -1) { | ||
return( | ||
<> | ||
<h2> | ||
{'New User Rolee'} | ||
</h2> | ||
</> | ||
); | ||
} else { | ||
return ( | ||
<> | ||
<h2> | ||
{this.state.record.role | ||
? this.state.record.role | ||
: '[Undefined Name]'} | ||
</h2> | ||
</> | ||
); | ||
} | ||
} | ||
|
||
/* onBeforeSaveRecord(record: any) { | ||
return record; | ||
} */ | ||
|
||
renderContent(): JSX.Element { | ||
const R = this.state.record; | ||
const showAdditional = R.id > 0 ? true : false; | ||
|
||
return ( | ||
<> | ||
<div className='grid grid-cols-2 gap-1' style= | ||
{{gridTemplateAreas:` | ||
'info info' | ||
'permissions permissions' | ||
`}}> | ||
<div className='card mt-4' style={{gridArea: 'info'}}> | ||
<div className='card-body'> | ||
{this.inputWrapper('role')} | ||
</div> | ||
</div> | ||
|
||
<div className='card mt-4' style={{gridArea: 'permissions'}}> | ||
<div className='card-header'>Permissions</div> | ||
<div className='card-body'> | ||
<InputTable | ||
uid={this.props.uid + '_table_permissions_steps_input'} | ||
{...this.getDefaultInputProps()} | ||
value={R.PERMISSIONS} | ||
onChange={(value: any) => { | ||
this.updateRecord({ PERMISSIONS: value }); | ||
}} | ||
> | ||
<TableRolePermissions | ||
uid={this.props.uid + '_permissions_steps'} | ||
context="Hello World" | ||
descriptionSource="props" | ||
description={{ | ||
ui: { | ||
showFooter: false, | ||
showHeader: false | ||
}, | ||
permissions: { | ||
canCreate: true, | ||
canDelete: true, | ||
canRead: true, | ||
canUpdate: true | ||
}, | ||
columns: { | ||
id_permission: { | ||
type: "lookup", | ||
title: "Permission", | ||
model: "CeremonyCrmApp/Modules/Core/Settings/Models/Permission", | ||
}, | ||
} | ||
}} | ||
></TableRolePermissions> | ||
</InputTable> | ||
{this.state.isInlineEditing ? ( | ||
<a | ||
role='button' | ||
onClick={() => { | ||
if (!R.PERMISSIONS) R.PERMISSIONS = []; | ||
R.PERMISSIONS.push({ | ||
id_role: { _useMasterRecordId_: true }, | ||
}); | ||
this.setState({ record: R }); | ||
}} | ||
> | ||
+ Add Permission | ||
</a> | ||
) : null} | ||
</div> | ||
</div> | ||
</div> | ||
</> | ||
); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/priv/Components/Modules/Core/Settings/TableRolePermissions.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React, { Component } from 'react' | ||
import Table, { TableProps, TableState } from 'adios/Table'; | ||
|
||
interface TableRolePermissionsProps extends TableProps { | ||
} | ||
|
||
interface TableRolePermissionsState extends TableState { | ||
} | ||
|
||
export default class TableRolePermissions extends Table<TableRolePermissionsProps, TableRolePermissionsState> { | ||
static defaultProps = { | ||
...Table.defaultProps, | ||
itemsPerPage: 15, | ||
formUseModalSimple: true, | ||
model: 'CeremonyCrmApp/Modules/Core/Settings/Models/RolePermission', | ||
} | ||
|
||
props: TableRolePermissionsProps; | ||
state: TableRolePermissionsState; | ||
|
||
constructor(props: TableRolePermissionsProps) { | ||
super(props); | ||
this.state = this.getStateFromProps(props); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/priv/Components/Modules/Core/Settings/TableUserRoles.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React, { Component } from 'react' | ||
import Table, { TableProps, TableState } from 'adios/Table'; | ||
import FormUserRoles from './FormUserRoles'; | ||
|
||
interface TableUserRolesProps extends TableProps { | ||
} | ||
|
||
interface TableUserRolesState extends TableState { | ||
} | ||
|
||
export default class TableUserRoles extends Table<TableUserRolesProps, TableUserRolesState> { | ||
static defaultProps = { | ||
...Table.defaultProps, | ||
itemsPerPage: 15, | ||
formUseModalSimple: true, | ||
model: 'CeremonyCrmApp/Modules/Core/Settings/Models/UserRole', | ||
} | ||
|
||
props: TableUserRolesProps; | ||
state: TableUserRolesState; | ||
|
||
constructor(props: TableUserRolesProps) { | ||
super(props); | ||
this.state = this.getStateFromProps(props); | ||
} | ||
|
||
renderForm(): JSX.Element { | ||
let formDescription = this.getFormProps(); | ||
return <FormUserRoles {...formDescription}/>; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.