diff --git a/src/main/js/bundles/dn_imprintprivacy/ToolHandler.js b/src/main/js/bundles/dn_imprintprivacy/ToolHandler.js deleted file mode 100644 index a8eaa5b..0000000 --- a/src/main/js/bundles/dn_imprintprivacy/ToolHandler.js +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2024 con terra GmbH (info@conterra.de) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import dojo from "dojo/_base/kernel"; - -class ToolHandler { - - activate() { - const toolsetManager = this._toolsetManager; - const toolset = this._properties.toolsetDefinition; - toolsetManager.addToolsetDefinition(toolset); - } - - openImprint() { - const locale = dojo.locale; - const imprintUrls = this._properties.imprintUrls; - const imprintUrl = imprintUrls.find((url) => url.locale === locale).url; - window.open(imprintUrl, '_blank'); - } - - openPrivacyStatements() { - const locale = dojo.locale; - const privacyUrls = this._properties.privacyUrls; - const privacyUrl = privacyUrls.find((url) => url.locale === locale).url; - window.open(privacyUrl, '_blank'); - } - -} - -module.exports = ToolHandler; - diff --git a/src/main/js/bundles/dn_imprintprivacy/ToolHandler.ts b/src/main/js/bundles/dn_imprintprivacy/ToolHandler.ts new file mode 100644 index 0000000..2f86995 --- /dev/null +++ b/src/main/js/bundles/dn_imprintprivacy/ToolHandler.ts @@ -0,0 +1,50 @@ +/// +/// Copyright (C) 2024 con terra GmbH (info@conterra.de) +/// +/// Licensed under the Apache License, Version 2.0 (the "License"); +/// you may not use this file except in compliance with the License. +/// You may obtain a copy of the License at +/// +/// http://www.apache.org/licenses/LICENSE-2.0 +/// +/// Unless required by applicable law or agreed to in writing, software +/// distributed under the License is distributed on an "AS IS" BASIS, +/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +/// See the License for the specific language governing permissions and +/// limitations under the License. +/// + +import type { InjectedReference } from "apprt-core/InjectedReference"; +import type { UrlConfigObject } from "./api"; + +import Locale from "ct/Locale"; + +export class ToolHandler { + private _toolsetManager: InjectedReference; + private _properties: InjectedReference>; + + public activate(): void { + const toolsetManager = this._toolsetManager; + const toolset = this._properties!.toolsetDefinition; + toolsetManager.addToolsetDefinition(toolset); + } + + public openImprint(): void { + const locale = Locale.getCurrent().getLanguage(); + const imprintUrls = this._properties!.imprintUrls; + const imprintUrl = imprintUrls.find((url: UrlConfigObject) => url.locale === locale).url; + if (!imprintUrl) { return; } + + window.open(imprintUrl, '_blank'); + } + + public openPrivacyStatements(): void { + const locale = Locale.getCurrent().getLanguage(); + const privacyUrls = this._properties!.privacyUrls; + const privacyUrl = privacyUrls.find((url: UrlConfigObject) => url.locale === locale).url; + if (!privacyUrl) { return; } + + window.open(privacyUrl, '_blank'); + } + +} diff --git a/src/main/js/bundles/dn_imprintprivacy/api.ts b/src/main/js/bundles/dn_imprintprivacy/api.ts new file mode 100644 index 0000000..7228229 --- /dev/null +++ b/src/main/js/bundles/dn_imprintprivacy/api.ts @@ -0,0 +1,20 @@ +/// +/// Copyright (C) 2024 con terra GmbH (info@conterra.de) +/// +/// Licensed under the Apache License, Version 2.0 (the "License"); +/// you may not use this file except in compliance with the License. +/// You may obtain a copy of the License at +/// +/// http://www.apache.org/licenses/LICENSE-2.0 +/// +/// Unless required by applicable law or agreed to in writing, software +/// distributed under the License is distributed on an "AS IS" BASIS, +/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +/// See the License for the specific language governing permissions and +/// limitations under the License. +/// + +export interface UrlConfigObject { + locale: string; + url: string; +} diff --git a/src/main/js/bundles/dn_imprintprivacy/nls/de/bundle.js b/src/main/js/bundles/dn_imprintprivacy/build.config.js similarity index 70% rename from src/main/js/bundles/dn_imprintprivacy/nls/de/bundle.js rename to src/main/js/bundles/dn_imprintprivacy/build.config.js index f180b5c..5ac344b 100644 --- a/src/main/js/bundles/dn_imprintprivacy/nls/de/bundle.js +++ b/src/main/js/bundles/dn_imprintprivacy/build.config.js @@ -14,10 +14,9 @@ * limitations under the License. */ module.exports = { - bundleName: "Imprint Privacy", - bundleDescription: "Dieses Bundle f\u00fcgt zwei Buttons zur App hinzu, die auf das Impressum und die Datenschutzerkl\u00e4rung verweisen.", - imprint: "Impressum", - privacyStatements: "Datenschutzerkl\u00e4rung" + // normally the type should be "bundle" + type: "bundle", + // list all files, which should stay after the build + // In this case only the "module.js" is the remaining artifact, all other files will be integrated into this file. + entryPoints: ["./module"] }; - - diff --git a/src/main/js/bundles/dn_imprintprivacy/main.js b/src/main/js/bundles/dn_imprintprivacy/main.js deleted file mode 100644 index a6aa592..0000000 --- a/src/main/js/bundles/dn_imprintprivacy/main.js +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (C) 2024 con terra GmbH (info@conterra.de) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import "dojo/i18n!./nls/bundle"; diff --git a/src/main/js/bundles/dn_imprintprivacy/manifest.json b/src/main/js/bundles/dn_imprintprivacy/manifest.json index ac82952..38f4e20 100644 --- a/src/main/js/bundles/dn_imprintprivacy/manifest.json +++ b/src/main/js/bundles/dn_imprintprivacy/manifest.json @@ -5,11 +5,14 @@ "description": "${bundleDescription}", "vendor": "con terra GmbH", "keywords": [ - "sample" + "imprint", + "privacy" ], - "icon": {}, - "license": {}, + "main": "", "productName": "devnet-mapapps-imprint-privacy", + "dependencies": { + "ct": "^4.10.0" + }, "CSS-Themes-Extension": [ { "name": "*", diff --git a/src/main/js/bundles/dn_imprintprivacy/module.js b/src/main/js/bundles/dn_imprintprivacy/module.js deleted file mode 100644 index cc1343a..0000000 --- a/src/main/js/bundles/dn_imprintprivacy/module.js +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (C) 2024 con terra GmbH (info@conterra.de) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import "."; -import "./ToolHandler"; diff --git a/src/main/js/bundles/dn_imprintprivacy/module.ts b/src/main/js/bundles/dn_imprintprivacy/module.ts new file mode 100644 index 0000000..697226b --- /dev/null +++ b/src/main/js/bundles/dn_imprintprivacy/module.ts @@ -0,0 +1,17 @@ +/// +/// Copyright (C) 2024 con terra GmbH (info@conterra.de) +/// +/// Licensed under the Apache License, Version 2.0 (the "License"); +/// you may not use this file except in compliance with the License. +/// You may obtain a copy of the License at +/// +/// http://www.apache.org/licenses/LICENSE-2.0 +/// +/// Unless required by applicable law or agreed to in writing, software +/// distributed under the License is distributed on an "AS IS" BASIS, +/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +/// See the License for the specific language governing permissions and +/// limitations under the License. +/// + +export { ToolHandler } from "./ToolHandler"; diff --git a/src/main/js/bundles/dn_imprintprivacy/nls/bundle.js b/src/main/js/bundles/dn_imprintprivacy/nls/bundle.js deleted file mode 100644 index 660ba3d..0000000 --- a/src/main/js/bundles/dn_imprintprivacy/nls/bundle.js +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) 2024 con terra GmbH (info@conterra.de) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -module.exports = { - root: { - bundleName: "Imprint Privacy", - bundleDescription: "This bundle adds two buttons to the app, which refer to the imprint and the privacy statements.", - imprint: "Imprint", - privacyStatements: "Privacy Statements" - }, - de: true -}; - diff --git a/src/main/js/bundles/dn_imprintprivacy/nls/bundle.ts b/src/main/js/bundles/dn_imprintprivacy/nls/bundle.ts new file mode 100644 index 0000000..b2bfca6 --- /dev/null +++ b/src/main/js/bundles/dn_imprintprivacy/nls/bundle.ts @@ -0,0 +1,28 @@ +/// +/// Copyright (C) 2024 con terra GmbH (info@conterra.de) +/// +/// Licensed under the Apache License, Version 2.0 (the "License"); +/// you may not use this file except in compliance with the License. +/// You may obtain a copy of the License at +/// +/// http://www.apache.org/licenses/LICENSE-2.0 +/// +/// Unless required by applicable law or agreed to in writing, software +/// distributed under the License is distributed on an "AS IS" BASIS, +/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +/// See the License for the specific language governing permissions and +/// limitations under the License. +/// + +const i18n = { + root: { + bundleName: "Imprint Privacy", + bundleDescription: "This bundle adds two buttons to the app, which refer to the imprint and the privacy statements.", + imprint: "Imprint", + privacyStatements: "Privacy Statements" + }, + "de": true +}; + +export type Messages = (typeof i18n)["root"]; +export default i18n; diff --git a/src/main/js/bundles/dn_imprintprivacy/nls/de/bundle.ts b/src/main/js/bundles/dn_imprintprivacy/nls/de/bundle.ts new file mode 100644 index 0000000..d3fe4a5 --- /dev/null +++ b/src/main/js/bundles/dn_imprintprivacy/nls/de/bundle.ts @@ -0,0 +1,26 @@ +/// +/// Copyright (C) 2024 con terra GmbH (info@conterra.de) +/// +/// Licensed under the Apache License, Version 2.0 (the "License"); +/// you may not use this file except in compliance with the License. +/// You may obtain a copy of the License at +/// +/// http://www.apache.org/licenses/LICENSE-2.0 +/// +/// Unless required by applicable law or agreed to in writing, software +/// distributed under the License is distributed on an "AS IS" BASIS, +/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +/// See the License for the specific language governing permissions and +/// limitations under the License. +/// + +import { type Messages } from "../bundle"; + +const i18n = { + bundleName: "Imprint Privacy", + bundleDescription: "Dieses Bundle f\u00fcgt zwei Buttons zur App hinzu, die auf das Impressum und die Datenschutzerkl\u00e4rung verweisen.", + imprint: "Impressum", + privacyStatements: "Datenschutzerkl\u00e4rung" +} satisfies Messages; + +export default i18n; diff --git a/src/main/js/bundles/dn_imprintprivacy/tests/all.js b/src/main/js/bundles/dn_imprintprivacy/tests/all.js deleted file mode 100644 index 3e84a4d..0000000 --- a/src/main/js/bundles/dn_imprintprivacy/tests/all.js +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (C) 2024 con terra GmbH (info@conterra.de) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ diff --git a/src/main/js/bundles/dn_imprintprivacy/tests/all.ts b/src/main/js/bundles/dn_imprintprivacy/tests/all.ts new file mode 100644 index 0000000..b52a2b0 --- /dev/null +++ b/src/main/js/bundles/dn_imprintprivacy/tests/all.ts @@ -0,0 +1,17 @@ +/// +/// Copyright (C) 2024 con terra GmbH (info@conterra.de) +/// +/// Licensed under the Apache License, Version 2.0 (the "License"); +/// you may not use this file except in compliance with the License. +/// You may obtain a copy of the License at +/// +/// http://www.apache.org/licenses/LICENSE-2.0 +/// +/// Unless required by applicable law or agreed to in writing, software +/// distributed under the License is distributed on an "AS IS" BASIS, +/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +/// See the License for the specific language governing permissions and +/// limitations under the License. +/// + +///