Skip to content

Enhance SearchEditor to configure user-defined condition metadata#376

Closed
sukhwinder33445 wants to merge 2 commits into
mainfrom
enhance-search-editor
Closed

Enhance SearchEditor to configure user-defined condition metadata#376
sukhwinder33445 wants to merge 2 commits into
mainfrom
enhance-search-editor

Conversation

@sukhwinder33445
Copy link
Copy Markdown
Contributor

@sukhwinder33445 sukhwinder33445 commented May 4, 2026

This PR enhances SearchEditor to support configuring user-defined condition metadata fields via setMetadataFields(). The declared fields are stored as hidden inputs during condition assembly and used to populate the condition's metadata on each form submission.

Completer.js is also updated to identify and populate these metadata fields when a suggestion is selected.

This comment was marked as resolved.

@sukhwinder33445 sukhwinder33445 force-pushed the enhance-search-editor branch 5 times, most recently from e7ba5dc to 76f47d7 Compare May 5, 2026 07:27
@sukhwinder33445 sukhwinder33445 changed the title SearchEditor: Store additional user defined condition meta-data Enhance SearchEditor to configure user-defined condition metadata May 5, 2026
@sukhwinder33445 sukhwinder33445 force-pushed the enhance-search-editor branch from 76e6d9f to 4db1ca1 Compare May 6, 2026 10:19
@nilmerg
Copy link
Copy Markdown
Member

nilmerg commented May 6, 2026

used to populate the condition's metadata on each form submission.

Is GitHub's files changed view broken or why do I see nothing regarding this?

@sukhwinder33445
Copy link
Copy Markdown
Contributor Author

used to populate the condition's metadata on each form submission.

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

Copy link
Copy Markdown
Member

@nilmerg nilmerg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/Control/SearchEditor.php Outdated

$metadataFields = new HtmlDocument();
foreach ($this->metadataFields as $fieldNameSuffix) {
$name = $identifier . '-column-metadata-' . $fieldNameSuffix;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-.

@sukhwinder33445 sukhwinder33445 force-pushed the enhance-search-editor branch 2 times, most recently from 9fe40e7 to 4db8d8d Compare May 8, 2026 11:39
@sukhwinder33445 sukhwinder33445 requested a review from Copilot May 8, 2026 11:39

This comment was marked as resolved.

@sukhwinder33445 sukhwinder33445 force-pushed the enhance-search-editor branch 2 times, most recently from cbefffd to fa3093a Compare May 12, 2026 07:31
@sukhwinder33445 sukhwinder33445 requested a review from Copilot May 12, 2026 07:36
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comment on lines +115 to +126
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;

Comment thread asset/js/widget/Completer.js
sukhwinder33445 and others added 2 commits May 12, 2026 10:03
@sukhwinder33445 sukhwinder33445 force-pushed the enhance-search-editor branch from fa3093a to 360d99d Compare May 12, 2026 08:04
@sukhwinder33445
Copy link
Copy Markdown
Contributor Author

This PR is no longer required.

@github-project-automation github-project-automation Bot moved this from In progress to Done in Icinga Notifications 1.0 May 12, 2026
@sukhwinder33445 sukhwinder33445 deleted the enhance-search-editor branch May 12, 2026 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants