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

Remove references and extra logic & styles of jquery-ui autocompleter which is now not used any more

Henriette Dargea63167aef4be
diff --git a/frontend/src/app/core/setup/init-vendors.ts b/frontend/src/app/core/setup/init-vendors.ts
index dbac0c8e7f5..220dc584a06 100644
--- a/frontend/src/app/core/setup/init-vendors.ts
+++ b/frontend/src/app/core/setup/init-vendors.ts
@@ -48,7 +48,6 @@ require('jquery-ui/ui/core.js');
require('jquery-ui/ui/position.js');
require('jquery-ui/ui/disable-selection.js');
require('jquery-ui/ui/widgets/sortable.js');
-require('jquery-ui/ui/widgets/autocomplete.js');
require('jquery-ui/ui/widgets/dialog.js');
require('jquery-ui/ui/widgets/tooltip.js');
diff --git a/frontend/src/app/shared/components/autocompleter/lazyloaded/lazyloaded-autocompleter.ts b/frontend/src/app/shared/components/autocompleter/lazyloaded/lazyloaded-autocompleter.ts
deleted file mode 100644
index 9cb598e170d..00000000000
--- a/frontend/src/app/shared/components/autocompleter/lazyloaded/lazyloaded-autocompleter.ts
+++ /dev/null
@@ -1,287 +0,0 @@
-import * as Fuse from 'fuse.js';
-
-export interface IAutocompleteItem<T> {
- label:string;
- render:'match' | 'disabled';
- object:T;
-}
-
-export abstract class ILazyAutocompleterBridge<T> {
- // Current page the autocompleter is on
- public currentPage:number;
-
- // Input autocomplete element
- public input:any;
-
- // Fuzzy instance for the results
- public fuseInstance:any;
-
- public constructor(public widgetName:string) {
- LazyLoadedAutocompleter.register(widgetName, this);
- }
-
- /**
- * Return the maximum number of items to render in this page.
- * Note that for this value, the container must be setup that a scrollbar exists.
- * @returns {number}
- */
- public abstract get maxItemsPerPage():number;
-
- /**
- * Handler function for when an active item was selected through the autocompleter
- * @param {T} item
- */
- public abstract onItemSelected(item:T):void;
-
- /**
- * Handler function for when no results were matched through the search term.
- * @param {JQueryUI.AutocompleteEvent} event
- * @param {JQueryUI.AutocompleteUIParams} ui
- */
- public abstract onNoResultsFound(event:JQueryUI.AutocompleteEvent, ui:any):void;
-
- /**
- * Customize the rendering of an inner item element.
- *
- * @param {IAutocompleteItem} item
- * @param {JQuery} div
- */
- public renderItem(item:IAutocompleteItem<T>, div:JQuery):void {
- div.text(item.label);
- }
-
- /**
- * Returns the elements matched by the fuzzy search
- */
- private fuzzySearch(items:IAutocompleteItem<T>[], term:string) {
- if (term === '') {
- return items;
- } if (term.length >= 3) {
- const literalMatches = this.literalSearch(items, term);
-
- if (literalMatches.length > 0) {
- return literalMatches as any;
- }
- }
-
- return this.fuseInstance.search(term);
- }
-
- /**
- * Filters the given list of items so that only items whose label contains
- * the exact search term (case insensitive).
- *
- * @param items Items to be searched
- * @param term Search term
- * @return The subset of the given items matching the search term.
- */
- private literalSearch(items:IAutocompleteItem<T>[], term:string) {
- const results:IAutocompleteItem<T>[] = [];
- const str:string = term.toLowerCase();
-
- items.forEach((e) => {
- if (e.label.toLowerCase().indexOf(str) !== -1) {
- results.push(e);
- }
- });
-
- return results;
- }
-
- /**
- * Allows to augment the set of matched items (e.g., to add hierarchy).
- * @param {IAutocompleteItem<T>[]} items
- * @param {IAutocompleteItem<T>[]} matched
- * @returns {IAutocompleteItem<T>[]}
- */
- protected augmentedResultSet(items:IAutocompleteItem<T>[], matched:IAutocompleteItem<T>[]) {
- // By default, set all to match
- const results:IAutocompleteItem<T>[] = [];
-
- matched.forEach((el) => {
- results.push({
- label: el.label,
- object: el.object,
- render: 'match',
- } as IAutocompleteItem<T>);
- });
-
- return results;
- }
-
- public setup(input:JQuery, items:IAutocompleteItem<T>[]) {
- this.currentPage = 0;
- this.input = input;
- this.input[this.widgetName].call(this.input, this.setupParams(items));
- const options = {
- shouldSort: true,
- tokenize: false,
- threshold: 0.2,
- location: 0,
- distance: 10000, // allow the term to appear anywhere
- maxPatternLength: 16,
- minMatchCharLength: 2,
- keys: ['label'] as any,
- };
-
- this.fuseInstance = new Fuse(items, options);
- }
-
- protected setupParams(autocompleteValues:IAutocompleteItem<T>[]) {
- const ctrl = this;
-
- return {
- delay: 50,
- source(request:any, response:any) {
- const fuzzyResults = ctrl.fuzzySearch(autocompleteValues, request.term);
- response(ctrl.augmentedResultSet(autocompleteValues, fuzzyResults));
- },
- select: (ul:any, selected:{ item:IAutocompleteItem<T> }) => {
- if (selected.item.render === 'match') {
- ctrl.onItemSelected(selected.item.object);
- }
- },
- create: () => ctrl.input.focus(),
- response: (event:JQueryUI.AutocompleteEvent, ui:JQueryUI.AutocompleteUIParams) => {
- ctrl.onNoResultsFound(event, ui);
- },
- autoFocus: true,
- minLength: 0,
- };
- }
-}
-
-export namespace LazyLoadedAutocompleter {
-
- /**
- * Returns whether the scrollbar is at a place where we should display additional elements
- * @param ul
- */
- function isScrollbarBottom(container:JQuery) {
- const height = container.outerHeight()!;
- const { scrollHeight } = container[0];
- const scrollTop = container.scrollTop()!;
- return scrollTop >= (scrollHeight - height - 6);
- }
-
- export function register<T>(name:string, ctrl:ILazyAutocompleterBridge<T>) {
- jQuery.widget(`custom.${name}`, jQuery.ui.autocomplete, {
- _create(this:any) {
- ctrl.currentPage = 0;
- this._super();
- this.widget().menu('option', 'items', '> .ui-matched-item');
- this._search('');
- },
-
- _renderMenu(this:any, ul:HTMLElement, items:IAutocompleteItem<T>[]) {
- // remove scroll event to prevent attaching multiple scroll events to one container element
- jQuery(ul).unbind('scroll');
-
- this._renderLazyMenu(ul, items);
- },
-
- // Rener the menu for the current page
- _renderMenuPage(this:any, ul:JQuery, items:IAutocompleteItem<T>[], page:number|null = null) {
- const widget = this;
- let rendered:number = items.length;
- let pageElements = items;
- const max = ctrl.maxItemsPerPage;
- if (page !== null) {
- pageElements = items.slice(page * max, (page * max) + max);
- rendered = Math.min(items.length, (page * max) + max);
- }
-
- // Insert elements of this page
- jQuery.each(pageElements, (index, item) => {
- widget._renderItemData(ul, item);
- });
-
- // Ensure scrollbar is shown when more results exist
- ul.css('height', 'auto');
- if (rendered < items.length) {
- const maxHeight = document.body.offsetHeight * 0.55;
- const shownHeight = rendered * 32;
-
- if (shownHeight < maxHeight) {
- ul.css('height', shownHeight - 50);
- }
- }
- },
-
- /**
- * Return the number of (lazy) pages for the current set of results
- * @param {IAutocompleteItem[]} items
- * @returns {number}
- */
- _pages(items:IAutocompleteItem<T>[]):number {
- return Math.ceil(items.length / ctrl.maxItemsPerPage);
- },
-
- _repositionMenu(this:any, container:JQuery) {
- const widget = this;
- const { menu } = widget;
-
- menu.refresh();
-
- // Call ui's own resize
- widget._resizeMenu();
-
- container.position(jQuery.extend({ of: widget.element }, widget.options.position));
- if (widget.options.autoFocus) {
- menu.next(new jQuery.Event('mouseover'));
- }
- },
-
- _resizeMenu(this:any) {
- const ul = this.menu.element;
- ul.outerWidth(this.element.outerWidth());
- },
-
- _renderItem(this:any, ul:JQuery, item:IAutocompleteItem<T>) {
- const term = this.element.val();
- const disabled = item.render === 'disabled';
- const div = jQuery('<div>').addClass('ui-menu-item-wrapper');
-
- ctrl.renderItem(item, div);
-
- const element = jQuery('<li>')
- .toggleClass('ui-state-disabled', disabled)
- .toggleClass('ui-matched-item', !disabled)
- .append(div)
- .appendTo(ul);
-
- if (term !== '') {
- (element as any).mark(term, { className: 'ui-autocomplete-match' });
- }
-
- return element;
- },
-
- _renderLazyMenu(this:any, ul:Element, items:IAutocompleteItem<T>[]) {
- const widget = this;
- const container = jQuery(ul) as JQuery;
- const pages = this._pages(items);
-
- if (pages <= 1) {
- return widget._renderMenuPage(ul, items);
- }
-
- widget._renderMenuPage(ul, items, 0);
-
- container.scroll(() => {
- if (isScrollbarBottom(container)) {
- if (++ctrl.currentPage >= pages) {
- return;
- }
-
- // Render the current menu page
- widget._renderMenuPage(ul, items, ctrl.currentPage);
-
- // Refresh the menu
- widget._repositionMenu(ul);
- }
- });
- },
- });
- }
-}
diff --git a/frontend/src/app/shared/components/autocompleter/project-menu-autocomplete/project-menu-autocomplete.template.html b/frontend/src/app/shared/components/autocompleter/project-menu-autocomplete/project-menu-autocomplete.template.html
index 8cb0e70356f..694002af7f2 100644
--- a/frontend/src/app/shared/components/autocompleter/project-menu-autocomplete/project-menu-autocomplete.template.html
+++ b/frontend/src/app/shared/components/autocompleter/project-menu-autocomplete/project-menu-autocomplete.template.html
@@ -101,32 +101,3 @@
</op-content-loader>
</ng-template>
</spot-drop-modal>
-
-
-<!--<div
- class="dropdown dropdown-relative project-search-results"
- id="project_autocompletion_wrapper"
->
- <div class="project-menu-autocomplete&#45;&#45;wrapper">
- <div class="project-menu-autocomplete&#45;&#45;input-container">
- <label
- for="project_autocompletion_input"
- class="hidden-for-sighted"
- [textContent]="text.label"
- ></label>
- <input
- type="text"
- id="project_autocompletion_input"
- name="project_autocompletion_input"
- class="ui-autocomplete&#45;&#45;input project-menu-autocomplete&#45;&#45;input"
- [attr.placeholder]="loadingText"
- />
- <i class="project-menu-autocomplete&#45;&#45;search-icon icon-search"></i>
- </div>
- <p
- class="project-menu-autocomplete&#45;&#45;no-results"
- hidden
- [textContent]="text.no_results"
- ></p>
- </div>
-</div>-->
diff --git a/frontend/src/global_styles/content/_autocomplete.sass b/frontend/src/global_styles/content/_autocomplete.sass
index 42bf03d0a0c..a5250b7996c 100644
--- a/frontend/src/global_styles/content/_autocomplete.sass
+++ b/frontend/src/global_styles/content/_autocomplete.sass
@@ -58,86 +58,6 @@ div.autocomplete
#parent_issue_candidates ul li, #related_issue_candidates ul li
width: 500px
-
-/** jquery-ui autocomplete */
-
-.ui-autocomplete
- position: absolute
- top: 0
- left: 0
- cursor: default
- margin: 0
- list-style: none
- z-index: 10000
-
- .ui-menu-item
- border-bottom: 1px solid var(--content-default-border-color)
-
- a
- color: var(--body-font-color)
- padding-left: 5px
-
- .ui-menu-item-wrapper
- word-break: break-word
- padding: 10px 5px
-
- // Necessary for iOS to recognize as clickable
- cursor: pointer
-
- &.ui-state-active,
- &.selected
- border: none
- a
- color: var(--drop-down-selected-font-color)
-
- &.ui-state-active
- background: var(--drop-down-hover-bg-color)
- &.selected:not(.ui-state-active)
- background: var(--drop-down-selected-bg-color)
-
- &.-inplace
- position: relative
- border: none
- padding-top: 15px
- line-height: 1.6
- font-size: 1rem
-
- .ui-menu-item
- border-bottom: none
-
- .ui-menu-item-wrapper
- padding: 4px 10px
-
-.ui-autocomplete--input
- // Error highlighting
- &.-error, &.-error:hover, &.-error:focus
- background: $nm-color-error-background
- border-color: var(--content-form-danger-zone-bg-color)
-
-mark.ui-autocomplete-match
- background: none
- color: var(--primary-color)
- text-decoration: underline
- font-weight: bold !important
-
-// Loading indicator
-.ui-autocomplete--loading
- background: white
- z-index: 200
- border: 1px solid #ccc
- border-top: none
- padding: 5px
- // Position bottom of input
- position: absolute
- // With same width as input
- width: 100%
-
-.ui-autocomplete--category
- padding: 0
- font-weight: bold
- text-transform: uppercase
-
-
// -------------------------- ng-select --------------------------
.ng-select
width: 100%
@@ -201,5 +121,3 @@ mark.ui-autocomplete-match
.work-package-table--container .ng-dropdown-panel
z-index: auto !important
-
-
diff --git a/frontend/src/global_styles/content/_index.sass b/frontend/src/global_styles/content/_index.sass
index 40586ed19f5..7b54ddf51a7 100644
--- a/frontend/src/global_styles/content/_index.sass
+++ b/frontend/src/global_styles/content/_index.sass
@@ -77,7 +77,6 @@
@import project_status
@import sidebar
-@import menus/project_autocompletion
@import menus/menu_blocks
@import editor/index
@import modules/index
diff --git a/frontend/src/global_styles/content/menus/_project_autocompletion.sass b/frontend/src/global_styles/content/menus/_project_autocompletion.sass
deleted file mode 100644
index 70e02e72349..00000000000
--- a/frontend/src/global_styles/content/menus/_project_autocompletion.sass
+++ /dev/null
@@ -1,101 +0,0 @@
-#project-search-container
- position: relative
-
- project-menu-autocomplete
- display: block
- max-height: inherit
-
- .project-menu-autocomplete--wrapper
- display: flex
- flex-direction: column
- max-height: inherit
-
-#project-search-container:nth-child(3)
- // Substract header height and the two project menu items ("view all", "create new")
- max-height: calc(100vh - var(--header-height) - 2 * 42px)
-#project-search-container:nth-child(2)
- // Substract header height and the project menu item ("view all")
- max-height: calc(100vh - var(--header-height) - 42px)
-
-.project-search-results,
-.project-search-results.dropdown
- position: relative
- overflow: hidden
- max-height: inherit
- width: 400px
- background: white
- // Avoid scrolling body when autocompleter is at bottom
- // (May not be supported by all browsers yet, but soonish)
- overscroll-behavior: contain
-
- @include breakpoint(680px down)
- width: 100vw
-
- @include default-font(var(--header-drop-down-projects-search-font-color), 13px)
- li
- padding: 0 10px
- font-size: 14px
-
- &:before
- color: #b3b3b3
- top: 21px
- right: 25px
- font-size: 14px
-
- // Search input wrapper
- .project-menu-autocomplete--input-container
- padding: 12px 0
- border-width: 1px 1px 0px 1px
- border-style: solid
- border-color: var(--header-drop-down-border-color)
-
- // Search input
- input.project-menu-autocomplete--input
- margin: 0 10px
- padding: 0px 32px 0px 10px
- border: 1px solid #D9D9D9
- border-radius: 3px
- box-shadow: inset 0px 1px 3px 0px rgba(0,0,0,0.1)
- box-sizing: border-box
- width: calc(100% - 20px)
- height: 2.125rem
- background: var(--header-drop-down-projects-search-input-bg-color)
-
- @include breakpoint(680px down)
- margin: 0 auto
- width: calc(100% - 35px)
-
- // Lens icon on the right
- .project-menu-autocomplete--search-icon
- position: absolute
- color: #b3b3b3
- top: 20px
- right: 20px
- font-size: 14px
-
- @include breakpoint(680px down)
- right: 40px
-
- // Override top menu height
- ul.project-menu-autocomplete--results
- max-height: 55vh
- overflow-y: auto
- // Override the computed width of the input, but span the entire width
- // of the dropdown
- width: 100% !important
- padding-top: 0px
- // Borders to complete the menu look
- border-right: 1px solid var(--header-drop-down-border-color)
- border-left: 1px solid var(--header-drop-down-border-color)
- @include styled-scroll-bar
-
- // Cut off result element width
- .ui-menu-item-wrapper
- @include text-shortener
-
- // Indent the no results pane
- .project-menu-autocomplete--no-results
- // Mirror border from ui results
- border: 2px solid var(--header-drop-down-border-color)
- border-top: none
- padding: 12px
diff --git a/lib/redmine/menu_manager/top_menu/projects_menu.rb b/lib/redmine/menu_manager/top_menu/projects_menu.rb
index a097be72fb5..9cd78befe2c 100644
--- a/lib/redmine/menu_manager/top_menu/projects_menu.rb
+++ b/lib/redmine/menu_manager/top_menu/projects_menu.rb
@@ -40,39 +40,6 @@ module Redmine::MenuManager::TopMenu::ProjectsMenu
content_tag(:li, class: 'op-app-menu--item') do
angular_component_tag('project-menu-autocomplete')
end
-
-=begin
- label = !!(@project && [email protected]?) ? @project.name : t(:label_select_project)
- render_menu_dropdown_with_items(
- label:,
- label_options: {
- id: 'projects-menu',
- accesskey: OpenProject::AccessKeys.key_for(:project_search),
- span_class: 'ellipsis'
- },
- items: project_items,
- options: {
- drop_down_class: 'drop-down--projects'
- }
- ) do
- content_tag(:li, id: 'project-search-container') do
- angular_component_tag('project-menu-autocomplete')
- end
- end
-=end
- end
-
- def project_items
- [project_index_item]
- end
-
- def project_index_item
- Redmine::MenuManager::MenuItem.new(
- :list_projects,
- main_app.projects_path,
- caption: t(:label_project_view_all),
- icon: "icon-show-all-projects icon4"
- )
end
include OpenProject::StaticRouting::UrlHelpers