Is there any way to hook into the save
# package-development
p
Is there any way to hook into the save button for document types? I want my custom view to send data when the save button is called
n
Not proper supported, but you could make your own Workspace Action that did something before calling
workspaceContext.requestSubmit()
? But do notice your custom view, which sounds like a Workspace View, is not necessary rendered, so I would put that logic into a Workspace Context of your own — see the Workspace Context Counter example in the core code base, this also comes with a Workspace Action, then you just need to define
overwrite: '[insert alias of the Document Submit workspace action]'
p
Yeah, that is what I am currently doing (and calling an event so the different workspaces can hook into it). Would it be worth to add something in the core to throw an event on save?
n
Yes, I would say yes to that. Can I ask more specifically about your use case? Cause I would like to know if a more generic event like “updated” would work in your case? (I imagine this would also be trigged when Published, and it could also be trigged via Signal-R once we implement that) Then I’ll make sure we get around it in near future.
p
Yes ofcourse. The SeoToolkit package extends the document type with a new content app (or workspace view). This is closely related to the loaded document type. So ideally I want to use the save button of the document type so that I can also send the data to my own endpoint whenever the user wants to save their document type https://cdn.discordapp.com/attachments/1313223851890708551/1316063260553773118/image.png?ex=6759aeec&is=67585d6c&hm=4e6b577e8b6b610481605ef494394c968acf8bd81a8427a4b41c97f7ef70884d&
I don't want it to be a seperate button in the view itself as that will only confuse people expecting a single flow of actions
n
Okay, I see, so it’s more of a local awareness of when the save action specifically was requested. And importantly only reacting when the Workspace of it is location is saved.
p
Yes indeed
n
Cool, I have a created a task for this 🙂
6 Views