Close All Drawers Action

  • 3
  • Question
  • Updated 1 year ago
  • Answered
Is there a way to close all drawers?  It'd be nice to have drawers close when another is opened.
Photo of Scott

Scott

  • 2,732 Points 2k badge 2x thumb

Posted 5 years ago

  • 3
Photo of Matt Sones

Matt Sones, Champion

  • 32,026 Points 20k badge 2x thumb
Hey friends.

Looks like some of the drawer-related functions are now exposed in the API. So, although this is UNDOCUMENTED, here's a snippet which when run immediately after an open/close drawers action in an action sequence, will close all the other open drawers, so you only have one open at a time.

// Run immediately after open/close drawer action to close other drawers.
var args = arguments[0],
thisID = args.item && args.item.drawers && args.item.drawers[0]._GUID,
tems = args.list.visibleItems,
drawer,
$ = skuid.$;
$.each(items,function(index,item){
drawer = item.drawers && item.drawers[0];
if (drawer && (drawer._GUID !== thisID) && drawer.isOpen) {
drawer.close();
}
});
Photo of Craig Rosenbaum

Craig Rosenbaum

  • 4,940 Points 4k badge 2x thumb
Real quick and minor correction if anyone pastes this and gets an error:
tems = args.list.visibleItems,
This should be
items = args.list.visibleItems,
Otherwise it works great
Photo of Laura Burnett

Laura Burnett

  • 588 Points 500 badge 2x thumb
Hello, this sort of worked for me, except for a button at the bottom of the drawer:




Additionally, once closed I can't reopen the draw.

The problem I have is that button "I want to meet with this person" is using the model from the draw, but if two are opened at the same time it always uses the data from the latest opened draw. I can't set context on the button as far as I can see?
Photo of Laura Burnett

Laura Burnett

  • 588 Points 500 badge 2x thumb
Update: I was adding in the wrong place. When I added "run Skuid Javascript" to the action framework and then selected the relevant script, it worked!