Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Make decorate-select behave more like op-autocompleter

Oliver Günther71af8f55edf5
diff --git a/app/views/augmented/_autocomplete_select_decoration.html.erb b/app/views/augmented/_autocomplete_select_decoration.html.erb
index e96307d4305..62f4ad43bb8 100644
--- a/app/views/augmented/_autocomplete_select_decoration.html.erb
+++ b/app/views/augmented/_autocomplete_select_decoration.html.erb
@@ -1,14 +1,9 @@
<div class="autocomplete-select-decoration--wrapper" hidden>
- <%= content_tag :'opce-select-decoration',
- {},
- data: {
- multiple:,
- "input-name": input_name,
- "input-id": input_id,
- "append-to": defined?(append_to) ? append_to : 'body',
- key:,
- options: JSON.dump(select_options),
- } %>
-
+ <%= angular_component_tag(
+ 'opce-select-decoration',
+ inputs: inputs.merge(
+ options: select_options,
+ )
+ ) %>
<!-- Mapped values are being input as hidden fields here -->
</div>
diff --git a/app/views/custom_actions/_form.html.erb b/app/views/custom_actions/_form.html.erb
index b1e2620f55a..1858ded3b32 100644
--- a/app/views/custom_actions/_form.html.erb
+++ b/app/views/custom_actions/_form.html.erb
@@ -1,5 +1,5 @@
<% initialize_hide_sections_with @custom_action.all_actions.map { |a| { key: a.key, label: a.human_name } },
- @custom_action.actions.map { |a| { key: a.key, label: a.human_name } } %>
+ @custom_action.actions.map { |a| { key: a.key, label: a.human_name } } %>
<div class="form--field -required">
<%= f.text_field :name, required: true, container_class: '-middle' %>
@@ -17,18 +17,34 @@
<div class="form--field">
<%= styled_label_tag("custom_action_conditions_#{condition.key}", condition.human_name, class: '-top') %>
<% input_name = "custom_action[conditions][#{condition.key}]" %>
- <% selected_values = condition.values
- select_options = condition.allowed_values.map { |v| { label: v[:label], value: v[:value], selected: selected_values.include?(v[:value]) } } %>
<div class="form--field-container">
<div class="form--select-container -middle">
- <%= render partial: 'augmented/autocomplete_select_decoration',
- locals: { input_name: input_name,
- input_id: "custom_action_conditions_#{condition.key}",
- select_options: select_options,
- multiple: true,
- key: condition.key.to_s
- } %>
+ <% if condition.key == :project %>
+ <%= angular_component_tag 'opce-project-autocompleter',
+ inputs: {
+ multiple: true,
+ filters: [{ name: 'active', operator: '=', values: ['t'] }],
+ resource: "projects",
+ inputName: input_name,
+ appendTo: "body",
+ inputValue: condition.values
+ }
+ %>
+ <% else %>
+ <% selected_values = condition.values
+ select_options = condition.allowed_values.map { |v| { label: v[:label], value: v[:value], selected: selected_values.include?(v[:value]) } } %>
+ <%= render partial: 'augmented/autocomplete_select_decoration',
+ locals: {
+ select_options:,
+ inputs: {
+ inputName: input_name,
+ inputId: "custom_action_conditions_#{condition.key}",
+ multiple: true,
+ key: condition.key.to_s
+ }
+ } %>
+ <% end %>
</div>
</div>
</div>
@@ -49,18 +65,33 @@
<% input_name = "custom_action[actions][#{action.key}]" %>
<% if %i(associated_property boolean).include?(action.type) %>
- <% selected_values = action.values
- select_options = action.allowed_values.map { |v| { label: v[:label], value: v[:value], selected: selected_values.include?(v[:value]) } } %>
-
<div class="form--field-container">
<div class="form--select-container -middle">
- <%= render partial: 'augmented/autocomplete_select_decoration',
- locals: { input_name: input_name,
- input_id: "custom_action_actions_#{action.key}",
- select_options: select_options,
- multiple: action.multi_value?,
- key: action.key.to_s
- } %>
+ <% if action.key == :project %>
+ <%= angular_component_tag 'opce-project-autocompleter',
+ inputs: {
+ multiple: true,
+ filters: [{ name: 'active', operator: '=', values: ['t'] }],
+ resource: "projects",
+ inputName: input_name,
+ appendTo: "body",
+ inputValue: action.values
+ }
+ %>
+ <% else %>
+ <% selected_values = action.values
+ select_options = action.allowed_values.map { |v| { label: v[:label], value: v[:value], selected: selected_values.include?(v[:value]) } } %>
+ <%= render partial: 'augmented/autocomplete_select_decoration',
+ locals: {
+ select_options:,
+ inputs: {
+ inputName: input_name,
+ inputId: "custom_action_actions_#{action.key}",
+ multiple: action.multi_value?,
+ key: action.key.to_s
+ }
+ } %>
+ <% end %>
</div>
</div>
<% elsif %i(date_property).include?(action.type) %>
diff --git a/frontend/src/app/features/invite-user-modal/project-selection/project-selection.component.ts b/frontend/src/app/features/invite-user-modal/project-selection/project-selection.component.ts
index 8ab369f2cee..8fcb21754dc 100644
--- a/frontend/src/app/features/invite-user-modal/project-selection/project-selection.component.ts
+++ b/frontend/src/app/features/invite-user-modal/project-selection/project-selection.component.ts
@@ -8,12 +8,7 @@ import {
OnInit,
Output,
} from '@angular/core';
-import {
- AbstractControl,
- UntypedFormControl,
- UntypedFormGroup,
- Validators,
-} from '@angular/forms';
+import { AbstractControl, UntypedFormControl, UntypedFormGroup, Validators } from '@angular/forms';
import { I18nService } from 'core-app/core/i18n/i18n.service';
import { BannersService } from 'core-app/core/enterprise/banners.service';
import { CurrentUserService } from 'core-app/core/current-user/current-user.service';
@@ -23,11 +18,14 @@ import { ProjectResource } from 'core-app/features/hal/resources/project-resourc
import { PrincipalType } from '../invite-user.component';
import { ProjectAllowedValidator } from './project-allowed.validator';
import { map } from 'rxjs/operators';
-import { IProjectAutocompleteItem } from 'core-app/shared/components/autocompleter/project-autocompleter/project-autocomplete-item';
+import {
+ IProjectAutocompleteItem,
+} from 'core-app/shared/components/autocompleter/project-autocompleter/project-autocomplete-item';
import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';
import idFromLink from 'core-app/features/hal/helpers/id-from-link';
import { ICapability } from 'core-app/core/state/capabilities/capability.model';
import { firstValueFrom } from 'rxjs';
+import { IAPIFilter } from 'core-app/shared/components/autocompleter/op-autocompleter/typings';
@Component({
selector: 'op-ium-project-selection',
diff --git a/frontend/src/app/features/user-preferences/notifications-settings/inline-create/notification-setting-inline-create.component.ts b/frontend/src/app/features/user-preferences/notifications-settings/inline-create/notification-setting-inline-create.component.ts
index b08241531d8..48ef45a120f 100644
--- a/frontend/src/app/features/user-preferences/notifications-settings/inline-create/notification-setting-inline-create.component.ts
+++ b/frontend/src/app/features/user-preferences/notifications-settings/inline-create/notification-setting-inline-create.component.ts
@@ -1,15 +1,11 @@
-import {
- ChangeDetectionStrategy,
- Component,
- EventEmitter,
- Input,
- Output,
-} from '@angular/core';
+import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core';
import { UntypedFormArray } from '@angular/forms';
-import { ApiV3ListFilter } from 'core-app/core/apiv3/paths/apiv3-list-resource.interface';
import { I18nService } from 'core-app/core/i18n/i18n.service';
import { HalSourceLink } from 'core-app/features/hal/resources/hal-resource';
-import { IProjectAutocompleteItem } from 'core-app/shared/components/autocompleter/project-autocompleter/project-autocomplete-item';
+import {
+ IProjectAutocompleteItem,
+} from 'core-app/shared/components/autocompleter/project-autocompleter/project-autocomplete-item';
+import { IAPIFilter } from 'core-app/shared/components/autocompleter/op-autocompleter/typings';
export interface NotificationSettingProjectOption {
name:string;
diff --git a/frontend/src/app/features/work-packages/components/filters/filter-project/filter-project.component.ts b/frontend/src/app/features/work-packages/components/filters/filter-project/filter-project.component.ts
index 2c0670c4ce1..1e74836f8ef 100644
--- a/frontend/src/app/features/work-packages/components/filters/filter-project/filter-project.component.ts
+++ b/frontend/src/app/features/work-packages/components/filters/filter-project/filter-project.component.ts
@@ -39,6 +39,7 @@ import {
import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';
import { CurrentProjectService } from 'core-app/core/current-project/current-project.service';
import { firstValueFrom } from 'rxjs';
+import { IAPIFilter } from 'core-app/shared/components/autocompleter/op-autocompleter/typings';
@Component({
selector: 'op-filter-project',
diff --git a/frontend/src/app/features/work-packages/components/wp-relations/embedded/inline/add-existing/wp-relation-inline-add-existing.component.ts b/frontend/src/app/features/work-packages/components/wp-relations/embedded/inline/add-existing/wp-relation-inline-add-existing.component.ts
index 8e967864527..a3ae9ab6dea 100644
--- a/frontend/src/app/features/work-packages/components/wp-relations/embedded/inline/add-existing/wp-relation-inline-add-existing.component.ts
+++ b/frontend/src/app/features/work-packages/components/wp-relations/embedded/inline/add-existing/wp-relation-inline-add-existing.component.ts
@@ -26,22 +26,31 @@
// See COPYRIGHT and LICENSE files for more details.
//++
-import {
- Component,
- Inject,
-} from '@angular/core';
+import { Component, Inject } from '@angular/core';
import { I18nService } from 'core-app/core/i18n/i18n.service';
-import { WorkPackageInlineCreateService } from 'core-app/features/work-packages/components/wp-inline-create/wp-inline-create.service';
-import { WorkPackageInlineCreateComponent } from 'core-app/features/work-packages/components/wp-inline-create/wp-inline-create.component';
-import { WorkPackageRelationsService } from 'core-app/features/work-packages/components/wp-relations/wp-relations.service';
-import { WpRelationInlineCreateServiceInterface } from 'core-app/features/work-packages/components/wp-relations/embedded/wp-relation-inline-create.service.interface';
+import {
+ WorkPackageInlineCreateService,
+} from 'core-app/features/work-packages/components/wp-inline-create/wp-inline-create.service';
+import {
+ WorkPackageInlineCreateComponent,
+} from 'core-app/features/work-packages/components/wp-inline-create/wp-inline-create.component';
+import {
+ WorkPackageRelationsService,
+} from 'core-app/features/work-packages/components/wp-relations/wp-relations.service';
+import {
+ WpRelationInlineCreateServiceInterface,
+} from 'core-app/features/work-packages/components/wp-relations/embedded/wp-relation-inline-create.service.interface';
import { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource';
import { UrlParamsHelperService } from 'core-app/features/work-packages/components/wp-query/url-params-helper';
import { RelationResource } from 'core-app/features/hal/resources/relation-resource';
import { HalEventsService } from 'core-app/features/hal/services/hal-events.service';
import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';
-import { WorkPackageNotificationService } from 'core-app/features/work-packages/services/notifications/work-package-notification.service';
+import {
+ WorkPackageNotificationService,
+} from 'core-app/features/work-packages/services/notifications/work-package-notification.service';
import { IsolatedQuerySpace } from 'core-app/features/work-packages/directives/query-space/isolated-query-space';
+import { IAPIFilter } from 'core-app/shared/components/autocompleter/op-autocompleter/typings';
+import { FilterOperator } from 'core-app/shared/helpers/api-v3/api-v3-filter-builder';
@Component({
templateUrl: './wp-relation-inline-add-existing.component.html',
@@ -140,8 +149,8 @@ export class WpRelationInlineAddExistingComponent {
filters.forEach((filter) => {
iApiFilters.push({
name: filter.id,
- operator: filter.operator.id,
- values: filter.values.map((f) => (typeof f === 'string' ? f : f.id)),
+ operator: filter.operator.id as FilterOperator,
+ values: filter.values.map((f) => (typeof f === 'string' ? f : f.id as string)),
});
});
diff --git a/frontend/src/app/features/work-packages/components/wp-relations/wp-relations-create/wp-relations-autocomplete/wp-relations-autocomplete.component.ts b/frontend/src/app/features/work-packages/components/wp-relations/wp-relations-create/wp-relations-autocomplete/wp-relations-autocomplete.component.ts
index 04acfcdcfec..3aa7e5b36af 100644
--- a/frontend/src/app/features/work-packages/components/wp-relations/wp-relations-create/wp-relations-autocomplete/wp-relations-autocomplete.component.ts
+++ b/frontend/src/app/features/work-packages/components/wp-relations/wp-relations-create/wp-relations-autocomplete/wp-relations-autocomplete.component.ts
@@ -41,6 +41,7 @@ import {
WorkPackageNotificationService,
} from 'core-app/features/work-packages/services/notifications/work-package-notification.service';
import { InjectField } from 'core-app/shared/helpers/angular/inject-field.decorator';
+import { TOpAutocompleterResource } from 'core-app/shared/components/autocompleter/op-autocompleter/typings';
export interface IWorkPackageAutocompleteItem extends WorkPackageResource {
id:string,
diff --git a/frontend/src/app/shared/components/autocompleter/autocomplete-select-decoration/autocomplete-select-decoration.component.ts b/frontend/src/app/shared/components/autocompleter/autocomplete-select-decoration/autocomplete-select-decoration.component.ts
index 583fb147b06..635665e04f2 100644
--- a/frontend/src/app/shared/components/autocompleter/autocomplete-select-decoration/autocomplete-select-decoration.component.ts
+++ b/frontend/src/app/shared/components/autocompleter/autocomplete-select-decoration/autocomplete-select-decoration.component.ts
@@ -26,18 +26,16 @@
// See COPYRIGHT and LICENSE files for more details.
//++
-import {
- AfterViewInit,
- Component,
- OnInit,
- ViewChild,
-} from '@angular/core';
+import { AfterViewInit, Component, Input, OnInit, ViewChild } from '@angular/core';
import { NgSelectComponent } from '@ng-select/ng-select';
-import { IProjectAutocompleteItem } from 'core-app/shared/components/autocompleter/project-autocompleter/project-autocomplete-item';
+import {
+ IProjectAutocompleteItem,
+} from 'core-app/shared/components/autocompleter/project-autocompleter/project-autocomplete-item';
import {
IAutocompleteItem,
OpAutocompleterComponent,
} from 'core-app/shared/components/autocompleter/op-autocompleter/op-autocompleter.component';
+import { populateInputsFromDataset } from 'core-app/shared/components/dataset-inputs';
type SelectItem = { label:string, value:string, selected?:boolean };
@@ -84,30 +82,20 @@ export class AutocompleteSelectDecorationComponent extends OpAutocompleterCompon
/** Get the selected options especially for the project autocompleter */
public currentProjectSelection:{ id:string, name:string }|{ id:string, name:string }[];
- /** The input name we're syncing selections to */
- private syncInputFieldName:string;
-
/** The field key (e.g. status, type, or project) */
- public key:string;
+ @Input() key:string;
text = {
placeholder: this.I18n.t('js.placeholders.selection'),
};
ngOnInit():void {
+ populateInputsFromDataset(this);
const element = this.elementRef.nativeElement as HTMLElement;
- // Set options
- this.multiple = element.dataset.multiple === 'true';
- this.labelForId = element.dataset.inputId;
- this.key = element.dataset.key!;
- this.appendTo = element.dataset.appendTo;
-
- // Get the sync target
- this.syncInputFieldName = element.dataset.inputName!;
// Add Rails multiple identifier if multiple
if (this.multiple) {
- this.syncInputFieldName += '[]';
+ this.inputName += '[]';
}
// Prepare and build the options
@@ -153,14 +141,14 @@ export class AutocompleteSelectDecorationComponent extends OpAutocompleterCompon
const element = jQuery(this.elementRef.nativeElement);
element
.parent()
- .append(`<input type="hidden" name="${this.syncInputFieldName || ''}" value="${value}" />`);
+ .append(`<input type="hidden" name="${this.inputName || ''}" value="${value}" />`);
}
removeCurrentSyncedFields():void {
const element = jQuery(this.elementRef.nativeElement);
element
.parent()
- .find(`input[name="${this.syncInputFieldName}"]`)
+ .find(`input[name="${this.inputName}"]`)
.remove();
}
diff --git a/frontend/src/app/shared/components/autocompleter/op-autocompleter/op-autocompleter.component.ts b/frontend/src/app/shared/components/autocompleter/op-autocompleter/op-autocompleter.component.ts
index 40fc8dad28f..87a41864d2c 100644
--- a/frontend/src/app/shared/components/autocompleter/op-autocompleter/op-autocompleter.component.ts
+++ b/frontend/src/app/shared/components/autocompleter/op-autocompleter/op-autocompleter.component.ts
@@ -24,7 +24,7 @@ import {
} from '@angular/core';
import { DropdownPosition, NgSelectComponent } from '@ng-select/ng-select';
import { BehaviorSubject, merge, NEVER, Observable, of, Subject, timer } from 'rxjs';
-import { debounce, distinctUntilChanged, filter, switchMap, tap, map } from 'rxjs/operators';
+import { debounce, distinctUntilChanged, filter, map, switchMap, tap } from 'rxjs/operators';
import { AddTagFn, GroupValueFn } from '@ng-select/ng-select/lib/ng-select.component';
import { HalResource } from 'core-app/features/hal/resources/hal-resource';
@@ -53,6 +53,11 @@ import { HalResourceService } from 'core-app/features/hal/services/hal-resource.
import { CollectionResource } from 'core-app/features/hal/resources/collection-resource';
import { ApiV3FilterBuilder } from 'core-app/shared/helpers/api-v3/api-v3-filter-builder';
import { addFiltersToPath } from 'core-app/core/apiv3/helpers/add-filters-to-path';
+import {
+ IAPIFilter,
+ IOPAutocompleterOption,
+ TOpAutocompleterResource,
+} from 'core-app/shared/components/autocompleter/op-autocompleter/typings';
export interface IAutocompleteItem {
id:ID;
diff --git a/frontend/src/app/shared/components/autocompleter/op-autocompleter/services/op-autocompleter.service.ts b/frontend/src/app/shared/components/autocompleter/op-autocompleter/services/op-autocompleter.service.ts
index 835d7cd402f..e6c394e7aa2 100644
--- a/frontend/src/app/shared/components/autocompleter/op-autocompleter/services/op-autocompleter.service.ts
+++ b/frontend/src/app/shared/components/autocompleter/op-autocompleter/services/op-autocompleter.service.ts
@@ -10,6 +10,12 @@ import { HalResource } from 'core-app/features/hal/resources/hal-resource';
import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';
import { forkJoin, Observable } from 'rxjs';
import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';
+import {
+ IAPIFilter,
+ TOpAutocompleterResource,
+} from 'core-app/shared/components/autocompleter/op-autocompleter/typings';
+import { ProjectResource } from 'core-app/features/hal/resources/project-resource';
+import { ApiV3ProjectPaths } from 'core-app/core/apiv3/endpoints/projects/apiv3-project-paths';
@Injectable()
@@ -45,7 +51,7 @@ export class OpAutocompleterService extends UntilDestroyedMixin {
protected loadSingleValue(id:string, resource:TOpAutocompleterResource) {
return (this.apiV3Service[resource] as
- ApiV3ResourceCollection<UserResource|WorkPackageResource, ApiV3UserPaths|ApiV3WorkPackagePaths>)
+ ApiV3ResourceCollection<UserResource|WorkPackageResource|ProjectResource, ApiV3UserPaths|ApiV3WorkPackagePaths|ApiV3ProjectPaths>)
.id(id)
.get();
}
diff --git a/frontend/src/app/shared/components/autocompleter/op-autocompleter/typings.d.ts b/frontend/src/app/shared/components/autocompleter/op-autocompleter/typings.d.ts
index 4fc08713255..08d56ff627e 100644
--- a/frontend/src/app/shared/components/autocompleter/op-autocompleter/typings.d.ts
+++ b/frontend/src/app/shared/components/autocompleter/op-autocompleter/typings.d.ts
@@ -1,12 +1,14 @@
-interface IAPIFilter {
+import { ApiV3FilterValueType, FilterOperator } from 'core-app/shared/helpers/api-v3/api-v3-filter-builder';
+
+export interface IAPIFilter {
name:string;
operator:FilterOperator;
values:ApiV3FilterValueType[];
}
-interface IOPAutocompleterOption {
+export interface IOPAutocompleterOption {
id:number;
name:string;
}
-type TOpAutocompleterResource = 'work_packages' | 'users' | 'principals';
+export type TOpAutocompleterResource = 'work_packages' | 'users' | 'principals' | 'projects';
diff --git a/frontend/src/app/shared/components/fields/edit/field-types/project-edit-field.component.ts b/frontend/src/app/shared/components/fields/edit/field-types/project-edit-field.component.ts
index a1f10065762..721ffe353dd 100644
--- a/frontend/src/app/shared/components/fields/edit/field-types/project-edit-field.component.ts
+++ b/frontend/src/app/shared/components/fields/edit/field-types/project-edit-field.component.ts
@@ -52,12 +52,11 @@ import { ResourceChangeset } from '../../changeset/resource-changeset';
import { IFieldSchema } from '../../field.base';
import { EditFieldHandler } from '../editing-portal/edit-field-handler';
import { HalResourceService } from 'core-app/features/hal/services/hal-resource.service';
-import {
- take,
- tap,
-} from 'rxjs/operators';
+import { take, tap } from 'rxjs/operators';
import isNewResource from 'core-app/features/hal/helpers/is-new-resource';
import idFromLink from 'core-app/features/hal/helpers/id-from-link';
+import { IAPIFilter } from 'core-app/shared/components/autocompleter/op-autocompleter/typings';
+import { FilterOperator } from 'core-app/shared/helpers/api-v3/api-v3-filter-builder';
@Component({
templateUrl: './project-edit-field.component.html',
@@ -117,12 +116,12 @@ export class ProjectEditFieldComponent extends EditFieldComponent implements OnI
public get APIFilters():IAPIFilter[] {
const filters = [
- { name: 'active', operator: '=', values: ['t'] },
+ { name: 'active', operator: '=' as FilterOperator, values: ['t'] },
];
if (isNewResource(this.resource) && this.change.value('type')) {
const typeId = idFromLink((this.change.value('type') as HalResource).href);
- filters.push({ name: 'type_id', operator: '=', values: [typeId] });
+ filters.push({ name: 'type_id', operator: '=' as FilterOperator, values: [typeId] });
}
return filters;
diff --git a/lib/primer/open_project/forms/autocompleter.html.erb b/lib/primer/open_project/forms/autocompleter.html.erb
index 04d63c65a95..6dd2b014ab4 100644
--- a/lib/primer/open_project/forms/autocompleter.html.erb
+++ b/lib/primer/open_project/forms/autocompleter.html.erb
@@ -4,12 +4,15 @@
<%= render partial: '/augmented/autocomplete_select_decoration',
formats: %i[html],
locals: {
- input_name: @autocomplete_options.fetch(:inputName) { builder.field_name(@input.name) },
- input_id: @autocomplete_options.fetch(:inputId) { builder.field_id(@input.name) },
+ inputs: @autocomplete_options.merge(
+ classes: "ng-select--primerized #{@input.invalid? ? '-error' : ''}",
+ inputName: @autocomplete_options.fetch(:inputName) { builder.field_name(@input.name) },
+ inputId: @autocomplete_options.fetch(:inputId) { builder.field_id(@input.name) },
+ inputValue: @autocomplete_options.fetch(:inputValue) { builder.object.send(@input.name) },
+ key: @autocomplete_options.fetch(:resource, ''),
+ defaultData: @autocomplete_options.fetch(:defaultData) { true }
+ ),
select_options: select_options.map(&:to_h),
- multiple: @autocomplete_options.fetch(:multiple, false),
- key: @autocomplete_options.fetch(:resource, ''),
- append_to: @autocomplete_options.fetch(:append_to, 'body')
} %>
<% else %>
<%= content_tag(:div, class: ("projects-autocomplete-with-search-icon" if @autocomplete_options.delete(:with_search_icon))) do %>