Modify OOB directive: sn-filter-widget
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2024 12:27 PM - edited 05-13-2024 12:52 PM
I am working on a portal widget to give customers access to their data without giving them the internal view.
The basic design will see them able to setup a number of filters on specified tables we specify, these will then run and load up the list of results in various tabs. I've got the portal loading a number of filter widgets using a custom copy of the SN Desktop Filter widget. (Main customisations are to pass in more variables to hide the various Run and Save buttons along with the close icon. This uses the sn-filter-widget directive located here: /scripts/js_includes_filter_widget.js
This is all working but now I need to actually get the data out of the filter and I'm a bit stuck on how to achieve this. A Looking at the code I don't think any of the $broadcast functions are set to run on the filter value changing and I think are waiting on the button to be pressed to update the encoded Query.
That said, my ideal solution would be for the user to press a button in the parent widget, it loop through all of the loaded filters and get the queries (to save $broadcast occurring on any incomplete filters). I can do the button call and loops but it's the reading of the data in the nested widgets I'm stuck on.
I'm wondering if there is a way to inject a custom field watcher into the existing query but this is not something I've done before and would appreciate any pointers the community may have. (Or a better / simpler approach or a function I may have overlooked that is already doing this).
Thank you.
UPDATE
I did a bit more digging and noted that the RUN button does trigger a broadcast (snfilter:update_query) which can be listened for. This is workable and I can build the design around it however I don't know how to know which of the nested widgets the broadcast came from. Is there a way to know this? (I would normally broadcast an ID back that was passed in when the widget was initialised but this comes back to editing OOB functions). I would also need to change the button text but that may be a step too far.