Skip to main content
Nintex Community Menu Bar
Question

Context Factory?

  • Jul 11, 2024 11:56 AM UTC
  • 12 replies
  • 44 views
  • Translate All

Forum|alt.badge.img+20

Does Skuid have a context factory or something we could use for generating context? ie. from component to component

This topic has been closed for replies.

12 replies

Forum|alt.badge.img+10

We have the deck component and page include… I don’t think I fully understand what you’re asking for. Could you elaborate and possibly give an exact use case? 

Translate

Forum|alt.badge.img+20
  • Author
  • Nintex Partner
  • Jul 11, 2024 12:24 PM UTC

When creating a custom component, we’d like to know how to generate the context.

The deck component is somewhat nice, but we are looking to build something a little more sophisticated than what the deck provides. Can we borrow Ben and/or Zack for an hour or two? 😉

Translate

Forum|alt.badge.img+10

Ben and Zack are brilliant, no doubt. I’ll ask and see if I can get a high level answer. 

Translate

Forum|alt.badge.img+20
  • Author
  • Nintex Partner
  • Jul 11, 2024 12:24 PM UTC

+1

Translate

Forum|alt.badge.img

I would love to pick those guys’ brains. Specifically, this refers to executing an ActionsNode, when creating the “context” object that needs to be passed in as follows:

$a&#46;runActionsNode(actionsNode, component, <b>context</b> || { model: model, item: k&#46;item, row: k&#46;item&#46;row, list: k&#46;item&#46;list, &#47;&#47; required &#47;&#47; if c&#46;attr("role", "button") &#47;&#47; button: c, &#47;&#47; not always required, what does this do???? &#47;&#47; _GUID = b&#46;prototype&#46;id &#47;&#47; &#46;&#46;&#46; so just iD? &#47;&#47; initiatorId: z&#46;editor&#46;_GUID })

The current context at this point is always null, so simply passing it in does nothing and it must be created from scratch… but how? I haven’t been able to figure out what k is in my scenario above… Also, clearly, this whole thing involves setting some custom click event handler on the initiating element… any pointers? somehting we could reuse?

Translate

Forum|alt.badge.img+18

If I had to guess, I’d expect k to be the element that was clicked to initiate the action sequence. Doesn’t element usually have an ‘item’ property?

Translate

Forum|alt.badge.img+20
  • Author
  • Nintex Partner
  • Jul 11, 2024 12:24 PM UTC

That makes sense to me. Hmmm …

Translate

Forum|alt.badge.img+13

@Pat If you’re building a custom component that does Deck-like functionality, where you’re iterating over all rows in a Model, and you want to use skuid.actions.runActionsNode() and have it run the actions in context of the particular row that you care about, then just ensure that you are passing in the current row, e.g. your context can be as simple as this:


skuid.actions.runActionsNode(actionsNode, component, {
   model: model, 
   row: row,
});

If you’re trying to do things with “selected Items” or “mass action” type capabilities, that’s more complicated, but I could touch on that a bit more.

Hope that helps.

Translate

Forum|alt.badge.img+20
  • Author
  • Nintex Partner
  • Jul 11, 2024 12:24 PM UTC

If only I could intern in the Skuid engineering dept for a week. 

Translate

Forum|alt.badge.img

Thanks Zach! that was all I needed. It was really much simpler than I thought…

Translate

Forum|alt.badge.img

So I ended up with the following code

$a.runActionsNode(actionsNode, component, context ||<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; model: model,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; row: rowID ? model.getRowById(rowID) : null,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; initiatorId: initiatorId=event._GUID,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }

Where the row attribute covers the case where context is row-based and the initiatorId is for component-based context cases

Translate

Arne-Per
Forum|alt.badge.img+8
  • Rookie
  • Jul 11, 2024 12:24 PM UTC

@zach could you expand what you offered Pat? 🙂 “If you’re trying to do things with “selected Items” or “mass action” type capabilities, that’s more complicated, but I could touch on that a bit more.”

Translate