Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ayush Tiwari
erp5
Commits
666ae2a6
Commit
666ae2a6
authored
Nov 06, 2017
by
Ayush Tiwari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bt5_config: Update state of children and parent considering the state of parent and vice-versa
parent
e741f6e5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
20 deletions
+43
-20
product/ERP5/bootstrap/erp5_business_package/SkinTemplateItem/portal_skins/erp5_business_package/business_manager_select_action_gadget.js.js
...iness_package/business_manager_select_action_gadget.js.js
+43
-20
No files found.
product/ERP5/bootstrap/erp5_business_package/SkinTemplateItem/portal_skins/erp5_business_package/business_manager_select_action_gadget.js.js
View file @
666ae2a6
...
...
@@ -66,7 +66,7 @@
state
=
tree
.
sub
[
key
].
value
;
node
=
{
id
:
subid
,
title
:
key
};
if
(
tree
.
sub
[
key
].
hasOwnProperty
(
'
value
'
))
{
node
.
state
=
tree
.
sub
[
key
].
value
;
node
.
state
=
tree
.
sub
[
key
].
value
;
}
if
(
tree
.
sub
[
key
].
hasOwnProperty
(
'
sub
'
))
{
node
.
tree_html
=
buildTreeHTML
(
subid
,
tree
.
sub
[
key
]);
...
...
@@ -79,18 +79,14 @@
return
html
;
}
function
getParentNode
(
data
,
childName
)
{
// Get the tree created from `item_path_list` and use it to find out parent
}
rJS
(
window
)
.
declareMethod
(
'
render
'
,
function
(
options
)
{
var
parameter_dict
=
JSON
.
parse
(
options
.
value
),
item_path_list
=
parameter_dict
.
item_path_list
;
item_path_list
=
parameter_dict
.
item_path_list
,
html_tree
=
buildTreeHTML
(
'
tree
'
,
convertPathListToTree
(
item_path_list
));
this
.
action_url
=
parameter_dict
.
action_url
;
var
html_tree
=
buildTreeHTML
(
'
tree
'
,
convertPathListToTree
(
item_path_list
));
this
.
element
.
innerHTML
=
html_tree
this
.
element
.
innerHTML
=
html_tree
;
console
.
log
(
html_tree
);
})
...
...
@@ -104,22 +100,49 @@
// 2 . If parent has no value:
// - All children checked -> Parent checked
// - Parent checked -> All children checked
var
childrenSelected
=
this
.
element
.
querySelectorAll
(
'
input[type=checkbox][id="item_path_list:list"][name="child_path"]:checked
'
);
var
parentSelected
=
this
.
element
.
querySelectorAll
(
'
input[type=checkbox][id^="tree"][name="parent_path"]:checked
'
);
// Spread the result value so that we can use map on it
var
parentValues
=
[...
parentSelected
].
map
(
function
(
x
){
return
x
.
nextSibling
.
textContent
;
});
var
childrenValues
=
[...
childrenSelected
].
map
(
function
(
x
){
return
x
.
nextSibling
.
textContent
;
})
if
(
evt
.
target
.
getAttribute
(
'
name
'
)
===
'
child_path
'
)
{
// Get the parent element with with path
var
parent
=
evt
.
target
.
parentElement
.
parentElement
.
parentElement
,
state
=
parent
.
querySelector
(
'
input[type=checkbox][name$="_path"]
'
).
nextElementSibling
.
getAttribute
(
'
state
'
);
// Only update the children and parents together if parent element
// has no state value
if
(
!
state
)
{
var
childrenChecked
=
parent
.
querySelectorAll
(
'
input[type=checkbox][name="child_path"]:checked
'
),
children
=
parent
.
querySelectorAll
(
'
input[type=checkbox][name="child_path"]
'
),
parentCheckBox
=
parent
.
querySelector
(
'
input[type=checkbox][name$="parent_path"]
'
);
if
(
children
.
length
===
childrenChecked
.
length
)
{
parentCheckBox
.
checked
=
evt
.
target
.
checked
;
}
}
}
if
(
evt
.
target
.
getAttribute
(
'
name
'
)
===
'
parent_path
'
)
{
// Check for the state of the target
// If there is no state, then check if all the children are flattened
// or not. If there is another tree in the child nodes, do nothing.
// Else update the checked status of all the child nodes similar to
// that of the parent
if
(
!
evt
.
target
.
nextSibling
.
getAttribute
(
'
state
'
))
{
var
nodeChildPath
=
evt
.
target
.
nextElementSibling
.
nextElementSibling
.
querySelectorAll
(
'
input[type=checkbox][name="child_path"]
'
),
nodeParentPath
=
evt
.
target
.
nextElementSibling
.
nextElementSibling
.
querySelectorAll
(
'
input[type=checkbox][name="parent_path"]
'
),
i
,
element
;
// If there is no nodeParentPath and some childParentPath, update
// the checked status of the childParentPath
if
((
!
nodeParentPath
.
length
)
&&
(
nodeChildPath
.
length
))
{
for
(
i
=
0
;
element
=
nodeChildPath
[
i
];
i
++
)
{
element
.
checked
=
evt
.
target
.
checked
;
}
}
}
}
console
.
log
(
'
Update the checkbox state of children (and parents too)
'
);
}
},
false
,
false
)
.
declareMethod
(
'
getContent
'
,
function
(
options
)
{
var
val
=
this
.
element
.
querySelectorAll
(
'
input[type=checkbox][name="item_path_list:list"]:checked
'
);
var
val_tree
=
this
.
element
.
querySelectorAll
(
'
input[type=checkbox][name^="tree"]:checked
'
);
var
input_list
=
options
.
input_list
;
console
.
log
(
input_list
);
return
jIO
.
util
.
ajax
({
type
:
'
POST
'
,
...
...
@@ -127,6 +150,6 @@
data
:
{
'
checkNeeded
'
:
'
True
'
,
'
item_path_list
'
:
input_list
}
});
})
})
;
}(
rJS
,
jIO
,
Handlebars
,
RSVP
,
window
));
\ No newline at end of file
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