How to trigger Assign to Analyst by Group
When you select a request in Team Request view (or Mywork/Active work) you can hit the Task button on the drawer task bar an select assign to analyst by group.
What I would like to do is making an icon in the assigned to column and trigger the same function when you click on that icon but I can't find out how trigger it.
Anyone who can help with this or guide me?
Best Answers
-
Ryan_Lane Cireson Support Advanced IT Monkey ✭✭✭Hello!
Piggybacking off of the suggestion by @Tom_Hendricks the following will trigger the Assign To Analyst By Group dialog on Work Items and My/Team Work views:$('li[data-bind*="click: analystByGroup"]').get(0).kendoBindingTarget.source.analystByGroup();
It locates the original view model used in the Kendo binding and calls the analystByGroup function from there. I'll have to play around a bit tomorrow for a full answer to the original question since the button creation will need to be plugged into the change event for the grid to add when necessary, handle deselecting and only selecting the relevant row and then finally calling the analystByGroup function.
Here's a quick and dirty solution to select a particular row by index I have so far:var gridEle = $("div[data-role='grid']"), gridData = $(gridEle).data("kendoGrid"), selectuid = gridData.dataSource.data()[3].uid, selectRow = $(gridEle).find('tr[data-uid="' + selectuid + '"]'); gridData.clearSelection(); gridData.select(selectRow);
9 -
Ryan_Lane Cireson Support Advanced IT Monkey ✭✭✭Made a small bit of progress on this today. Instead of forcing the script to monitor for any changes in the grid or page with a mutation observer or heavily scripted event subscriber I've modified the grid's AssignedUser column template. This can be done either via updating the SQL definition for the out of the box My/Team Work views or by creating a custom view. In my case I created a quick custom 'My Work' view to test.(attached)
New AssignedUser field template:"template": "<span style=\"display: inherit; width: 100%\">#: AssignedUser #</span># if (session.user.Analyst) { #<ul class=\"ra-grid-task-menu\" style=\"display: inherit; list-style: none;\"><li onclick=\"app.events.publish('newGridTask','AssignToAnalystByGroup');\"><a class=\"ra-icon\" style=\"display: inherit;\"><i class=\"fa fa-pencil\"></i></a></li></ul># } #"
This template adds a nice edit button to the AssignedUser column publishes the event newGridTask via app events when you click it.
The following view model and app event subscribers are then added to custom.js to watch for changes to the grid and clicking any edit buttons to start up Assign Analyst By Group feature.
custom.js:var gridTasksViewModel = new kendo.observable({ PendingTask: '', AssignToAnalystByGroup: function AssignToAnalystByGroup () { console.log('gridTasksViewModel:AssignToAnalystByGroup'); $('li[data-bind*="click: analystByGroup"]').trigger('click'); } }); app.events.subscribe("gridChange", function (event, grid) { console.log('grid:change event', event); console.log('grid:change grid', grid); if (gridTasksViewModel.get('PendingTask').length !== 0) { gridTasksViewModel.AssignToAnalystByGroup(); gridTasksViewModel.set('PendingTask', ''); } }); app.events.subscribe("newGridTask", function (event, taskName) { console.log('grid:newGridTask event', event); console.log('grid:newGridTask taskName', taskName); gridTasksViewModel.set('PendingTask', taskName); });<br>
With this we can select one or multiple items in the grid and then immediately go into the Assign To Analyst By Group dialog.
Some random thoughts so far:- We could even go a step or two further and set the initial Support Group dropdown to the value from the last selected item.
- My changes to the column template could be applied manually after the page load with a quick jQuery function subscribed to the gridChange app event and the change instead of with the template changes to save having to change any Cireson files/database entries.
- The drawer button to initiate Assign To Analyst By Group is selectively enabled/disabled depending on what is selected so a check to match that behavior may be in order.
- My initial view model gridTasksViewModel where I store the pending task state and custom AssignToAnalystByGroup function could be adapted to handle other custom grid tasks like Assign To Me and Change Status or any unique tasks we could apply to one or more work items.
- Modifying the button HTML/CSS to better account for smaller column widths and multiple buttons is probably going to be my next step in refining what I have so far.
6
Answers
Can you help?
Piggybacking off of the suggestion by @Tom_Hendricks the following will trigger the Assign To Analyst By Group dialog on Work Items and My/Team Work views:
It locates the original view model used in the Kendo binding and calls the analystByGroup function from there. I'll have to play around a bit tomorrow for a full answer to the original question since the button creation will need to be plugged into the change event for the grid to add when necessary, handle deselecting and only selecting the relevant row and then finally calling the analystByGroup function.
Here's a quick and dirty solution to select a particular row by index I have so far:
New AssignedUser field template:
The following view model and app event subscribers are then added to custom.js to watch for changes to the grid and clicking any edit buttons to start up Assign Analyst By Group feature.
custom.js:
Some random thoughts so far:
New custom.js script:
TBD:
EDIT: Modified the custom.js script to account for edge cases of swapping back and forth between non-IR/SR selections and then immediately selecting a valid option as well as moving tasks functions into a small library under gridTasksViewModel.lib for a better interface.
Hope everyone had a great holiday weekend. For this small update of my work in progress I've made a bit of a breakthrough in altering grid columns dynamically without removing existing bindings or functionality. Here are some screenshots of multiple button types per field, conditional filtering and formatting based on field values:
My Work:
Team Work:
I'm still working on the grid tasks framework but so far it has provided a wealth of potential benefits:
- No need to modify Cireson's source files, create custom views or modify view definitions in ServiceManagement db.
- Efficiently uses Kendo's templating system to handle refreshes, page navigation and grid changes without mutation observers, timers or excessive subscriptions to any event systems.
- Easily expandable to handle multiple separate functions per field. So far I am working on the following functionality: edit buttons, info/popup buttons, conditional formatting and access control to these custom features.
On another note, I've moved away from allowing multiple selections at once when clicking on individual field buttons so clicking an edit button will select that single row and un-select all other rows. This still leaves the option of selecting multiple items and then clicking Assign To Analyst By Group under Tasks.Please let me know if anyone has any thoughts or ideas as I'm working on this one. Thanks!
It's me again with another update on my work in progress for the custom buttons/styles in grids portion of this thread.
I have created app.custom.gridTasks (in a similar vein to app.custom.formTasks) to handle adding custom tasks to specific grids. Using each Kendo grid's own column template array to store our custom data and anonymous functions to return angular template strings we can have any grid populate and use our custom code however we would like to without destroying the grids and undoing existing bindings from Cireson, subscriptions or other scripts.
app.custom.gridTasks:
Adding a grid style to Priority with different colors depending on value:
Adding two grid tasks to AssignedUser with unique callbacks and filters:
Some custom CSS for our new grid task elements:
And finally updating the grid to show our changes: TBD:
- Combining this new grid task functionality with my previous trigger script for Assign To Analyst By Group.
- Adding the option of using a html file to define Kendo external templates.
- Still potentially adding enable/disable functionality to buttons rather than just not rendering them.
Please let me know if anyone has any thoughts or ideas as I'm working on this one. Thanks!
Hope you had a good weekend. I have added quite a bit more polish on this (attached).
- Custom task templates now support tasks and links.
- Callbacks can now dynamically stop click propagation to the built-in click functionality.
- Added to custom.css for better highlighting of tasks in the grid title and regular cell sections and removed the built-in right-arrow in Team Work/Active Work views.
- Fully functional Assign To Analyst By Group and custom Title links for same page and new tab. (below)
custom.js:
WIP In Action:
The script below shows a fully functional customization with:
- Internal/External Links in Title.
- Quick edit buttons for Assign To Analyst By Group in Assigned User
- Background color conditional formatting for Priority.
TBD:
- Adding the option of using html files to define Kendo external templates.
- Potentially adding enable/disable functionality to buttons rather than just not rendering them. Leaning more on a no on this feature as I go.
- Removing custom tasks and potentially resetting grid columns to out of the box.
Please let me know if anyone has any thoughts or ideas as I'm working on this. Thanks!
@Brian_Wiest That's most likely due to the script triggering before the grid is ready to be modified. A quick subscription to the dynamicPageReady event and a new variable to track if our customization is done at app.custom.gridTasks.built should do it. I have updated, renamed and pushed custom.js and custom.css to the github repo.
Related new code from custom.js (updated with latest push):
Thanks for the feedback!
EDIT: I've also added a quick check after the dynamicPageReady event to confirm the page actually has a grid to customize. Updated custom.js has been pushed.
If you'd like to target the non-title section icons you can use the following CSS:
This works with the other CustomGridTask CSS in order of complexity so we can keep the title section links replicating the out of the box behavior while targeting the new icons with new coloring.
Example 1:
1. Selected Row
2. Unselected Row
3. Hovered Row & Icon
Example 2:
1. Selected Row & Hovered Icon
2. Unselected Row
3. Unselected Row
If you'd also like to change the icon color behavior when selected and hovering let me know and I'll see about the CSS for that scenario.
EDIT: I have added the examples as commented out classes in custom.css. Also, I have made some light changes to custom.js to minimize the amount of whitespace in the final cell templates so that jQuery isn't sending unnecessarily large numbers of empty characters to the server when columns are converted to params:
Have a good weekend all!
It's been a busy couple of weeks but I've got a few updates for my gridTasks plugin. I'm not sure how many others make use of the RequireJS optimizer in production but we do in our environment and I've updated the repo with it as well as other functionality and bug-fixes:
1. Custom Session Debugging
Added app.storage.custom to handle storing debug data for a session to make troubleshooting from the client side easier. Now you can enable/disable debug mode via:
In my case I made a quick tampermonkey script to quickly enable/disable debug mode:
2. Custom Utilities
Included a small number of utility functions under app.custom.utils to be used with this and other custom scripts:
- getCachedScript
- getCSS
- isGuid
- sortList
- stringFormat
3. Rewrote gridTask as a RequireJS module
RequireJS has a great option for optimizing module dependencies in production that we use for all of the *main.js files (wiMain/viewMain/profileMain) so gridTasks has been refactored to work as a module. The "built" folder in the repo contains the RequireJS Configs and a batch file to build /custom.min.css and /Scripts/grids/gridTaskMain-built.min.js.
4. RequireJS Ready Monitoring
Added a small section bit of code at the end of custom.js to monitor for RequireJS so we can immediately start loading the plugin as soon as the page is ready by subscribing to requirejsReady.
After loading, gridTasks will publish the gridTasksReady event. So we subscribe to gridTasksReady and place any custom grid task function calls within the callback argument:
6. New HTML templates and OnClick callback behavior bug-fixes
Moved the Angular templates used creating the final column templates for gridTasks from inline variables to individual HTML files in /Scripts/grids/tasks. Now customizing them and adding new types should be an easier process. I have also updated the OnClick callback behavior to handle stopping click propagation in browsers like Firefox where the Event object is no longer global.
Please let me know if anyone has any questions or comments, thanks!
It's been some time since I last checked in and I've made a number of improvements to the gridTasks plugin. I have attached a minimal configuration to get gridTasks up and running. The main custom.js file includes utility functions for (un)loading javascript and css files, enabling/disabling debug mode and the calls for actually loading gridTasks.
To load the plugin, custom.js loads the minified gridTaskMain-built.min.js to get the base gridTasks library and then custom.gridTasks.js for the actual customization:
custom.gridTasks.js is very similar to the previous examples I've provided. I've just wrapped the calls in some logic for handling async loads and simplified the template strings to make them hopefully more readable. With this setup you could also have multiple versions of files to serve users/analysts if you find that the customizations are getting a bit involved as well.
For a more detailed view of my setup and changes you can check out the source files on my github repo here. Still working on a lot of the documentation so if you have any questions feel free to let me know!
The dark green background in the images below represents the clickable area for links (not visible to end users).
Previous icon-only hover+click:
New hover+click:
EDIT:
I was walking through how Search grids are generated and they have a nice queryBuilderGridReady event published on searching for both saved searches and in the query builder that I was able to plug into custom.gridTasks.js:
Added a small check for the AssignToAnalystByGroup task in the Assigned User column too and voilà!
<img alt="" src="https://us.v-cdn.net/6026663/uploads/editor/tw/ypr2o718idse.png" title="Image: https://us.v-cdn.net/6026663/uploads/editor/tw/ypr2o718idse.png"><br>
I have been going over my current code base for documentation and refactoring and have made a number of small improvements to gridTasks.
- Style task now applies provided template (either function or string) to the column.attributes.style value instead of modifying the column's template string.
- Simplified the anchor Underscore/Kendo template to remove the container div and content span thanks to using the column.attributes.class value.
Old:
New:
- app.custom.gridTasks.updateGrid has been renamed to app.custom.gridTasks.apply and includes some minor modifications on when a column's template is updated.
- New app.custom.gridTasks.ready function to provide a deferred callback when gridTasks is ready so code can be executed immediately after gridTasks is ready without needed to wait for an event trigger.
The following is an excerpt from custom.gridTasks.js where I use app.custom.gridTasks.ready. Just in case the code is loaded and executed before gridTaskMain-built.min.js is I also use a single event subscriber with $.one() to gridTasks.ready:
Please let me know if anyone has any questions or comments, thanks!
Another small update. Due to how Work Item grids handle hidden field attributes and state saving/loading, using a Kendo template for style on a hidden column will cause parsing errors on refresh. To work around this I have created a new 'Class' option when adding a grid task.
Priority colors are now handled via:
Please let me know if you any questions or comments, thanks!
Minor feature updates of the day:
1. 'Class' task now has a check for previously created templates for Priority to remove deprecated templates.
a. This isn't needed if a user resets their cache or view, but does help sanitize things in the background.
2. Added an optional title param for links and task templates.
3. Updated app.custom.gridTasks.apply function to handle pre-rendered grids.
a. Resolves loading masks not displaying properly ('No Results' shows while loading).
1. To remove deprecated Priority field templates now that we use Class/Style I added the following check for a pre-existing definition of the template to set back to out of the box behavior:
(gridTaskBuilder.js:119):
2. Here's a sample use for the 'Assign To Analyst By Group' grid task using localizationHelper:
(custom.gridTasks.js:67):
Result:
3. app.custom.gridTasks.apply function now only calls grid.refresh when data is already loaded and rendered, otherwise it calls the grid._updateCols internal function to update column templates before the pending render. This means the loading mask (three green squares animation) displays properly instead of showing 'No Results' while waiting for a load to complete.
Have a great day!
@Ryan_Lane - TBH I've just now gotten around to implementing this. IT IS AMAZING! I'm swimming with ideas! I just have one question. Are your most recent updates reflected in the github repo?
@Justin_Workman Hey Justin, thanks! That's right, the most recent changes are located in the repo at https://github.com/ryanlanegit/CustomSpace/tree/master/Scripts/grids
Haven't had the chance to create documentation on it's usage outside of my environment so it may be a task to get it up and running. Let me know if you have any questions on it.
Here are a couple examples from our current evironment to show how we're using it.
Work Item grid view tasks:
Adding an Edit task to new comments in the Action Log: