-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Custom Asset Field Reordering #17873
base: main
Are you sure you want to change the base?
Custom Asset Field Reordering #17873
Conversation
2cb5785
to
024575a
Compare
Now #17462 has been merged, here are a few notes on that feature as it's the continuation; Technically
Regarding UX/UI
That's all for the moment, I may have other minor suggestions later (after seeing a first iteration) |
9b8edd1
to
40ba2a6
Compare
3c9f33d
to
42e5059
Compare
A checklist based on previous review comment:
Also had to redo the field display as flexbox instead of grid for sorting to work properly when fields could be regular or full width. |
Tests need updated, but I think this is ready for a review of the initial implementation. |
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.
Could you also add some tests ?
New logic should be validated as much as possible on PHPunit side, with a few cypress tests for the things that can also be done on the UI.
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.
Symfony controllers have been available for a while now, IMO we shouldn't create any new legacy front files.
A quick functional review for today's checkout on my side:
|
Didn't realize that was required. This PR was originally just to reorder fields in the UI. I didn't see a spec anywhere for anything extra like making core fields mandatory/readonly/full width/etc. Also all this extra stuff is just in the web UI display. Nothing enforces it on the server side so the API doesn't respect it.
Doubt it is useful
Not intended to even have this option. Core fields have no structure so I faked it by reusing the custom field stuff.
We kind of do. You just need to know that select2 controls look like a regular text field when they allow multiple options.
Not supposed to be an option.
You cannot hide fields using this UI currently. Look at the generic_show_form template and you see how this is all handled. It takes a custom defined order if one is provided and then appends the missing fields based on the default order. So, if we add new core fields that don't exist in the field order config for a custom asset, they will still appear in the form but be at the end of the form. I did add handling for a The original spec was basically just:
|
6c0c6a2
to
27d3488
Compare
When hiding everything except "name", a few fields remain on a custom asset: "UUID" and "update source".
|
I can't recreate. I also cannot recreate the situation where all fields can be removed. AFAIK it would be impossible from the web UI because all |
Not previously requested:
|
All points addressed except the dragged field still being in the UI. I haven't found a way to target the original element in CSS without also targeting the drag image element. |
I'll try to make a test in 1h or 2 |
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.
Regarding the functional side, we arrived at an ok state.
The UX for adding native or custom fields needs reflection and work, but this can be achieved in a later PR.
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.
-
IMHO, the
glpi_assets_customfielddefinitions.field_options
field should not contain anymore options related to the form layout. Indeed, with the current data model, the layout options are not all stored in the same place, and it will probably lead to some confusion. -
When a custom field definition is removed, it is not automatically removed from the
glpi_assets_assetdefinitions.fields_display
field. It should be done inside thecleanDBonPurge
method.
819ef84
to
116ba38
Compare
What do we need to finish this pr (and #18145 ) ? |
Translations PR needs tests added now that it should be functionally and technically complete. This PR should clean the field display values when a custom field is deleted. Then, I assume it is finally ready for tests to be added. |
f1c0f40
to
71138da
Compare
71138da
to
6057921
Compare
Sonarcloud report: remaining alert seems the same and should probably ignored. The current failing e2e test is due to the modal losing focus on the input while Cypress is typing the label. diff --git a/templates/components/form/viewsubitem.html.twig b/templates/components/form/viewsubitem.html.twig
index 40c2bdc79b..3f302044d6 100644
--- a/templates/components/form/viewsubitem.html.twig
+++ b/templates/components/form/viewsubitem.html.twig
@@ -56,6 +56,12 @@
<script>
function viewAddEditSubItem{{ rand }}(id) {
const modal_el = $('#{{ subitem_container_id ~ '_modal' }}');
+ modal_el[0].addEventListener('shown.bs.modal', (event) => {
+ event.target.setAttribute('data-cy-ready', 'true')
+ });
+ modal_el[0].addEventListener('hidden.bs.modal', (event) => {
+ event.target.removeAttribute('data-cy-ready')
+ });
$('#{{ subitem_container_id }}').load('/ajax/viewsubitem.php',{
type: "{{ type|e('js') }}",
parenttype: "{{ parenttype|e('js') }}",
diff --git a/tests/cypress/e2e/Asset/custom_fields.cy.js b/tests/cypress/e2e/Asset/custom_fields.cy.js
index ade0902bc2..b97e7d065a 100644
--- a/tests/cypress/e2e/Asset/custom_fields.cy.js
+++ b/tests/cypress/e2e/Asset/custom_fields.cy.js
@@ -125,7 +125,7 @@ describe("Custom Assets - Custom Fields", () => {
function createField(label, type, options = new Map()) {
cy.findByRole('button', {name: 'Create new field'}).click();
cy.waitForNetworkIdle('/ajax/viewsubitem.php', 100);
- cy.findByRole('button', {name: 'Create new field'}).siblings('.modal').should('be.visible').within(() => {
+ cy.findByRole('button', {name: 'Create new field'}).siblings('.modal[data-cy-ready=true]').should('be.visible').within(() => {
cy.findByLabelText('Label').type(label);
cy.findByLabelText('Type').select(type, {force: true}); They may be a better solution, but we should avoid adding a |
c6bfcb9
to
1730b58
Compare
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.
It seems OK from the functional point of view. I have not done a detailed technical review because I am having difficulty assimilating all the changes as a whole.
Co-authored-by: Cédric Anne <[email protected]>
E2E tests seems to fail. |
Taking over from #16975
Currently focusing on reordering default fields until the custom fields PR is merged, and then the Fields tab UI will be adjusted and support for the custom fields added.