Browse Source

update filter by company and project

pull/2/head
farhantock 12 months ago
parent
commit
676ebfcce1
  1. 8
      src/views/Master/MasterRoles/DialogForm.js
  2. 7
      src/views/Master/MasterRoles/DialogMenuRoles.js
  3. 5
      src/views/Master/MasterRoles/index.js

8
src/views/Master/MasterRoles/DialogForm.js

@ -30,7 +30,6 @@ class DialogForm extends Component {
isParentClick: false, isParentClick: false,
menu: [], menu: [],
selectedMenu: null, selectedMenu: null,
company_id
} }
} }
@ -134,12 +133,13 @@ class DialogForm extends Component {
} }
handleSave = () => { handleSave = () => {
const { companyID } = this.props;
const { const {
id, id,
name, name,
description, description,
selectedMenu, selectedMenu,
company_id
} = this.state } = this.state
let data = ''; let data = '';
@ -151,7 +151,7 @@ class DialogForm extends Component {
name, name,
description, description,
selectedMenu, selectedMenu,
company_id company_id: companyID
} }
// console.log('data', data); // console.log('data', data);
this.props.closeDialog('save', data); this.props.closeDialog('save', data);
@ -161,7 +161,7 @@ class DialogForm extends Component {
name, name,
description, description,
selectedMenu, selectedMenu,
company_id company_id: companyID
} }
this.props.closeDialog('edit', data); this.props.closeDialog('edit', data);
} }

7
src/views/Master/MasterRoles/DialogMenuRoles.js

@ -51,8 +51,6 @@ class DialogMenuRoles extends Component {
} }
getAllMenu = async () => { getAllMenu = async () => {
const { companyID } = this.props; const { companyID } = this.props;
const { roleName } = this.props; const { roleName } = this.props;
if (roleName !== "Super Admin") { if (roleName !== "Super Admin") {
@ -81,7 +79,6 @@ class DialogMenuRoles extends Component {
.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) {
console.log('data Menu Role :', result.data.data);
this.setState({ menu: result.data.data }, () => { this.setState({ menu: result.data.data }, () => {
this.setStateMenu(false); this.setStateMenu(false);
}); });
@ -129,13 +126,14 @@ class DialogMenuRoles extends Component {
let copyStateMenu = [...this.state.stateMenu]; let copyStateMenu = [...this.state.stateMenu];
this.props.menuRoles.map((val, indexMenu) => { this.props.menuRoles.map((val, indexMenu) => {
let index = this.getIndexDataMenu(val.menu_id); let index = this.getIndexDataMenu(val.menu_id);
console.log("index true", val.menu_id); console.log('index true', index);
if (index >= 0) { if (index >= 0) {
copyStateMenu[index] = true; copyStateMenu[index] = true;
} }
}) })
this.setState({ stateMenu: [] }, () => { this.setState({ stateMenu: [] }, () => {
let check = copyStateMenu.some(this.checkArray); let check = copyStateMenu.some(this.checkArray);
console.log('icheck', check);
if (check === false) { if (check === false) {
this.setState({ allChecked: true, stateMenu: copyStateMenu }) this.setState({ allChecked: true, stateMenu: copyStateMenu })
} else { } else {
@ -184,6 +182,7 @@ class DialogMenuRoles extends Component {
renderForm = () => { renderForm = () => {
const { menu, stateMenu } = this.state const { menu, stateMenu } = this.state
console.log('stateMenu', stateMenu);
return ( return (
menu.map((val, index) => { menu.map((val, index) => {
return ( return (

5
src/views/Master/MasterRoles/index.js

@ -198,7 +198,7 @@ class index extends Component {
name: data.name, name: data.name,
description: data.description, description: data.description,
default_page: data.selectedMenu, default_page: data.selectedMenu,
company_id: this.company_id company_id: data.company_id
} }
const result = await axios.post(ROLE_ADD, formData, this.config) const result = await axios.post(ROLE_ADD, formData, this.config)
@ -218,7 +218,8 @@ class index extends Component {
const formData = { const formData = {
name: data.name, name: data.name,
description: data.description, description: data.description,
default_page: data.selectedMenu default_page: data.selectedMenu,
company_id: data.company_id
} }
const url = ROLE_EDIT(data.id) const url = ROLE_EDIT(data.id)
const result = await axios.put(url, formData, this.config) const result = await axios.put(url, formData, this.config)

Loading…
Cancel
Save