Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
Tia-dev
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dida Adams Arizona
Tia-dev
Commits
531b7efe
Commit
531b7efe
authored
Aug 17, 2020
by
d.arizona
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto GG PARAH
parent
a88981d1
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
161 additions
and
106 deletions
+161
-106
AddUser.js
src/container/Otorisasi/User/AddUser.js
+109
-37
EditUser.js
src/container/Otorisasi/User/EditUser.js
+52
-69
No files found.
src/container/Otorisasi/User/AddUser.js
View file @
531b7efe
This diff is collapsed.
Click to expand it.
src/container/Otorisasi/User/EditUser.js
View file @
531b7efe
...
...
@@ -183,7 +183,6 @@ export default class EditUser extends Component {
api
.
create
().
getPerusahaanHierarki
().
then
((
response
)
=>
{
if
(
response
.
data
.
status
===
'success'
)
{
this
.
setState
({
listCompany
:
response
.
data
.
data
})
// console.log(response.data.data)
}
})
}
...
...
@@ -216,10 +215,10 @@ export default class EditUser extends Component {
{
item
.
child
.
map
((
data
,
index
)
=>
{
return
(
<
li
>
<
Collapse
timeout
=
"auto"
unmountOnExit
in
=
{
item
.
collapse
}
>
<
Collapse
key
=
{
index
}
timeout
=
"auto"
unmountOnExit
in
=
{
item
.
collapse
}
>
<
div
style
=
{{
display
:
'flex'
,
flexDirection
:
'row'
,
alignItems
:
'center'
,
justifyContent
:
'flex-start'
,
paddingLeft
:
R
.
isNil
(
data
.
child
)
?
(
padding
+
20
)
:
padding
}}
>
{
!
R
.
isNil
(
data
.
child
)
&&
<
span
onClick
=
{()
=>
this
.
setState
({
selectedIndex
:
data
.
company_id
===
this
.
state
.
selectedIndex
?
0
:
data
.
company_id
}
)}
style
=
{{
marginLeft
:
7
,
marginRight
:
2
}}
>
{
data
.
co
mpany_id
===
this
.
state
.
selectedIndex
?
<
RemoveIcon
color
=
{
'action'
}
fontSize
=
{
'small'
}
/> : <AddIcon color={'action'} fontSize={'small'} /
>
}
{
!
R
.
isNil
(
data
.
child
)
&&
<
span
onClick
=
{()
=>
this
.
handleCollapse
(
data
)}
style
=
{{
marginLeft
:
7
,
marginRight
:
2
}}
>
{
data
.
co
llapse
?
<
RemoveIcon
color
=
{
'action'
}
fontSize
=
{
'small'
}
/> : <AddIcon color={'action'} fontSize={'small'} /
>
}
<
/span>
}
<
span
>
<
CustomCheckbox
...
...
@@ -238,59 +237,56 @@ export default class EditUser extends Component {
)
}
renderChild
(
item
,
index
)
{
return
(
item
.
child
.
map
((
items
,
indexs
,
paddingLeft
)
=>
{
return
(
<
div
>
<
div
style
=
{{
paddingLeft
:
R
.
isNil
(
items
.
child
)
?
120
:
60
,
display
:
'flex'
,
flexDirection
:
'row'
,
alignItems
:
'center'
,
justifyContent
:
'flex-start'
}}
>
{
/* {item.sub_menu.length > 0 && <span onClick={() => this.setState({ selectedIndex: index === this.state.selectedIndex ? 0 : index })} style={{ marginLeft: 7, marginRight: 2 }}>
{index === this.state.selectedIndex ? <RemoveIcon color={'action'} fontSize={'small'} /> : <AddIcon color={'action'} fontSize={'small'} />}
</span>} */
}
{
/* <RemoveIcon color={'action'} fontSize={'small'} /> */
}
<
span
>
<
CustomCheckbox
checked
=
{
this
.
handleItemChecked
(
items
)}
onChange
=
{()
=>
this
.
handleItemClick
(
items
)}
/
>
<
/span
>
<
Typography
style
=
{{
fontSize
:
12
}}
>
{
titleCase
(
items
.
company_name
)}
<
/Typography
>
<
/div
>
{
!
R
.
isNil
(
items
.
child
)
&&
this
.
renderChild
(
items
,
indexs
)}
<
/div
>
)
})
)
}
handleCollapse
(
item
)
{
let
path
=
this
.
searchIt
({
child
:
this
.
state
.
listCompany
},
item
.
company_id
)
let
listCompany
=
this
.
state
.
listCompany
let
arrayPath
=
[]
handleCollapse
(
item
,
index
)
{
let
result
=
this
.
findIndexNested
(
this
.
state
.
listCompany
,
index
);
console
.
log
(
"Found index "
+
index
+
" via these child indexes: "
+
result
);
}
if
(
path
.
length
>
1
)
{
arrayPath
=
path
.
split
(
'-'
);
arrayPath
=
arrayPath
.
map
((
item
)
=>
{
return
item
})
}
else
{
arrayPath
.
push
(
path
)
}
// handleCollapseChildren(item,index) {
// let listCompany = this.state.listCompany[index]
// let index = listCompany.findIndex((val) => val.company_id === item.company_id)
// if (index == -1 ) {
// item.child.map((item,index) => this.handleCollapseChildren(item,index))
// } else {
// listCompany[index].collapse = !listCompany[index].collapse
// }
// }
findIndexNested
(
data
,
index
)
{
if
(
data
.
index
===
index
)
return
[];
let
result
;
const
i
=
(
data
.
children
||
[]).
findIndex
(
child
=>
{
return
result
=
this
.
findIndexNested
(
child
,
index
)
});
if
(
result
)
return
[
i
,
...
result
];
}
let
pathSelect
=
null
if
(
arrayPath
.
length
==
1
)
{
pathSelect
=
listCompany
[
arrayPath
[
0
]]
}
else
if
(
arrayPath
.
length
==
2
)
{
pathSelect
=
listCompany
[
arrayPath
[
0
]].
child
[
arrayPath
[
1
]]
}
else
if
(
arrayPath
.
length
==
3
)
{
pathSelect
=
listCompany
[
arrayPath
[
0
]].
child
[
arrayPath
[
1
]].
child
[
arrayPath
[
2
]]
}
else
if
(
arrayPath
.
length
==
4
)
{
pathSelect
=
listCompany
[
arrayPath
[
0
]].
child
[
arrayPath
[
1
]].
child
[
arrayPath
[
2
]].
child
[
arrayPath
[
3
]]
}
else
if
(
arrayPath
.
length
==
5
)
{
pathSelect
=
listCompany
[
arrayPath
[
0
]].
child
[
arrayPath
[
1
]].
child
[
arrayPath
[
2
]].
child
[
arrayPath
[
3
]].
child
[
arrayPath
[
4
]]
}
else
if
(
arrayPath
.
length
==
6
)
{
pathSelect
=
listCompany
[
arrayPath
[
0
]].
child
[
arrayPath
[
1
]].
child
[
arrayPath
[
2
]].
child
[
arrayPath
[
3
]].
child
[
arrayPath
[
4
]].
child
[
arrayPath
[
5
]]
}
else
if
(
arrayPath
.
length
==
7
)
{
pathSelect
=
listCompany
[
arrayPath
[
0
]].
child
[
arrayPath
[
1
]].
child
[
arrayPath
[
2
]].
child
[
arrayPath
[
3
]].
child
[
arrayPath
[
4
]].
child
[
arrayPath
[
5
]].
child
[
arrayPath
[
6
]]
}
findByPath
(
data
,
path
)
{
for
(
let
i
of
path
)
data
=
data
.
children
[
i
];
return
data
pathSelect
.
collapse
=
!
pathSelect
.
collapse
// console.log(pathSelect.collapse)
this
.
setState
({
listCompany
},
()
=>
console
.
log
(
pathSelect
))
}
searchIt
=
(
node
,
search
,
path
=
''
,
position
=
0
)
=>
{
if
(
node
.
company_id
&&
node
.
company_id
===
search
)
{
return
path
!==
''
?
`
${
path
}
-
${
position
}
`
:
position
;}
if
(
!
node
.
child
)
{
return
false
}
const
index
=
node
.
child
.
findIndex
((
x
)
=>
x
.
company_id
&&
x
.
company_id
===
search
);
if
(
index
>=
0
)
{
return
path
!==
''
?
`
${
path
}
-
${
index
}
`
:
index
;
}
for
(
let
i
=
0
;
i
<
node
.
child
.
length
;
i
++
)
{
const
result
=
this
.
searchIt
(
node
.
child
[
i
],
search
,
path
!==
''
?
`
${
path
}
-
${
i
}
`
:
i
,
i
);
if
(
result
){
return
result
;
}
}
return
false
;
};
render
()
{
return
(
<
div
className
=
"test app-popup-show"
>
...
...
@@ -401,7 +397,7 @@ export default class EditUser extends Component {
/
>
<
/div
>
<
/div
>
<
div
className
=
"column-2"
>
<
div
className
=
"margin-bottom-20px"
>
<
DatePicker
...
...
@@ -480,8 +476,8 @@ export default class EditUser extends Component {
<
ul
>
<
li
>
<
div
style
=
{{
display
:
'flex'
,
flexDirection
:
'row'
,
alignItems
:
'center'
,
justifyContent
:
'flex-start'
}}
>
{
item
.
child
.
length
>
0
&&
<
span
onClick
=
{()
=>
this
.
handleCollapse
(
item
,
index
)}
style
=
{{
marginLeft
:
7
,
marginRight
:
2
}}
>
{
i
ndex
===
this
.
state
.
selectedIndex
?
<
RemoveIcon
color
=
{
'action'
}
fontSize
=
{
'small'
}
/> : <AddIcon color={'action'} fontSize={'small'} /
>
}
{
item
.
child
.
length
>
0
&&
<
span
onClick
=
{()
=>
this
.
handleCollapse
(
item
)}
style
=
{{
marginLeft
:
7
,
marginRight
:
2
}}
>
{
i
tem
.
collapse
?
<
RemoveIcon
color
=
{
'action'
}
fontSize
=
{
'small'
}
/> : <AddIcon color={'action'} fontSize={'small'} /
>
}
<
/span>
}
<
span
>
<
CustomCheckbox
...
...
@@ -494,19 +490,6 @@ export default class EditUser extends Component {
{
!
R
.
isNil
(
item
.
child
)
&&
this
.
renderChildren
(
item
)}
<
/li
>
<
/ul
>
{
/* <div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start' }}>
{item.child.length > 0 && <span onClick={() => this.setState({ selectedIndex: index === this.state.selectedIndex ? 0 : index })} style={{ marginLeft: 7, marginRight: 2 }}>
{index === this.state.selectedIndex ? <RemoveIcon color={'action'} fontSize={'small'} /> : <AddIcon color={'action'} fontSize={'small'} />}
</span>}
<span>
<CustomCheckbox
checked={this.handleItemChecked(item)}
onChange={() => this.handleItemClick(item)}
/>
</span>
<Typography style={{ fontSize: 12 }}>{titleCase(item.company_name)}</Typography>
</div> */
}
{
/* {this.renderChild(item,index, 0)} */
}
<
/div
>
)
})}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment