shotgunsoftware / tk-multi-shotgunpanel

Access Flow Production Tracking data inside the artist app.
Other
6 stars 20 forks source link

SG-36129 Add customized sort fields #96

Open pscadding opened 1 month ago

pscadding commented 1 month ago

Makes the My Tasks tab sort fields configurable through the yml settings.

The user can choose any fields including linked fields to sort by, assuming that they are valid fields to sort by.

The default sort options are the same as before + the step which appeared to be mostly added by possibly accidentally excluded. (Note the UI styling looks a little weird here, because I'm running out of my terminal and not a DCC)

Screenshot 2024-08-29 at 14 25 13

The user can then customise the list through the env config.

Screenshot 2024-08-29 at 14 01 33

If its configured with a non existing field it will result in an error in the console if the user picks that sort field in the list. I'm not sure there is a better way of handling this as it asynchronous so I can't just wrap the instruction to load data in a try except. I think in order to get a better handle on it we might need to make changed to the shotgun model. An example of the error you would get is here:

Traceback (most recent call last):
  File "/Users/~/Library/Caches/Shotgun/bundle_cache/app_store/tk-framework-shotgunutils/v5.10.0/python/shotgun_model/shotgun_query_model.py", line 945, in __on_data_retriever_work_completed
[DEBUG sgtk.env.project.tk-shell.tk-framework-shotgunutils] [ShotgunFindDataHandler] Completed save of <ShotgunFindDataHandler@/Users/~/Library/Caches/Shotgun/~/site/fw-shotgunutils/sg/Task/13e9f728d4fb0da7fddc52ad0d4667f1/c03bbd4b1d8823fc1223737b3b9bbc27.27 (13 items)>. Size 12432 bytes
    self.__on_sg_data_arrived(sg_data)
  File "/Users/~/Library/Caches/Shotgun/bundle_cache/app_store/tk-framework-shotgunutils/v5.10.0/python/shotgun_model/shotgun_query_model.py", line 1022, in __on_sg_data_arrived
[DEBUG sgtk.stopwatch.tkimp3a0aee2b525d4fc89c43e818c9d4a225.shotgun_model.data_handler] save_cache: 0.002371s
[DEBUG sgtk.env.project.tk-shell.tk-framework-shotgunutils] [SgTaskListingModel] Asynchronous cache save complete.
    self._data_handler.generate_child_nodes(None, root, self._create_item)
  File "/Users/~/Library/Caches/Shotgun/~/p419c67.basic.shell/cfg/install/core/python/tank/log.py", line 514, in wrapper
    response = func(*args, **kwargs)
  File "/Users/~/Library/Caches/Shotgun/bundle_cache/app_store/tk-framework-shotgunutils/v5.10.0/python/shotgun_model/data_handler.py", line 272, in generate_child_nodes
    factory_fn(parent_object, data_item)
  File "/Users/~/Library/Caches/Shotgun/bundle_cache/app_store/tk-framework-shotgunutils/v5.10.0/python/shotgun_model/shotgun_model.py", line 623, in _create_item
    self._update_item(item, data_item)
  File "/Users/~/Library/Caches/Shotgun/bundle_cache/app_store/tk-framework-shotgunutils/v5.10.0/python/shotgun_model/shotgun_model.py", line 664, in _update_item
    {"name": data_item.field, "value": data_item.shotgun_data[data_item.field]},
KeyError: 'bad'
pscadding commented 1 month ago

Also I wonder if the setting name should not be my tasks specific and then you list the tab under it. That way if we add the sort field to other tabs we wont need to change the setting name.

pscadding commented 1 month ago

Is it possible to invest more time for it?

I've spent some more time today, and if I modify SG utils I can catch the error, and raise it as a signal

Screenshot 2024-08-30 at 12 55 04

I am nervous about this though, I'm not sure if this will negatively impact other tools using the SG Utils.

I've created a PR for that here: https://github.com/shotgunsoftware/tk-framework-shotgunutils/pull/158

pscadding commented 1 month ago

We decided not to implement the changes on the SG Utils for better catching. We didn't want to introduce unnecessary risk for the handling of this edge case.