Enhance SearchEditor to configure user-defined condition metadata#376
Enhance SearchEditor to configure user-defined condition metadata#376sukhwinder33445 wants to merge 2 commits into
SearchEditor to configure user-defined condition metadata#376Conversation
aa7f5df to
d1b8024
Compare
d1b8024 to
f96f308
Compare
e7ba5dc to
76f47d7
Compare
SearchEditor: Store additional user defined condition meta-dataSearchEditor to configure user-defined condition metadata
76e6d9f to
4db1ca1
Compare
Is GitHub's files changed view broken or why do I see nothing regarding this? |
I mean this line of code: https://github.com/Icinga/ipl-web/pull/376/changes#diff-3f1f0dbb1b41dd0a49c9312052306cf0435c4cb1e610c0cf88b2e0787fb897ffR602 |
4db1ca1 to
6ff833a
Compare
nilmerg
left a comment
There was a problem hiding this comment.
Please drop the metadata knowledge from the javascript implementation. The SearchSuggestions transfer any remaining data values to data attributes and so they don't know anything of this term either. The SearchEditor must prevent the usage of additional hidden fields that collide with what's already part of the form. (e.g. -search)
The reset of these fields might be necessary in case the user doesn't choose a suggestion, but this shouldn't rely on the name of a field either. The only special case is the -search field again, because that must not be reset but should receive the user's input. Other additional fields, as introduced here, do not have any meaning and so can simply be emptied because they're hidden and do not end with -search.
The transfer of submitted values is also error prone right now. assemble should not be responsible to register such changes. Speaking of changes, an appropriate method is already part of this class, so please register metadata values there instead.
|
|
||
| $metadataFields = new HtmlDocument(); | ||
| foreach ($this->metadataFields as $fieldNameSuffix) { | ||
| $name = $identifier . '-column-metadata-' . $fieldNameSuffix; |
There was a problem hiding this comment.
oh and please also drop the -column- prefix. I don't think that's really necessary as meta data generally is for the entire condition.
There was a problem hiding this comment.
As discussed offline, we cannot omit the prefix without making changes to the JS file, as the input.name used by JS already contains the suffix -column-.
9fe40e7 to
4db8d8d
Compare
cbefffd to
fa3093a
Compare
| public function setMetadataFields(array $fields): static | ||
| { | ||
| // `search` is already a hidden field, and `title` has special handling in js Completer.complete() | ||
| $reserved = array_intersect($fields, ['search', 'title']); | ||
| if (! empty($reserved)) { | ||
| throw new ConfigurationError( | ||
| sprintf("Reserved keyword(s) not allowed as metadata field: %s", implode(', ', $reserved)) | ||
| ); | ||
| } | ||
|
|
||
| $this->metadataFields = $fields; | ||
|
|
Completer.js: Unset values of suggestion-based fields on manual input and reset missing title
fa3093a to
360d99d
Compare
|
This PR is no longer required. |
This PR enhances
SearchEditorto support configuring user-defined conditionmetadatafields viasetMetadataFields(). The declared fields are stored as hidden inputs during condition assembly and used to populate the condition'smetadataon each form submission.Completer.jsis also updated to identify and populate thesemetadatafields when a suggestion is selected.