Problem/Motivation
The verbose extra fields have been implemented for the DB sensor with a text area, using a line per verbose extra field
#2495089: Entity aggregator: Verbose extra fields
Proposed resolution
Should we use separate text fields per extra field with an "Add item" pattern?
As an example, the entity aggregator could offer a dropdown instead of a free text field.
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #55 | separate_text_fields-2525432-55-interdiff.txt | 975 bytes | berdir |
| #55 | separate_text_fields-2525432-55.patch | 29.45 KB | berdir |
| #53 | separate_text_fields-2525432-51-interdiff.txt | 902 bytes | berdir |
| #53 | separate_text_fields-2525432-51.patch | 28.69 KB | berdir |
| #46 | Screen Shot 2015-07-24 at 15.39.40.png | 23.91 KB | LKS90 |
Comments
Comment #1
LKS90 commentedHere is a start, no text area anymore, validation has moved to the validateConfigurationForm() function, renamed all 'keys' instances to 'fields'. Adding and deleting fields is possible, fields are validated before saving, so requesting a non-existing field won't break the whole sensor.
Comment #2
miro_dietikerUI issue, so screenshot please.
Comment #3
LKS90 commentedHere is a screenshot:
Comment #4
LKS90 commentedComment #5
miro_dietikerAlready needs a reroll.
Dunno if i'm happy with the new key. :-)
Filter what?
We can expect valid defaults. Remove this health check / fix.
The core pattern is more "Add another xyz". So we should switch and also alter the other form button for a similar option on this form. ;-)
This is inacceptable. You temporarily set the sensor settings to a "wrong" value just for being able to execute the query to validate it... sensorConfig is then in an invalid state!
Comment #6
LKS90 commented1. Back to keys it is.
2. I went over all comments and checked if they make sense/are still copy&paste.
3. Removed this health check as well as the equivalent for the conditions.
4. Changed the button accordingly for keys and conditions.
5.
$database->schema()->fieldExists($table, $key_name)is way easier than configuring a sensor and running it. Also added validation for the table (because I use that for later validation).Comment #10
LKS90 commentedRebased, and this time the issue and the patch belong together.
Comment #11
miro_dietiker5. That is one option. But schema is not complete (Berdir said)! Best is to check Schema and if it does not work, try running the query.
As mentioned in the related issue: i was not happy with keys => fields since it's about verbose only. I would be more for verbose_fields or similar.
Comment #12
LKS90 commentedNew version, switched to verbose_fields, re-added try/catch block which runs a query on that table with the field (and it's a simple query now instead of running a modified sensor).
Comment #14
LKS90 commentedCorrected the schema, should have run a test locally first : /.
Comment #15
miro_dietikerfields?
You are now executing the whole query for each field (without schema) again and again...
style
Comment #16
LKS90 commentedNot finished, just uploading a patch so I can continue from home :).
Edit: Some feedback for the validation would be nice though :). (reverting the fields is unnecessary, as the form won't continue until the form_state is error free)
Comment #17
miro_dietikerYeah, $settings is unused, but i think we should consistently use getSetting($key) and not do $settings array access.
Drop $delta.
Hm, if schema is incomplete, will it even contain that table or just miss fields?
So in case of a wrong line, all verbose field changes are dropped? Bad. I thought we just drop the single change.
Comment #18
LKS90 commentedRemoved the $settings array and the usage where possible (I use it once to save the submitted settings), removed the unused delta, made another query for the table in case the schema says the table doesn't exist, fixed the fields query.
Comment #19
miro_dietikerYou should not do an array_pop in a foreach.
Anyway, instead of adding early and later unsetting, just add the field after all checks passed.
Comment #20
LKS90 commentedRemoved the array_pop (the whole line was rather pointless) and cleaned up the validation/saving of new fields.
Comment #22
LKS90 commentedFixed the test fails which are related to this issue in MonitroingCoreWebTest. Couldn't reproduce the payment test fail though.
Comment #26
mbovan commentedWhy not use
$fieldsin foreach?Is it
#treefalse by default?One line?
Do we need this change? If we do like before then we don't need
$settings['conditions'] = $conditions;line.Same here, you can use
$settings['verbose_fields'][]instead of$verbose_fields[].%tablearray key is missing.Comment #27
LKS90 commented1. Done
2. It's not, removing it breaks saving of fields.
3. Done
4. & 5. Done
6. Done
Comment #28
mbovan commentedRe #27 (3): You changed different empty message. That's good, but this one is still here. :)
Comment #29
LKS90 commentedThanks! Fixed the second #empty message.
Comment #30
miro_dietikerThis key level seems unneeded.
Oh wow, is this item now always properly updated? I remember we needed the different code to get access to the entity updated by the form state / submissions...
Don't drop the comment.
Comment #31
LKS90 commentedReadded the comment, removed one empty line in a docblock and changed the header for the verbose fields and conditions table slightly.
The 'field' nesting is necessary because every verbose field is a row in a table with only one column (the 'field' column). I tried helping alleviate the confusion by adding a comment and renaming the column field to field_key (so the key for a field is the content of that column). I also changed the header for the conditions to also say 'Field key', so both are consistent.
Comment #35
LKS90 commentedThe tests did need some updating with the new column key, couldn't reproduce in the beginning because I was in the completly wrong branch... :D
Here is the patch with the updated tests.
Comment #36
miro_dietikerWhen i create a new sensor, i still only get "id" and "label" is missing as verbose field.
Comment #37
miro_dietikerAlso the conceptual fields like id / label / ... are not on the field list, making me confused as a user.
We should list them separately.
Comment #38
miro_dietikerI tried to add a "path" field to a node sensor. Column was empty and when executing, the sensor has thrown an error.
Comment #39
LKS90 commentedStupid mistake, fixed.
I put the synonymous key in brackets after the field now, see screenshot.
Finally managed to fix that according to berdir's proposal, I check if there is a field default_formatter with the FieldTypePluginManager. If not, I don't try and '
view()' the field but keep the $value as set previously ($entity->$field->$property).Comment #40
LKS90 commentedHere is the interdiff, thought I clicked on upload, apparently not.
Comment #44
berdirI don't think you need UiDefinitions() here ? Those are already filtered, so path will never even be in there.
Instead, you could just write if (isset($field_type_manager->getDefinition($field_type)['default_formatter']
Do we really support all the keys her? Stuff like langcode and status?
I'd just hardcode those that you explicitly support.
Comment #45
LKS90 commented1. Done
2. Except for Changed which caused some problems (I could add a case for changed and handle it correctly though) all fields seemed fined. I switched to getting the keys from the entity_type directly. Less keys are displayed now (but more are supported).
There is another problem though with some entities: File for example has for key
labelthe fieldfilename, the fieldlabelhas a special case for rendering a link, the File doesn't have a canonical Url though and getUrlInfo() does not work. I fixed it now by switching the from field key to the field itself in case that is possible (as it is with File), if there is no field set for the key label, I use thecase 'label':instead of the default case which renders the linked label to the entity.Comment #46
LKS90 commentedHere is the screenshot I was talking about up there, it's from the latest version with less keys.
Comment #47
LKS90 commentedPostponed and waiting for #2534498: Modify EntityAggregatorSensor to only aggregate content entities.
Comment #51
miro_dietikerThis is now unlocked by #2534498: Modify EntityAggregatorSensor to only aggregate content entities.
Comment #52
miro_dietikerFrom minor to major: This contains a config schema change. ;-)
Comment #53
berdirNot so sure about the direction of the last patches, we lost all the real fields.
I dropped the keys stuff almost completely. Instead, just hardcoding id and label as suggested above. We have a small overlap but that makes defaults a lot easier. Also simplified the label case a bit and made sure it doesn't fail when we don't have a canonical link template.
We have quite some checks and special cases now. And not that much test coverage for them.
I'm going to commit this when it is green. And I'll create a follow-up to test creating sensors for nodes and files with all available fields and make sure the output is correct and doesn't fail anywhere.
Comment #55
berdirFixed that test.
Comment #57
berdirCommitted.