glpi icon indicating copy to clipboard operation
glpi copied to clipboard

Feat(Search): handle polymorphic (itemtype / items_id) criteria

Open stonebuzz opened this issue 1 year ago • 0 comments

Currently, GLPI can't search correctly on polymorphic linking tables.

Ex with Cable (and Agent, DatabaseInstance and other classes with searchoption field is items_id)

        $tab[] = [
            'id'                 => '10',
            'table'              => $this->getTable(),
            'field'              => 'items_id_endpoint_a',
            'name'               => sprintf(__('%s (%s)'), _n('Associated item', 'Associated items', 1), __('Endpoint A')),
            'massiveaction'      => false,
            'datatype'           => 'specific',
            'searchtype'         => 'equals',
            'additionalfields'   => ['itemtype_endpoint_a']
        ];

The SQL query generated cannot link to the itemtype column to add a left join to the related table.

This PR ttry to handle a new datatype to handle this case

image

  • [x] Implement itemtype / items_id search
  • [ ] Ensure that the search engine also uses the itemtype input (to add a related where -> itemtype = 'Computer' )
  • [ ] Ensure that the search engine also returns the value selected in the itemtype input to avoid losing selected option when the page is refreshed
Q A
Bug fix? yes
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #number

stonebuzz avatar Jun 12 '24 14:06 stonebuzz