|
|
@ -43,7 +43,6 @@ class index extends Component { |
|
|
|
tooltipTambah: false, |
|
|
|
tooltipTambah: false, |
|
|
|
totalPage: 0, |
|
|
|
totalPage: 0, |
|
|
|
typeDialog: 'Save', |
|
|
|
typeDialog: 'Save', |
|
|
|
company_id: props.company_id || 0, |
|
|
|
|
|
|
|
role_name: props.role_name || '', |
|
|
|
role_name: props.role_name || '', |
|
|
|
role_id: props.role_id || 0, |
|
|
|
role_id: props.role_id || 0, |
|
|
|
user_id: props.user_id || 0, |
|
|
|
user_id: props.user_id || 0, |
|
|
@ -69,21 +68,19 @@ class index extends Component { |
|
|
|
<Tooltip title={this.props.t('menuRoles')}> |
|
|
|
<Tooltip title={this.props.t('menuRoles')}> |
|
|
|
{ |
|
|
|
{ |
|
|
|
checkActMenup('/roles', 'update') ? |
|
|
|
checkActMenup('/roles', 'update') ? |
|
|
|
<i className="cil-menu fa-lg" style={{ color: 'green', marginRight: 10, cursor: "pointer" }} onClick={() => this.handleMenuRoles(text.id)}></i> |
|
|
|
<i className="cil-menu fa-lg" style={{ color: 'green', marginRight: 10, cursor: "pointer" }} onClick={() => this.handleMenuRoles(text)}></i> |
|
|
|
: |
|
|
|
: |
|
|
|
null |
|
|
|
null |
|
|
|
} |
|
|
|
} |
|
|
|
</Tooltip> |
|
|
|
</Tooltip> |
|
|
|
|
|
|
|
|
|
|
|
<Tooltip title={this.props.t('delete')}> |
|
|
|
<Tooltip title={this.props.t('delete')}> |
|
|
|
{ |
|
|
|
{ |
|
|
|
checkActMenup('/roles', 'delete') ? |
|
|
|
checkActMenup('/roles', 'delete') ? |
|
|
|
<i className="fa fa-trash" style={{ color: 'red', marginRight: 10, cursor: "pointer" }} onClick={() => this.handleDelete(text.id)}></i> |
|
|
|
<i className="fa fa-trash" style={{ color: 'red', marginRight: 10, cursor: "pointer" }} onClick={() => this.handleDelete(text)}></i> |
|
|
|
: |
|
|
|
: |
|
|
|
null |
|
|
|
null |
|
|
|
} |
|
|
|
} |
|
|
|
</Tooltip> |
|
|
|
</Tooltip> |
|
|
|
|
|
|
|
|
|
|
|
<Tooltip title={this.props.t('edit')}> |
|
|
|
<Tooltip title={this.props.t('edit')}> |
|
|
|
{ |
|
|
|
{ |
|
|
|
checkActMenup('/roles', 'update') ? |
|
|
|
checkActMenup('/roles', 'update') ? |
|
|
@ -133,7 +130,6 @@ class index extends Component { |
|
|
|
if (this.state.currentPage !== 1 && this.state.currentPage > 1) { |
|
|
|
if (this.state.currentPage !== 1 && this.state.currentPage > 1) { |
|
|
|
start = (this.state.currentPage * this.state.rowsPerPage) - this.state.rowsPerPage |
|
|
|
start = (this.state.currentPage * this.state.rowsPerPage) - this.state.rowsPerPage |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const formData = { |
|
|
|
const formData = { |
|
|
|
"paging": { "start": start, "length": this.state.rowsPerPage }, |
|
|
|
"paging": { "start": start, "length": this.state.rowsPerPage }, |
|
|
|
"columns": [], |
|
|
|
"columns": [], |
|
|
@ -153,12 +149,9 @@ class index extends Component { |
|
|
|
} |
|
|
|
} |
|
|
|
if (this.state.role_name !== "Super Admin") { |
|
|
|
if (this.state.role_name !== "Super Admin") { |
|
|
|
formData.columns.push( |
|
|
|
formData.columns.push( |
|
|
|
{ "name": "company_id", "logic_operator": "=", "value": this.state.company_id, "operator": "AND" }, |
|
|
|
{ "name": "company_id", "logic_operator": "=", "value": this.props.company_id, "operator": "AND" }, |
|
|
|
) |
|
|
|
) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// formData.columns.push(
|
|
|
|
|
|
|
|
// { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
|
|
|
|
|
|
|
|
// )
|
|
|
|
|
|
|
|
formData.joins.push( |
|
|
|
formData.joins.push( |
|
|
|
{ "name": "m_company", "column_join": "company_id", "column_results": ["company_name"] } |
|
|
|
{ "name": "m_company", "column_join": "company_id", "column_results": ["company_name"] } |
|
|
|
) |
|
|
|
) |
|
|
@ -228,7 +221,6 @@ class index extends Component { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
saveRole = async (data) => { |
|
|
|
saveRole = async (data) => { |
|
|
|
|
|
|
|
|
|
|
|
const formData = { |
|
|
|
const formData = { |
|
|
|
name: data.name, |
|
|
|
name: data.name, |
|
|
|
description: data.description, |
|
|
|
description: data.description, |
|
|
@ -247,7 +239,6 @@ class index extends Component { |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
NotificationManager.error(`Data role gagal ditambahkan`, 'Failed!!'); |
|
|
|
NotificationManager.error(`Data role gagal ditambahkan`, 'Failed!!'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
editRole = async (data) => { |
|
|
|
editRole = async (data) => { |
|
|
@ -272,13 +263,13 @@ class index extends Component { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
handleEdit = (data) => { |
|
|
|
handleEdit = (data) => { |
|
|
|
this.setState({ dataEdit: data }); |
|
|
|
this.setState({ dataEdit: data, company_id: data.company_id }); |
|
|
|
this.handleOpenDialog('Edit'); |
|
|
|
this.handleOpenDialog('Edit'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
handleDelete = (id) => { |
|
|
|
handleDelete = (data) => { |
|
|
|
id == '1' ? this.setState({ alertNotDelete: true }) : |
|
|
|
data.id == '1' ? this.setState({ alertNotDelete: true }) : |
|
|
|
this.setState({ alertDelete: true, idDelete: id }); |
|
|
|
this.setState({ alertDelete: true, idDelete: data.id }); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
onShowSizeChange = (current, pageSize) => { |
|
|
|
onShowSizeChange = (current, pageSize) => { |
|
|
@ -317,29 +308,24 @@ class index extends Component { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
handleMenuRoles = async (id) => { |
|
|
|
handleMenuRoles = async (data) => { |
|
|
|
const formData = { |
|
|
|
const formData = { |
|
|
|
"paging": { "start": 0, "length": -1 }, |
|
|
|
"paging": { "start": 0, "length": -1 }, |
|
|
|
"columns": [], |
|
|
|
"columns": [], |
|
|
|
"joins": [{ "name": "m_menu", "column_join": "menu_id", "column_results": ["parent_id", "name"] }], |
|
|
|
"joins": [{ "name": "m_menu", "column_join": "menu_id", "column_results": ["parent_id", "name"] }], |
|
|
|
"orders": { "columns": ["id"], "ascending": false } |
|
|
|
"orders": { "columns": ["id"], "ascending": false } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (this.state.role_name !== "Super Admin") { |
|
|
|
|
|
|
|
formData.columns.push( |
|
|
|
formData.columns.push( |
|
|
|
{ "name": "role_id", "logic_operator": "=", "value": `${id}`, "operator": "AND" } |
|
|
|
{ "name": "role_id", "logic_operator": "=", "value": parseInt(data.id), "operator": "AND" } |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const result = await axios |
|
|
|
const result = await axios |
|
|
|
.post(ROLEMENU_SEARCH, formData, this.state.config) |
|
|
|
.post(ROLEMENU_SEARCH, formData, this.state.config) |
|
|
|
.then(res => res) |
|
|
|
.then(res => res) |
|
|
|
.catch((error) => error.response); |
|
|
|
.catch((error) => error.response); |
|
|
|
if (result && result.data && result.data.code == 200) { |
|
|
|
if (result && result.data && result.data.code == 200) { |
|
|
|
this.setState({ menuRoles: result.data.data, idRoles: id }, () => { |
|
|
|
this.setState({ menuRoles: result.data.data, idRoles: data.id, company_id: data.company_id }, () => { |
|
|
|
this.handleOpenDialogMr(); |
|
|
|
this.handleOpenDialogMr(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} else { |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -348,8 +334,7 @@ class index extends Component { |
|
|
|
if (payloadArray.length > 0) { |
|
|
|
if (payloadArray.length > 0) { |
|
|
|
await this.deleteCurrentRoleMenu(payloadArray[0].roles_id) |
|
|
|
await this.deleteCurrentRoleMenu(payloadArray[0].roles_id) |
|
|
|
} |
|
|
|
} |
|
|
|
let promises = [] |
|
|
|
let dataArr = [] |
|
|
|
let result = [] |
|
|
|
|
|
|
|
dataArray.map((val, index) => { |
|
|
|
dataArray.map((val, index) => { |
|
|
|
if (val.read === true) { |
|
|
|
if (val.read === true) { |
|
|
|
const formData = { |
|
|
|
const formData = { |
|
|
@ -359,23 +344,21 @@ class index extends Component { |
|
|
|
read: val.read, |
|
|
|
read: val.read, |
|
|
|
update: val.update, |
|
|
|
update: val.update, |
|
|
|
delete: val.delete |
|
|
|
delete: val.delete |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
promises.push(axios.post(ROLEMENU_ADD, formData, this.state.config) |
|
|
|
dataArr.push(formData); |
|
|
|
.then(res => result.push(res))) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const result = await axios |
|
|
|
|
|
|
|
.post(ROLEMENU_ADD, dataArr, this.state.config) |
|
|
|
|
|
|
|
.then((res) => res) |
|
|
|
|
|
|
|
.catch((err) => err.response); |
|
|
|
|
|
|
|
|
|
|
|
await Promise.all(promises); |
|
|
|
if (result && result.data && result.data.code == 200) { |
|
|
|
if (result) { |
|
|
|
|
|
|
|
if (result.length > 0) { |
|
|
|
|
|
|
|
if (result[0].data.code === 200) { |
|
|
|
|
|
|
|
this.getDataRoles(); |
|
|
|
this.getDataRoles(); |
|
|
|
NotificationManager.success('Data roles berhasil ditambahkan!!', 'Success!!'); |
|
|
|
NotificationManager.success('Data roles berhasil ditambahkan!!', 'Success!!'); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
NotificationManager.error(`${result[0].data.message}`, 'Failed!!'); |
|
|
|
NotificationManager.error(`${result.data.message}`, 'Failed!!'); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -413,12 +396,9 @@ class index extends Component { |
|
|
|
|
|
|
|
|
|
|
|
if (this.state.role_name !== "Super Admin") { |
|
|
|
if (this.state.role_name !== "Super Admin") { |
|
|
|
formData.columns.push( |
|
|
|
formData.columns.push( |
|
|
|
{ "name": "company_id", "logic_operator": "=", "value": this.state.company_id, "operator": "AND" }, |
|
|
|
{ "name": "company_id", "logic_operator": "=", "value": this.props.company_id, "operator": "AND" }, |
|
|
|
) |
|
|
|
) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// formData.columns.push(
|
|
|
|
|
|
|
|
// { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
|
|
|
|
|
|
|
|
// )
|
|
|
|
|
|
|
|
formData.joins.push( |
|
|
|
formData.joins.push( |
|
|
|
{ "name": "m_company", "column_join": "company_id", "column_results": ["company_name"] } |
|
|
|
{ "name": "m_company", "column_join": "company_id", "column_results": ["company_name"] } |
|
|
|
) |
|
|
|
) |
|
|
@ -462,9 +442,7 @@ class index extends Component { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
render() { |
|
|
|
render() { |
|
|
|
const { t } = this.props; |
|
|
|
const { dialogMenuForm, dataTable, openDialog, currentPage, rowsPerPage, totalPage, search } = this.state |
|
|
|
const { tooltipTambah, tooltipExport, dialogMenuForm, dataTable, openDialog, currentPage, rowsPerPage, totalPage, search, tooltipEdit, tooltipDelete, tooltipMenu } = this.state |
|
|
|
|
|
|
|
let noSeq = 0; |
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<div> |
|
|
|
<div> |
|
|
|
<NotificationContainer /> |
|
|
|
<NotificationContainer /> |
|
|
@ -527,7 +505,6 @@ class index extends Component { |
|
|
|
checkActMenup('/roles', 'create') ? |
|
|
|
checkActMenup('/roles', 'create') ? |
|
|
|
<Button Button id="TooltipTambah" color="success" onClick={() => this.handleOpenDialog('Save')}><i className="fa fa-plus"></i> |
|
|
|
<Button Button id="TooltipTambah" color="success" onClick={() => this.handleOpenDialog('Save')}><i className="fa fa-plus"></i> |
|
|
|
</Button> |
|
|
|
</Button> |
|
|
|
|
|
|
|
|
|
|
|
: |
|
|
|
: |
|
|
|
null |
|
|
|
null |
|
|
|
} |
|
|
|
} |
|
|
|