-
-
Notifications
You must be signed in to change notification settings - Fork 824
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
SearchKit - Improve editable UX by not allowing required fields to be left blank #22358
Conversation
(Standard links)
|
Not sure if I'm understanding correctly with respect to non-custom fields: Would the next step be to update all the xml schema files to add a not_null setting? I'm confused because api4 getfields seems to ignore the existing And if that's correct, then this is going to be confusing terminology because GenCode etc uses Relatedly this line, while correct I think, is confusing: Maybe "nullable" would be a better keyword? |
Just noting that I tested this change and made the custom field marital status required but I can still remove it using edit in place with this patch (I logged a couple of issues in testing). I'm with @demeritcowboy in struggling to get my head around this one - I think it needs to be documented as a confusing new 'getfields' value - I guess we have 3 things
I think isnullable gets as as close as we are likely to get to something that makes sense |
961bf7e
to
4db672c
Compare
…ble UX Unlike the 'required' field property, which only determines if the API requires a value to Create, the 'nullable' property tells a UI whether a field is allowed to be set to NULL in Create OR Update. SearchKit uses this property during in-place edit and bulk edit operations to determine whether a field can be left blank.
4db672c
to
f8d39ba
Compare
@demeritcowboy I'm finally happy with this. Ready for a second round of review. See updated description. |
@@ -58,7 +59,8 @@ public static function arrayToField(array $data, $entity) { | |||
$field = new FieldSpec($name, $entity, $dataTypeName); | |||
$field->setType('Field'); | |||
$field->setColumnName($name); | |||
$field->setRequired(!empty($data['required'])); | |||
$field->setNullable(empty($data['required'])); |
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.
Is this an "approximation" for now? For example I don't think activity date or status are really "nullable".
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.
Both of those fields are nullable in our schema. I think you could make a very good argument that they shouldn't be. Fixing it on the schema level can be a pain though because you have to deal with any existing data with null values. A quicker fix would be to set nullable=false just at the APIv4 layer for those fields (via the ActivitySpecProvider
). I can do that as a followup.
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.
Ok. My only other comment then was the one below about custom date fields. Otherwise looked good.
It doesn't seem to work for non-required custom date fields. I can't blank it out. |
@demeritcowboy I tracked that down to something pretty obscure. The API was returning a full date-time value for custom fields which only contain a date, and it was making the Angular field validation confused. Fixed in #22649. |
Thanks @colemanw I tested both together and looks good. Will put merge-ready here. |
Overview
Fixes dev/report#92 by enforcing required fields during in-place and bulk editing in SearchKit.
Before
SearchKit would allow you to save required fields with blank values.
After
Saving a blank value for a custom field marked "required" is prevented in the inline-edit UI:
It's also prevented in the bulk-update action:
Works similarly for select, date, and numeric inputs.
Technical Details
Unlike the
'required'
field property, which only determines if the API requires a value to Create, the new'nullable'
property tells a UI whether a field is allowed to be set toNULL
in Create OR Update. This value is now documented in APIv4getFields
and is returned consistently for both core and custom fields.SearchKit uses this property during in-place edit and bulk edit operations to determine whether a field can be left blank.