spine-tools / Spine-Toolbox

Spine Toolbox is an open source Python package to manage data, scenarios and workflows for modelling and simulation. You can have your local workflow, but work as a team through version control and SQL databases.
https://www.tools-for-energy-system-modelling.org/
GNU Lesser General Public License v3.0
72 stars 17 forks source link

Better Add entity dialog #2370

Open jkiviluo opened 1 year ago

jkiviluo commented 1 year ago

Here's a mock-up for creating new entities. It was motivated by the need to support abstract classes (there is a need to show what is the subclass in order to distinguish entities with the same name but different subclass), but it should be an improvement for the current 'Add entities' dialog in other ways too. It limits the user choices based on the chosen entity in the Entity tree. It should also limit choices if specific entity class is chosen. If the whole tree is chosen, then it would be list of all possible entity_classes that can be filled in (but user should probably rather limit the choices).

image

The picture has a small mistake: there shouldn't be a drop-down available for the unit entity_class - this is about adding new entities (multi-dimensional classes are based on 0-dimensional classes, so there drop-downs are needed).

Naturally typing in would limit the choices in the drop-downs. Copy-pasting should also work.

Pressing enter should

It would be nice if the dialog would update when the user chooses something else on the entity tree (keeping all new staged additions so far made in the view).

Links to https://github.com/spine-tools/Spine-Toolbox/issues/2364 and to https://github.com/spine-tools/SpineOpt.jl/issues/773

DillonJ commented 1 year ago

I was thinking that whatever we do here, you would need to be able to copy/paste. Also, currently, if I paste a relationship parameter value row into DB editor, it will create the relationship if it doesn't exist - this is very nice functionality that I use all the time

jkiviluo commented 1 year ago

Copy-pasting updated to the issue description.

Also, currently, if I paste a relationship parameter value row into DB editor, it will create the relationship if it doesn't exist

I didn't know about that. I feel conflicted. It's of course very handy and I would probably have used it a lot had I known. However, it can be dangerous because you can paste in misspellings. Maybe the new entity name in the parameter value pane should be highlighted? Just to let user know that the entity was just created. Should be another issue...

manuelma commented 1 year ago

Copy-pasting updated to the issue description.

Also, currently, if I paste a relationship parameter value row into DB editor, it will create the relationship if it doesn't exist

I didn't know about that. I feel conflicted. It's of course very handy and I would probably have used it a lot had I known. However, it can be dangerous because you can paste in misspellings. Maybe the new entity name in the parameter value pane should be highlighted? Just to let user know that the entity was just created. Should be another issue...

Only multi-D entities are added on the fly, not zero-D entities. And if you paste a multi-D entity byname that has misspellings, it will fail because it won't find the zero-D entity.

jkiviluo commented 1 year ago

At least in v0.8 I can paste a new 0-D entity through the parameter value pane.

manuelma commented 1 year ago

Does it get added?

manuelma commented 1 year ago

What shouldn't work is paste a multi-D entity with non-existing elements. Only if the elements exist, the multi-D entity gets added on the fly.

jkiviluo commented 1 year ago

Yes, it got added. Does not work in 0.7 though. (Unknown entity 'foo')