-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Form Gramplet: per Form, per Column actions[v52] #267
base: master
Are you sure you want to change the base?
Conversation
ca74418
to
abb1d0e
Compare
Following discussion on the gramps-devel list I've completly reworked the implementation. Actions are now separated from transcription. A new "Actions" button has been added for the FormGramplet window. When clicked, this displays a list of available actions for the selected form. This list is dynamic, only displaying actions which could make sense. The user selects the actions they wish to apply (multi-selection is permitted) and when OK is clicked, the actions are run. The interesting code is
The code to decide which actions are possible, and the implementation of the action can be found in UK1841.py All actions derive from a common base class, ActionBase. I've provided two prototype actions.
Longer term I think more code can be moved from UK1841.py into ActionBase.py. ActionBase then becomes a library of helper functions to keep the amount of form specific code as light as possible. This is still a work in progess submitted to get feedback on the implementation approach. |
This dialog present a list of possible actions to the user. The user selects one or more actions to be run when OK is clicked.
abb1d0e
to
c1919d4
Compare
I've added initial support for creating birth events Code now compatible with Python 3.3 |
This is a good start. As far as the UI is concerned, I think that adding checkboxes for selection would be clearer. You could also add some extra information such as the place of birth and date of the occupation event. The design also needs some more thought. I see the interpretation of the raw data as being part of the transcription phase. This would include calculation of the date of birth from the age as well as things like transliteration/translation where relevant. In previous discussions, I have suggested extra hidden attributes for this purpose (e.g %DOB for date of birth). I suggest that you also start to tidy up the code:
|
9834f50
to
007667d
Compare
This is now done. Thanks. I've added a new action: residence event, relevant to your second bullet point
This action is slightly different because there is a single action, no matter how many rows on the form. It also does not require any attributes from the people on the form. Do you have any advice on what level of granularity is best for db transactions? See for example ResidenceEvent.command where I have N+1 tranactions for the N rows on the form. I've changed to having individual transactions in preparation for allowing the user to, optionally, display the object edit window before the action completes. I can see two reasons for wanting this:
Each action would need to decide which steps to show the edit window for. However this does go against your first bullet point of no UI in the actions code. Thoughts? Actions also need to be smarter
Check boxes - yes agreed, before merging. They are more discoverable for a user. Need convenience routines e.g. select several actions and tick in one go. For now, multi-selection is good enough for me to test with! re hidden attributes:
|
Some more experimental work to investigate if it is possible / sensible to allow the user to edit the detail of an action when it is run. Each action can indicate if a user cannot, can or must edit the detail of the action. This is then shown in the GUI. In the example below I've deliberately configured the actions, for testing purposes, so that all 3 states of editing are present. All comments welcome. |
263db4c
to
36e03bd
Compare
This helps the user confirm the action is correct.
In future this will allow objects created by the action to be, optionally, edited by the user before committing to the db.
…e actions. This avoids leaking FormAction implementation detail (the use of a TreeStore) into the action classes.
Adds a single residence and links to all people on the form. Residence place and date are copied from the form event place and date.
…ntick all actions within that category.
The additional context is to help the user understand what data the action will be adding to the family tree.
This is required to correctly initialise module global variables
…ed by the user when run. There are three editing options available to an action CANNOT_EDIT_DETAIL - no editing is possible CAN_EDIT_DETAIL - the user can choose to edit the detail MUST_EDIT_DETAIL - the user must edit the detail MUST_EDIT_DETAIL is intended to cater for cases where the action cannot be certain of some data. For example computing a date of birth from an age on a census form when the age is "1m"
36e03bd
to
d1bb8a3
Compare
It sounds good. Maybe just an issue around python version as we need to use at least python3.5 for
https://docs.python.org/3/library/importlib.html#importlib.util.module_from_spec |
Ooops. That wasn't deliberate - thanks for letting me know. The gramps 5.2 roadmap shows a dependency update to python 3.5.x. (though note that pyton 3.5 is end of life 2020-09-13). This PR is targetting 5.2 so I don't think any change is required. |
This allows us to reuse features of ManagedWindow and more easily have a modeless window
The flag is not currently used.
…he end of the command. Instead of looping over the actions to be run with a for loop, use a callback function to recursively call _do_next_action, with the remaining actions to be run. When there are no more actions left to run, close the FormAction window. In future, this change will allow each action command to show any number of editor windows, sequentially. The user will be able to cancel at any point.
…vent, the other to add the event_ref to a person
All action commands are now implemented as chained callbacks using an expanded set of helper functions in actionutils.
…ing. If not closing display a message after actions are successfully run.
The edit check boxes are now functional and use the standard Editor windows, displaying them sequentially, as required. The user can make any desired edits and these get reflected in the change applied to the database. Overall, this PR is now at the stage where I feel it is ready for review however I will not officially change its status due to the notes below. Note:
|
@stevenyoungs Thanks. I should get a chance to look at this over the weekend. |
Thanks. I'm tempted to split out the (example) actions, in UK1841.py, into a separate PR, if the core change gets to an accepted level. Let me know if you think that's the right way to go. For now it made sense to keep things together so I, and reviewers, had concrete examples to consider and test. |
First of all, I am only looking at code, I have not yet tried it out. One area I am concerned about is your method of sequentially opening the Editors. At first glance, it looks like you are depending on each editor doing the callback to go onto the next. I saw another PR for the main Gramps code to make this more consistent. One concern is what happens if the user doesn't use 'Save', but rather closes the Editor? I think the callback doesn't get called in that case. So What happens to the Form? One possibility that occurs to me that would make this PR independent of the main Gramps code changes, and fix the potential problem above, would be to use a Gtk callback when the Editor Window is destroyed. I think this would always work, as that must happen when the Editor is closed by 'Cancel', the corner 'x' or Save'. Something like
I don't know if this will work, in part because I wonder if stacking up a bunch of new window creations will work in a destroy callback. If it doesn't, I would then try setting a flag in self in the destroy callback, and using Glib.idle_add to restart your code when the flag gets set. |
Sequentially calling editors is a horrible design. Users hate this type of interface. We must think of something better. |
I can't really argue with that :-(
but I saw challenges in achieving this which I wasn't sure I could overcome.
A fallback could be to let the user only run one action at a time. You could still, depending on the action, get sequential edit windows appearing. Consider the 'simple' action of adding a residence event for N people on the form. The user potentially needs / wants to edit
Ways Forward
I'm tending toward route 1; in general I prefer multiple, smaller, PRs over one larger one. It would give more space/time to develop a better UX for the Edit side. The downside is it would restrict possible actions to those where there was certainty. Advice on any and all of the above sought and welcome. |
That's correct.
Correct. I took any closure of the Editor window, other than via the 'Save' button, to mean cancel the actions that have not yet been run.
I did experiment with this approach. I had two issues:
Is there a way to overcome 1 and is 2 acceptable? |
Thnking out loud, I wonder if I could store the difference between the original objects
and then if the action is run, apply the stored difference to the current db version of the object? Not sure it would work for adding object references though, since the handle of the object the action intends to add a ref for may not have been created yet. |
The usual way to compare these objects is to do |
@stevenyoungs are you still working on this feature? |
Yes in the sense that I would still like to get an acceptable working solution to the basic problem and I continue to think about ways to acheive that. A solution will save me a lot of time with my own research. No in the sense that I've not had time to revisit since February. There are still some design level challenges that need to be overcome. I'm not 100% sure in my own mind what the "correct" design is. All ideas and thoughts welcome. |
I'll put some more thought into this shortly. I'd like to make a little more progress with the new combined view first and the place enhancements in core may take some of my time. |
Extend the Form gramplet so that the Form creator can specify per column actions which the user can invoke as required. An 'action' is a snippet of Python code defined in the form XML definition. These actions are intended to automate steps you can already do manually.
An example action is provided that extends the UK1841 census form to allow an 'Occupation' event to be created, with appropriate date and source citation, from the Occupation column.
It is hoped that the framework is sufficiently generic to allow more complex actions to be implemented in future. Indeed you already can add actions to other columns by simply editing the form XML file.
The XML definition of an action consists of three bits of data
WARNING: this is very much a proof of concept.
The extended popup menu
The event created by this action
To Do
and much much more
I'm no Gramps, Gtk or Python expert so I'm sure the code can be improved - all ideas and comments welcome. In particular
Ideas for actions