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 jQuery usage from main.ts

Alexander Brandon Coles662300819f48
diff --git a/frontend/src/app/core/setup/globals/global-helpers.ts b/frontend/src/app/core/setup/globals/global-helpers.ts
index d74475153c3..449f6b045a4 100644
--- a/frontend/src/app/core/setup/globals/global-helpers.ts
+++ b/frontend/src/app/core/setup/globals/global-helpers.ts
@@ -45,3 +45,7 @@ export class GlobalHelpers {
checkboxes.forEach((el) => { el.checked = !allChecked; });
}
}
+
+export function getMetaElement(name:string):HTMLMetaElement|null {
+ return document.querySelector(`meta[name=${name}]`);
+}
diff --git a/frontend/src/app/core/setup/globals/openproject.ts b/frontend/src/app/core/setup/globals/openproject.ts
index a7d03afb0a5..02e089ffbd5 100644
--- a/frontend/src/app/core/setup/globals/openproject.ts
+++ b/frontend/src/app/core/setup/globals/openproject.ts
@@ -28,7 +28,7 @@
import { OpenProjectPluginContext } from 'core-app/features/plugins/plugin-context';
import { input, InputState } from '@openproject/reactivestates';
-import { GlobalHelpers } from 'core-app/core/setup/globals/global-helpers';
+import { getMetaElement, GlobalHelpers } from 'core-app/core/setup/globals/global-helpers';
import { firstValueFrom } from 'rxjs';
/**
@@ -58,15 +58,15 @@ export class OpenProject {
}
public get urlRoot():string {
- return this.getMetaElement('app_base_path')?.content || '';
+ return getMetaElement('app_base_path')?.content || '';
}
public get environment():string {
- return this.getMetaElement('openproject_initializer')?.dataset.environment || '';
+ return getMetaElement('openproject_initializer')?.dataset.environment || '';
}
public get edition():string {
- return this.getMetaElement('openproject_initializer')?.dataset.edition || '';
+ return getMetaElement('openproject_initializer')?.dataset.edition || '';
}
public get isStandardEdition():boolean {
@@ -99,10 +99,6 @@ export class OpenProject {
console.error('Failed to access your browsers local storage. Is your local database corrupted?');
}
}
-
- private getMetaElement(name:string):HTMLMetaElement|null {
- return document.querySelector(`meta[name=${name}]`);
- }
}
window.OpenProject = new OpenProject();
diff --git a/frontend/src/main.ts b/frontend/src/main.ts
index 82f7151eae7..cac79a57a95 100644
--- a/frontend/src/main.ts
+++ b/frontend/src/main.ts
@@ -6,6 +6,7 @@ import { initializeLocale } from 'core-app/core/setup/init-locale';
import { environment } from './environments/environment';
import { configureErrorReporter } from 'core-app/core/errors/configure-reporter';
import { initializeGlobalListeners } from 'core-app/core/setup/globals/global-listeners';
+import { getMetaElement } from 'core-app/core/setup/globals/global-helpers';
(window as any).global = window;
@@ -15,10 +16,10 @@ import { initializeGlobalListeners } from 'core-app/core/setup/globals/global-li
const ASSET_BASE_PATH = '/assets/frontend/';
// Sets the relative base path
-window.appBasePath = jQuery('meta[name=app_base_path]').attr('content') || '';
+window.appBasePath = getMetaElement('app_base_path')?.content || '';
// Get the asset host, if any
-const initializer = document.querySelector<HTMLMetaElement>('meta[name="openproject_initializer"]');
+const initializer = getMetaElement('openproject_initializer');
const ASSET_HOST = initializer?.dataset.assetHost ? `//${initializer.dataset.assetHost}` : '';
// Ensure to set the asset base for dynamic code loading