Collapse or expand all properties 'Onclick'

I want to move from this

to this with one click how can i make it

Maybe you want to add an HTML button to collapse all panels. Its click function would look something like this, assuming panel names ‘PROPERTIES’ and ‘METHODS’:

function collapseAllPanels() {
  myDiagram.startTransaction('collapse all');
  for (var it = myDiagram.nodes;; ) {
    var n = it.value;  // n is now a Node or a Group
    var pan = n.findObject('PROPERTIES');
    if (pan) pan.visible = false;
    pan = n.findObject('METHODS');
    if (pan) pan.visible = false;
  myDiagram.commitTransaction('collapse all');

Thank you so much , it works