-
-
Notifications
You must be signed in to change notification settings - Fork 143
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
[Feature] New management of the N to M relations #4024
Conversation
505e3a0
to
396d2eb
Compare
03ce578
to
db49c9d
Compare
5277449
to
a96a97c
Compare
547ff22
to
0b2493a
Compare
The cypress error is coming from #4055 you can skip it |
16220eb
to
d8a606f
Compare
81eb83a
to
4b86889
Compare
Thanks a lot for this proposal. It is huge, we think it will be easier to test against several projects if we merge it asap. A question regarding your sentence
Did you meant
|
@mind84 Maybe you have notice, we have started to autogenerate the documention, for JavaScript in #4185 which is temporary available on https://docs.3liz.org/lizmap-web-client/ and also for PHP in #4200 (we will organize permanent URL a little bit later, it's just a work in progress for now). Can you, for just newly added function in JS/PHP add the corresponding docstring ? For Javascript, this kind of helper https://developer.wordpress.org/coding-standards/inline-documentation-standards/javascript/ or the PR #4185 We will make this good practice step by step on existing function. I guess you need to rebase. |
4b86889
to
8ba0f30
Compare
Hi @mdouchin,
In this regard, I think it's a sort of "breaking change" and I am aware that the tests are not trivial at all. If there is anything I can do to support you in this process let me know.
Take for example the test project of this PR (
If you want to add a new bird as "child", you can add it from the corresponding button on the n layer table. This choice is mainly based on the fact that the user is editing the Same for About the pivot table, user cannot act on it anymore since it is hidden. Thanks |
8ba0f30
to
de6826c
Compare
de6826c
to
8110df8
Compare
Hi @mind84 thanks for your answers. I agree with you this will help the users. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot !
Thanks to you guys for taking the time to review this! |
This PR changes the way n-m relationships are handled.
Precondition
Two layers are explicitly related in an "n" to "m" relationship, i.e. in the
QGIS
project properties (Relations
tab) both layers are related to a third "join layer" and in theLizmap
configuration (Attribute table
tab) this join layer is defined as "pivot".Changes on current behavior
Attribute table:
toolbar
of the "n" layer attribute table, the button to add records to the pivot no longer appears, and is replaced with an "add a new m feature" button. This allows the user to create a new "m" feature and directly associate it to the selected feature of the "m" layer. This means that after the new "n" feature is added,Lizmap
automatically inserts the association record on thepivot table
.lizmap-feature-toolbar
of the "n" layer, the buttonCreate feature
now shows only the layers that are 1:n related with the "n" layer.lizmap-feature-toolbar
of the "n" layer, the buttonDelete
will also delete the records on all pivots involved in an "n" to "m" relation with the current "n" feature. A confirmation dialog is displayed, containing the list of all "m" layer associated with the "n" layer, in order to make the user fully aware of the changes that he is making. The deletion of record is done in a database transaction: the records in the pivot are deleted, then the "n" layer feature is deleted. If any step goes wrong, the transaction is rolled back and no changes will happen. The order of execution ensures that, if a foreign key relation was defined in the database, it will not be violated.lizmap-feature-toolbar
of the "m" layer, the buttonsCreate feature
andDelete
are hidden in order to avoid confusion for the user.lizmap-feature-toolbar
of the "m" layer, the buttonUnlink child
deletes the corresponding pivot record.The behavior to link existing features is not changed, thus the user should select the records to link, and then click on the button
Link selected features
.Popup:
popup
is displayed for "n" layer, the list of pivot feature associated with the record is replaced with the list of "m" layer features associated (the behaviour is the same one described in the attribute table)unlink
an "m" record with an action on thelizmap-feature-toolbar
(the behaviour is the same one described in the attribute table)Edition form:
edition form
is opened from the attribute table ("add a new m feature" button), a message on the form informs the user that the new "m" feature will be linked to the "n" layer.This also happens if the user adds a new child "m" feature from an "n" feature while editing (i.e. editing a child from edition form).
Submit
a form: if a pivot record is added during the "m" feature creation (previous case), the success/failure of the insertion is displayed along the same dialog message used to notify the user on the result of the "m" record insertion/update. The "m" record insert/update operation is independent from the corresponding pivot record insert action, so if the pivot insertion fails for some reason the "m" record is inserted/updated anyway, if no errors occurs.Reopen form
vsCreate new feature
options: when the "create new feature" option is selected, the new form that opens after the first submit still has the "link to pivot table behavior". On the other hand, if "Reopen form" is selected, this behavior is suppressed in order to avoid any duplication on the pivot table.In both cases, after submitting the form, if the "link to pivot table" is enabled, a notification message appears on the top of the form along with the main record insert/update message, informing the user that the new feature has been linked (or not) to the "n" layer.
Limitations/concerns:
serial
connection object
first and pass it along the various delete methods. I performed several tests on my local environment, but I still don't know if this could lead to issues.wfs filter
for the "m" layer. This could be avoided if in the wfs filter of the "m" layer I could specify something likefilter = "id" IN (SELECT m_id from pivot WHERE n_id = 'foo')
. Unfortunately this seems unsupported, isn't it?TODO
Add the
Link selected features
option in thePopup
Funded by Faunalia