diff --git a/modules/ui-module/src/main/resources/manager/actions/media/edit-focal-point.d.ts b/modules/ui-module/src/main/resources/manager/actions/media/edit-focal-point.d.ts index 6dc2ed246..85620d3ab 100644 --- a/modules/ui-module/src/main/resources/manager/actions/media/edit-focal-point.d.ts +++ b/modules/ui-module/src/main/resources/manager/actions/media/edit-focal-point.d.ts @@ -1,21 +1 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export declare function runAction(params: any): Promise; diff --git a/modules/ui-module/src/main/resources/manager/actions/media/edit-media-form.d.ts b/modules/ui-module/src/main/resources/manager/actions/media/edit-media-form.d.ts index 1dc39e464..6abc321a1 100644 --- a/modules/ui-module/src/main/resources/manager/actions/media/edit-media-form.d.ts +++ b/modules/ui-module/src/main/resources/manager/actions/media/edit-media-form.d.ts @@ -1,21 +1 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export function runAction(params: any): Promise; diff --git a/modules/ui-module/src/main/resources/manager/actions/media/select-content-media.d.ts b/modules/ui-module/src/main/resources/manager/actions/media/select-content-media.d.ts index 6dc2ed246..85620d3ab 100644 --- a/modules/ui-module/src/main/resources/manager/actions/media/select-content-media.d.ts +++ b/modules/ui-module/src/main/resources/manager/actions/media/select-content-media.d.ts @@ -1,21 +1 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export declare function runAction(params: any): Promise; diff --git a/modules/ui-module/src/main/resources/manager/actions/media/select-content-media.js b/modules/ui-module/src/main/resources/manager/actions/media/select-content-media.js index 02e50d2f3..e620fd10c 100644 --- a/modules/ui-module/src/main/resources/manager/actions/media/select-content-media.js +++ b/modules/ui-module/src/main/resources/manager/actions/media/select-content-media.js @@ -18,7 +18,7 @@ * along with this program. If not, see . * #L% */ -import { openFileBrowser } from "@cms/modules/filebrowser.js"; +import { openMediaBrowser } from "@cms/modules/media/mediabrowser.js"; import { i18n } from "@cms/modules/localization.js"; import { getPreviewUrl, reloadPreview } from "@cms/modules/preview.utils.js"; import { getContentNode, replaceContent } from "@cms/modules/rpc/rpc-content.js"; @@ -34,7 +34,7 @@ export async function runAction(params) { }); uri = contentNode.result.uri; } - openFileBrowser({ + openMediaBrowser({ type: "assets", filter: (file) => { return file.media || file.directory; diff --git a/modules/ui-module/src/main/resources/manager/actions/media/select-media.d.ts b/modules/ui-module/src/main/resources/manager/actions/media/select-media.d.ts index 6dc2ed246..85620d3ab 100644 --- a/modules/ui-module/src/main/resources/manager/actions/media/select-media.d.ts +++ b/modules/ui-module/src/main/resources/manager/actions/media/select-media.d.ts @@ -1,21 +1 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export declare function runAction(params: any): Promise; diff --git a/modules/ui-module/src/main/resources/manager/actions/media/select-media.js b/modules/ui-module/src/main/resources/manager/actions/media/select-media.js index e0753be54..c6fce5a50 100644 --- a/modules/ui-module/src/main/resources/manager/actions/media/select-media.js +++ b/modules/ui-module/src/main/resources/manager/actions/media/select-media.js @@ -18,7 +18,7 @@ * along with this program. If not, see . * #L% */ -import { openFileBrowser } from "@cms/modules/filebrowser.js"; +import { openMediaBrowser } from "@cms/modules/media/mediabrowser.js"; import { i18n } from "@cms/modules/localization.js"; import { getPreviewUrl, reloadPreview } from "@cms/modules/preview.utils.js"; import { getContentNode, setMeta } from "@cms/modules/rpc/rpc-content.js"; @@ -34,7 +34,7 @@ export async function runAction(params) { }); uri = contentNode.result.uri; } - openFileBrowser({ + openMediaBrowser({ type: "assets", filter: (file) => { return file.media || file.directory; diff --git a/modules/ui-module/src/main/resources/manager/actions/page/add-section.d.ts b/modules/ui-module/src/main/resources/manager/actions/page/add-section.d.ts index 1dc39e464..6abc321a1 100644 --- a/modules/ui-module/src/main/resources/manager/actions/page/add-section.d.ts +++ b/modules/ui-module/src/main/resources/manager/actions/page/add-section.d.ts @@ -1,21 +1 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export function runAction(params: any): Promise; diff --git a/modules/ui-module/src/main/resources/manager/actions/page/create-node.d.ts b/modules/ui-module/src/main/resources/manager/actions/page/create-node.d.ts index 1dc39e464..6abc321a1 100644 --- a/modules/ui-module/src/main/resources/manager/actions/page/create-node.d.ts +++ b/modules/ui-module/src/main/resources/manager/actions/page/create-node.d.ts @@ -1,21 +1 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export function runAction(params: any): Promise; diff --git a/modules/ui-module/src/main/resources/manager/actions/page/create-page.d.ts b/modules/ui-module/src/main/resources/manager/actions/page/create-page.d.ts index 1dc39e464..6abc321a1 100644 --- a/modules/ui-module/src/main/resources/manager/actions/page/create-page.d.ts +++ b/modules/ui-module/src/main/resources/manager/actions/page/create-page.d.ts @@ -1,21 +1 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export function runAction(params: any): Promise; diff --git a/modules/ui-module/src/main/resources/manager/actions/page/delete-section.d.ts b/modules/ui-module/src/main/resources/manager/actions/page/delete-section.d.ts index 1dc39e464..6abc321a1 100644 --- a/modules/ui-module/src/main/resources/manager/actions/page/delete-section.d.ts +++ b/modules/ui-module/src/main/resources/manager/actions/page/delete-section.d.ts @@ -1,21 +1 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export function runAction(params: any): Promise; diff --git a/modules/ui-module/src/main/resources/manager/actions/page/edit-content.d.ts b/modules/ui-module/src/main/resources/manager/actions/page/edit-content.d.ts index 1dc39e464..6abc321a1 100644 --- a/modules/ui-module/src/main/resources/manager/actions/page/edit-content.d.ts +++ b/modules/ui-module/src/main/resources/manager/actions/page/edit-content.d.ts @@ -1,21 +1 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export function runAction(params: any): Promise; diff --git a/modules/ui-module/src/main/resources/manager/actions/page/edit-metaattribute-form.d.ts b/modules/ui-module/src/main/resources/manager/actions/page/edit-metaattribute-form.d.ts index 1dc39e464..6abc321a1 100644 --- a/modules/ui-module/src/main/resources/manager/actions/page/edit-metaattribute-form.d.ts +++ b/modules/ui-module/src/main/resources/manager/actions/page/edit-metaattribute-form.d.ts @@ -1,21 +1 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export function runAction(params: any): Promise; diff --git a/modules/ui-module/src/main/resources/manager/actions/page/edit-metaattribute-list.d.ts b/modules/ui-module/src/main/resources/manager/actions/page/edit-metaattribute-list.d.ts index 1dc39e464..6abc321a1 100644 --- a/modules/ui-module/src/main/resources/manager/actions/page/edit-metaattribute-list.d.ts +++ b/modules/ui-module/src/main/resources/manager/actions/page/edit-metaattribute-list.d.ts @@ -1,21 +1 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export function runAction(params: any): Promise; diff --git a/modules/ui-module/src/main/resources/manager/actions/page/edit-metaattribute.d.ts b/modules/ui-module/src/main/resources/manager/actions/page/edit-metaattribute.d.ts index 1dc39e464..6abc321a1 100644 --- a/modules/ui-module/src/main/resources/manager/actions/page/edit-metaattribute.d.ts +++ b/modules/ui-module/src/main/resources/manager/actions/page/edit-metaattribute.d.ts @@ -1,21 +1 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export function runAction(params: any): Promise; diff --git a/modules/ui-module/src/main/resources/manager/actions/page/edit-page-settings.d.ts b/modules/ui-module/src/main/resources/manager/actions/page/edit-page-settings.d.ts index 1dc39e464..6abc321a1 100644 --- a/modules/ui-module/src/main/resources/manager/actions/page/edit-page-settings.d.ts +++ b/modules/ui-module/src/main/resources/manager/actions/page/edit-page-settings.d.ts @@ -1,21 +1 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export function runAction(params: any): Promise; diff --git a/modules/ui-module/src/main/resources/manager/actions/page/edit-sections.d.ts b/modules/ui-module/src/main/resources/manager/actions/page/edit-sections.d.ts index 1dc39e464..6abc321a1 100644 --- a/modules/ui-module/src/main/resources/manager/actions/page/edit-sections.d.ts +++ b/modules/ui-module/src/main/resources/manager/actions/page/edit-sections.d.ts @@ -1,21 +1 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export function runAction(params: any): Promise; diff --git a/modules/ui-module/src/main/resources/manager/actions/page/list-unpublished-pages.d.ts b/modules/ui-module/src/main/resources/manager/actions/page/list-unpublished-pages.d.ts index 44d1f6c2a..8052ef2c6 100644 --- a/modules/ui-module/src/main/resources/manager/actions/page/list-unpublished-pages.d.ts +++ b/modules/ui-module/src/main/resources/manager/actions/page/list-unpublished-pages.d.ts @@ -1,23 +1,3 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ interface ListUnpublishedPagesOptions { page?: number; } diff --git a/modules/ui-module/src/main/resources/manager/actions/page/manage-assets.d.ts b/modules/ui-module/src/main/resources/manager/actions/page/manage-assets.d.ts index 1dc39e464..6abc321a1 100644 --- a/modules/ui-module/src/main/resources/manager/actions/page/manage-assets.d.ts +++ b/modules/ui-module/src/main/resources/manager/actions/page/manage-assets.d.ts @@ -1,21 +1 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export function runAction(params: any): Promise; diff --git a/modules/ui-module/src/main/resources/manager/actions/page/manage-assets.js b/modules/ui-module/src/main/resources/manager/actions/page/manage-assets.js index e9d22d620..97d85305f 100644 --- a/modules/ui-module/src/main/resources/manager/actions/page/manage-assets.js +++ b/modules/ui-module/src/main/resources/manager/actions/page/manage-assets.js @@ -18,10 +18,13 @@ * along with this program. If not, see . * #L% */ -import { openFileBrowser } from '@cms/modules/filebrowser.js'; +import { openMediaBrowser } from '@cms/modules/media/mediabrowser.js'; // hook.js export async function runAction(params) { - openFileBrowser({ - type: "assets" + openMediaBrowser({ + type: "assets", + filter: (file) => { + return file.media || file.directory; + }, }); } diff --git a/modules/ui-module/src/main/resources/manager/actions/page/section-set-published.d.ts b/modules/ui-module/src/main/resources/manager/actions/page/section-set-published.d.ts index 6dc2ed246..85620d3ab 100644 --- a/modules/ui-module/src/main/resources/manager/actions/page/section-set-published.d.ts +++ b/modules/ui-module/src/main/resources/manager/actions/page/section-set-published.d.ts @@ -1,21 +1 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export declare function runAction(params: any): Promise; diff --git a/modules/ui-module/src/main/resources/manager/actions/page/translations.d.ts b/modules/ui-module/src/main/resources/manager/actions/page/translations.d.ts index 6dc2ed246..85620d3ab 100644 --- a/modules/ui-module/src/main/resources/manager/actions/page/translations.d.ts +++ b/modules/ui-module/src/main/resources/manager/actions/page/translations.d.ts @@ -1,21 +1 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export declare function runAction(params: any): Promise; diff --git a/modules/ui-module/src/main/resources/manager/actions/reload-preview.d.ts b/modules/ui-module/src/main/resources/manager/actions/reload-preview.d.ts index 6dc2ed246..85620d3ab 100644 --- a/modules/ui-module/src/main/resources/manager/actions/reload-preview.d.ts +++ b/modules/ui-module/src/main/resources/manager/actions/reload-preview.d.ts @@ -1,21 +1 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export declare function runAction(params: any): Promise; diff --git a/modules/ui-module/src/main/resources/manager/actions/site-change.d.ts b/modules/ui-module/src/main/resources/manager/actions/site-change.d.ts index 672d1f3de..ba8a4fff2 100644 --- a/modules/ui-module/src/main/resources/manager/actions/site-change.d.ts +++ b/modules/ui-module/src/main/resources/manager/actions/site-change.d.ts @@ -1,21 +1 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export function runAction(parameters: any): Promise; diff --git a/modules/ui-module/src/main/resources/manager/actions/test-command.d.ts b/modules/ui-module/src/main/resources/manager/actions/test-command.d.ts index 1dc39e464..6abc321a1 100644 --- a/modules/ui-module/src/main/resources/manager/actions/test-command.d.ts +++ b/modules/ui-module/src/main/resources/manager/actions/test-command.d.ts @@ -1,21 +1 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export function runAction(params: any): Promise; diff --git a/modules/ui-module/src/main/resources/manager/css/manager.css b/modules/ui-module/src/main/resources/manager/css/manager.css index 8f40dc4da..a18a3b699 100644 --- a/modules/ui-module/src/main/resources/manager/css/manager.css +++ b/modules/ui-module/src/main/resources/manager/css/manager.css @@ -23,10 +23,6 @@ i[data-cms-section-handle] { cursor: pointer; } -tr[data-cms-file-directory] { - cursor: pointer; -} - #drop-zone { width: 100%; padding: 50px; @@ -45,38 +41,71 @@ tr[data-cms-file-directory] { } /* ========================================================= - IMAGE HOVER + MEDIA BROWSER GRID ========================================================= */ -.cms-image-hover-wrapper { - position: relative; +.cms-media-grid { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); + gap: 12px; + padding: 4px 0; } -.cms-small-image { - width: 50px; - height: auto; +.cms-media-card { + border: 1px solid var(--bs-border-color, #dee2e6); + border-radius: 6px; + overflow: hidden; cursor: pointer; + transition: box-shadow 0.15s ease, border-color 0.15s ease; + background: var(--bs-body-bg, #fff); } -.cms-overlay-image { - display: none; - position: absolute; - top: -10px; - left: 110%; - z-index: 1000; - background-color: white; - padding: 5px; - border: 1px solid #ccc; - box-shadow: 0 0 10px rgba(0, 0, 0, 0.3); +.cms-media-card:hover { + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15); +} + +.cms-media-card.selected { + border-color: var(--bs-primary, #0d6efd); + box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.25); } -.cms-image-hover-wrapper:hover .cms-overlay-image { +.cms-media-card__preview { + height: 140px; + display: flex; + align-items: center; + justify-content: center; + background: var(--bs-secondary-bg, #f8f9fa); + overflow: hidden; +} + +.cms-media-card__preview img { + width: 100%; + height: 100%; + object-fit: cover; display: block; } -.cms-enlarged-image { - width: 300px; - height: auto; +.cms-media-card__preview .cms-media-icon { + font-size: 3rem; + color: var(--bs-secondary, #6c757d); +} + +.cms-media-card__footer { + display: flex; + align-items: center; + justify-content: space-between; + padding: 6px 8px; + gap: 4px; + border-top: 1px solid var(--bs-border-color, #dee2e6); +} + +.cms-media-card__name { + font-size: 0.8rem; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + flex: 1; + min-width: 0; } /* ========================================================= diff --git a/modules/ui-module/src/main/resources/manager/js/manager-globals.d.ts b/modules/ui-module/src/main/resources/manager/js/manager-globals.d.ts index 7818ef73c..255f59f32 100644 --- a/modules/ui-module/src/main/resources/manager/js/manager-globals.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/manager-globals.d.ts @@ -1,23 +1,3 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export function executeScriptAction(action: any): Promise; export function executeHookAction(action: any): Promise; /** diff --git a/modules/ui-module/src/main/resources/manager/js/manager-inject-init.d.ts b/modules/ui-module/src/main/resources/manager/js/manager-inject-init.d.ts index 5f66dedac..de2be067b 100644 --- a/modules/ui-module/src/main/resources/manager/js/manager-inject-init.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/manager-inject-init.d.ts @@ -1,22 +1,2 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export function initIframe(): void; export function isSectionPublishedExpired(section: any): boolean; diff --git a/modules/ui-module/src/main/resources/manager/js/manager-inject.d.ts b/modules/ui-module/src/main/resources/manager/js/manager-inject.d.ts index 802d6a315..e69de29bb 100644 --- a/modules/ui-module/src/main/resources/manager/js/manager-inject.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/manager-inject.d.ts @@ -1,20 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ diff --git a/modules/ui-module/src/main/resources/manager/js/manager.d.ts b/modules/ui-module/src/main/resources/manager/js/manager.d.ts index 4562057ed..cb0ff5c3b 100644 --- a/modules/ui-module/src/main/resources/manager/js/manager.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/manager.d.ts @@ -1,21 +1 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export {}; diff --git a/modules/ui-module/src/main/resources/manager/js/modules/alerts.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/alerts.d.ts index c25caa88d..629a61d8f 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/alerts.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/alerts.d.ts @@ -1,23 +1,3 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export function alertSelect(options: any): Promise; export function alertError(options: any): void; export function alertConfirm(options: any): Promise; diff --git a/modules/ui-module/src/main/resources/manager/js/modules/event-bus.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/event-bus.d.ts index 462f38dae..d44295919 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/event-bus.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/event-bus.d.ts @@ -1,23 +1,3 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export namespace EventBus { function on(event: any, handler: any): void; function emit(event: any, payload: any): void; diff --git a/modules/ui-module/src/main/resources/manager/js/modules/filebrowser.actions.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/filebrowser.actions.d.ts index f8d509a6b..7dc80374c 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/filebrowser.actions.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/filebrowser.actions.d.ts @@ -1,23 +1,3 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export function renameFileAction({ state, getTargetFolder, filename }: { state: any; getTargetFolder: any; diff --git a/modules/ui-module/src/main/resources/manager/js/modules/filebrowser.create.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/filebrowser.create.d.ts index db898301c..fb627bf7e 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/filebrowser.create.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/filebrowser.create.d.ts @@ -1,21 +1 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export function openCreateContentBrowser(params: any): Promise; diff --git a/modules/ui-module/src/main/resources/manager/js/modules/filebrowser.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/filebrowser.d.ts index 0869c773e..e10842a8d 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/filebrowser.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/filebrowser.d.ts @@ -1,23 +1,3 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export function openFileBrowser(optionsParam: any): Promise; export namespace state { let options: null; diff --git a/modules/ui-module/src/main/resources/manager/js/modules/filebrowser.template.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/filebrowser.template.d.ts index e21fdb20e..72c47da10 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/filebrowser.template.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/filebrowser.template.d.ts @@ -1,22 +1,2 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export { template as filebrowserTemplate }; declare const template: any; diff --git a/modules/ui-module/src/main/resources/manager/js/modules/filebrowser.upload.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/filebrowser.upload.d.ts index 954f1b3fc..5b1bd46d8 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/filebrowser.upload.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/filebrowser.upload.d.ts @@ -1,22 +1,2 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export function initDragAndDropUpload(): void; export function handleFileUpload(): Promise; diff --git a/modules/ui-module/src/main/resources/manager/js/modules/form/field.checkbox.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/form/field.checkbox.d.ts index a930d60c6..d2a0c9280 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/form/field.checkbox.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/form/field.checkbox.d.ts @@ -1,23 +1,3 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ import { FieldOptions, FormField } from "@cms/modules/form/forms.js"; export interface CheckboxOptions extends FieldOptions { key?: string; diff --git a/modules/ui-module/src/main/resources/manager/js/modules/form/field.checkbox.js b/modules/ui-module/src/main/resources/manager/js/modules/form/field.checkbox.js index 6bbe7a57b..3efa4721d 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/form/field.checkbox.js +++ b/modules/ui-module/src/main/resources/manager/js/modules/form/field.checkbox.js @@ -1,23 +1,3 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ import { createID } from "@cms/modules/form/utils.js"; const createCheckboxField = (options, value = []) => { const id = createID(); diff --git a/modules/ui-module/src/main/resources/manager/js/modules/form/field.code.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/form/field.code.d.ts index 4118facce..ada1f20f1 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/form/field.code.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/form/field.code.d.ts @@ -1,23 +1,3 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export namespace CodeField { export { createCodeField as markup }; export { init }; diff --git a/modules/ui-module/src/main/resources/manager/js/modules/form/field.color.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/form/field.color.d.ts index 0225e9768..cab0d2e87 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/form/field.color.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/form/field.color.d.ts @@ -1,23 +1,3 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ import { FieldOptions, FormField } from "@cms/modules/form/forms.js"; export interface ColorFieldOptions extends FieldOptions { } diff --git a/modules/ui-module/src/main/resources/manager/js/modules/form/field.date.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/form/field.date.d.ts index e45cc358c..f07e3cc6e 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/form/field.date.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/form/field.date.d.ts @@ -1,23 +1,3 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ import { FieldOptions, FormField } from "@cms/modules/form/forms.js"; export interface DateFieldOptions extends FieldOptions { placeholder?: string; diff --git a/modules/ui-module/src/main/resources/manager/js/modules/form/field.datetime.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/form/field.datetime.d.ts index 13130d6a8..272202696 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/form/field.datetime.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/form/field.datetime.d.ts @@ -1,23 +1,3 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ import { FieldOptions, FormField } from "@cms/modules/form/forms.js"; export interface DateTimeFieldOptions extends FieldOptions { placeholder?: string; diff --git a/modules/ui-module/src/main/resources/manager/js/modules/form/field.divider.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/form/field.divider.d.ts index d52208432..f57944c90 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/form/field.divider.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/form/field.divider.d.ts @@ -1,23 +1,3 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ import { FieldOptions, FormField } from "@cms/modules/form/forms.js"; export interface DividerOptions extends FieldOptions { } diff --git a/modules/ui-module/src/main/resources/manager/js/modules/form/field.easymde.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/form/field.easymde.d.ts index 8b94a8e15..9ac807575 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/form/field.easymde.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/form/field.easymde.d.ts @@ -1,23 +1,3 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ import { FieldOptions, FormField } from "@cms/modules/form/forms.js"; export interface EasyMDEFieldOptions extends FieldOptions { } diff --git a/modules/ui-module/src/main/resources/manager/js/modules/form/field.list.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/form/field.list.d.ts index eac48f3db..7bfcc69a9 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/form/field.list.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/form/field.list.d.ts @@ -1,23 +1,3 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ import { FieldOptions, FormField } from "@cms/modules/form/forms.js"; export interface ListFieldOptions extends FieldOptions { options: { diff --git a/modules/ui-module/src/main/resources/manager/js/modules/form/field.mail.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/form/field.mail.d.ts index df6a6ab49..36f178178 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/form/field.mail.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/form/field.mail.d.ts @@ -1,23 +1,3 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ import { FieldOptions, FormField } from "@cms/modules/form/forms.js"; export interface MailFieldOptions extends FieldOptions { placeholder?: string; diff --git a/modules/ui-module/src/main/resources/manager/js/modules/form/field.markdown.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/form/field.markdown.d.ts index 21c39aafe..32fc0b8bf 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/form/field.markdown.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/form/field.markdown.d.ts @@ -1,23 +1,3 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ import { FieldOptions, FormField } from "@cms/modules/form/forms.js"; declare global { interface HTMLInputElement { diff --git a/modules/ui-module/src/main/resources/manager/js/modules/form/field.markdown.js b/modules/ui-module/src/main/resources/manager/js/modules/form/field.markdown.js index 776ad5319..fefb6ef37 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/form/field.markdown.js +++ b/modules/ui-module/src/main/resources/manager/js/modules/form/field.markdown.js @@ -21,7 +21,7 @@ import { createID } from "@cms/modules/form/utils.js"; import { i18n } from "@cms/modules/localization.js"; import { getMediaFormats, getShortCodeNames } from "@cms/modules/rpc/rpc-manager.js"; -import { openFileBrowser } from "@cms/modules/filebrowser.js"; +import { openMediaBrowser } from "@cms/modules/media/mediabrowser.js"; import { alertSelect } from "@cms/modules/alerts.js"; import { patchPathWithContext } from "@cms/js/manager-globals"; const createMarkdownField = (options, value = '') => { @@ -144,7 +144,7 @@ const cmsImageSelection = window.Cherry.createMenuHook("Image", { iconName: "image", title: "Image", onClick: (selection, name, event) => { - openFileBrowser({ + openMediaBrowser({ type: "assets", fullscreen: false, filter: (file) => { diff --git a/modules/ui-module/src/main/resources/manager/js/modules/form/field.media.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/form/field.media.d.ts index 1350f89f2..b359b73f0 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/form/field.media.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/form/field.media.d.ts @@ -1,23 +1,3 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ import { FieldOptions, FormField } from "@cms/modules/form/forms.js"; export interface MediaFieldOptions extends FieldOptions { } diff --git a/modules/ui-module/src/main/resources/manager/js/modules/form/field.media.js b/modules/ui-module/src/main/resources/manager/js/modules/form/field.media.js index 653d4ab9e..112609c54 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/form/field.media.js +++ b/modules/ui-module/src/main/resources/manager/js/modules/form/field.media.js @@ -21,7 +21,7 @@ import { createID } from "@cms/modules/form/utils.js"; import { i18n } from "@cms/modules/localization.js"; import { uploadFileWithProgress } from "@cms/modules/upload.js"; -import { openFileBrowser } from "@cms/modules/filebrowser.js"; +import { openMediaBrowser } from "@cms/modules/media/mediabrowser.js"; import { patchPathWithContext } from "@cms/js/manager-globals"; const createMediaField = (options, value = '') => { const id = createID(); @@ -123,7 +123,7 @@ const init = (context) => { // Handle MediaManager button robust: remove old handler, use onclick openMediaManager.onclick = null; openMediaManager.onclick = () => { - openFileBrowser({ + openMediaBrowser({ type: "assets", filter: (file) => { return file.media || file.directory; diff --git a/modules/ui-module/src/main/resources/manager/js/modules/form/field.number.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/form/field.number.d.ts index 50b700cb0..c034ebbc7 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/form/field.number.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/form/field.number.d.ts @@ -1,23 +1,3 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ import { FieldOptions, FormField } from "@cms/modules/form/forms.js"; export interface NumberFieldOptions extends FieldOptions { options: { diff --git a/modules/ui-module/src/main/resources/manager/js/modules/form/field.radio.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/form/field.radio.d.ts index 344bb4fda..a238a4826 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/form/field.radio.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/form/field.radio.d.ts @@ -1,23 +1,3 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ import { FieldOptions, FormField } from "@cms/modules/form/forms.js"; export interface RadioFieldOptions extends FieldOptions { options?: { diff --git a/modules/ui-module/src/main/resources/manager/js/modules/form/field.range.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/form/field.range.d.ts index e57f403cf..47e6c847c 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/form/field.range.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/form/field.range.d.ts @@ -1,23 +1,3 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ import { FieldOptions, FormField } from "@cms/modules/form/forms.js"; export interface RangeFieldOptions extends FieldOptions { options?: { diff --git a/modules/ui-module/src/main/resources/manager/js/modules/form/field.reference.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/form/field.reference.d.ts index fc0de6ab4..7f1b0b8c4 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/form/field.reference.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/form/field.reference.d.ts @@ -1,23 +1,3 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ import { FieldOptions, FormField } from "@cms/modules/form/forms.js"; export interface ReferenceFieldOptions extends FieldOptions { options?: { diff --git a/modules/ui-module/src/main/resources/manager/js/modules/form/field.select.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/form/field.select.d.ts index 5ae22bd43..c781deccb 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/form/field.select.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/form/field.select.d.ts @@ -1,23 +1,3 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ import { FieldOptions, FormField } from "@cms/modules/form/forms.js"; export interface SelectFieldOptions extends FieldOptions { options?: { diff --git a/modules/ui-module/src/main/resources/manager/js/modules/form/field.text.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/form/field.text.d.ts index 7a72faae8..b406c7cf8 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/form/field.text.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/form/field.text.d.ts @@ -1,23 +1,3 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ import { FieldOptions, FormField } from "@cms/modules/form/forms.js"; export interface TextFieldOptions extends FieldOptions { placeholder?: string; diff --git a/modules/ui-module/src/main/resources/manager/js/modules/form/field.textarea.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/form/field.textarea.d.ts index 4b4659e7b..f83d21361 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/form/field.textarea.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/form/field.textarea.d.ts @@ -1,23 +1,3 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ import { FieldOptions, FormField } from "@cms/modules/form/forms.js"; export interface TextAreaFieldOptions extends FieldOptions { rows?: number; diff --git a/modules/ui-module/src/main/resources/manager/js/modules/form/forms.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/form/forms.d.ts index a162fe5d9..a20eefd41 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/form/forms.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/form/forms.d.ts @@ -1,23 +1,3 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ declare const createForm: (options: any) => Form; export { createForm }; export interface FormContext { diff --git a/modules/ui-module/src/main/resources/manager/js/modules/form/utils.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/form/utils.d.ts index 23eeb2258..525b147b7 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/form/utils.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/form/utils.d.ts @@ -1,23 +1,3 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ declare const createID: () => string; declare const utcToLocalDateTimeInputValue: (utcString: string) => string; declare function getUTCDateTimeFromInput(inputElement: HTMLInputElement): string | null; diff --git a/modules/ui-module/src/main/resources/manager/js/modules/frameMessenger.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/frameMessenger.d.ts index b50f99006..1d74a5193 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/frameMessenger.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/frameMessenger.d.ts @@ -1,23 +1,3 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ declare namespace _default { export { send }; export { on }; diff --git a/modules/ui-module/src/main/resources/manager/js/modules/locale-utils.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/locale-utils.d.ts index aca04a87b..98374290b 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/locale-utils.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/locale-utils.d.ts @@ -1,22 +1,2 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export function getLocale(): any; export function setLocale(locale: any): void; diff --git a/modules/ui-module/src/main/resources/manager/js/modules/localization-actions.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/localization-actions.d.ts index 6db9e8af0..43acad38a 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/localization-actions.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/localization-actions.d.ts @@ -1,23 +1,3 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export namespace ACTION_LOCALIZATIONS { let en: {}; let de: { diff --git a/modules/ui-module/src/main/resources/manager/js/modules/localization-loader.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/localization-loader.d.ts index 5cca57e0f..ea5b0a075 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/localization-loader.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/localization-loader.d.ts @@ -1,23 +1,3 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export function loadLocalizationsWithDefaults(): Promise<{ en: { "ui.filebrowser.filename": string; diff --git a/modules/ui-module/src/main/resources/manager/js/modules/localization-modules.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/localization-modules.d.ts index 1061b15e9..4a0c49e47 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/localization-modules.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/localization-modules.d.ts @@ -1,23 +1,3 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export namespace MODULE_LOCALIZATIONS { let en: {}; let de: { diff --git a/modules/ui-module/src/main/resources/manager/js/modules/localization.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/localization.d.ts index e91051759..9eeed5a15 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/localization.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/localization.d.ts @@ -1,23 +1,3 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export function localizeUi(): Promise; export namespace i18n { let _locale: any; diff --git a/modules/ui-module/src/main/resources/manager/js/modules/manager-ui.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/manager-ui.d.ts index 247c12e7c..d25e9cb32 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/manager-ui.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/manager-ui.d.ts @@ -1,21 +1 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export function updateStateButton(): void; diff --git a/modules/ui-module/src/main/resources/manager/js/modules/manager/manager.message.handlers.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/manager/manager.message.handlers.d.ts index 5b7c71b35..dd88b9fe0 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/manager/manager.message.handlers.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/manager/manager.message.handlers.d.ts @@ -1,22 +1,2 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ declare const initMessageHandlers: () => void; export { initMessageHandlers }; diff --git a/modules/ui-module/src/main/resources/manager/js/modules/manager/media.inject.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/manager/media.inject.d.ts index 067619660..ebd61d27b 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/manager/media.inject.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/manager/media.inject.d.ts @@ -1,23 +1,3 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export declare const initMediaUploadOverlay: (img: HTMLImageElement) => void; export declare const initContentMediaToolbar: (img: HTMLImageElement) => void; export declare const initMediaToolbar: (img: HTMLImageElement) => void; diff --git a/modules/ui-module/src/main/resources/manager/js/modules/manager/toolbar-icons.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/manager/toolbar-icons.d.ts index 92761a64f..37904af59 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/manager/toolbar-icons.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/manager/toolbar-icons.d.ts @@ -1,23 +1,3 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export declare const EDIT_PAGE_ICON = "\n\n \n \n"; export declare const EDIT_ATTRIBUTES_ICON = "\n\n \n\n"; export declare const SECTION_SORT_ICON = "\n\n \n \n\n"; diff --git a/modules/ui-module/src/main/resources/manager/js/modules/manager/toolbar.inject.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/manager/toolbar.inject.d.ts index 8a082a5df..6e3a61bf4 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/manager/toolbar.inject.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/manager/toolbar.inject.d.ts @@ -1,21 +1 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export declare const initToolbar: (container: HTMLElement) => void; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/filebrowser.actions.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/media/mediabrowser.actions.d.ts similarity index 100% rename from modules/ui-module/src/main/ts/dist/js/modules/filebrowser.actions.d.ts rename to modules/ui-module/src/main/resources/manager/js/modules/media/mediabrowser.actions.d.ts diff --git a/modules/ui-module/src/main/ts/dist/js/modules/filebrowser.actions.js b/modules/ui-module/src/main/resources/manager/js/modules/media/mediabrowser.actions.js similarity index 83% rename from modules/ui-module/src/main/ts/dist/js/modules/filebrowser.actions.js rename to modules/ui-module/src/main/resources/manager/js/modules/media/mediabrowser.actions.js index 63726ce39..78aa175c7 100644 --- a/modules/ui-module/src/main/ts/dist/js/modules/filebrowser.actions.js +++ b/modules/ui-module/src/main/resources/manager/js/modules/media/mediabrowser.actions.js @@ -21,9 +21,8 @@ import { createFolder, createFile, renameFile } from '@cms/modules/rpc/rpc-files.js'; import { createPage } from '@cms/modules/rpc/rpc-page.js'; import { i18n } from '@cms/modules/localization.js'; -import { alertSelect, alertConfirm, alertPrompt } from '@cms/modules/alerts.js'; +import { alertConfirm, alertPrompt } from '@cms/modules/alerts.js'; import { showToast } from '@cms/modules/toast.js'; -import { getPageTemplates } from '@cms/modules/rpc/rpc-manager.js'; export async function renameFileAction({ state, getTargetFolder, filename }) { const newName = await alertPrompt({ title: i18n.t("filebrowser.rename.title", "Rename file"), @@ -173,34 +172,32 @@ export async function createPageActionOfContentType({ state, getTargetFolder, co label: i18n.t("filebrowser.createPage.label", "Page name"), placeholder: i18n.t("filebrowser.createPage.placeholder", "New Page") }); - if (pageName) { - if (contentType) { - var extraOptions = {}; - if (state.options.siteId) { - extraOptions.siteId = state.options.siteId; - } - let response = await createPage({ - uri: getTargetFolder(), - name: pageName, - contentType: contentType, - ...extraOptions - }); - if (response.error) { - showToast({ - title: i18n.t("filebrowser.createPage.error.title", 'Error creating page'), - message: response.error.message, - type: 'error', // optional: info | success | warning | error - timeout: 3000 - }); - } - else { - showToast({ - title: i18n.t("filebrowser.createPage.success.title", 'Page created'), - message: i18n.t("filebrowser.createPage.success.message", 'Page successfuly created'), - type: 'success', // optional: info | success | warning | error - timeout: 3000 - }); - } - } + if (!pageName || !contentType) + return; + var extraOptions = {}; + if (state.options.siteId) { + extraOptions.siteId = state.options.siteId; + } + let response = await createPage({ + uri: getTargetFolder(), + name: pageName, + contentType: contentType, + ...extraOptions + }); + if (response.error) { + showToast({ + title: i18n.t("filebrowser.createPage.error.title", 'Error creating page'), + message: response.error.message, + type: 'error', + timeout: 3000 + }); + } + else { + showToast({ + title: i18n.t("filebrowser.createPage.success.title", 'Page created'), + message: i18n.t("filebrowser.createPage.success.message", 'Page successfuly created'), + type: 'success', + timeout: 3000 + }); } } diff --git a/modules/ui-module/src/main/ts/dist/js/modules/filebrowser.create.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/media/mediabrowser.create.d.ts similarity index 100% rename from modules/ui-module/src/main/ts/dist/js/modules/filebrowser.create.d.ts rename to modules/ui-module/src/main/resources/manager/js/modules/media/mediabrowser.create.d.ts diff --git a/modules/ui-module/src/main/ts/dist/js/modules/filebrowser.create.js b/modules/ui-module/src/main/resources/manager/js/modules/media/mediabrowser.create.js similarity index 96% rename from modules/ui-module/src/main/ts/dist/js/modules/filebrowser.create.js rename to modules/ui-module/src/main/resources/manager/js/modules/media/mediabrowser.create.js index b5b1681d0..d3c4bed49 100644 --- a/modules/ui-module/src/main/ts/dist/js/modules/filebrowser.create.js +++ b/modules/ui-module/src/main/resources/manager/js/modules/media/mediabrowser.create.js @@ -24,8 +24,8 @@ import { openModal } from '@cms/modules/modal.js'; import { i18n } from '@cms/modules/localization.js'; import { alertPrompt } from '@cms/modules/alerts.js'; import { showToast } from '@cms/modules/toast.js'; -import { filebrowserTemplate } from '@cms/modules/filebrowser.template.js'; -import { createFolderAction } from '@cms/modules/filebrowser.actions.js'; +import { mediabrowserTemplate } from '@cms/modules/media/mediabrowser.template.js'; +import { createFolderAction } from '@cms/modules/media/mediabrowser.actions.js'; const defaultOptions = { uri: "", template: null, @@ -109,7 +109,7 @@ const initBrowser = async (uri) => { const browserElement = document.getElementById("cms-create-content-browser"); if (!browserElement) return; - browserElement.innerHTML = filebrowserTemplate({ + browserElement.innerHTML = mediabrowserTemplate({ files: directories, filenameHeader: i18n.t("filebrowser.filename", "Filename"), actionHeader: i18n.t("filebrowser.action", "Action"), diff --git a/modules/ui-module/src/main/ts/dist/js/modules/filebrowser.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/media/mediabrowser.d.ts similarity index 54% rename from modules/ui-module/src/main/ts/dist/js/modules/filebrowser.d.ts rename to modules/ui-module/src/main/resources/manager/js/modules/media/mediabrowser.d.ts index e10842a8d..e1623869c 100644 --- a/modules/ui-module/src/main/ts/dist/js/modules/filebrowser.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/media/mediabrowser.d.ts @@ -1,4 +1,4 @@ -export function openFileBrowser(optionsParam: any): Promise; +export function openMediaBrowser(optionsParam: any): Promise; export namespace state { let options: null; let currentFolder: string; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/filebrowser.js b/modules/ui-module/src/main/resources/manager/js/modules/media/mediabrowser.js similarity index 80% rename from modules/ui-module/src/main/ts/dist/js/modules/filebrowser.js rename to modules/ui-module/src/main/resources/manager/js/modules/media/mediabrowser.js index 7ff72b83a..90f57c507 100644 --- a/modules/ui-module/src/main/ts/dist/js/modules/filebrowser.js +++ b/modules/ui-module/src/main/resources/manager/js/modules/media/mediabrowser.js @@ -23,10 +23,10 @@ import { deletePage } from '@cms/modules/rpc/rpc-page.js'; import { openModal } from '@cms/modules/modal.js'; import { loadPreview } from '@cms/modules/preview.utils.js'; import { i18n } from '@cms/modules/localization.js'; -import { renameFileAction, deleteElementAction, createFolderAction, createFileAction, createPageActionOfContentType } from '@cms/modules/filebrowser.actions.js'; -import { initDragAndDropUpload, handleFileUpload } from '@cms/modules/filebrowser.upload.js'; +import { renameFileAction, deleteElementAction, createFolderAction, createFileAction, createPageActionOfContentType } from '@cms/modules/media/mediabrowser.actions.js'; +import { initDragAndDropUpload, handleFileUpload } from '@cms/modules/media/mediabrowser.upload.js'; import { EventBus } from '@cms/modules/event-bus.js'; -import { filebrowserTemplate } from '@cms/modules/filebrowser.template.js'; +import { mediabrowserTemplate } from '@cms/modules/media/mediabrowser.template.js'; import { getPageTemplates } from '@cms/modules/rpc/rpc-manager.js'; import { showToast } from '@cms/modules/toast.js'; const defaultOptions = { @@ -34,7 +34,7 @@ const defaultOptions = { uri: "", onSelect: null, fullscreen: true, - title: i18n.t("filebrowser.title", "Filesystem"), + title: i18n.t("mediabrowser.title", "Media Browser"), filter: (file) => { return true; // Default filter allows all files } @@ -43,10 +43,11 @@ const state = { options: null, currentFolder: "" }; +let cachedPageTemplates = null; EventBus.on("upload:success", (folder) => { - initFileBrowser(state.currentFolder); + initMediaBrowser(state.currentFolder); }); -const openFileBrowser = async (optionsParam) => { +const openMediaBrowser = async (optionsParam) => { state.options = { ...defaultOptions, ...optionsParam @@ -56,7 +57,7 @@ const openFileBrowser = async (optionsParam) => { body: '
', fullscreen: state.options.fullscreen, onOk: async (event) => { - const selectedRow = document.querySelector("tr.table-active[data-cms-file-uri]:not([data-cms-file-directory])"); + const selectedRow = document.querySelector(".cms-media-card.selected[data-cms-file-uri]:not([data-cms-file-directory])"); if (selectedRow && state.options.onSelect) { const uri = selectedRow.getAttribute("data-cms-file-uri"); const name = selectedRow.getAttribute("data-cms-file-name"); @@ -64,11 +65,13 @@ const openFileBrowser = async (optionsParam) => { } }, onShow: async () => { - initFileBrowser(state.options.uri); + initMediaBrowser(state.options.uri); } }); }; -const initFileBrowser = async (uri) => { +const initMediaBrowser = async (uri) => { + if (!state.options) + return; state.currentFolder = uri ? uri : ""; var options = { type: state.options.type, @@ -84,18 +87,17 @@ const initFileBrowser = async (uri) => { } const fileBrowserElement = document.getElementById("cms-file-browser"); if (fileBrowserElement) { - fileBrowserElement.innerHTML = filebrowserTemplate({ + fileBrowserElement.innerHTML = mediabrowserTemplate({ files: files, filenameHeader: i18n.t("filebrowser.filename", "Filename"), actionHeader: i18n.t("filebrowser.action", "Action"), actions: getActions(), asset: state.options.type === "assets", - pageContentTypes: (await getPageTemplates()).result + pageContentTypes: (cachedPageTemplates ?? (cachedPageTemplates = (await getPageTemplates()).result)) }); makeDirectoriesClickable(); if (state.options.onSelect) { - makeFilesSelectable(); - enableRowSelection(); + makeFilesSelectableAndSelectable(); } fileActions(); initBootstrapTooltips(); @@ -108,8 +110,8 @@ const initBootstrapTooltips = () => { new bootstrap.Tooltip(tooltipTriggerEl); }); }; -const makeFilesSelectable = () => { - const rows = document.querySelectorAll("tr[data-cms-file-uri]:not([data-cms-file-directory])"); +const makeFilesSelectableAndSelectable = () => { + const rows = document.querySelectorAll(".cms-media-card[data-cms-file-uri]:not([data-cms-file-directory])"); rows.forEach((row) => { row.addEventListener("dblclick", () => { const uri = row.getAttribute("data-cms-file-uri"); @@ -119,25 +121,18 @@ const makeFilesSelectable = () => { } state.modal.hide(); }); - }); -}; -const enableRowSelection = () => { - const rows = document.querySelectorAll("tr[data-cms-file-uri]:not([data-cms-file-directory])"); - rows.forEach((row) => { row.addEventListener("click", () => { - rows.forEach(r => r.classList.remove("table-active")); - row.classList.add("table-active"); + rows.forEach(r => r.classList.remove("selected")); + row.classList.add("selected"); }); }); }; -const getActions = () => { - const actions = []; - actions.push({ +const getActions = () => [ + { id: "cms-filebrowser-action-createFolder", name: i18n.t("filebrowser.create.folder", "Create folder") - }); - return actions; -}; + } +]; const makeDirectoriesClickable = () => { const elements = document.querySelectorAll("[data-cms-file-directory]"); elements.forEach((element) => { @@ -145,7 +140,7 @@ const makeDirectoriesClickable = () => { event.stopPropagation(); const directory = element.getAttribute("data-cms-file-uri"); if (directory) { - initFileBrowser(directory); + initMediaBrowser(directory); } }); }); @@ -174,7 +169,7 @@ const fileActions = () => { showToast({ title: i18n.t('filebrowser.actions.url.copy.title.error', "Error copying URL"), message: i18n.t('filebrowser.actions.url.copy.message.error', "Failed to copy URL"), - type: 'success', + type: 'error', timeout: 3000 }); }); @@ -186,7 +181,7 @@ const fileActions = () => { deleteFN: deletePage, getTargetFolder: getTargetFolder }).then(async () => { - await initFileBrowser(state.currentFolder); + await initMediaBrowser(state.currentFolder); }); } else if (action === "deleteFile") { @@ -196,7 +191,7 @@ const fileActions = () => { deleteFN: deleteFile, getTargetFolder: getTargetFolder }).then(async () => { - await initFileBrowser(state.currentFolder); + await initMediaBrowser(state.currentFolder); }); } else if (action === "deleteFolder") { @@ -206,7 +201,7 @@ const fileActions = () => { deleteFN: deleteFolder, getTargetFolder: getTargetFolder }).then(async () => { - await initFileBrowser(state.currentFolder); + await initMediaBrowser(state.currentFolder); }); } else if (action === "renameFile") { @@ -215,19 +210,22 @@ const fileActions = () => { getTargetFolder: getTargetFolder, filename: filename }).then(async () => { - await initFileBrowser(state.currentFolder); + await initMediaBrowser(state.currentFolder); }); } }); }); - document.getElementById("cms-filebrowser-action-createFolder").addEventListener("click", async (event) => { - createFolderAction({ - state: state, - getTargetFolder: getTargetFolder - }).then(async () => { - await initFileBrowser(state.currentFolder); + const createFolderBtn = document.getElementById("cms-filebrowser-action-createFolder"); + if (createFolderBtn) { + createFolderBtn.addEventListener("click", async (event) => { + createFolderAction({ + state: state, + getTargetFolder: getTargetFolder + }).then(async () => { + await initMediaBrowser(state.currentFolder); + }); }); - }); + } if (document.getElementById("cms-filebrowser-upload-button")) { document.getElementById("cms-filebrowser-upload-button").addEventListener("click", async (event) => { await handleFileUpload(); @@ -243,7 +241,7 @@ const fileActions = () => { getTargetFolder: getTargetFolder, contentType: contentType }).then(async () => { - await initFileBrowser(state.currentFolder); + await initMediaBrowser(state.currentFolder); }); } }); @@ -255,4 +253,4 @@ const getTargetFolder = () => { } return state.currentFolder; }; -export { openFileBrowser, state }; +export { openMediaBrowser, state }; diff --git a/modules/ui-module/src/main/resources/manager/js/modules/media/mediabrowser.template.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/media/mediabrowser.template.d.ts new file mode 100644 index 000000000..2c8ff55fe --- /dev/null +++ b/modules/ui-module/src/main/resources/manager/js/modules/media/mediabrowser.template.d.ts @@ -0,0 +1,2 @@ +export { template as mediabrowserTemplate }; +declare const template: any; diff --git a/modules/ui-module/src/main/resources/manager/js/modules/media/mediabrowser.template.js b/modules/ui-module/src/main/resources/manager/js/modules/media/mediabrowser.template.js new file mode 100644 index 000000000..8864889dc --- /dev/null +++ b/modules/ui-module/src/main/resources/manager/js/modules/media/mediabrowser.template.js @@ -0,0 +1,133 @@ +/*- + * #%L + * UI Module + * %% + * Copyright (C) 2023 - 2026 CondationCMS + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * #L% + */ +import Handlebars from 'https://cdn.jsdelivr.net/npm/handlebars@4.7.8/+esm'; +import { patchPathWithContext } from "@cms/js/manager-globals"; +Handlebars.registerHelper("patchPathWithContext", patchPathWithContext); +Handlebars.registerHelper('concat', function (...args) { + args.pop(); + return args.join(''); +}); +Handlebars.registerHelper('ifNotEquals', function (arg1, arg2, options) { + return (arg1 !== arg2) ? options.fn(this) : options.inverse(this); +}); +Handlebars.registerPartial('mediaBrowserContentActions', ` + {{#if pageTemplates}} + + {{/if}} +`); +const template = Handlebars.compile(` +
+
+ + + {{#unless asset}} + {{> mediaBrowserContentActions pageTemplates=pageContentTypes }} + {{/unless}} +
+ +
+ {{#each files}} +
+
+ {{#if directory}} + + {{else if media}} + {{name}} + {{else}} + + {{/if}} +
+ +
+ {{/each}} +
+ + {{#if asset}} +
+ + + +
Drop files here
+
+ {{/if}} +
+`); +export { template as mediabrowserTemplate }; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/filebrowser.upload.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/media/mediabrowser.upload.d.ts similarity index 100% rename from modules/ui-module/src/main/ts/dist/js/modules/filebrowser.upload.d.ts rename to modules/ui-module/src/main/resources/manager/js/modules/media/mediabrowser.upload.d.ts diff --git a/modules/ui-module/src/main/ts/dist/js/modules/filebrowser.upload.js b/modules/ui-module/src/main/resources/manager/js/modules/media/mediabrowser.upload.js similarity index 83% rename from modules/ui-module/src/main/ts/dist/js/modules/filebrowser.upload.js rename to modules/ui-module/src/main/resources/manager/js/modules/media/mediabrowser.upload.js index b046c0c71..82684f86b 100644 --- a/modules/ui-module/src/main/ts/dist/js/modules/filebrowser.upload.js +++ b/modules/ui-module/src/main/resources/manager/js/modules/media/mediabrowser.upload.js @@ -20,7 +20,7 @@ */ import { showToast } from '@cms/modules/toast.js'; import { i18n } from '@cms/modules/localization.js'; -import { state } from '@cms/modules/filebrowser.js'; +import { state } from '@cms/modules/media/mediabrowser.js'; import { uploadFileWithProgress } from '@cms/modules/upload.js'; import { EventBus } from '@cms/modules/event-bus.js'; const allowedMimeTypes = [ @@ -38,24 +38,24 @@ export const initDragAndDropUpload = () => { if (!dropZone || !fileInput) { return; } - // Prevent default drag behaviors - ['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => { - dropZone.addEventListener(eventName, e => e.preventDefault()); - dropZone.addEventListener(eventName, e => e.stopPropagation()); - }); - // Highlight drop zone on dragover - dropZone.addEventListener('dragover', () => { + // Prevent default drag behaviors; combine preventDefault+stopPropagation with per-event logic + dropZone.addEventListener('dragenter', e => { e.preventDefault(); e.stopPropagation(); }); + dropZone.addEventListener('dragover', e => { + e.preventDefault(); + e.stopPropagation(); dropZone.classList.add('dragover'); }); - dropZone.addEventListener('dragleave', () => { + dropZone.addEventListener('dragleave', e => { + e.preventDefault(); + e.stopPropagation(); dropZone.classList.remove('dragover'); }); - dropZone.addEventListener('drop', (e) => { + dropZone.addEventListener('drop', e => { + e.preventDefault(); + e.stopPropagation(); dropZone.classList.remove('dragover'); const files = e.dataTransfer.files; - // Optional: Update file input (useful for reusing existing logic) fileInput.files = files; - // Now you can upload files uploadFile(files[0]); }); }; @@ -83,12 +83,10 @@ const uploadFile = async (file) => { }); return; } - let formData = new FormData(); - formData.append("file", file); - formData.append("uri", getTargetFolder()); + const targetFolder = getTargetFolder(); uploadFileWithProgress({ file, - uri: getTargetFolder(), + uri: targetFolder, onProgress: (percent) => { updateProgressBar(percent); }, diff --git a/modules/ui-module/src/main/resources/manager/js/modules/modal.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/modal.d.ts index 4f6c59a03..a6bc8574c 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/modal.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/modal.d.ts @@ -1,21 +1 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export function openModal(optionsParam: any): any; diff --git a/modules/ui-module/src/main/resources/manager/js/modules/node.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/node.d.ts index 81527fd56..ade17f827 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/node.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/node.d.ts @@ -1,23 +1,3 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ /** * Retrieves a nested value from an object using a dot-notated path like "meta.title" * @param {object} sourceObj - The object to retrieve the value from diff --git a/modules/ui-module/src/main/resources/manager/js/modules/preview.history.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/preview.history.d.ts index 6cfeb16ad..19f953414 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/preview.history.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/preview.history.d.ts @@ -1,23 +1,3 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export namespace PreviewHistory { export { init }; export { navigatePreview }; diff --git a/modules/ui-module/src/main/resources/manager/js/modules/preview.utils.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/preview.utils.d.ts index 20c850ee6..24beb8ecc 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/preview.utils.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/preview.utils.d.ts @@ -1,23 +1,3 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export function activatePreviewOverlay(): void; export function deActivatePreviewOverlay(): void; export function getPreviewUrl(): any; diff --git a/modules/ui-module/src/main/resources/manager/js/modules/rpc/rpc-content.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/rpc/rpc-content.d.ts index 0df37da31..500f28b21 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/rpc/rpc-content.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/rpc/rpc-content.d.ts @@ -1,23 +1,3 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ import { RPCResponse } from '@cms/modules/rpc/rpc.js'; declare const getContentNode: (options: any) => Promise; declare const getContent: (options: any) => Promise; diff --git a/modules/ui-module/src/main/resources/manager/js/modules/rpc/rpc-files.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/rpc/rpc-files.d.ts index 4b1d33075..19350eb0f 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/rpc/rpc-files.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/rpc/rpc-files.d.ts @@ -1,23 +1,3 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ declare const listFiles: (options: any) => Promise; declare const deleteFile: (options: any) => Promise; declare const deleteFolder: (options: any) => Promise; diff --git a/modules/ui-module/src/main/resources/manager/js/modules/rpc/rpc-i18n.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/rpc/rpc-i18n.d.ts index e28dcc439..97184c7b3 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/rpc/rpc-i18n.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/rpc/rpc-i18n.d.ts @@ -1,22 +1,2 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ declare const loadLocalizations: (options: any) => Promise; export { loadLocalizations }; diff --git a/modules/ui-module/src/main/resources/manager/js/modules/rpc/rpc-manager.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/rpc/rpc-manager.d.ts index e473c39fc..09de5e435 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/rpc/rpc-manager.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/rpc/rpc-manager.d.ts @@ -1,23 +1,3 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ declare const getSectionEntryTemplates: (options: any) => Promise; declare const getPageTemplates: (options: any) => Promise; declare const getListItemTypes: (options: any) => Promise; diff --git a/modules/ui-module/src/main/resources/manager/js/modules/rpc/rpc-media.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/rpc/rpc-media.d.ts index 6a7743d97..e2f3eb480 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/rpc/rpc-media.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/rpc/rpc-media.d.ts @@ -1,23 +1,3 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ declare const getMediaMetaData: (options: any) => Promise; declare const setMediaMetaData: (options: any) => Promise; export { getMediaMetaData, setMediaMetaData }; diff --git a/modules/ui-module/src/main/resources/manager/js/modules/rpc/rpc-page.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/rpc/rpc-page.d.ts index 617c1efe9..5e9c6f05a 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/rpc/rpc-page.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/rpc/rpc-page.d.ts @@ -1,23 +1,3 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export interface CreatePageOptions { uri: string; name: string; diff --git a/modules/ui-module/src/main/resources/manager/js/modules/rpc/rpc-translation.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/rpc/rpc-translation.d.ts index dd3eb8c8e..0f2b8e64a 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/rpc/rpc-translation.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/rpc/rpc-translation.d.ts @@ -1,23 +1,3 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export interface GetTranslationsOptions { uri: string; } diff --git a/modules/ui-module/src/main/resources/manager/js/modules/rpc/rpc.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/rpc/rpc.d.ts index 753fc6d82..121bc30e4 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/rpc/rpc.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/rpc/rpc.d.ts @@ -1,23 +1,3 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ interface Options { method: string; parameters?: any; diff --git a/modules/ui-module/src/main/resources/manager/js/modules/sidebar.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/sidebar.d.ts index cdfd08d7f..268aae235 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/sidebar.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/sidebar.d.ts @@ -1,21 +1 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export function openSidebar(options: any): void; diff --git a/modules/ui-module/src/main/resources/manager/js/modules/state.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/state.d.ts index 80f03d1b9..7d224a238 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/state.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/state.d.ts @@ -1,23 +1,3 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ declare class State { constructor(initialState?: {}); state: {}; diff --git a/modules/ui-module/src/main/resources/manager/js/modules/toast.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/toast.d.ts index f5a574c37..0fcd8a129 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/toast.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/toast.d.ts @@ -1,21 +1 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export function showToast(options: any): void; diff --git a/modules/ui-module/src/main/resources/manager/js/modules/ui-state.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/ui-state.d.ts index 30e36cd4d..d064b5d45 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/ui-state.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/ui-state.d.ts @@ -1,23 +1,3 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export namespace UIStateManager { function setTabState(key: any, value: any): void; function getTabState(key: any, defaultValue?: null): any; diff --git a/modules/ui-module/src/main/resources/manager/js/modules/upload.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/upload.d.ts index 757755054..760c8f380 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/upload.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/upload.d.ts @@ -1,23 +1,3 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export function uploadFileWithProgress({ uploadEndpoint, file, uri, onProgress, onSuccess, onError }: { uploadEndpoint: any; file: any; diff --git a/modules/ui-module/src/main/resources/manager/js/modules/utils.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/utils.d.ts index 366bf425d..73eff8a4d 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/utils.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/utils.d.ts @@ -1,22 +1,2 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export declare function getCSRFToken(): string | null; export declare function setCSRFToken(token: string): void; diff --git a/modules/ui-module/src/main/resources/manager/js/modules/wizard.d.ts b/modules/ui-module/src/main/resources/manager/js/modules/wizard.d.ts index bb3a3b4b0..13b63e736 100644 --- a/modules/ui-module/src/main/resources/manager/js/modules/wizard.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/modules/wizard.d.ts @@ -1,23 +1,3 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export function openWizard(optionsParam: any): { wizardId: string; modalInstance: any; diff --git a/modules/ui-module/src/main/resources/manager/js/ui-actions.d.ts b/modules/ui-module/src/main/resources/manager/js/ui-actions.d.ts index 4562057ed..cb0ff5c3b 100644 --- a/modules/ui-module/src/main/resources/manager/js/ui-actions.d.ts +++ b/modules/ui-module/src/main/resources/manager/js/ui-actions.d.ts @@ -1,21 +1 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ export {}; diff --git a/modules/ui-module/src/main/resources/manager/public/manager-login.d.ts b/modules/ui-module/src/main/resources/manager/public/manager-login.d.ts index ce810c5cb..5b5817d8a 100644 --- a/modules/ui-module/src/main/resources/manager/public/manager-login.d.ts +++ b/modules/ui-module/src/main/resources/manager/public/manager-login.d.ts @@ -1,23 +1,3 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ declare const ui: { state: string; }; diff --git a/modules/ui-module/src/main/ts/dist/actions/media/edit-focal-point.d.ts b/modules/ui-module/src/main/ts/dist/actions/media/edit-focal-point.d.ts deleted file mode 100644 index 85620d3ab..000000000 --- a/modules/ui-module/src/main/ts/dist/actions/media/edit-focal-point.d.ts +++ /dev/null @@ -1 +0,0 @@ -export declare function runAction(params: any): Promise; diff --git a/modules/ui-module/src/main/ts/dist/actions/media/edit-focal-point.js b/modules/ui-module/src/main/ts/dist/actions/media/edit-focal-point.js deleted file mode 100644 index a917e7b54..000000000 --- a/modules/ui-module/src/main/ts/dist/actions/media/edit-focal-point.js +++ /dev/null @@ -1,113 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { i18n } from "@cms/modules/localization.js"; -import { openModal } from "@cms/modules/modal.js"; -import { reloadPreview } from "@cms/modules/preview.utils.js"; -import { getMediaMetaData, setMediaMetaData } from "@cms/modules/rpc/rpc-media.js"; -import { showToast } from "@cms/modules/toast.js"; -export async function runAction(params) { - var uri = params.options.uri || null; - var mediaUrl = removeFormatParamFromUrl(uri); - const template = ` -
- - -
- `; - var mediaMeta = (await getMediaMetaData({ image: params.options.uri })).result.meta; - const focal = mediaMeta?.focal || {}; - const focalX = typeof focal.x === 'number' ? focal.x : 0.5; - const focalY = typeof focal.y === 'number' ? focal.y : 0.5; - openModal({ - title: i18n.t("media.focal.title", "Edit focal point"), - body: template, - onCancel: (event) => { }, - onOk: async (event) => { - var setMetaResponse = await setMediaMetaData({ - image: mediaUrl, - meta: { - "focal.x": { - "type": "number", - "value": focal.x - }, - "focal.y": { - "type": "number", - "value": focal.y - } - } - }); - showToast({ - title: i18n.t('manager.actions.media.focal-point.toast.title', "Media focal point updated"), - message: i18n.t('manager.actions.media.focal-point.toast.message', "The focal point was successfuly updated."), - type: 'success', - timeout: 3000 - }); - reloadPreview(); - }, - onShow: () => { - const wrapper = document.getElementById("cmsFocalWrapper"); - const image = document.getElementById("cms-image"); - const point = document.getElementById("cmsFocalPoint"); - if (wrapper === null || image === null || point === null) { - console.error("One or more required elements not found"); - return; - } - if (image.complete) { - setFocalPoint(image, point, focalX, focalY); - } - else { - image.onload = () => setFocalPoint(image, point, focalX, focalY); - } - wrapper.addEventListener("click", function (e) { - const rect = image.getBoundingClientRect(); - const x = e.clientX - rect.left; - const y = e.clientY - rect.top; - const relX = (x / rect.width).toFixed(4); - const relY = (y / rect.height).toFixed(4); - // Punkt anzeigen - point.style.left = `${x}px`; - point.style.top = `${y}px`; - point.style.display = "block"; - focal.x = parseFloat(relX); - focal.y = parseFloat(relY); - }); - } - }); -} -const setFocalPoint = (image, point, relX, relY) => { - const rect = image.getBoundingClientRect(); - const x = rect.width * relX; - const y = rect.height * relY; - point.style.left = `${x}px`; - point.style.top = `${y}px`; - point.style.display = "block"; -}; -const removeFormatParamFromUrl = (url) => { - try { - const parsedUrl = new URL(url, window.location.origin); // Fallback-Basis falls nur Pfad übergeben wird - parsedUrl.searchParams.delete("format"); - return parsedUrl.toString(); - } - catch (e) { - console.warn("Ungültige URL:", url); - return url; // Fallback: gib Original zurück - } -}; diff --git a/modules/ui-module/src/main/ts/dist/actions/media/edit-media-form.d.ts b/modules/ui-module/src/main/ts/dist/actions/media/edit-media-form.d.ts deleted file mode 100644 index 6abc321a1..000000000 --- a/modules/ui-module/src/main/ts/dist/actions/media/edit-media-form.d.ts +++ /dev/null @@ -1 +0,0 @@ -export function runAction(params: any): Promise; diff --git a/modules/ui-module/src/main/ts/dist/actions/media/edit-media-form.js b/modules/ui-module/src/main/ts/dist/actions/media/edit-media-form.js deleted file mode 100644 index de852933c..000000000 --- a/modules/ui-module/src/main/ts/dist/actions/media/edit-media-form.js +++ /dev/null @@ -1,87 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { openSidebar } from '@cms/modules/sidebar.js'; -import { createForm } from '@cms/modules/form/forms.js'; -import { showToast } from '@cms/modules/toast.js'; -import { setMeta } from '@cms/modules/rpc/rpc-content.js'; -import { reloadPreview } from '@cms/modules/preview.utils.js'; -import { i18n } from '@cms/modules/localization.js'; -import { getMediaForm } from '@cms/modules/rpc/rpc-manager.js'; -import { getMediaMetaData, setMediaMetaData } from '@cms/modules/rpc/rpc-media.js'; -export async function runAction(params) { - var mediaForm = (await getMediaForm({ - form: params.options.form || 'meta' - })).result; - const fields = [ - ...mediaForm?.form?.fields - ]; - const values = { - ...(await getMediaMetaData({ image: params.options.image })).result.meta - }; - const form = createForm({ - fields: fields, - values: values - }); - openSidebar({ - title: 'Media attributes', - body: 'modal body', - form: form, - onCancel: (event) => { }, - onOk: async (event) => { - var updateData = form.getData(); - var setMetaResponse = await setMediaMetaData({ - image: params.options.image, - meta: updateData - }); - showToast({ - title: i18n.t('manager.actions.media.edit-media-form.toast.title', "Media meta updated"), - message: i18n.t('manager.actions.media.edit-media-form.toast.message', "The media meta have been updated successfully."), - type: 'success', // optional: info | success | warning | error - timeout: 3000 - }); - reloadPreview(); - } - }); -} -/** - * Retrieves a nested value from an object using a dot-notated path like "meta.title" - * @param {object} sourceObj - The object to retrieve the value from - * @param {string} path - Dot-notated string path, e.g., "meta.title" - * @returns {*} - The value found at the given path, or undefined if not found - */ -const getValueByPath = (sourceObj, path) => { - return path.split('.').reduce((acc, part) => acc?.[part], sourceObj); -}; -/** - * Builds a values object from an array of form fields - * @param {Array} fields - Array of form field objects, each with a .name property - * @param {object} sourceObj - The source object to extract the values from - * @returns {object} values - An object mapping field names to their corresponding values - */ -const buildValuesFromFields = (fields, sourceObj) => { - const values = {}; - for (const field of fields) { - if (!field.name) - continue; - values[field.name] = getValueByPath(sourceObj, field.name); - } - return values; -}; diff --git a/modules/ui-module/src/main/ts/dist/actions/media/select-content-media.d.ts b/modules/ui-module/src/main/ts/dist/actions/media/select-content-media.d.ts deleted file mode 100644 index 85620d3ab..000000000 --- a/modules/ui-module/src/main/ts/dist/actions/media/select-content-media.d.ts +++ /dev/null @@ -1 +0,0 @@ -export declare function runAction(params: any): Promise; diff --git a/modules/ui-module/src/main/ts/dist/actions/media/select-content-media.js b/modules/ui-module/src/main/ts/dist/actions/media/select-content-media.js deleted file mode 100644 index 02e50d2f3..000000000 --- a/modules/ui-module/src/main/ts/dist/actions/media/select-content-media.js +++ /dev/null @@ -1,81 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { openFileBrowser } from "@cms/modules/filebrowser.js"; -import { i18n } from "@cms/modules/localization.js"; -import { getPreviewUrl, reloadPreview } from "@cms/modules/preview.utils.js"; -import { getContentNode, replaceContent } from "@cms/modules/rpc/rpc-content.js"; -import { showToast } from "@cms/modules/toast.js"; -export async function runAction(params) { - var uri = null; - if (params.options.uri) { - uri = params.options.uri; - } - else { - const contentNode = await getContentNode({ - url: getPreviewUrl() - }); - uri = contentNode.result.uri; - } - openFileBrowser({ - type: "assets", - filter: (file) => { - return file.media || file.directory; - }, - onSelect: async (file) => { - if (file && file.uri) { - var selectedFile = file.uri; // Use the file's URI - if (file.uri.startsWith("/")) { - selectedFile = file.uri.substring(1); // Remove leading slash if present - } - var updateData = {}; - updateData[params.options.metaElement] = { - type: 'media', - value: selectedFile - }; - var options = { - uri: uri, - content: selectedFile, - start: params.options.start, - end: params.options.end - }; - var replaceMedia = await replaceContent(options); - if (replaceMedia.result.error != null && replaceMedia.result.error === true) { - showToast({ - title: i18n.t('manager.actions.media.select-content-media.toast.title-error', "Media not updated"), - message: i18n.t('manager.actions.media.select-content-media.toast.message-error', "New media has not been updated successfully."), - type: 'error', // optional: info | success | warning | error - timeout: 3000 - }); - reloadPreview(); - } - else { - showToast({ - title: i18n.t('manager.actions.media.select-media.toast.title', "Media updated"), - message: i18n.t('manager.actions.media.select-media.toast.message', "New media has been updated successfully."), - type: 'success', // optional: info | success | warning | error - timeout: 3000 - }); - reloadPreview(); - } - } - } - }); -} diff --git a/modules/ui-module/src/main/ts/dist/actions/media/select-media.d.ts b/modules/ui-module/src/main/ts/dist/actions/media/select-media.d.ts deleted file mode 100644 index 85620d3ab..000000000 --- a/modules/ui-module/src/main/ts/dist/actions/media/select-media.d.ts +++ /dev/null @@ -1 +0,0 @@ -export declare function runAction(params: any): Promise; diff --git a/modules/ui-module/src/main/ts/dist/actions/media/select-media.js b/modules/ui-module/src/main/ts/dist/actions/media/select-media.js deleted file mode 100644 index e0753be54..000000000 --- a/modules/ui-module/src/main/ts/dist/actions/media/select-media.js +++ /dev/null @@ -1,67 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { openFileBrowser } from "@cms/modules/filebrowser.js"; -import { i18n } from "@cms/modules/localization.js"; -import { getPreviewUrl, reloadPreview } from "@cms/modules/preview.utils.js"; -import { getContentNode, setMeta } from "@cms/modules/rpc/rpc-content.js"; -import { showToast } from "@cms/modules/toast.js"; -export async function runAction(params) { - var uri = null; - if (params.options.uri) { - uri = params.options.uri; - } - else { - const contentNode = await getContentNode({ - url: getPreviewUrl() - }); - uri = contentNode.result.uri; - } - openFileBrowser({ - type: "assets", - filter: (file) => { - return file.media || file.directory; - }, - onSelect: async (file) => { - if (file && file.uri) { - var selectedFile = file.uri; // Use the file's URI - if (file.uri.startsWith("/")) { - selectedFile = file.uri.substring(1); // Remove leading slash if present - } - var updateData = {}; - updateData[params.options.metaElement] = { - type: 'media', - value: selectedFile - }; - var setMetaResponse = await setMeta({ - uri: uri, - meta: updateData - }); - showToast({ - title: i18n.t('manager.actions.media.select-media.toast.title', "Media updated"), - message: i18n.t('manager.actions.media.select-media.toast.message', "New media has been updated successfully."), - type: 'success', // optional: info | success | warning | error - timeout: 3000 - }); - reloadPreview(); - } - } - }); -} diff --git a/modules/ui-module/src/main/ts/dist/actions/page/add-section.d.ts b/modules/ui-module/src/main/ts/dist/actions/page/add-section.d.ts deleted file mode 100644 index 6abc321a1..000000000 --- a/modules/ui-module/src/main/ts/dist/actions/page/add-section.d.ts +++ /dev/null @@ -1 +0,0 @@ -export function runAction(params: any): Promise; diff --git a/modules/ui-module/src/main/ts/dist/actions/page/add-section.js b/modules/ui-module/src/main/ts/dist/actions/page/add-section.js deleted file mode 100644 index 4eaed5385..000000000 --- a/modules/ui-module/src/main/ts/dist/actions/page/add-section.js +++ /dev/null @@ -1,129 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { openModal } from '@cms/modules/modal.js'; -import { showToast } from '@cms/modules/toast.js'; -import { addSection, getContentNode } from '@cms/modules/rpc/rpc-content.js'; -import { getPreviewUrl, reloadPreview } from '@cms/modules/preview.utils.js'; -import Handlebars from 'https://cdn.jsdelivr.net/npm/handlebars@4.7.8/+esm'; -import { i18n } from '@cms/modules/localization.js'; -import { getSectionEntryTemplates } from '@cms/modules/rpc/rpc-manager.js'; -export async function runAction(params) { - const contentNode = await getContentNode({ - url: getPreviewUrl() - }); - var template = Handlebars.compile(` -
- - -
- - `); - var sectionsResponse = await getSectionEntryTemplates({ - section: params.section - }); - openModal({ - title: i18n.t("addsection.titles.modal", 'Add entry'), - body: template({ - templates: sectionsResponse.result, - }), - fullscreen: false, - onCancel: (event) => { }, - validate: () => validate(contentNode, params.section), - onOk: async (event) => { - var result = await createSection(contentNode.result.uri, params.section); - if (result) { - showToast({ - title: i18n.t("manager.actions.addsection.titles.alert", "Create Entry"), - message: i18n.t("manager.actions.addsection.alerts.success.message", "Entry successfuly created."), - type: 'success', // optional: info | success | warning | error - timeout: 3000 - }); - await new Promise(resolve => setTimeout(resolve, 1000)); - reloadPreview(); - } - else { - showToast({ - title: i18n.t("manager.actions.addsection.titles.alert", 'Create Entry'), - message: i18n.t("manager.actions.addsection.alerts.error.message", "Entry not created."), - type: 'warning', // optional: info | success | warning | error - timeout: 3000 - }); - } - } - }); -} -const getSectionEntryName = () => { - return document.getElementById("cms-section-name").value; -}; -const validate = (contentNode, targetSection) => { - const template = document.getElementById("cms-section-template-selection").value; - if (template === "000") { - showToast({ - title: i18n.t("manager.actions.addsection.titles.alert", 'Create Entry'), - message: i18n.t("manager.actions.addsection.alerts.notemplate.message", "No template selected."), - type: 'error', // optional: info | success | warning | error - timeout: 3000 - }); - return false; - } - const sectionEntryName = getSectionEntryName(); - if (sectionEntryName === "" || sectionEntryName === null) { - showToast({ - title: i18n.t("manager.actions.addsection.titles.alert", 'Create Entry'), - message: i18n.t("manager.actions.addsection.alerts.noname.message", "No Entry name provided."), - type: 'error', - timeout: 3000 - }); - return false; - } - return true; -}; -function isUriInSection(data, sectionEntryKey, targetUri) { - if (!data || - !data.result || - !data.result.sections || - typeof data.result.sections !== 'object') { - return false; - } - const sectionArray = data.result.sections[sectionEntryKey]; - if (!Array.isArray(sectionArray)) { - return false; - } - return sectionArray.some(item => item.uri === targetUri); -} -const createSection = async (parentUri, parentSectionName) => { - const template = document.getElementById("cms-section-template-selection").value; - if (template === "000") { - return false; - } - await addSection({ - parentUri: parentUri, - sectionEntryName: getSectionEntryName(), - section: parentSectionName, - template: template - }); - return true; -}; diff --git a/modules/ui-module/src/main/ts/dist/actions/page/create-node.d.ts b/modules/ui-module/src/main/ts/dist/actions/page/create-node.d.ts deleted file mode 100644 index 6abc321a1..000000000 --- a/modules/ui-module/src/main/ts/dist/actions/page/create-node.d.ts +++ /dev/null @@ -1 +0,0 @@ -export function runAction(params: any): Promise; diff --git a/modules/ui-module/src/main/ts/dist/actions/page/create-node.js b/modules/ui-module/src/main/ts/dist/actions/page/create-node.js deleted file mode 100644 index a06f8a9f0..000000000 --- a/modules/ui-module/src/main/ts/dist/actions/page/create-node.js +++ /dev/null @@ -1,38 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { i18n } from '@cms/modules/localization'; -import { openCreateContentBrowser } from '@cms/modules/filebrowser.create.js'; -import { loadPreview } from '@cms/modules/preview.utils'; -import { patchPathWithContext } from '@cms/js/manager-globals'; -// hook.js -export async function runAction(params) { - openCreateContentBrowser({ - type: "content", - template: params.template, - contentType: params.contentType, - uri: params.folder, - title: i18n.t("filebrowser.createContent.title", "Create Node"), - onCreate: (newContent) => { - console.log("Created new content:", newContent); - loadPreview(patchPathWithContext(newContent.uri)); // Reload the preview to reflect the new content - } - }); -} diff --git a/modules/ui-module/src/main/ts/dist/actions/page/create-page.d.ts b/modules/ui-module/src/main/ts/dist/actions/page/create-page.d.ts deleted file mode 100644 index 6abc321a1..000000000 --- a/modules/ui-module/src/main/ts/dist/actions/page/create-page.d.ts +++ /dev/null @@ -1 +0,0 @@ -export function runAction(params: any): Promise; diff --git a/modules/ui-module/src/main/ts/dist/actions/page/create-page.js b/modules/ui-module/src/main/ts/dist/actions/page/create-page.js deleted file mode 100644 index a0e42d021..000000000 --- a/modules/ui-module/src/main/ts/dist/actions/page/create-page.js +++ /dev/null @@ -1,27 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { openFileBrowser } from '@cms/modules/filebrowser.js'; -// hook.js -export async function runAction(params) { - openFileBrowser({ - type: "content" - }); -} diff --git a/modules/ui-module/src/main/ts/dist/actions/page/delete-section.d.ts b/modules/ui-module/src/main/ts/dist/actions/page/delete-section.d.ts deleted file mode 100644 index 6abc321a1..000000000 --- a/modules/ui-module/src/main/ts/dist/actions/page/delete-section.d.ts +++ /dev/null @@ -1 +0,0 @@ -export function runAction(params: any): Promise; diff --git a/modules/ui-module/src/main/ts/dist/actions/page/delete-section.js b/modules/ui-module/src/main/ts/dist/actions/page/delete-section.js deleted file mode 100644 index e27099bdb..000000000 --- a/modules/ui-module/src/main/ts/dist/actions/page/delete-section.js +++ /dev/null @@ -1,58 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { i18n } from '@cms/modules/localization.js'; -import { alertConfirm } from '@cms/modules/alerts.js'; -import { deleteSection } from '@cms/modules/rpc/rpc-content.js'; -import { showToast } from '@cms/modules/toast.js'; -import { reloadPreview } from '@cms/modules/preview.utils.js'; -export async function runAction(params) { - var confimred = await alertConfirm({ - title: i18n.t("filebrowser.delete.confirm.title", "Are you sure?"), - message: i18n.t("filebrowser.delete.confirm.message", "You won't be able to revert this!"), - confirmText: i18n.t("filebrowser.delete.confirm.yes", "Yes, delete it!"), - cancelText: i18n.t("filebrowser.delete.confirm.no", "No, cancel!") - }); - if (!confimred) { - return; - } - const sectionUri = params.sectionUri; - deleteSection({ - uri: sectionUri - }).then((response) => { - if (response.error) { - showToast({ - title: i18n.t("manager.actions.section.delete.error.title", "Error deleting item"), - message: i18n.t("manager.actions.section.delete.error.message", "Error deleting item"), - type: 'error', - timeout: 3000 - }); - } - else { - showToast({ - title: i18n.t("manager.actions.section.delete.success.title", "Delete item"), - message: i18n.t("manager.actions.section.delete.success.message", "Item deleted successfully"), - type: 'success', - timeout: 3000 - }); - reloadPreview(); - } - }); -} diff --git a/modules/ui-module/src/main/ts/dist/actions/page/edit-content.d.ts b/modules/ui-module/src/main/ts/dist/actions/page/edit-content.d.ts deleted file mode 100644 index 6abc321a1..000000000 --- a/modules/ui-module/src/main/ts/dist/actions/page/edit-content.d.ts +++ /dev/null @@ -1 +0,0 @@ -export function runAction(params: any): Promise; diff --git a/modules/ui-module/src/main/ts/dist/actions/page/edit-content.js b/modules/ui-module/src/main/ts/dist/actions/page/edit-content.js deleted file mode 100644 index 6d816262a..000000000 --- a/modules/ui-module/src/main/ts/dist/actions/page/edit-content.js +++ /dev/null @@ -1,76 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { openModal } from '@cms/modules/modal.js'; -import { createForm } from '@cms/modules/form/forms.js'; -import { getPreviewUrl, reloadPreview } from '@cms/modules/preview.utils.js'; -import { getContentNode, getContent, setContent } from '@cms/modules/rpc/rpc-content.js'; -import { i18n } from '@cms/modules/localization.js'; -import { showToast } from '@cms/modules/toast.js'; -// hook.js -export async function runAction(params) { - var uri = null; - if (params.uri) { - uri = params.uri; - } - else { - const contentNode = await getContentNode({ - url: getPreviewUrl() - }); - uri = contentNode.result.uri; - } - const nodeContent = await getContent({ - uri: uri - }); - const form = createForm({ - fields: [ - { - type: params.editor, - name: 'content', - title: 'Main content', - height: '80%' - } - ], - values: { - "content": nodeContent?.result?.content - } - }); - openModal({ - title: 'Edit Content', - body: 'modal body', - form: form, - fullscreen: true, - onCancel: (event) => { }, - onOk: async (event) => { - var updateData = form.getData(); - var setContentResponse = await setContent({ - uri: uri, - content: updateData.content - }); - showToast({ - title: i18n.t('manager.actions.page.edit-content.toast.title', "Content updated"), - message: i18n.t('manager.actions.page.edit-content.toast.message', "The content has been updated successfully."), - type: 'success', // optional: info | success | warning | error - timeout: 3000 - }); - reloadPreview(); - } - }); -} diff --git a/modules/ui-module/src/main/ts/dist/actions/page/edit-metaattribute-form.d.ts b/modules/ui-module/src/main/ts/dist/actions/page/edit-metaattribute-form.d.ts deleted file mode 100644 index 6abc321a1..000000000 --- a/modules/ui-module/src/main/ts/dist/actions/page/edit-metaattribute-form.d.ts +++ /dev/null @@ -1 +0,0 @@ -export function runAction(params: any): Promise; diff --git a/modules/ui-module/src/main/ts/dist/actions/page/edit-metaattribute-form.js b/modules/ui-module/src/main/ts/dist/actions/page/edit-metaattribute-form.js deleted file mode 100644 index 04c8704e8..000000000 --- a/modules/ui-module/src/main/ts/dist/actions/page/edit-metaattribute-form.js +++ /dev/null @@ -1,88 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { createForm } from '@cms/modules/form/forms.js'; -import { showToast } from '@cms/modules/toast.js'; -import { getPreviewUrl, reloadPreview } from '@cms/modules/preview.utils.js'; -import { buildValuesFromFields, getValueByPath } from '@cms/modules/node.js'; -import { getContentNode, getContent, setMeta } from '@cms/modules/rpc/rpc-content.js'; -import { i18n } from '@cms/modules/localization.js'; -import { openSidebar } from '@cms/modules/sidebar.js'; -import { getPageTemplates, getSectionEntryTemplates } from '@cms/modules/rpc/rpc-manager'; -// hook.js -export async function runAction(params) { - var uri = null; - if (params.uri) { - uri = params.uri; - } - else { - const contentNode = await getContentNode({ - url: getPreviewUrl() - }); - uri = contentNode.result.uri; - } - const getContentResponse = await getContent({ - uri: uri - }); - var templates = null; - if (params.type === "sectionEntry") { - templates = (await getSectionEntryTemplates()).result; - } - else { - templates = (await getPageTemplates()).result; - } - var selected = templates.filter(item => item.template === getContentResponse?.result?.meta?.template); - var attrForm = []; - if (selected.length === 1) { - attrForm = selected[0].data?.forms[params.form] ? selected[0].data.forms[params.form].fields : []; - } - //const previewMetaForm = getMetaForm() - const fields = [ - ...attrForm - ]; - const values = { - ...buildValuesFromFields(attrForm, getContentResponse?.result?.meta) - }; - const form = createForm({ - fields: fields, - values: values - }); - openSidebar({ - title: 'Edit meta attribute', - body: 'modal body', - form: form, - resizable: true, - onCancel: (event) => { }, - onOk: async (event) => { - var updateData = form.getData(); - var setMetaResponse = await setMeta({ - uri: uri, - meta: updateData - }); - showToast({ - title: i18n.t('manager.actions.page.edit-metaattribute-list.toast.title', "MetaData updated"), - message: i18n.t('manager.actions.page.edit-metaattribute-list.toast.message', "The metadata has been updated successfully."), - type: 'success', // optional: info | success | warning | error - timeout: 3000 - }); - reloadPreview(); - } - }); -} diff --git a/modules/ui-module/src/main/ts/dist/actions/page/edit-metaattribute-list.d.ts b/modules/ui-module/src/main/ts/dist/actions/page/edit-metaattribute-list.d.ts deleted file mode 100644 index 6abc321a1..000000000 --- a/modules/ui-module/src/main/ts/dist/actions/page/edit-metaattribute-list.d.ts +++ /dev/null @@ -1 +0,0 @@ -export function runAction(params: any): Promise; diff --git a/modules/ui-module/src/main/ts/dist/actions/page/edit-metaattribute-list.js b/modules/ui-module/src/main/ts/dist/actions/page/edit-metaattribute-list.js deleted file mode 100644 index 388a3764f..000000000 --- a/modules/ui-module/src/main/ts/dist/actions/page/edit-metaattribute-list.js +++ /dev/null @@ -1,78 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { createForm } from '@cms/modules/form/forms.js'; -import { showToast } from '@cms/modules/toast.js'; -import { getPreviewUrl, reloadPreview } from '@cms/modules/preview.utils.js'; -import { getValueByPath } from '@cms/modules/node.js'; -import { getContentNode, getContent, setMeta } from '@cms/modules/rpc/rpc-content.js'; -import { i18n } from '@cms/modules/localization.js'; -import { openSidebar } from '@cms/modules/sidebar.js'; -// hook.js -export async function runAction(params) { - var uri = null; - if (params.uri) { - uri = params.uri; - } - else { - const contentNode = await getContentNode({ - url: getPreviewUrl() - }); - uri = contentNode.result.uri; - } - const getContentResponse = await getContent({ - uri: uri - }); - let formDefinition = { - fields: [], - values: {} - }; - params.attributes.forEach(attr => { - formDefinition.values[attr.name] = getValueByPath(getContentResponse?.result?.meta, attr.name); - formDefinition.fields.push({ - type: attr.editor, - name: attr.name, - title: attr.name, - options: attr.options ? attr.options : {} - }); - }); - const form = createForm(formDefinition); - openSidebar({ - title: 'Edit meta attribute', - body: 'modal body', - form: form, - resizable: true, - onCancel: (event) => { }, - onOk: async (event) => { - var updateData = form.getData(); - var setMetaResponse = await setMeta({ - uri: uri, - meta: updateData - }); - showToast({ - title: i18n.t('manager.actions.page.edit-metaattribute-list.toast.title', "MetaData updated"), - message: i18n.t('manager.actions.page.edit-metaattribute-list.toast.message', "The metadata has been updated successfully."), - type: 'success', // optional: info | success | warning | error - timeout: 3000 - }); - reloadPreview(); - } - }); -} diff --git a/modules/ui-module/src/main/ts/dist/actions/page/edit-metaattribute.d.ts b/modules/ui-module/src/main/ts/dist/actions/page/edit-metaattribute.d.ts deleted file mode 100644 index 6abc321a1..000000000 --- a/modules/ui-module/src/main/ts/dist/actions/page/edit-metaattribute.d.ts +++ /dev/null @@ -1 +0,0 @@ -export function runAction(params: any): Promise; diff --git a/modules/ui-module/src/main/ts/dist/actions/page/edit-metaattribute.js b/modules/ui-module/src/main/ts/dist/actions/page/edit-metaattribute.js deleted file mode 100644 index b87ff053b..000000000 --- a/modules/ui-module/src/main/ts/dist/actions/page/edit-metaattribute.js +++ /dev/null @@ -1,77 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { createForm } from '@cms/modules/form/forms.js'; -import { showToast } from '@cms/modules/toast.js'; -import { getPreviewUrl, reloadPreview } from '@cms/modules/preview.utils.js'; -import { getValueByPath } from '@cms/modules/node.js'; -import { getContentNode, setMeta, getContent } from '@cms/modules/rpc/rpc-content.js'; -import { i18n } from '@cms/modules/localization.js'; -import { openSidebar } from '@cms/modules/sidebar.js'; -// hook.js -export async function runAction(params) { - var uri = null; - if (params.uri) { - uri = params.uri; - } - else { - const contentNode = await getContentNode({ - url: getPreviewUrl() - }); - uri = contentNode.result.uri; - } - const getContentResponse = await getContent({ - uri: uri - }); - let formDefinition = { - fields: [ - { - type: params.editor, - options: params.options ? params.options : {}, - name: params.attribute, - title: "Edit attribute: " + params.attribute - } - ], - values: {} - }; - formDefinition.values[params.attribute] = getValueByPath(getContentResponse?.result?.meta, params.attribute); - const form = createForm(formDefinition); - openSidebar({ - title: 'Edit meta attribute', - body: 'modal body', - form: form, - resizable: true, - onCancel: (event) => { }, - onOk: async (event) => { - var updateData = form.getData(); - var setMetaResponse = await setMeta({ - uri: uri, - meta: updateData - }); - showToast({ - title: i18n.t('manager.actions.page.edit-metaattribute.toast.title', "MetaData updated"), - message: i18n.t('manager.actions.page.edit-metaattribute.toast.message', "The metadata has been updated successfully."), - type: 'success', // optional: info | success | warning | error - timeout: 3000 - }); - reloadPreview(); - } - }); -} diff --git a/modules/ui-module/src/main/ts/dist/actions/page/edit-page-settings.d.ts b/modules/ui-module/src/main/ts/dist/actions/page/edit-page-settings.d.ts deleted file mode 100644 index 6abc321a1..000000000 --- a/modules/ui-module/src/main/ts/dist/actions/page/edit-page-settings.d.ts +++ /dev/null @@ -1 +0,0 @@ -export function runAction(params: any): Promise; diff --git a/modules/ui-module/src/main/ts/dist/actions/page/edit-page-settings.js b/modules/ui-module/src/main/ts/dist/actions/page/edit-page-settings.js deleted file mode 100644 index 4ff4d5a32..000000000 --- a/modules/ui-module/src/main/ts/dist/actions/page/edit-page-settings.js +++ /dev/null @@ -1,107 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { openSidebar } from '@cms/modules/sidebar.js'; -import { createForm } from '@cms/modules/form/forms.js'; -import { showToast } from '@cms/modules/toast.js'; -import { getContentNode, setMeta, getContent } from '@cms/modules/rpc/rpc-content.js'; -import { getPreviewUrl, reloadPreview } from '@cms/modules/preview.utils.js'; -import { i18n } from '@cms/modules/localization.js'; -import { getPageTemplates } from '@cms/modules/rpc/rpc-manager.js'; -import { buildValuesFromFields } from '@cms/modules/node.js'; -const DEFAULT_FIELDS = [ - { - type: 'text', - name: 'title', - title: 'Title' - }, - { - type: 'select', - name: 'published', - title: 'Published', - options: { - choices: [ - { label: 'No', value: false }, - { label: 'Yes', value: true } - ] - } - }, - { - type: 'datetime', - name: 'publish_date', - title: 'Publish Date', - }, - { - type: 'datetime', - name: 'unpublish_date', - title: 'Unpublish Date', - } -]; -export async function runAction(params) { - const contentNode = await getContentNode({ - url: getPreviewUrl() - }); - const getContentResponse = await getContent({ - uri: contentNode.result.uri - }); - var pageTemplates = (await getPageTemplates()).result; - var selected = pageTemplates.filter(pageTemplate => pageTemplate.template === getContentResponse?.result?.meta?.template); - var pageSettingsForm = []; - if (selected.length === 1) { - pageSettingsForm = selected[0].data?.forms?.settings ? selected[0].data.forms.settings.fields : []; - } - //const previewMetaForm = getMetaForm() - const fields = [ - ...DEFAULT_FIELDS, - ...pageSettingsForm - ]; - const values = { - 'title': getContentResponse?.result?.meta?.title, - 'published': getContentResponse?.result?.meta?.published, - 'publish_date': getContentResponse?.result?.meta?.publish_date, - 'unpublish_date': getContentResponse?.result?.meta?.unpublish_date, - ...buildValuesFromFields(pageSettingsForm, getContentResponse?.result?.meta) - }; - const form = createForm({ - fields: fields, - values: values - }); - openSidebar({ - title: 'Page settings', - body: 'modal body', - form: form, - resizable: true, - onCancel: (event) => { }, - onOk: async (event) => { - var updateData = form.getData(); - var setMetaResponse = await setMeta({ - uri: contentNode.result.uri, - meta: updateData - }); - showToast({ - title: i18n.t('manager.actions.page.edit-page-settings.toast.title', "Page settings updated"), - message: i18n.t('manager.actions.page.edit-page-settings.toast.message', "The page settings have been updated successfully."), - type: 'success', // optional: info | success | warning | error - timeout: 3000 - }); - reloadPreview(); - } - }); -} diff --git a/modules/ui-module/src/main/ts/dist/actions/page/edit-sections.d.ts b/modules/ui-module/src/main/ts/dist/actions/page/edit-sections.d.ts deleted file mode 100644 index 6abc321a1..000000000 --- a/modules/ui-module/src/main/ts/dist/actions/page/edit-sections.d.ts +++ /dev/null @@ -1 +0,0 @@ -export function runAction(params: any): Promise; diff --git a/modules/ui-module/src/main/ts/dist/actions/page/edit-sections.js b/modules/ui-module/src/main/ts/dist/actions/page/edit-sections.js deleted file mode 100644 index 77791cd14..000000000 --- a/modules/ui-module/src/main/ts/dist/actions/page/edit-sections.js +++ /dev/null @@ -1,93 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { openModal } from '@cms/modules/modal.js'; -import { showToast } from '@cms/modules/toast.js'; -import { getPreviewUrl, reloadPreview } from '@cms/modules/preview.utils.js'; -import Sortable from 'https://cdn.jsdelivr.net/npm/sortablejs@1.15.6/+esm'; -import Handlebars from 'https://cdn.jsdelivr.net/npm/handlebars@4.7.8/+esm'; -import { getContentNode, setMetaBatch } from '@cms/modules/rpc/rpc-content.js'; -// hook.js -export async function runAction(params) { - const contentNode = await getContentNode({ - url: getPreviewUrl() - }); - var template = Handlebars.compile(` -
    - {{#each sectionEntries}} -
  • - {{#if data.title}} - {{data.title}} - {{else}} - {{uri}} - {{/if}} -
  • - {{/each}} -
- `); - var sectionEntries = []; - if (contentNode.result.sections[params.section]) { - var sectionEntries = contentNode.result.sections[params.section]; - } - sectionEntries = sectionEntries.sort((a, b) => a.index - b.index); - openModal({ - title: 'Edit items', - body: template({ sectionEntries: sectionEntries }), - fullscreen: false, - onCancel: (event) => { }, - onOk: async (event) => { - await saveSections(); - showToast({ - title: 'Entry saved', - message: 'Entry successfuly saved.', - type: 'success', // optional: info | success | warning | error - timeout: 3000 - }); - await new Promise(resolve => setTimeout(resolve, 1000)); - reloadPreview(); - }, - onShow: () => { - document.querySelectorAll(".cms-sortable").forEach(elem => { - var sortable = Sortable.create(elem, { - handle: '[data-cms-section-handle]' - }); - }); - } - }); -} -const saveSections = async () => { - const items = document.querySelectorAll(".cms-sortable li"); - var updates = []; - for (const [index, el] of Array.from(items).entries()) { - var uri = el.dataset.cmsSectionUri; - updates.push({ - uri: uri, - meta: { - "layout.order": { - type: 'number', - value: parseInt(index) - } - } - }); - } - await setMetaBatch({ - updates: updates - }); -}; diff --git a/modules/ui-module/src/main/ts/dist/actions/page/list-unpublished-pages.d.ts b/modules/ui-module/src/main/ts/dist/actions/page/list-unpublished-pages.d.ts deleted file mode 100644 index 8052ef2c6..000000000 --- a/modules/ui-module/src/main/ts/dist/actions/page/list-unpublished-pages.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -interface ListUnpublishedPagesOptions { - page?: number; -} -export declare const runAction: (options?: ListUnpublishedPagesOptions) => Promise; -export {}; diff --git a/modules/ui-module/src/main/ts/dist/actions/page/list-unpublished-pages.js b/modules/ui-module/src/main/ts/dist/actions/page/list-unpublished-pages.js deleted file mode 100644 index a5ecece14..000000000 --- a/modules/ui-module/src/main/ts/dist/actions/page/list-unpublished-pages.js +++ /dev/null @@ -1,122 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { openModal } from '@cms/modules/modal.js'; -import { i18n } from '@cms/modules/localization.js'; -import { filterPages } from '@cms/modules/rpc/rpc-page'; -import { loadPreview } from '@cms/modules/preview.utils'; -const ITEMS_PER_PAGE = 5; // Feste Seitengröße wie angefordert -const renderPageListHtml = (pages, currentPage, totalPages) => { - let pageItemsHtml = ''; - if (pages.length === 0) { - pageItemsHtml = `

${i18n.t('page.unpublished.noPages', 'No unpublished pages found.')}

`; - } - else { - pageItemsHtml = ` - - `; - } - const paginationHtml = ` - - `; - return ` -
- ${pageItemsHtml} - ${paginationHtml} -
- `; -}; -const state = { - modal: null -}; -const updateDialog = async (pageNumber) => { - const filterOptions = { - where: [ - { - field: "published", - operator: "=", - value: false - } - ], - page: pageNumber, - size: ITEMS_PER_PAGE - }; - const response = await filterPages(filterOptions); - var pageData = response.result; - const modalBodyHtml = renderPageListHtml(pageData.items, pageData.page, pageData.totalPages); - var modalElement = document.getElementById('cms-unpublished-pages-modal-body'); - if (modalElement) { - modalElement.innerHTML = modalBodyHtml; - modalElement.querySelectorAll('.page-link').forEach(link => { - link.addEventListener('click', (e) => { - e.preventDefault(); - const newPage = parseInt(e.target.dataset.page || '1'); - if (newPage >= 1 && newPage <= pageData.totalPages) { - updateDialog(newPage); - } - }); - }); - modalElement.querySelectorAll('a[data-cms-page-uri]').forEach((link) => { - link.addEventListener('click', (e) => { - e.preventDefault(); - state.modal.hide(); - loadPreview(link.dataset.cmsPageUri || ''); - }); - }); - } -}; -export const runAction = async (options = {}) => { - let currentPage = options.page || 1; - state.modal = openModal({ - title: i18n.t('page.unpublished.title', 'Unpublished Pages'), - body: "
", - fullscreen: false, - onCancel: () => { }, - onOk: () => { }, - onShow: (modalElement) => { - updateDialog(currentPage); - } - }); -}; diff --git a/modules/ui-module/src/main/ts/dist/actions/page/manage-assets.d.ts b/modules/ui-module/src/main/ts/dist/actions/page/manage-assets.d.ts deleted file mode 100644 index 6abc321a1..000000000 --- a/modules/ui-module/src/main/ts/dist/actions/page/manage-assets.d.ts +++ /dev/null @@ -1 +0,0 @@ -export function runAction(params: any): Promise; diff --git a/modules/ui-module/src/main/ts/dist/actions/page/manage-assets.js b/modules/ui-module/src/main/ts/dist/actions/page/manage-assets.js deleted file mode 100644 index e9d22d620..000000000 --- a/modules/ui-module/src/main/ts/dist/actions/page/manage-assets.js +++ /dev/null @@ -1,27 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { openFileBrowser } from '@cms/modules/filebrowser.js'; -// hook.js -export async function runAction(params) { - openFileBrowser({ - type: "assets" - }); -} diff --git a/modules/ui-module/src/main/ts/dist/actions/page/section-set-published.d.ts b/modules/ui-module/src/main/ts/dist/actions/page/section-set-published.d.ts deleted file mode 100644 index 85620d3ab..000000000 --- a/modules/ui-module/src/main/ts/dist/actions/page/section-set-published.d.ts +++ /dev/null @@ -1 +0,0 @@ -export declare function runAction(params: any): Promise; diff --git a/modules/ui-module/src/main/ts/dist/actions/page/section-set-published.js b/modules/ui-module/src/main/ts/dist/actions/page/section-set-published.js deleted file mode 100644 index 7a408e61d..000000000 --- a/modules/ui-module/src/main/ts/dist/actions/page/section-set-published.js +++ /dev/null @@ -1,35 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { reloadPreview } from "@cms/modules/preview.utils"; -import { setMeta } from "@cms/modules/rpc/rpc-content"; -export async function runAction(params) { - var request = { - uri: params.sectionUri, - meta: { - published: { - type: "select", - value: params.published ? true : false, - } - } - }; - var setMetaResponse = await setMeta(request); - reloadPreview(); -} diff --git a/modules/ui-module/src/main/ts/dist/actions/page/translations.d.ts b/modules/ui-module/src/main/ts/dist/actions/page/translations.d.ts deleted file mode 100644 index 85620d3ab..000000000 --- a/modules/ui-module/src/main/ts/dist/actions/page/translations.d.ts +++ /dev/null @@ -1 +0,0 @@ -export declare function runAction(params: any): Promise; diff --git a/modules/ui-module/src/main/ts/dist/actions/page/translations.js b/modules/ui-module/src/main/ts/dist/actions/page/translations.js deleted file mode 100644 index f026bca19..000000000 --- a/modules/ui-module/src/main/ts/dist/actions/page/translations.js +++ /dev/null @@ -1,115 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { openFileBrowser } from '@cms/modules/filebrowser.js'; -import { i18n } from '@cms/modules/localization.js'; -import { openModal } from '@cms/modules/modal.js'; -import { getPreviewUrl } from '@cms/modules/preview.utils.js'; -import { getContentNode } from '@cms/modules/rpc/rpc-content.js'; -import { addTranslation, getTranslations } from '@cms/modules/rpc/rpc-translation.js'; -import { showToast } from '@cms/modules/toast.js'; -// hook.js -export async function runAction(params) { - const contentNode = await getContentNode({ - url: getPreviewUrl() - }); - const uri = contentNode.result.uri; - var translations = await getTranslations({ uri: uri }); - var modelContent = createTranslationsTable(translations.translations); - openModal({ - title: 'Manage Translations', - body: modelContent, - onCancel: (event) => { }, - onOk: async (event) => { - }, - onShow: async (modalElement) => { - modalElement.querySelectorAll('button[data-action]').forEach((button) => { - button.addEventListener('click', async (e) => { - const action = e.currentTarget.getAttribute('data-action'); - const siteId = e.currentTarget.getAttribute('data-id'); - const lang = e.currentTarget.getAttribute('data-lang'); - if (action === 'select') { - // Open file browser to select existing translation - openFileBrowser({ - siteId: siteId || '', - type: 'content', - onSelect: async (file) => { - console.log('Selected translation file:', file); - if (file && file.uri) { - var selectedFile = file.uri; // Use the file's URI - await addTranslation({ - uri: uri, - language: lang || '', - translationUri: selectedFile - }); - showToast({ - title: i18n.t('manager.translation.added.title', "Translation Added"), - message: i18n.t('manager.translation.added.message', "Translation successfuly added."), - type: 'success', // optional: info | success | warning | error - timeout: 3000 - }); - } - } - }); - } - }); - }); - } - }); -} -function createTranslationsTable(translations) { - const table = document.createElement('table'); - table.className = 'table table-striped table-bordered'; - table.innerHTML = ` - - - Language - Site - Status - Actions - - - - ${translations.map(translation => createTranslationRow(translation)).join('')} - - `; - return table.outerHTML; -} -function createTranslationRow(translation) { - const status = translation.managerDeepLink ? `Linked` : 'Not linked'; - return ` - - - ${translation.site} - ${status} - - ${getActionButtons(translation)} - - - `; -} -function getActionButtons(translation) { - let buttons = ''; - buttons += ``; - if (translation.url) { - buttons += ``; - } - return buttons; -} diff --git a/modules/ui-module/src/main/ts/dist/actions/reload-preview.d.ts b/modules/ui-module/src/main/ts/dist/actions/reload-preview.d.ts deleted file mode 100644 index 85620d3ab..000000000 --- a/modules/ui-module/src/main/ts/dist/actions/reload-preview.d.ts +++ /dev/null @@ -1 +0,0 @@ -export declare function runAction(params: any): Promise; diff --git a/modules/ui-module/src/main/ts/dist/actions/reload-preview.js b/modules/ui-module/src/main/ts/dist/actions/reload-preview.js deleted file mode 100644 index b46cabed9..000000000 --- a/modules/ui-module/src/main/ts/dist/actions/reload-preview.js +++ /dev/null @@ -1,24 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { reloadPreview } from "@cms/modules/preview.utils.js"; -export async function runAction(params) { - reloadPreview(); -} diff --git a/modules/ui-module/src/main/ts/dist/actions/site-change.d.ts b/modules/ui-module/src/main/ts/dist/actions/site-change.d.ts deleted file mode 100644 index ba8a4fff2..000000000 --- a/modules/ui-module/src/main/ts/dist/actions/site-change.d.ts +++ /dev/null @@ -1 +0,0 @@ -export function runAction(parameters: any): Promise; diff --git a/modules/ui-module/src/main/ts/dist/actions/site-change.js b/modules/ui-module/src/main/ts/dist/actions/site-change.js deleted file mode 100644 index f76f45d62..000000000 --- a/modules/ui-module/src/main/ts/dist/actions/site-change.js +++ /dev/null @@ -1,23 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -export async function runAction(parameters) { - window.location.href = parameters.href; -} diff --git a/modules/ui-module/src/main/ts/dist/actions/test-command.d.ts b/modules/ui-module/src/main/ts/dist/actions/test-command.d.ts deleted file mode 100644 index 6abc321a1..000000000 --- a/modules/ui-module/src/main/ts/dist/actions/test-command.d.ts +++ /dev/null @@ -1 +0,0 @@ -export function runAction(params: any): Promise; diff --git a/modules/ui-module/src/main/ts/dist/actions/test-command.js b/modules/ui-module/src/main/ts/dist/actions/test-command.js deleted file mode 100644 index ab354e896..000000000 --- a/modules/ui-module/src/main/ts/dist/actions/test-command.js +++ /dev/null @@ -1,32 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { executeCommand } from '@cms/modules/system-commands.js'; -import { getPreviewUrl } from '@cms/modules/preview.utils.js'; -// hook.js -export async function runAction(params) { - var contentNode = await executeCommand({ - command: "getContentNode", - parameters: { - url: getPreviewUrl() - } - }); - console.log(contentNode); -} diff --git a/modules/ui-module/src/main/ts/dist/js/manager-globals.d.ts b/modules/ui-module/src/main/ts/dist/js/manager-globals.d.ts deleted file mode 100644 index 255f59f32..000000000 --- a/modules/ui-module/src/main/ts/dist/js/manager-globals.d.ts +++ /dev/null @@ -1,17 +0,0 @@ -export function executeScriptAction(action: any): Promise; -export function executeHookAction(action: any): Promise; -/** - * Patches a relative path so that it's correctly prefixed with the given manager base path. - * - * @param {string} relativePath e.g. "/manager/module" - * @param {string} managerBasePath e.g. "/manager" or "/de/manager" - * @returns {string} e.g. "/de/manager/module" - */ -export function patchManagerPath(relativePath: string, managerBasePath: string): string; -/** - * Patches a path with the context path, if not already present. - * - * @param {string} path - The original path (e.g. "/assets/images/test.jpg"). - * @returns {string} - The patched path with context prefix if needed. - */ -export function patchPathWithContext(path: string): string; diff --git a/modules/ui-module/src/main/ts/dist/js/manager-globals.js b/modules/ui-module/src/main/ts/dist/js/manager-globals.js deleted file mode 100644 index 8a78f957b..000000000 --- a/modules/ui-module/src/main/ts/dist/js/manager-globals.js +++ /dev/null @@ -1,98 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { getCSRFToken } from "./modules/utils"; -export async function executeScriptAction(action) { - if (action.module && action.function === "runAction") { - var modulePath = patchManagerPath(action.module, window.manager.baseUrl); - import(modulePath) - .then(mod => { - if (typeof mod[action.function] === "function") { - mod[action.function](action.parameters || {}); - } - else { - console.error("Function runAction not found", action.module); - } - }) - .catch(err => { - if (err && (err.status === 403 || (err.message && err.message.includes("403")))) { - alert(i18n.t("ui.redirect.login", "You where logged out due to inactivity. Please log in again.")); - window.location.href = window.manager.baseUrl + "/login"; - } - else { - console.error("Error loading module:", action.module, err); - } - }); - } -} -export async function executeHookAction(action) { - var data = { - hook: action.hook - }; - if (action.parameters) { - data.parameters = action.parameters; - } - const response = await fetch(window.manager.baseUrl + "/hooks", { - headers: { - 'Content-Type': 'application/json', - 'X-CSRF-Token': getCSRFToken() - }, - method: "POST", - body: JSON.stringify(data) - }); -} -/** - * Patches a relative path so that it's correctly prefixed with the given manager base path. - * - * @param {string} relativePath e.g. "/manager/module" - * @param {string} managerBasePath e.g. "/manager" or "/de/manager" - * @returns {string} e.g. "/de/manager/module" - */ -export function patchManagerPath(relativePath, managerBasePath) { - if (!relativePath || !managerBasePath) { - throw new Error("Both paths must be provided."); - } - // Remove trailing slash from base path if present - const base = managerBasePath.endsWith('/') ? managerBasePath.slice(0, -1) : managerBasePath; - // Ensure relative path starts with a slash - const rel = relativePath.startsWith('/') ? relativePath : '/' + relativePath; - // If the relative path already starts with the base, avoid double prefixing - if (rel.startsWith(base)) { - return rel; - } - return base + rel; -} -/** - * Patches a path with the context path, if not already present. - * - * @param {string} path - The original path (e.g. "/assets/images/test.jpg"). - * @returns {string} - The patched path with context prefix if needed. - */ -export function patchPathWithContext(path) { - const contextPath = window.manager.contextPath || "/"; - // Normalize context path (remove trailing slash if not just "/") - const normalizedContext = contextPath !== "/" ? contextPath.replace(/\/+$/, "") : ""; - // Check if the path already starts with the context - if (normalizedContext && path.startsWith(normalizedContext + "/")) { - return path; - } - // Patch path (avoid double slashes) - return normalizedContext + (path.startsWith("/") ? path : "/" + path); -} diff --git a/modules/ui-module/src/main/ts/dist/js/manager-inject-init.d.ts b/modules/ui-module/src/main/ts/dist/js/manager-inject-init.d.ts deleted file mode 100644 index de2be067b..000000000 --- a/modules/ui-module/src/main/ts/dist/js/manager-inject-init.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export function initIframe(): void; -export function isSectionPublishedExpired(section: any): boolean; diff --git a/modules/ui-module/src/main/ts/dist/js/manager-inject-init.js b/modules/ui-module/src/main/ts/dist/js/manager-inject-init.js deleted file mode 100644 index 39935f0d8..000000000 --- a/modules/ui-module/src/main/ts/dist/js/manager-inject-init.js +++ /dev/null @@ -1,121 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import frameMessenger from '@cms/modules/frameMessenger.js'; -import { initContentMediaToolbar, initMediaToolbar, initMediaUploadOverlay } from '@cms/modules/manager/media.inject.js'; -import { EDIT_ATTRIBUTES_ICON, EDIT_PAGE_ICON, SECTION_ADD_ICON, SECTION_DELETE_ICON, SECTION_PUBLISHED_ICON, SECTION_SORT_ICON, SECTION_UNPUBLISHED_ICON } from '@cms/modules/manager/toolbar-icons'; -import { initToolbar } from '@cms/modules/manager/toolbar.inject.js'; -const isIframe = () => { - return typeof window !== 'undefined' && window.self !== window.top; -}; -export function initIframe() { - if (!isIframe()) { - return; - } - frameMessenger.send(window.parent, { - type: 'loaded', - payload: {} - }); - const toolbarContainers = document.querySelectorAll('[data-cms-toolbar]'); - toolbarContainers.forEach(initToolbar); - const mediaToolbarContainers = document.querySelectorAll('img[data-cms-media-toolbar]'); - mediaToolbarContainers.forEach(initMediaToolbar); - const contentMediaContainers = document.querySelectorAll('img[data-cms-ui-selector=content-image]'); - contentMediaContainers.forEach(initContentMediaToolbar); - //const mediaUploadContainers = document.querySelectorAll('img[data-cms-media-actions~=upload]'); - //mediaUploadContainers.forEach(initMediaUploadOverlay); - document.addEventListener('keydown', (event) => { - if (event.key.toLowerCase() === 'k' && (event.metaKey || event.ctrlKey)) { - event.preventDefault(); - frameMessenger.send(window.parent, { - type: 'shortkeys', - payload: {} - }); - } - }); - frameMessenger.on('getContentNodeResponse', async (payload) => { - for (const [sectionName, items] of Object.entries(payload.contentNode.sections)) { - for (const item of items) { - const sectionContainer = document.querySelector(`[data-cms-section-uri="${item.uri}"]`); - if (!sectionContainer) { - continue; - } - if (item.data.published) { - sectionContainer.setAttribute('data-cms-action', 'unpublish'); - sectionContainer.setAttribute("title", "Unpublish"); - if (isSectionPublishedExpired(item)) { - sectionContainer.innerHTML = SECTION_UNPUBLISHED_ICON; - sectionContainer.classList.remove('cms-unpublished'); - sectionContainer.classList.remove('cms-published'); - sectionContainer.classList.add('cms-published-expired'); - } - else { - sectionContainer.innerHTML = SECTION_PUBLISHED_ICON; - sectionContainer.classList.remove('cms-unpublished'); - sectionContainer.classList.remove('cms-published-expired'); - sectionContainer.classList.add('cms-published'); - } - } - else { - sectionContainer.innerHTML = SECTION_UNPUBLISHED_ICON; - sectionContainer.setAttribute('data-cms-action', 'publish'); - sectionContainer.setAttribute("title", "Publish"); - sectionContainer.classList.remove('cms-published'); - sectionContainer.classList.remove('cms-published-expired'); - sectionContainer.classList.add('cms-unpublished'); - } - } - } - }); - frameMessenger.send(window.parent, { - type: 'getContentNode', - payload: {} - }); - document.addEventListener('click', function (event) { - if (event.target.matches('[data-cms-action]')) { - const button = event.target; - // Wenn bereits disabled, nichts tun - if (button.disabled) { - event.preventDefault(); - return; - } - // Button deaktivieren - button.disabled = true; - // Nach 2 Sekunden wieder aktivieren - setTimeout(() => { - button.disabled = false; - }, 2000); - } - }); -} -; -export function isSectionPublishedExpired(section) { - const publishDateStr = section.data.publish_date; - const unpublishDateStr = section.data.unpublish_date; - const now = new Date(); - const publishDate = publishDateStr ? new Date(publishDateStr) : null; - const unpublishDate = unpublishDateStr ? new Date(unpublishDateStr) : null; - // section is published if: - // - publishDate empty or in the past - // - und unpublishDate empty or in the future - const isPublished = (!publishDate || publishDate <= now) && - (!unpublishDate || unpublishDate > now); - return !isPublished; -} diff --git a/modules/ui-module/src/main/ts/dist/js/manager-inject.d.ts b/modules/ui-module/src/main/ts/dist/js/manager-inject.d.ts deleted file mode 100644 index e69de29bb..000000000 diff --git a/modules/ui-module/src/main/ts/dist/js/manager-inject.js b/modules/ui-module/src/main/ts/dist/js/manager-inject.js deleted file mode 100644 index 2b11d2b1d..000000000 --- a/modules/ui-module/src/main/ts/dist/js/manager-inject.js +++ /dev/null @@ -1,48 +0,0 @@ -"use strict"; -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -(async function () { - // Basis-URLs aus Parent ableiten - const parentManager = window.parent?.manager || {}; - const baseUrl = parentManager.baseUrl || '/manager'; - const contextPath = parentManager.contextPath || '/'; - const importMap = { - imports: { - "@cms/js/": `${baseUrl}/js/`, - "@cms/libs/": `${baseUrl}/js/libs/`, - "@cms/manager/": `${baseUrl}/js/manager/`, - "@cms/modules/": `${baseUrl}/js/modules/` - } - }; - // 2. Import Map setzen - const script = document.createElement('script'); - script.type = 'importmap'; - script.textContent = JSON.stringify(importMap); - script.onload = () => { - resolve(); - }; - document.head.appendChild(script); - // 3. window.manager kopieren - window.manager = parentManager; - // 4. Plugins laden - const { initIframe } = await import('@cms/js/manager-inject-init.js'); - initIframe(); -})(); diff --git a/modules/ui-module/src/main/ts/dist/js/manager.d.ts b/modules/ui-module/src/main/ts/dist/js/manager.d.ts deleted file mode 100644 index cb0ff5c3b..000000000 --- a/modules/ui-module/src/main/ts/dist/js/manager.d.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/modules/ui-module/src/main/ts/dist/js/manager.js b/modules/ui-module/src/main/ts/dist/js/manager.js deleted file mode 100644 index 506b4e966..000000000 --- a/modules/ui-module/src/main/ts/dist/js/manager.js +++ /dev/null @@ -1,97 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import frameMessenger from '@cms/modules/frameMessenger.js'; -import { activatePreviewOverlay, getPreviewFrame, loadPreview } from '@cms/modules/preview.utils.js'; -import { UIStateManager } from '@cms/modules/ui-state.js'; -import { updateStateButton } from '@cms/modules/manager-ui.js'; -import { EventBus } from '@cms/modules/event-bus.js'; -import { initMessageHandlers } from '@cms/modules/manager/manager.message.handlers.js'; -import { createCSRFToken } from '@cms/modules/rpc/rpc-manager.js'; -import { setCSRFToken } from '@cms/modules/utils.js'; -frameMessenger.on('load', (payload) => { - EventBus.emit("preview:loaded", {}); -}); -function heartbeat() { - fetch(window.manager.refreshUrl, { - method: "POST", - credentials: "include" - }) - .then(res => res.json()) - .then(data => { - window.manager.previewToken = data.previewToken; - }); -} -document.addEventListener("DOMContentLoaded", function () { - setInterval(() => { - heartbeat(); - }, 10 * 60 * 1000); - //PreviewHistory.init("/"); - //updateStateButton(); - activatePreviewOverlay(); - const intervalId = window.setInterval(() => { - var token = createCSRFToken({}); - token.then((token) => { - setCSRFToken(token.result); - }); - }, 5 * 60 * 1000); - const iframe = getPreviewFrame(); - iframe.addEventListener("load", previewLoadedHandler); - const urlParams = new URLSearchParams(window.location.search); - const pageUrl = urlParams.get('page'); - /* - page param is use for deeplinks when changing translation - */ - if (pageUrl) { - loadPreview(pageUrl); - // Clean the URL - const newUrl = window.location.pathname; - window.history.replaceState({}, document.title, newUrl); - } - else { - const preview = UIStateManager.getTabState("preview", null); - if (preview && preview.siteId === window.manager.siteId) { - loadPreview(preview.url); - } - else { - loadPreview(window.manager.previewUrl); - } - } - initMessageHandlers(); -}); -const previewLoadedHandler = () => { - try { - const iframe = getPreviewFrame(); - const currentUrl = iframe.contentWindow.location.href; - const url = new URL(currentUrl); - const preview_url = url.pathname + url.search; - const preview_update = { - url: preview_url, - siteId: window.manager.siteId - }; - UIStateManager.setTabState("preview", preview_update); - updateStateButton(); - EventBus.emit("preview:loaded", {}); - } - catch (e) { - console.log(e); - } -}; -// DOMContentLoaded end diff --git a/modules/ui-module/src/main/ts/dist/js/modules/alerts.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/alerts.d.ts deleted file mode 100644 index 629a61d8f..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/alerts.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -export function alertSelect(options: any): Promise; -export function alertError(options: any): void; -export function alertConfirm(options: any): Promise; -export function alertPrompt(options: any): Promise; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/alerts.js b/modules/ui-module/src/main/ts/dist/js/modules/alerts.js deleted file mode 100644 index c24992bd0..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/alerts.js +++ /dev/null @@ -1,81 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { openModal } from '@cms/modules/modal.js'; -import { i18n } from '@cms/modules/localization.js'; -const alertSelect = (options) => { - return new Promise((resolve) => { - const modalBody = ` - `; - openModal({ - title: options.title || i18n.t("alerts.select.title", "Select element"), - body: modalBody, - onOk: () => { - const selectedValue = document.getElementById('modalSelect').value; - resolve(selectedValue); - }, - onCancel: () => resolve(null) - }); - }); -}; -const alertError = (options) => { - openModal({ - title: options.title || i18n.t("alerts.error.title", "Error"), - body: `

${options.message || i18n.t("alerts.error.message", "Some error occured")}

`, - }); -}; -const alertConfirm = (options) => { - return new Promise((resolve) => { - openModal({ - title: options.title || i18n.t("alerts.confirm.title", "Are you sure?"), - body: `

${options.message || i18n.t("alerts.confirm.message", "You won't be able to revert this!")}

`, - onOk: () => resolve(true), - onCancel: () => resolve(false) - }); - }); -}; -const alertPrompt = (options) => { - return new Promise((resolve) => { - const modalBody = ` - - `; - openModal({ - title: options.title || i18n.t("alerts.prompt.title", "Enter value?"), - body: modalBody, - validate: () => { - const value = document.getElementById('modalInput').value; - if (options.validator) { - const validationResult = options.validator(value); - return validationResult === null || validationResult === undefined; - } - return true; - }, - onOk: () => { - const value = document.getElementById('modalInput').value; - resolve(value); - }, - onCancel: () => resolve(null) - }); - }); -}; -export { alertSelect, alertError, alertConfirm, alertPrompt }; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/event-bus.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/event-bus.d.ts deleted file mode 100644 index d44295919..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/event-bus.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -export namespace EventBus { - function on(event: any, handler: any): void; - function emit(event: any, payload: any): void; -} diff --git a/modules/ui-module/src/main/ts/dist/js/modules/event-bus.js b/modules/ui-module/src/main/ts/dist/js/modules/event-bus.js deleted file mode 100644 index 16ee9dff6..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/event-bus.js +++ /dev/null @@ -1,29 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -const listeners = {}; -export const EventBus = { - on(event, handler) { - (listeners[event] || (listeners[event] = [])).push(handler); - }, - emit(event, payload) { - (listeners[event] || []).forEach(fn => fn(payload)); - } -}; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/filebrowser.template.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/filebrowser.template.d.ts deleted file mode 100644 index 72c47da10..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/filebrowser.template.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { template as filebrowserTemplate }; -declare const template: any; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/filebrowser.template.js b/modules/ui-module/src/main/ts/dist/js/modules/filebrowser.template.js deleted file mode 100644 index 154a666f3..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/filebrowser.template.js +++ /dev/null @@ -1,150 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import Handlebars from 'https://cdn.jsdelivr.net/npm/handlebars@4.7.8/+esm'; -import { patchPathWithContext } from "@cms/js/manager-globals"; -Handlebars.registerHelper("patchPathWithContext", patchPathWithContext); -Handlebars.registerHelper('concat', function (...args) { - args.pop(); - return args.join(''); -}); -Handlebars.registerHelper('ifNotEquals', function (arg1, arg2, options) { - return (arg1 !== arg2) ? options.fn(this) : options.inverse(this); -}); -Handlebars.registerPartial('fileBrowserContentActions', ` - {{#if pageTemplates}} - - {{/if}} -`); -const template = Handlebars.compile(` -
-
- - - {{#unless asset}} - {{> fileBrowserContentActions pageTemplates=pageContentTypes }} - {{/unless}} -
- - - - - - - - - - {{#each files}} - - - - - - {{/each}} - -
{{filenameHeader}}{{actionHeader}}
- {{#if directory}} - - {{else if media}} -
- {{name}} -
- Zoom -
-
- {{else}} - - {{/if}} -
{{name}} - {{#if directory}} - {{#ifNotEquals name ".."}} - - {{/ifNotEquals}} - {{else if content}} - - - - {{else}} - - {{/if}} - {{#ifNotEquals name ".."}} - - {{/ifNotEquals}} -
- {{#if asset}} - - - -
Drop files here
- {{/if}} -
-`); -export { template as filebrowserTemplate }; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/form/field.checkbox.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/form/field.checkbox.d.ts deleted file mode 100644 index d2a0c9280..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/form/field.checkbox.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { FieldOptions, FormField } from "@cms/modules/form/forms.js"; -export interface CheckboxOptions extends FieldOptions { - key?: string; - options?: { - choices: Array<{ - label: string; - value: string; - }>; - }; -} -export declare const CheckboxField: FormField; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/form/field.checkbox.js b/modules/ui-module/src/main/ts/dist/js/modules/form/field.checkbox.js deleted file mode 100644 index 3efa4721d..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/form/field.checkbox.js +++ /dev/null @@ -1,48 +0,0 @@ -import { createID } from "@cms/modules/form/utils.js"; -const createCheckboxField = (options, value = []) => { - const id = createID(); - const key = options.key || ""; - const name = options.name || id; - const title = options.title || ""; - const choices = options.options?.choices || []; - const selectedValues = new Set(value); - const checkboxes = choices.map((choice, idx) => { - const inputId = `${id}-${idx}`; - const checked = selectedValues.has(choice.value) ? 'checked' : ''; - return ` -
- - -
- `; - }).join(''); - return ` -
- - ${checkboxes} -
- `; -}; -const getData = (context) => { - var data = {}; - if (!context.formElement) { - return data; - } - context.formElement.querySelectorAll("[data-cms-form-field-type='checkbox']").forEach(container => { - const name = container.querySelector("input[type='checkbox']").name; - const checkedBoxes = container.querySelectorAll("input[type='checkbox']:checked"); - const values = Array.from(checkedBoxes).map((el) => el.value); - data[name] = { - type: 'checkbox', - value: values - }; - }); - return data; -}; -export const CheckboxField = { - markup: createCheckboxField, - init: (context) => { }, - data: getData -}; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/form/field.code.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/form/field.code.d.ts deleted file mode 100644 index ada1f20f1..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/form/field.code.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -export namespace CodeField { - export { createCodeField as markup }; - export { init }; - export { getData as data }; -} -declare function createCodeField(options: any, value?: string): string; -declare function init(context: any): void; -declare function getData(context: any): {}; -export {}; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/form/field.code.js b/modules/ui-module/src/main/ts/dist/js/modules/form/field.code.js deleted file mode 100644 index 0b5b38657..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/form/field.code.js +++ /dev/null @@ -1,68 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { createID } from "@cms/modules/form/utils.js"; -import { i18n } from "@cms/modules/localization.js"; -let monacoEditors = []; -const createCodeField = (options, value = '') => { - const id = createID(); - const key = "field." + options.name; - const title = i18n.t(key, options.title); - return ` -
- -
- -
- `; -}; -const getData = (context) => { - var data = {}; - monacoEditors.forEach(({ input, editor }) => { - data[input.name] = { - type: 'code', - value: editor.getValue() - }; - }); - return data; -}; -const init = (context) => { - monacoEditors = []; - require.config({ paths: { vs: 'https://cdn.jsdelivr.net/npm/monaco-editor@0.52.2/min/vs' } }); - require(['vs/editor/editor.main'], function () { - const editorInputs = document.querySelectorAll('[data-cms-form-field-type="code"] input'); - editorInputs.forEach(input => { - const editorContainer = document.getElementById(input.dataset.monacoId); - const initialValue = decodeURIComponent(input.dataset.initialValue || ""); - const editor = monaco.editor.create(editorContainer, { - value: initialValue, - language: 'markdown', - //theme: 'vs-dark', - automaticLayout: true - }); - monacoEditors.push({ input, editor }); - }); - }); -}; -export const CodeField = { - markup: createCodeField, - init: init, - data: getData -}; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/form/field.color.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/form/field.color.d.ts deleted file mode 100644 index cab0d2e87..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/form/field.color.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { FieldOptions, FormField } from "@cms/modules/form/forms.js"; -export interface ColorFieldOptions extends FieldOptions { -} -export declare const ColorField: FormField; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/form/field.color.js b/modules/ui-module/src/main/ts/dist/js/modules/form/field.color.js deleted file mode 100644 index 6cfba7fd7..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/form/field.color.js +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { createID } from "@cms/modules/form/utils.js"; -import { i18n } from "@cms/modules/localization.js"; -const createColorField = (options, value = '#000000') => { - const id = createID(); - const key = "field." + options.name; - const title = i18n.t(key, options.title); - return ` -
- - -
- `; -}; -const getColorData = (context) => { - const data = {}; - if (!context.formElement) { - return data; - } - context.formElement.querySelectorAll("[data-cms-form-field-type='color'] input").forEach((el) => { - data[el.name] = { - type: 'color', - value: el.value - }; - }); - return data; -}; -export const ColorField = { - markup: createColorField, - init: (context) => { }, - data: getColorData -}; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/form/field.date.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/form/field.date.d.ts deleted file mode 100644 index f07e3cc6e..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/form/field.date.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { FieldOptions, FormField } from "@cms/modules/form/forms.js"; -export interface DateFieldOptions extends FieldOptions { - placeholder?: string; -} -export declare const DateField: FormField; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/form/field.date.js b/modules/ui-module/src/main/ts/dist/js/modules/form/field.date.js deleted file mode 100644 index 4a090c7e8..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/form/field.date.js +++ /dev/null @@ -1,60 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { createID, getUTCDateFromInput, utcToLocalDateInputValue } from "@cms/modules/form/utils.js"; -import { i18n } from "@cms/modules/localization.js"; -const createDateField = (options, value = '') => { - const placeholder = options.placeholder || ""; - const id = createID(); - const key = "field." + options.name; - const title = i18n.t(key, options.title); - let val = ''; - if (value instanceof Date) { - val = utcToLocalDateInputValue(value.toISOString()); - } - else if (typeof value === 'string' && value.length > 0) { - val = utcToLocalDateInputValue(value); - } - return ` -
- - -
- `; -}; -const getDateData = (context) => { - const data = {}; - if (!context.formElement) { - return data; - } - context.formElement.querySelectorAll("[data-cms-form-field-type='date'] input").forEach((el) => { - const value = getUTCDateFromInput(el); // "2025-05-31" - data[el.name] = { - type: "date", - value: value === "" ? null : value - }; // Format: "YYYY-MM-DD" - }); - return data; -}; -export const DateField = { - markup: createDateField, - init: (context) => { }, - data: getDateData -}; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/form/field.datetime.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/form/field.datetime.d.ts deleted file mode 100644 index 272202696..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/form/field.datetime.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { FieldOptions, FormField } from "@cms/modules/form/forms.js"; -export interface DateTimeFieldOptions extends FieldOptions { - placeholder?: string; -} -export declare const DateTimeField: FormField; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/form/field.datetime.js b/modules/ui-module/src/main/ts/dist/js/modules/form/field.datetime.js deleted file mode 100644 index 8df816d5e..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/form/field.datetime.js +++ /dev/null @@ -1,60 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { createID, getUTCDateTimeFromInput, utcToLocalDateTimeInputValue } from "@cms/modules/form/utils.js"; -import { i18n } from "@cms/modules/localization.js"; -const createDateTimeField = (options, value = '') => { - const placeholder = options.placeholder || ""; - const id = createID(); - const key = "field." + options.name; - const title = i18n.t(key, options.title); - let val = ''; - if (value instanceof Date) { - val = utcToLocalDateTimeInputValue(value.toISOString()); - } - else if (typeof value === 'string' && value.length > 0) { - val = utcToLocalDateTimeInputValue(value); - } - return ` -
- - -
- `; -}; -const getDateTimeData = (context) => { - const data = {}; - if (!context.formElement) { - return data; - } - context.formElement.querySelectorAll("[data-cms-form-field-type='datetime'] input").forEach((el) => { - const value = getUTCDateTimeFromInput(el); // "2025-05-31T15:30" - data[el.name] = { - type: 'datetime', - value: value === "" ? null : value - }; - }); - return data; -}; -export const DateTimeField = { - markup: createDateTimeField, - init: (context) => { }, - data: getDateTimeData -}; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/form/field.divider.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/form/field.divider.d.ts deleted file mode 100644 index f57944c90..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/form/field.divider.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { FieldOptions, FormField } from "@cms/modules/form/forms.js"; -export interface DividerOptions extends FieldOptions { -} -export declare const Divider: FormField; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/form/field.divider.js b/modules/ui-module/src/main/ts/dist/js/modules/form/field.divider.js deleted file mode 100644 index 2bf07f1bf..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/form/field.divider.js +++ /dev/null @@ -1,40 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { i18n } from "@cms/modules/localization.js"; -const createDivider = (options, value) => { - const key = "field." + options.name; - const title = i18n.t(key, options.title || ""); - const showTitle = title && title.trim().length > 0; - return ` -
-
- ${showTitle ? `
${title}
` : ""} -
- `; -}; -const getData = (context) => { - return {}; // Divider liefert keine Daten zurück -}; -export const Divider = { - markup: createDivider, - init: (context) => { }, - data: getData -}; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/form/field.easymde.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/form/field.easymde.d.ts deleted file mode 100644 index 9ac807575..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/form/field.easymde.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { FieldOptions, FormField } from "@cms/modules/form/forms.js"; -export interface EasyMDEFieldOptions extends FieldOptions { -} -export declare const EasyMDEField: FormField; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/form/field.easymde.js b/modules/ui-module/src/main/ts/dist/js/modules/form/field.easymde.js deleted file mode 100644 index 12e86fe6e..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/form/field.easymde.js +++ /dev/null @@ -1,70 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { createID } from "@cms/modules/form/utils.js"; -import { i18n } from "@cms/modules/localization.js"; -let markdownEditors = []; -const createMarkdownField = (options, value = '') => { - const id = createID(); - const key = "field." + options.name; - const title = i18n.t(key, options.title); - return ` -
- - -
- `; -}; -const getData = (context) => { - const data = {}; - if (!context.formElement) { - return data; - } - markdownEditors.forEach(({ input, editor }) => { - data[input.name] = { - type: "easymde", - value: editor.value() - }; - }); - return data; -}; -const init = (context) => { - markdownEditors = []; - const editorInputs = document.querySelectorAll('[data-cms-form-field-type="easymde"] textarea'); - editorInputs.forEach((input) => { - const initialValue = decodeURIComponent(input.dataset.initialValue || ""); - input.value = initialValue; // Set initial value for EasyMDE - const editor = new window.EasyMDE({ - element: input, - initialValue: initialValue, - autoDownloadFontAwesome: true, - spellChecker: false, - forceSync: true, // keeps textarea value updated - toolbar: ["bold", "italic", "heading", "|", "quote", "unordered-list", "ordered-list"] - }); - setTimeout(() => editor.codemirror.refresh(), 500); - markdownEditors.push({ input, editor }); - }); -}; -export const EasyMDEField = { - markup: createMarkdownField, - init: init, - data: getData -}; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/form/field.list.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/form/field.list.d.ts deleted file mode 100644 index 7bfcc69a9..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/form/field.list.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { FieldOptions, FormField } from "@cms/modules/form/forms.js"; -export interface ListFieldOptions extends FieldOptions { - options: { - nameField?: string; - }; -} -export declare const ListField: FormField; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/form/field.list.js b/modules/ui-module/src/main/ts/dist/js/modules/form/field.list.js deleted file mode 100644 index b7b60256e..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/form/field.list.js +++ /dev/null @@ -1,193 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { createID } from "@cms/modules/form/utils.js"; -import { i18n } from "@cms/modules/localization.js"; -import { createForm } from "@cms/modules/form/forms.js"; -import { openModal } from "@cms/modules/modal.js"; -import { buildValuesFromFields } from "@cms/modules/node.js"; -import { getListItemTypes, getPageTemplates } from "@cms/modules/rpc/rpc-manager.js"; -import { getContent, getContentNode } from "@cms/modules/rpc/rpc-content.js"; -import { getPreviewUrl } from "@cms/modules/preview.utils.js"; -const createListField = (options, value = []) => { - const id = createID(); - const key = "field." + options.name; - const title = i18n.t(key, options.title); - const nameField = options.options?.nameField || "name"; - var items = ""; - if (value) { - items = value.map((item, index) => { - const itemId = createID(); - return ` -
- ${item[nameField]} - -
- `; - }).join('\n'); - } - return ` -
- -
- ${items} -
- -
- `; -}; -const handleAddItem = (e, container, context) => { - e.preventDefault(); - const listGroup = container.querySelector(".list-group"); - if (!listGroup) - return; - const itemId = createID(); - const nameField = container.getAttribute('data-name-field') || 'name'; - const newItem = { [nameField]: "New Item" }; - const itemMarkup = ` -
- ${newItem[nameField]} - -
- `; - listGroup.insertAdjacentHTML("beforeend", itemMarkup); - const itemElement = listGroup.querySelector(`[data-cms-form-field-item="${itemId}"]`); - if (itemElement) { - itemElement.addEventListener('dblclick', (e) => handleDoubleClick(e, context)); - const removeBtn = itemElement.querySelector('.remove-btn'); - if (removeBtn) { - removeBtn.addEventListener('click', () => { - itemElement.remove(); - }); - } - } -}; -const getItemForm = async (el) => { - var pageTemplates = (await getPageTemplates({})).result; - const contentNode = await getContentNode({ - url: getPreviewUrl() - }); - const getContentResponse = await getContent({ - uri: contentNode.result.uri - }); - var selected = pageTemplates.filter((pageTemplate) => pageTemplate.template === getContentResponse?.result?.meta?.template); - const listContainer = el.closest("[data-cms-form-field-type='list']"); - const fieldName = listContainer?.getAttribute('name'); - var itemForm = []; - if (selected.length === 1) { - itemForm = (fieldName && selected[0].data?.forms[fieldName]) ? selected[0].data.forms[fieldName].fields : []; - } - if (!itemForm || itemForm.length === 0) { - let itemTypes = (await getListItemTypes({})).result; - var selectedItemType = itemTypes.filter((itemType) => itemType.name === fieldName); - itemForm = (selectedItemType.length === 1) ? selectedItemType[0].data?.form.fields : []; - } - return itemForm; -}; -const handleDoubleClick = async (event, context) => { - event.preventDefault(); - const el = event.currentTarget; - const itemDataString = el.getAttribute('data-cms-form-field-item-data'); - if (itemDataString) { - const itemData = JSON.parse(itemDataString); - var itemForm = await getItemForm(el); - const form = createForm({ - fields: itemForm, - values: { - ...buildValuesFromFields(itemForm, itemData) - } - }); - openModal({ - title: 'Edit Item', - fullscreen: true, - form: form, - onCancel: (event) => { }, - onOk: async (event) => { - var updateData = form.getRawData(); - el.setAttribute('data-cms-form-field-item-data', JSON.stringify(updateData)); - const listContainer = el.closest("[data-cms-form-field-type='list']"); - const nameField = listContainer?.getAttribute('data-name-field') || 'name'; - const objectNameEl = el.querySelector('.object-name'); - if (!objectNameEl) - return; - objectNameEl.textContent = updateData[nameField] || ""; - } - }); - } -}; -const getData = (context) => { - var data = {}; - if (!context.formElement) { - return data; - } - context.formElement.querySelectorAll("[data-cms-form-field-type='list']").forEach((el) => { - let value = []; - el.querySelectorAll("[data-cms-form-field-item]").forEach((itemEl) => { - const itemData = itemEl.getAttribute('data-cms-form-field-item-data'); - if (itemData) { - value.push(JSON.parse(itemData)); - } - }); - const fieldName = el.getAttribute('name'); - if (fieldName) { - data[fieldName] = { - type: 'list', - value: value - }; - } - }); - return data; -}; -const init = (context) => { - context.formElement?.querySelectorAll("[data-cms-form-field-type='list']").forEach(listContainer => { - listContainer.querySelectorAll("[data-cms-form-field-item]").forEach(field => { - field.addEventListener('dblclick', (e) => handleDoubleClick(e, context)); - // Remove-Button-Listener setzen - const removeBtn = field.querySelector('.remove-btn'); - if (removeBtn) { - removeBtn.addEventListener('click', () => { - field.remove(); - }); - } - }); - // Event-Listener für den "Add"-Button hinzufügen - const addButton = listContainer.querySelector("[data-cms-form-field-item-add-btn]"); - if (addButton) { - addButton.addEventListener("click", (e) => handleAddItem(e, listContainer, context)); - } - }); -}; -export const ListField = { - markup: createListField, - init: init, - data: getData -}; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/form/field.mail.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/form/field.mail.d.ts deleted file mode 100644 index 36f178178..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/form/field.mail.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { FieldOptions, FormField } from "@cms/modules/form/forms.js"; -export interface MailFieldOptions extends FieldOptions { - placeholder?: string; -} -export declare const MailField: FormField; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/form/field.mail.js b/modules/ui-module/src/main/ts/dist/js/modules/form/field.mail.js deleted file mode 100644 index cb4651b92..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/form/field.mail.js +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { createID } from "@cms/modules/form/utils.js"; -import { i18n } from "@cms/modules/localization.js"; -const createEmailField = (options, value = '') => { - const placeholder = options.placeholder || ""; - const id = createID(); - const key = "field." + options.name; - const title = i18n.t(key, options.title); - return ` -
- - -
- `; -}; -const getData = (context) => { - var data = {}; - if (!context.formElement) { - return data; - } - context.formElement.querySelectorAll("[data-cms-form-field-type='mail'] input").forEach((el) => { - let value = el.value; - data[el.name] = { - type: 'mail', - value: value - }; - }); - return data; -}; -export const MailField = { - markup: createEmailField, - init: (context) => { }, - data: getData -}; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/form/field.markdown.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/form/field.markdown.d.ts deleted file mode 100644 index 32fc0b8bf..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/form/field.markdown.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { FieldOptions, FormField } from "@cms/modules/form/forms.js"; -declare global { - interface HTMLInputElement { - cherryEditor?: any; - } -} -export interface MarkdownFieldOptions extends FieldOptions { - placeholder?: string; - height?: string; -} -export declare const MarkdownField: FormField; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/form/field.markdown.js b/modules/ui-module/src/main/ts/dist/js/modules/form/field.markdown.js deleted file mode 100644 index 776ad5319..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/form/field.markdown.js +++ /dev/null @@ -1,189 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { createID } from "@cms/modules/form/utils.js"; -import { i18n } from "@cms/modules/localization.js"; -import { getMediaFormats, getShortCodeNames } from "@cms/modules/rpc/rpc-manager.js"; -import { openFileBrowser } from "@cms/modules/filebrowser.js"; -import { alertSelect } from "@cms/modules/alerts.js"; -import { patchPathWithContext } from "@cms/js/manager-globals"; -const createMarkdownField = (options, value = '') => { - const id = createID(); - const key = "field." + options.name; - const title = i18n.t(key, options.title); - return ` -
- -
- -
- `; -}; -const getData = (context) => { - const data = {}; - const formElement = context.formElement; - if (!formElement) { - return data; - } - const editorInputs = formElement.querySelectorAll('[data-cms-form-field-type="markdown"] input'); - editorInputs.forEach((input) => { - const editor = input.cherryEditor; - if (editor && editor.getMarkdown) { - data[input.name] = { - type: "markdown", - value: editor.getMarkdown() - }; - } - else { - // Fallback: leerer Wert, falls Editor nicht initialisiert - data[input.name] = { - type: "markdown", - value: "" - }; - } - }); - return data; -}; -const init = async (context) => { - const formElement = context.formElement; - if (!formElement) { - return; - } - const cmsShortCodesMenu = await buildCmsShortCodesMenu(); - const editorInputs = formElement.querySelectorAll('[data-cms-form-field-type="markdown"] input'); - editorInputs.forEach((input) => { - const containerId = input.dataset.cherryId; - const initialValue = decodeURIComponent(input.dataset.initialValue || ""); - const editor = new window.Cherry({ - id: containerId, - value: initialValue, - height: '100%', - locale: 'en_US', - editor: { - defaultModel: 'editOnly' - }, - toolbars: { - toolbar: [ - 'bold', - 'italic', - 'strikethrough', - '|', - 'color', - 'header', - '|', - 'list', - 'code', - '|', - 'cmsImageSelection', - 'cmsShortCodesMenu', - ], - bubble: ['bold', 'italic', 'underline', 'strikethrough', 'sub', 'sup', 'quote', '|', 'size', 'color'], // array or false - float: ['h1', 'h2', 'h3', '|', 'checklist', 'table', 'code'], - customMenu: { - cmsShortCodesMenu: cmsShortCodesMenu, - cmsImageSelection: cmsImageSelection - }, - } - }); - input.cherryEditor = editor; - }); -}; -export const MarkdownField = { - markup: createMarkdownField, - init: init, - data: getData -}; -// Helper-Funktion -const getEditorFromEvent = (event) => { - const editorContainer = event.target.closest('.cherry-editor-container'); - if (!editorContainer) - return null; - const input = document.querySelector(`input[data-cherry-id="${editorContainer.id}"]`); - return input ? input.cherryEditor : null; -}; -const buildCmsShortCodesMenu = async () => { - const response = await getShortCodeNames({}); - const shortCodeNames = response.result || []; - const submenuConfig = shortCodeNames.map((shortCode) => ({ - name: shortCode.charAt(0).toUpperCase() + shortCode.slice(1), - value: shortCode, - noIcon: true, - onclick: (event) => { - const editor = getEditorFromEvent(event); - if (editor) { - editor.toolbar.menus.hooks["cmsShortCodesMenu"].fire(null, shortCode); - } - } - })); - return window.Cherry.createMenuHook("CMS-ShortCodes", { - title: "CMS Short Codes", - onClick: (selection, shortCode) => { - return `[[${shortCode}]]${selection || ""}[[/${shortCode}]]`; - }, - subMenuConfig: submenuConfig - }); -}; -const cmsImageSelection = window.Cherry.createMenuHook("Image", { - iconName: "image", - title: "Image", - onClick: (selection, name, event) => { - openFileBrowser({ - type: "assets", - fullscreen: false, - filter: (file) => { - return file.media || file.directory; - }, - onSelect: async (file) => { - if (file && file.uri) { - var value = file.uri; // Use the file's URI - if (file.uri.startsWith("/")) { - value = file.uri.substring(1); // Remove leading slash if present - } - var imageUrl = value; - if (value && value != '') { - imageUrl = patchPathWithContext("/media/" + value); - } - let altText = file.title || file.name || "Image"; - // select media format - var mediaFormats = (await getMediaFormats({})).result || []; - var formatOptions = {}; - formatOptions["original"] = "Original"; - mediaFormats.forEach((format) => { - formatOptions[format.name] = format.name; - }); - var selectedFormat = await alertSelect({ - title: i18n.t("form.media.format.title", "Select Media Format"), - values: formatOptions - }); - if (selectedFormat && selectedFormat !== "original") { - imageUrl += "?format=" + selectedFormat; - } - const editor = getEditorFromEvent(event); - const cm = editor.editor?.editor; - if (cm) { - const markdown = `![${altText}](${imageUrl})`; - cm.replaceSelection(markdown, "end"); - cm.focus(); - } - } - } - }); - } -}); diff --git a/modules/ui-module/src/main/ts/dist/js/modules/form/field.media.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/form/field.media.d.ts deleted file mode 100644 index b359b73f0..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/form/field.media.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { FieldOptions, FormField } from "@cms/modules/form/forms.js"; -export interface MediaFieldOptions extends FieldOptions { -} -export declare const MediaField: FormField; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/form/field.media.js b/modules/ui-module/src/main/ts/dist/js/modules/form/field.media.js deleted file mode 100644 index 653d4ab9e..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/form/field.media.js +++ /dev/null @@ -1,177 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { createID } from "@cms/modules/form/utils.js"; -import { i18n } from "@cms/modules/localization.js"; -import { uploadFileWithProgress } from "@cms/modules/upload.js"; -import { openFileBrowser } from "@cms/modules/filebrowser.js"; -import { patchPathWithContext } from "@cms/js/manager-globals"; -const createMediaField = (options, value = '') => { - const id = createID(); - const key = "field." + options.name; - const title = i18n.t(key, options.title); - var previewUrl = value; - if (value && value != '') { - previewUrl = patchPathWithContext("/assets/" + value); - } - else { - previewUrl = "https://placehold.co/100x100"; - } - return ` -
-
-
- Image preview -
-
- - -
-
-
- `; -}; -const getData = (context) => { - const data = {}; - if (!context.formElement) { - return data; - } - context.formElement.querySelectorAll("[data-cms-form-field-type='media']").forEach(wrapper => { - const input = wrapper.querySelector(".cms-media-input-value"); - if (input) { - data[input.name] = { - type: 'media', - value: input.value - }; - } - }); - return data; -}; -const init = (context) => { - if (!context.formElement) { - return; - } - context.formElement.querySelectorAll("[data-cms-form-field-type='media']").forEach(wrapper => { - const dropZone = wrapper.querySelector(".cms-drop-zone"); - const input = wrapper.querySelector(".cms-media-input"); - const preview = wrapper.querySelector(".cms-media-image"); - const openMediaManager = wrapper.querySelector(".cms-media-button"); - if (!input || !dropZone || !preview || !openMediaManager) - return; - // Handle file drop - dropZone.addEventListener("dragover", (e) => { - e.preventDefault(); - e.stopPropagation(); - dropZone.classList.add("drag-over"); - }); - dropZone.addEventListener("dragleave", (e) => { - e.preventDefault(); - e.stopPropagation(); - dropZone.classList.remove("drag-over"); - }); - dropZone.addEventListener("drop", (e) => { - e.preventDefault(); - e.stopPropagation(); - dropZone.classList.remove("drag-over"); - if (e.dataTransfer.files.length > 0) { - input.files = e.dataTransfer.files; - preview.src = URL.createObjectURL(e.dataTransfer.files[0]); - var file = e.dataTransfer.files[0]; - handleUpload(wrapper, file); - } - }); - // Handle click to open file chooser - //dropZone.addEventListener("click", () => input.click()); - // Handle file selection - input.addEventListener("change", (e) => { - if (e.target === null) { - return; - } - var inputElement = e.target; - if (inputElement.files == null) { - return; - } - const file = inputElement.files[0]; - if (file) { - preview.src = URL.createObjectURL(file); - handleUpload(wrapper, file); - } - }); - // Handle MediaManager button robust: remove old handler, use onclick - openMediaManager.onclick = null; - openMediaManager.onclick = () => { - openFileBrowser({ - type: "assets", - filter: (file) => { - return file.media || file.directory; - }, - onSelect: (file) => { - const preview = wrapper.querySelector(".cms-media-image"); - const inputValue = wrapper.querySelector(".cms-media-input-value"); - if (file && file.uri) { - var value = file.uri; // Use the file's URI - if (file.uri.startsWith("/")) { - value = file.uri.substring(1); // Remove leading slash if present - } - inputValue.value = value; // Set the input value to the selected file's name - var previewUrl = value; - if (value && value != '') { - previewUrl = patchPathWithContext("/assets/" + value); - } - else { - previewUrl = "https://placehold.co/100x100"; - } - preview.src = previewUrl; // Update the preview image - } - } - }); - }; - }); -}; -const handleUpload = (wrapper, file) => { - const inputValue = wrapper.querySelector(".cms-media-input-value"); - uploadFileWithProgress({ - uploadEndpoint: "/manager/upload2", - file: file, - uri: "not relevant for media fields", - onProgress: (percent) => { - console.log(`Upload progress: ${percent}%`); - }, - onSuccess: (data) => { - if (data.filename) { - inputValue.value = data.filename; // Set the input value to the uploaded file's name - } - }, - onError: (error) => { - console.error("Upload failed:", error); - } - }); -}; -export const MediaField = { - markup: createMediaField, - init: init, - data: getData -}; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/form/field.number.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/form/field.number.d.ts deleted file mode 100644 index c034ebbc7..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/form/field.number.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { FieldOptions, FormField } from "@cms/modules/form/forms.js"; -export interface NumberFieldOptions extends FieldOptions { - options: { - min?: number; - max?: number; - step?: number; - }; - placeholder?: string; -} -export declare const NumberField: FormField; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/form/field.number.js b/modules/ui-module/src/main/ts/dist/js/modules/form/field.number.js deleted file mode 100644 index 10f481286..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/form/field.number.js +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { i18n } from "@cms/modules/localization.js"; -import { createID } from "@cms/modules/form/utils.js"; -const createNumberField = (options, value = '') => { - const placeholder = options.placeholder || ""; - const id = createID(); - const key = "field." + options.name; - const min = options.options.min != null ? `min="${options.options.min}"` : ""; - const max = options.options.max != null ? `max="${options.options.max}"` : ""; - const step = options.options.step != null ? `step="${options.options.step}"` : ""; - const title = i18n.t(key, options.title); - return ` -
- - -
- `; -}; -const getData = (context) => { - const data = {}; - const formElement = context.formElement; - if (!formElement) { - return data; - } - formElement.querySelectorAll("[data-cms-form-field-type='number'] input").forEach((el) => { - const value = el.value; - data[el.name] = { - type: 'number', - value: value !== '' ? Number(value) : null - }; - }); - return data; -}; -export const NumberField = { - markup: createNumberField, - init: (context) => { }, - data: getData -}; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/form/field.radio.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/form/field.radio.d.ts deleted file mode 100644 index a238a4826..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/form/field.radio.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { FieldOptions, FormField } from "@cms/modules/form/forms.js"; -export interface RadioFieldOptions extends FieldOptions { - options?: { - choices: Array<{ - label: string; - value: string; - }>; - }; -} -export declare const RadioField: FormField; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/form/field.radio.js b/modules/ui-module/src/main/ts/dist/js/modules/form/field.radio.js deleted file mode 100644 index 9412f5aa5..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/form/field.radio.js +++ /dev/null @@ -1,70 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { createID } from "@cms/modules/form/utils.js"; -import { i18n } from "@cms/modules/localization.js"; -const createRadioField = (options, value = '') => { - const id = createID(); - const key = "field." + options.name; - const name = options.name || id; - const title = i18n.t(key, options.title); - const choices = options.options?.choices || []; - const radios = choices.map((choice, idx) => { - const inputId = `${id}-${idx}`; - const checked = value === choice.value ? 'checked' : ''; - return ` -
- - -
- `; - }).join(''); - return ` -
- - ${radios} -
- `; -}; -const getData = (context) => { - const data = {}; - const formElement = context.formElement; - if (!formElement) { - return data; - } - formElement.querySelectorAll("[data-cms-form-field-type='radio']").forEach(container => { - const name = container.querySelector("input[type='radio']").name; - const checked = container.querySelector("input[type='radio']:checked"); - if (checked) { - data[name] = { - type: 'radio', - value: checked.value - }; - } - }); - return data; -}; -export const RadioField = { - markup: createRadioField, - init: (context) => { }, - data: getData -}; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/form/field.range.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/form/field.range.d.ts deleted file mode 100644 index 47e6c847c..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/form/field.range.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { FieldOptions, FormField } from "@cms/modules/form/forms.js"; -export interface RangeFieldOptions extends FieldOptions { - options?: { - min?: number; - max?: number; - step?: number; - }; -} -export declare const RangeField: FormField; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/form/field.range.js b/modules/ui-module/src/main/ts/dist/js/modules/form/field.range.js deleted file mode 100644 index 19485a951..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/form/field.range.js +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { createID } from "@cms/modules/form/utils.js"; -import { i18n } from "@cms/modules/localization.js"; -const createRangeField = (options, value = '') => { - const id = createID(); - const key = "field." + options.name; - const min = options.options?.min ?? 0; - const max = options.options?.max ?? 100; - const step = options.options?.step ?? 1; - const title = i18n.t(key, options.title); - return ` -
- - -
- `; -}; -const getData = (context) => { - const data = {}; - const formElement = context.formElement; - if (!formElement) { - return data; - } - formElement.querySelectorAll("[data-cms-form-field-type='range'] input").forEach((el) => { - data[el.name] = { - type: 'range', - value: parseFloat(el.value) - }; - }); - return data; -}; -export const RangeField = { - markup: createRangeField, - init: (context) => { }, - data: getData -}; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/form/field.reference.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/form/field.reference.d.ts deleted file mode 100644 index 7f1b0b8c4..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/form/field.reference.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { FieldOptions, FormField } from "@cms/modules/form/forms.js"; -export interface ReferenceFieldOptions extends FieldOptions { - options?: { - siteid?: string; - }; -} -export declare const ReferenceField: FormField; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/form/field.reference.js b/modules/ui-module/src/main/ts/dist/js/modules/form/field.reference.js deleted file mode 100644 index 958b62884..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/form/field.reference.js +++ /dev/null @@ -1,101 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { createID } from "@cms/modules/form/utils.js"; -import { i18n } from "@cms/modules/localization.js"; -import { openFileBrowser } from "@cms/modules/filebrowser.js"; -const createReferenceField = (options, value = '') => { - const id = createID(); - const key = "field." + options.name; - const title = i18n.t(key, options.title); - return ` -
-
-
- - -
- -
-
- `; -}; -const getData = (context) => { - const data = {}; - const formElement = context.formElement; - if (!formElement) { - return data; - } - formElement.querySelectorAll("[data-cms-form-field-type='reference'] input").forEach((el) => { - let value = el.value; - data[el.name] = { - type: 'reference', - value: value - }; - }); - return data; -}; -const init = (context) => { - const formElement = context.formElement; - if (!formElement) { - return; - } - formElement.querySelectorAll("[data-cms-form-field-type='reference']").forEach(wrapper => { - const fileManager = wrapper.querySelector(".cms-reference-button"); - if (!fileManager) - return; - let parsedField = null; - const raw = wrapper.dataset.cmsFieldOptions; - if (raw) { - try { - parsedField = JSON.parse(raw); - } - catch (e) { - console.warn("Invalid field options JSON", e); - } - } - const siteid = parsedField?.options?.siteid ?? undefined; - // Handle MediaManager button robust: remove old handler, use onclick - fileManager.onclick = null; - fileManager.onclick = () => { - openFileBrowser({ - type: "content", - siteid: siteid, - filter: (file) => { - return file.content || file.directory; - }, - onSelect: (file) => { - const inputValue = wrapper.querySelector(".cms-reference-input-value"); - if (file && file.uri) { - var value = file.uri; // Use the file's URI - inputValue.value = value; // Set the input value to the selected file's name - } - } - }); - }; - }); -}; -export const ReferenceField = { - markup: createReferenceField, - init: init, - data: getData -}; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/form/field.select.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/form/field.select.d.ts deleted file mode 100644 index c781deccb..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/form/field.select.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { FieldOptions, FormField } from "@cms/modules/form/forms.js"; -export interface SelectFieldOptions extends FieldOptions { - options?: { - choices?: Array; - }; -} -export declare const SelectField: FormField; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/form/field.select.js b/modules/ui-module/src/main/ts/dist/js/modules/form/field.select.js deleted file mode 100644 index 9da65446f..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/form/field.select.js +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { createID } from "@cms/modules/form/utils.js"; -import { i18n } from "@cms/modules/localization.js"; -const createSelectField = (options, value = '') => { - const id = createID(); - const key = "field." + options.name; - const title = i18n.t(key, options.title); - const optionTags = (options.options?.choices || []).map(opt => { - const label = typeof opt === 'object' ? opt.label : opt; - const val = typeof opt === 'object' ? opt.value : opt; - const selected = val === value ? ' selected' : ''; - return ``; - }).join('\n'); - return ` -
- - -
- `; -}; -const getData = (context) => { - const data = {}; - context.formElement?. - querySelectorAll("[data-cms-form-field-type='select'] select") - .forEach((el) => { - let value = el.value; - // optional: type-konvertierung, aber fallback ist immer der echte Wert - if (value === 'true') { - value = true; - } - else if (value === 'false') { - value = false; - } - data[el.name] = { - type: 'select', - value: value - }; - }); - return data; -}; -export const SelectField = { - markup: createSelectField, - init: (context) => { }, - data: getData -}; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/form/field.text.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/form/field.text.d.ts deleted file mode 100644 index b406c7cf8..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/form/field.text.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { FieldOptions, FormField } from "@cms/modules/form/forms.js"; -export interface TextFieldOptions extends FieldOptions { - placeholder?: string; -} -export declare const TextField: FormField; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/form/field.text.js b/modules/ui-module/src/main/ts/dist/js/modules/form/field.text.js deleted file mode 100644 index 0c01a7971..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/form/field.text.js +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { createID } from "@cms/modules/form/utils.js"; -import { i18n } from "@cms/modules/localization.js"; -const createTextField = (options, value = '') => { - const placeholder = options.placeholder || ""; - const id = createID(); - const key = "field." + options.name; - const title = i18n.t(key, options.title); - return ` -
- - -
- `; -}; -const getData = (context) => { - var data = {}; - if (!context.formElement) { - return data; - } - context.formElement.querySelectorAll("[data-cms-form-field-type='text'] input").forEach((el) => { - let value = el.value; - data[el.name] = { - type: 'text', - value: value - }; - }); - return data; -}; -export const TextField = { - markup: createTextField, - init: (context) => { }, - data: getData -}; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/form/field.textarea.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/form/field.textarea.d.ts deleted file mode 100644 index f83d21361..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/form/field.textarea.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { FieldOptions, FormField } from "@cms/modules/form/forms.js"; -export interface TextAreaFieldOptions extends FieldOptions { - rows?: number; -} -export declare const TextAreaField: FormField; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/form/field.textarea.js b/modules/ui-module/src/main/ts/dist/js/modules/form/field.textarea.js deleted file mode 100644 index a26c4bb31..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/form/field.textarea.js +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { createID } from "@cms/modules/form/utils.js"; -import { i18n } from "@cms/modules/localization.js"; -const createTextAreaField = (options, value = '') => { - const rows = options.rows || 5; - const id = createID(); - const key = "field." + options.name; - const title = i18n.t(key, options.title); - return ` -
- - -
- `; -}; -const getData = (context) => { - var data = {}; - if (context.formElement === null) { - console.error('Form element not found.'); - return data; - } - context.formElement.querySelectorAll("[data-cms-form-field-type='text'] textarea").forEach((el) => { - let value = el.value; - data[el.name] = { - type: 'textarea', - value: value - }; - }); - return data; -}; -export const TextAreaField = { - markup: createTextAreaField, - init: (context) => { }, - data: getData -}; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/form/forms.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/form/forms.d.ts deleted file mode 100644 index a20eefd41..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/form/forms.d.ts +++ /dev/null @@ -1,20 +0,0 @@ -declare const createForm: (options: any) => Form; -export { createForm }; -export interface FormContext { - formElement: HTMLFormElement | null; - fields: any[]; -} -export interface Form { - init: (container: Element | string) => void; - getData: () => any; - getRawData: () => any; -} -export interface FormField { - markup: (options: FieldOptions, value?: any) => string; - init: (context: FormContext) => void; - data: (context: FormContext) => any; -} -export interface FieldOptions { - name?: string; - title?: string; -} diff --git a/modules/ui-module/src/main/ts/dist/js/modules/form/forms.js b/modules/ui-module/src/main/ts/dist/js/modules/form/forms.js deleted file mode 100644 index ea091c80c..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/form/forms.js +++ /dev/null @@ -1,183 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { createID } from "@cms/modules/form/utils.js"; -import { TextField } from "@cms/modules/form/field.text.js"; -import { MailField } from "@cms/modules/form/field.mail.js"; -import { CodeField } from "@cms/modules/form/field.code.js"; -import { SelectField } from "@cms/modules/form/field.select.js"; -import { MarkdownField } from "@cms/modules/form/field.markdown.js"; -import { EasyMDEField } from "@cms/modules/form/field.easymde.js"; -import { NumberField } from "@cms/modules/form/field.number.js"; -import { DateField } from "@cms/modules/form/field.date.js"; -import { ColorField } from "@cms/modules/form/field.color.js"; -import { DateTimeField } from "@cms/modules/form/field.datetime.js"; -import { RangeField } from "@cms/modules/form/field.range.js"; -import { RadioField } from "@cms/modules/form/field.radio.js"; -import { CheckboxField } from "@cms/modules/form/field.checkbox.js"; -import { Divider } from "@cms/modules/form/field.divider.js"; -import { MediaField } from "@cms/modules/form/field.media.js"; -import { ListField } from "@cms/modules/form/field.list.js"; -import { TextAreaField } from "@cms/modules/form/field.textarea.js"; -import { ReferenceField } from "@cms/modules/form/field.reference.js"; -const createForm = (options) => { - const fields = options.fields || []; - const values = options.values || {}; - const formId = createID(); - const context = { - formElement: null, - fields: fields - }; - const fieldHtml = fields.map((field) => { - const val = values[field.name] || ''; - switch (field.type) { - case 'email': - return MailField.markup(field, val); - case 'text': - return TextField.markup(field, val); - case 'select': - return SelectField.markup(field, val); - case 'code': - return CodeField.markup(field, val); - case 'markdown': - return MarkdownField.markup(field, val); - case 'easymde': - return EasyMDEField.markup(field, val); - case 'number': - return NumberField.markup(field, val); - case 'date': - return DateField.markup(field, val); - case 'datetime': - return DateTimeField.markup(field, val); - case 'color': - return ColorField.markup(field, val); - case 'range': - return RangeField.markup(field, val); - case 'radio': - return RadioField.markup(field, val); - case 'checkbox': - return CheckboxField.markup(field, val); - case 'divider': - return Divider.markup(field, val); - case 'media': - return MediaField.markup(field, val); - case 'list': - return ListField.markup(field, val); - case 'textarea': - return TextAreaField.markup(field, val); - case 'reference': - return ReferenceField.markup(field, val); - default: - return ''; - } - }).join('\n'); - const html = ` -
- ${fieldHtml} -
- `; - const init = (container) => { - if (typeof container === 'string') { - container = document.querySelector(container); - } - if (!container) { - console.error("From container not found."); - return; - } - container.innerHTML = html; - context.formElement = container.querySelector('form'); - if (!context.formElement) { - console.error('Form element not found.'); - return; - } - context.formElement.addEventListener('keydown', (e) => { - if (e.key === 'Enter' && e.target.tagName.toLowerCase() !== 'textarea') { - e.preventDefault(); - } - }); - context.formElement.addEventListener('submit', (e) => { - e.preventDefault(); - e.stopPropagation(); - context.formElement?.classList.add('was-validated'); - }); - CodeField.init(context); - MarkdownField.init(context); - EasyMDEField.init(context); - MediaField.init(context); - ListField.init(context); - ReferenceField.init(context); - }; - const getData = () => { - if (!context.formElement) { - console.warn("Form not initialised."); - return {}; - } - const data = { - ...TextField.data(context), - ...SelectField.data(context), - ...MailField.data(context), - ...CodeField.data(context), - ...MarkdownField.data(context), - ...EasyMDEField.data(context), - ...NumberField.data(context), - ...DateField.data(context), - ...DateTimeField.data(context), - ...ColorField.data(context), - ...RangeField.data(context), - ...RadioField.data(context), - ...CheckboxField.data(context), - ...MediaField.data(context), - ...ListField.data(context), - ...TextAreaField.data(context), - ...ReferenceField.data(context) - }; - return data; - }; - return { - init, - getData, - getRawData: () => { - let data = getData(); - return flattenFormData(data); - } - }; -}; -const flattenFormData = (input) => { - const result = {}; - for (const key in input) { - const value = input[key].value; - const parts = key.split("."); - let current = result; - for (let i = 0; i < parts.length; i++) { - const part = parts[i]; - if (i === parts.length - 1) { - current[part] = value; - } - else { - if (!(part in current)) - current[part] = {}; - current = current[part]; - } - } - } - return result; -}; -export { createForm }; -; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/form/utils.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/form/utils.d.ts deleted file mode 100644 index 525b147b7..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/form/utils.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -declare const createID: () => string; -declare const utcToLocalDateTimeInputValue: (utcString: string) => string; -declare function getUTCDateTimeFromInput(inputElement: HTMLInputElement): string | null; -declare function utcToLocalDateInputValue(utcString: string): string; -declare function getUTCDateFromInput(inputElement: HTMLInputElement): string | null; -export { createID, utcToLocalDateTimeInputValue, getUTCDateTimeFromInput, utcToLocalDateInputValue, getUTCDateFromInput }; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/form/utils.js b/modules/ui-module/src/main/ts/dist/js/modules/form/utils.js deleted file mode 100644 index 6b147f250..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/form/utils.js +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -const createID = () => "id" + Math.random().toString(16).slice(2); -const utcToLocalDateTimeInputValue = (utcString) => { - const date = new Date(utcString); - if (isNaN(date.getTime())) - return ""; - const pad = (n) => String(n).padStart(2, '0'); - const yyyy = date.getFullYear(); - const MM = pad(date.getMonth() + 1); - const dd = pad(date.getDate()); - const hh = pad(date.getHours()); - const mm = pad(date.getMinutes()); - return `${yyyy}-${MM}-${dd}T${hh}:${mm}`; -}; -function getUTCDateTimeFromInput(inputElement) { - const localValue = inputElement.value; // "2025-05-31T03:00" - if (!localValue) - return null; - const localDate = new Date(localValue); // interpretiert als lokale Zeit - return localDate.toISOString(); // → "2025-05-31T01:00:00.000Z" -} -function utcToLocalDateInputValue(utcString) { - const date = new Date(utcString); - if (isNaN(date.getTime())) - return ""; - const pad = (n) => String(n).padStart(2, '0'); - return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`; -} -function getUTCDateFromInput(inputElement) { - const dateOnly = inputElement.value; // z. B. "2025-05-31" - if (!dateOnly) - return null; - const date = new Date(dateOnly); // wird zu 00:00 lokale Zeit - return date.toISOString(); // → "2025-05-30T22:00:00.000Z" (wenn in CEST) -} -export { createID, utcToLocalDateTimeInputValue, getUTCDateTimeFromInput, utcToLocalDateInputValue, getUTCDateFromInput }; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/frameMessenger.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/frameMessenger.d.ts deleted file mode 100644 index 1d74a5193..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/frameMessenger.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -declare namespace _default { - export { send }; - export { on }; - export { off }; -} -export default _default; -declare function send(targetWindow: any, message: any, targetOrigin?: string): void; -declare function on(type: any, callback: any): void; -declare function off(type: any, callback: any): void; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/frameMessenger.js b/modules/ui-module/src/main/ts/dist/js/modules/frameMessenger.js deleted file mode 100644 index 8185c07d6..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/frameMessenger.js +++ /dev/null @@ -1,60 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -// frameMessenger.js -const listeners = new Map(); -function send(targetWindow, message, targetOrigin = '*') { - targetWindow.postMessage({ __frameMessenger: true, ...message }, targetOrigin); -} -function on(type, callback) { - if (!listeners.has(type)) { - listeners.set(type, []); - } - listeners.get(type).push(callback); -} -function off(type, callback) { - const callbacks = listeners.get(type); - if (!callbacks) - return; - const index = callbacks.indexOf(callback); - if (index >= 0) { - callbacks.splice(index, 1); - } -} -function handleMessage(event) { - const data = event.data; - if (!data || !data.__frameMessenger || !data.type) - return; - const callbacks = listeners.get(data.type) || []; - for (const cb of callbacks) { - try { - cb(data.payload, event); - } - catch (err) { - console.error('frameMessenger callback error:', err); - } - } -} -window.addEventListener('message', handleMessage); -export default { - send, - on, - off -}; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/locale-utils.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/locale-utils.d.ts deleted file mode 100644 index 98374290b..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/locale-utils.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export function getLocale(): any; -export function setLocale(locale: any): void; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/locale-utils.js b/modules/ui-module/src/main/ts/dist/js/modules/locale-utils.js deleted file mode 100644 index 778fce73d..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/locale-utils.js +++ /dev/null @@ -1,28 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { UIStateManager } from '@cms/modules/ui-state.js'; -const DEFAULT_LOCALE = 'en'; -export function getLocale() { - return UIStateManager.getLocale(DEFAULT_LOCALE); -} -export function setLocale(locale) { - UIStateManager.setLocale(locale); -} diff --git a/modules/ui-module/src/main/ts/dist/js/modules/localization-actions.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/localization-actions.d.ts deleted file mode 100644 index 43acad38a..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/localization-actions.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -export namespace ACTION_LOCALIZATIONS { - let en: {}; - let de: { - "addsection.input.name": string; - "addsection.select.": string; - "addsection.titles.modal": string; - "addsection.titles.alert": string; - "addsection.alerts.success.message": string; - "addsection.alerts.error.message": string; - "addsection.alerts.notemplate.message": string; - "addsection.alerts.nameexists.message": string; - }; -} diff --git a/modules/ui-module/src/main/ts/dist/js/modules/localization-actions.js b/modules/ui-module/src/main/ts/dist/js/modules/localization-actions.js deleted file mode 100644 index 51eceec86..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/localization-actions.js +++ /dev/null @@ -1,33 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -export const ACTION_LOCALIZATIONS = { - en: {}, - de: { - "addsection.input.name": "Name des Absatzes", - "addsection.select.": "Name of the section", - "addsection.titles.modal": "Absatz hinuzfügen", - "addsection.titles.alert": 'Absatz erstellen', - "addsection.alerts.success.message": 'Absatz wurde erfolgreich erstellt.', - "addsection.alerts.error.message": 'Absatz konnte nicht erstellt werden.', - "addsection.alerts.notemplate.message": 'Kein Absatz-Template ausgewählt.', - "addsection.alerts.nameexists.message": 'Der Name ist schon vergeben.' - } -}; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/localization-loader.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/localization-loader.d.ts deleted file mode 100644 index ea5b0a075..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/localization-loader.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -export function loadLocalizationsWithDefaults(): Promise<{ - en: { - "ui.filebrowser.filename": string; - "ui.filebrowser.title": string; - "menu.settings": string; - "menu.settings.logout": string; - "language.en": string; - "language.de": string; - "buttons.ok": string; - "buttons.cancle": string; - "menu.page.settings": string; - }; - de: { - "ui.filebrowser.filename": string; - "ui.filebrowser.title": string; - "menu.settings": string; - "menu.settings.logout": string; - "language.en": string; - "language.de": string; - "buttons.ok": string; - "buttons.cancle": string; - "menu.page.settings": string; - }; -}>; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/localization-loader.js b/modules/ui-module/src/main/ts/dist/js/modules/localization-loader.js deleted file mode 100644 index 2694eebd0..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/localization-loader.js +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { ACTION_LOCALIZATIONS } from '@cms/modules/localization-actions.js'; -import { MODULE_LOCALIZATIONS } from '@cms/modules/localization-modules.js'; -import { loadLocalizations } from '@cms/modules/rpc/rpc-i18n.js'; -const DEFAULT_LOCALIZATIONS = { - en: { - "ui.filebrowser.filename": "Filename", - "ui.filebrowser.title": "Filesystem", - "menu.settings": "Settings", - "menu.settings.logout": "Logout", - "language.en": "English", - "language.de": "German", - "buttons.ok": "Ok", - "buttons.cancle": "Cancel", - "menu.page.settings": "Page Settings" - }, - de: { - "ui.filebrowser.filename": "Dateiname", - "ui.filebrowser.title": "Dateisystem", - "menu.settings": "Einstellungen", - "menu.settings.logout": "Abmelden", - "language.en": "Englisch", - "language.de": "Deutsch", - "buttons.ok": "Ok", - "buttons.cancle": "Abbrechen", - "menu.page.settings": "Seiten-Einstellungen" - } -}; -const loadLocalizationsWithDefaults = async () => { - try { - const response = (await loadLocalizations()).result; - // Merge server response into defaults - for (const lang in response) { - DEFAULT_LOCALIZATIONS[lang] = { - ...DEFAULT_LOCALIZATIONS[lang], - ...ACTION_LOCALIZATIONS[lang], - ...MODULE_LOCALIZATIONS[lang], - ...response[lang] - }; - } - } - catch (e) { - console.warn("Could not load remote translations, falling back to defaults.", e); - } - return DEFAULT_LOCALIZATIONS; -}; -export { loadLocalizationsWithDefaults }; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/localization-modules.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/localization-modules.d.ts deleted file mode 100644 index 4a0c49e47..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/localization-modules.d.ts +++ /dev/null @@ -1,21 +0,0 @@ -export namespace MODULE_LOCALIZATIONS { - let en: {}; - let de: { - "alerts.select.title": string; - "alerts.select.placeholder": string; - "alerts.error.title": string; - "alerts.error.message": string; - "alerts.confirm.title": string; - "alerts.confirm.message": string; - "alerts.confirm.button.ok": string; - "alerts.confirm.button.cancel": string; - "alerts.prompt.title": string; - "alerts.prompt.lable": string; - "alerts.prompt.placeholder": string; - "page.unpublished.title": string; - "page.unpublished.noPages": string; - "page.unpublished.editLink": string; - "pagination.previous": string; - "pagination.next": string; - }; -} diff --git a/modules/ui-module/src/main/ts/dist/js/modules/localization-modules.js b/modules/ui-module/src/main/ts/dist/js/modules/localization-modules.js deleted file mode 100644 index 84189b7cb..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/localization-modules.js +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -export const MODULE_LOCALIZATIONS = { - en: {}, - de: { - "alerts.select.title": "Element wählen", - "alerts.select.placeholder": "Ein Element wählen", - "alerts.error.title": "Fehler", - "alerts.error.message": "Fehler aufgetreten", - "alerts.confirm.title": "Sicher?", - "alerts.confirm.message": "Achtung: Diese Aktion kann nicht rückgängig gemacht werden!", - "alerts.confirm.button.ok": "Ok", - "alerts.confirm.button.cancel": "Abbrechen", - "alerts.prompt.title": "Wert eingeben.", - "alerts.prompt.lable": "Wert", - "alerts.prompt.placeholder": "Geben sie ihren Wert ein", - "page.unpublished.title": "Unveröffentlichte Seiten", - "page.unpublished.noPages": "Keine unveröffentlichten Seiten gefunden.", - "page.unpublished.editLink": "Bearbeiten", - "pagination.previous": "Zurück", - "pagination.next": "Weiter" - } -}; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/localization.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/localization.d.ts deleted file mode 100644 index 9eeed5a15..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/localization.d.ts +++ /dev/null @@ -1,32 +0,0 @@ -export function localizeUi(): Promise; -export namespace i18n { - let _locale: any; - let _cache: null; - /** - * Loads and merges remote localizations with defaults. - */ - function init(): Promise; - /** - * Get current locale. - */ - function getLocale(): any; - /** - * Change the active locale and update cookie. - * @param {string} locale - */ - function setLocale(locale: string): void; - /** - * Returns the translation synchronously after init. - * @param {string} key - * @param {string} [defaultValue] - * @returns {string} - */ - function t(key: string, defaultValue?: string): string; - /** - * Returns the translation asynchronously (no need to call init beforehand). - * @param {string} key - * @param {string} [defaultValue] - * @returns {Promise} - */ - function tAsync(key: string, defaultValue?: string): Promise; -} diff --git a/modules/ui-module/src/main/ts/dist/js/modules/localization.js b/modules/ui-module/src/main/ts/dist/js/modules/localization.js deleted file mode 100644 index cb2847ce8..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/localization.js +++ /dev/null @@ -1,99 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { getLocale, setLocale } from '@cms/modules/locale-utils.js'; -import { loadLocalizationsWithDefaults } from '@cms/modules/localization-loader.js'; -const DEFAULT_LOCALE = 'en'; -const i18n = { - _locale: getLocale(), - _cache: null, - /** - * Loads and merges remote localizations with defaults. - */ - async init() { - try { - if (this._cache != null) { - return; - } - this._cache = await loadLocalizationsWithDefaults(); - } - catch (err) { - console.warn("[i18n] Failed to load remote translations, using defaults.", err); - this._cache = await loadLocalizationsWithDefaults(); - } - }, - /** - * Get current locale. - */ - getLocale() { - return this._locale || DEFAULT_LOCALE; - }, - /** - * Change the active locale and update cookie. - * @param {string} locale - */ - setLocale(locale) { - setLocale(locale); - this._locale = locale; - }, - /** - * Returns the translation synchronously after init. - * @param {string} key - * @param {string} [defaultValue] - * @returns {string} - */ - t(key, defaultValue) { - const loc = this.getLocale(); - return this._cache?.[loc]?.[key] - || this._cache?.[DEFAULT_LOCALE]?.[key] - || defaultValue - || key; - }, - /** - * Returns the translation asynchronously (no need to call init beforehand). - * @param {string} key - * @param {string} [defaultValue] - * @returns {Promise} - */ - async tAsync(key, defaultValue) { - if (!this._cache) { - await this.init(); - } - return this.t(key, defaultValue); - } -}; -const localizeUi = async () => { - i18n.init(); - document.querySelectorAll("[data-cms-i18n-key]").forEach($elem => { - const key = $elem.getAttribute("data-cms-i18n-key"); - const translation = i18n.t(key, $elem.textContent); - if (translation) { - $elem.textContent = translation; - } - else { - // Optional: Fallback zur Default-Sprache oder Anzeige eines Platzhalters - const fallback = localizations?.[DEFAULT_LOCALE]?.[key]; - if (fallback) { - $elem.textContent = fallback; - } - } - }); -}; -export { localizeUi, i18n }; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/manager-ui.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/manager-ui.d.ts deleted file mode 100644 index d25e9cb32..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/manager-ui.d.ts +++ /dev/null @@ -1 +0,0 @@ -export function updateStateButton(): void; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/manager-ui.js b/modules/ui-module/src/main/ts/dist/js/modules/manager-ui.js deleted file mode 100644 index 46f88817e..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/manager-ui.js +++ /dev/null @@ -1,65 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { getPreviewUrl } from '@cms/modules/preview.utils.js'; -import { getContent, getContentNode } from '@cms/modules/rpc/rpc-content.js'; -export function updateStateButton() { - var previewUrl = getPreviewUrl(); - ; - if (!previewUrl) { - document.querySelector('#cms-btn-status').classList.add('disabled'); - document.querySelector('#cms-btn-status').setAttribute('title', 'No preview URL available'); - return; - } - var previewUrl = getPreviewUrl(); - getContentNode({ - url: previewUrl - }).then((contentNode) => { - getContent({ - uri: contentNode.result.uri - }).then((getContentResponse) => { - updateNodeStatus(getContentResponse); - }); - }); -} -function updateNodeStatus(getContentResponse) { - const statusBtn = document.querySelector('#cms-btn-status'); - if (!statusBtn) - return; - // Alle cms-node-status-* Klassen entfernen - Array.from(statusBtn.classList).forEach(className => { - if (className.startsWith('cms-node-status-')) { - statusBtn.classList.remove(className); - } - }); - var published = getContentResponse?.result?.status?.published; - // Status bestimmen (Provider-fähig) - let status; - if (!published) { - status = 'unpublished'; - } - else if (!getContentResponse?.result?.status?.withinSchedule) { - status = 'published-not-visible'; - } - else { - status = 'published'; - } - statusBtn.classList.add(`cms-node-status-${status}`); -} diff --git a/modules/ui-module/src/main/ts/dist/js/modules/manager/manager.message.handlers.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/manager/manager.message.handlers.d.ts deleted file mode 100644 index dd88b9fe0..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/manager/manager.message.handlers.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -declare const initMessageHandlers: () => void; -export { initMessageHandlers }; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/manager/manager.message.handlers.js b/modules/ui-module/src/main/ts/dist/js/modules/manager/manager.message.handlers.js deleted file mode 100644 index 44176fd74..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/manager/manager.message.handlers.js +++ /dev/null @@ -1,194 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { executeScriptAction } from '@cms/js/manager-globals.js'; -import frameMessenger from '@cms/modules/frameMessenger.js'; -import { getPreviewFrame, getPreviewUrl } from '@cms/modules/preview.utils.js'; -import { getContentNode } from '@cms/modules/rpc/rpc-content.js'; -const executeImageForm = (payload) => { - const cmd = { - "module": window.manager.baseUrl + "/actions/media/edit-media-form", - "function": "runAction", - "parameters": { - "editor": payload.editor, - "attribute": payload.metaElement, - "options": payload.options ? payload.options : {} - } - }; - if (payload.uri) { - cmd.parameters.uri = payload.uri; - } - executeScriptAction(cmd); -}; -const executeImageSelect = (payload) => { - const cmd = { - "module": window.manager.baseUrl + "/actions/media/select-media", - "function": "runAction", - "parameters": { - "options": payload.options ? payload.options : {} - } - }; - executeScriptAction(cmd); -}; -const executeContentImageReplace = (payload) => { - const cmd = { - "module": window.manager.baseUrl + "/actions/media/select-content-media", - "function": "runAction", - "parameters": { - "options": payload.options ? payload.options : {} - } - }; - executeScriptAction(cmd); -}; -const initMessageHandlers = () => { - frameMessenger.on('preview:reload', (payload) => { - }); - frameMessenger.on('edit', (payload) => { - if (payload.element === "content") { - var cmd = { - "module": window.manager.baseUrl + "/actions/page/edit-content", - "function": "runAction", - "parameters": { - "editor": payload.editor, - "options": payload.options ? payload.options : {} - } - }; - if (payload.uri) { - cmd.parameters.uri = payload.uri; - } - executeScriptAction(cmd); - } - else if (payload.element === "meta" && payload.editor === "form") { - var cmd = { - "module": window.manager.baseUrl + "/actions/page/edit-metaattribute-form", - "function": "runAction", - "parameters": { - "editor": payload.editor, - "attributes": payload.metaElements, - "options": payload.options ? payload.options : {}, - "form": payload.form, - "type": payload.type - } - }; - if (payload.uri) { - cmd.parameters.uri = payload.uri; - } - executeScriptAction(cmd); - } - else if (payload.element === "image" && payload.editor === "form") { - executeImageForm(payload); - } - else if (payload.element === "image" && payload.editor === "select") { - executeImageSelect(payload); - } - else if (payload.element === "image" && payload.editor === "replace") { - executeContentImageReplace(payload); - } - else if (payload.element === "image" && payload.editor === "focal-point") { - var cmd = { - "module": window.manager.baseUrl + "/actions/media/edit-focal-point", - "function": "runAction", - "parameters": { - "options": payload.options ? payload.options : {} - } - }; - if (payload.uri) { - cmd.parameters.uri = payload.uri; - } - executeScriptAction(cmd); - } - else if (payload.element === "meta") { - var cmd = { - "module": window.manager.baseUrl + "/actions/page/edit-metaattribute", - "function": "runAction", - "parameters": { - "editor": payload.editor, - "attribute": payload.metaElement, - "options": payload.options ? payload.options : {} - } - }; - if (payload.uri) { - cmd.parameters.uri = payload.uri; - } - executeScriptAction(cmd); - } - }); - frameMessenger.on('edit-sections', (payload) => { - var cmd = { - "module": window.manager.baseUrl + "/actions/page/edit-sections", - "function": "runAction", - "parameters": { - "section": payload.section - } - }; - if (payload.uri) { - cmd.parameters.uri = payload.uri; - } - executeScriptAction(cmd); - }); - frameMessenger.on('add-sectionEntry', (payload) => { - var cmd = { - "module": window.manager.baseUrl + "/actions/page/add-section", - "function": "runAction", - "parameters": { - "section": payload.section - } - }; - executeScriptAction(cmd); - }); - frameMessenger.on('delete-sectionEntry', (payload) => { - var cmd = { - "module": window.manager.baseUrl + "/actions/page/delete-section", - "function": "runAction", - "parameters": { - "sectionUri": payload.sectionUri - } - }; - executeScriptAction(cmd); - }); - frameMessenger.on('shortkeys', (payload) => { - window.manager.commandPalette.open(); - }); - frameMessenger.on("section-set-published", (payload) => { - var cmd = { - "module": window.manager.baseUrl + "/actions/page/section-set-published", - "function": "runAction", - "parameters": { - "sectionUri": payload.sectionUri, - "published": payload.published - } - }; - executeScriptAction(cmd); - }); - frameMessenger.on('getContentNode', async (payload) => { - const contentNode = await getContentNode({ - url: getPreviewUrl() - }); - var message = { - "type": "getContentNodeResponse", - "payload": { - "contentNode": contentNode.result - } - }; - var previewFrame = getPreviewFrame(); - frameMessenger.send(previewFrame.contentWindow, message); - }); -}; -export { initMessageHandlers }; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/manager/media.inject.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/manager/media.inject.d.ts deleted file mode 100644 index ebd61d27b..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/manager/media.inject.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -export declare const initMediaUploadOverlay: (img: HTMLImageElement) => void; -export declare const initContentMediaToolbar: (img: HTMLImageElement) => void; -export declare const initMediaToolbar: (img: HTMLImageElement) => void; -export declare const initToolbar: (img: HTMLImageElement, toolbarDefinition: any) => void; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/manager/media.inject.js b/modules/ui-module/src/main/ts/dist/js/modules/manager/media.inject.js deleted file mode 100644 index c89fd2596..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/manager/media.inject.js +++ /dev/null @@ -1,245 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { EDIT_ATTRIBUTES_ICON, IMAGE_ICON, MEDIA_CROP_ICON } from "@cms/modules/manager/toolbar-icons"; -import frameMessenger from '@cms/modules/frameMessenger.js'; -const isSameDomainImage = (imgElement) => { - if (!(imgElement instanceof HTMLImageElement)) { - return false; // ist kein - } - if (!imgElement.src) { - return false; - } - try { - const imgUrl = new URL(imgElement.src, window.location.href); - return imgUrl.hostname === window.location.hostname; - } - catch (e) { - return false; - } -}; -export const initMediaUploadOverlay = (img) => { - if (!isSameDomainImage(img)) { - return; - } - // Overlay erstellen - const overlay = document.createElement('div'); - overlay.classList.add("cms-ui-overlay-bottom"); - overlay.innerHTML = IMAGE_ICON; - document.body.appendChild(overlay); - const positionOverlay = () => { - const rect = img.getBoundingClientRect(); - const overlayHeight = rect.height / 3; // unteres Drittel - overlay.style.top = `${window.scrollY + rect.top + rect.height - overlayHeight}px`; - overlay.style.left = `${window.scrollX + rect.left}px`; - overlay.style.width = `${rect.width}px`; - overlay.style.height = `${overlayHeight}px`; - }; - img.addEventListener('mouseenter', () => { - positionOverlay(); - overlay.classList.add('visible'); - }); - img.addEventListener('mouseleave', (event) => { - if (!event.relatedTarget || !(event.relatedTarget instanceof Node) || !overlay.contains(event.relatedTarget)) { - overlay.classList.remove('visible'); - } - }); - overlay.addEventListener('mouseleave', (event) => { - if (!event.relatedTarget || event.relatedTarget !== img) { - overlay.classList.remove('visible'); - } - }); - overlay.addEventListener('click', (e) => { - selectMedia(img.dataset.cmsMetaElement, img.dataset.cmsNodeUri); - }); - window.addEventListener('scroll', () => { - if (overlay.classList.contains('visible')) - positionOverlay(); - }); - window.addEventListener('resize', () => { - if (overlay.classList.contains('visible')) - positionOverlay(); - }); - positionOverlay(); -}; -export const initContentMediaToolbar = (img) => { - if (!isSameDomainImage(img)) { - return; - } - var toolbar = img.closest('[data-cms-toolbar]'); - var parentToolbarDef = JSON.parse(toolbar.dataset.cmsToolbar || '{}'); - if (!parentToolbarDef) { - return; - } - var toolbarDefinition = { - "options": { - "uri": parentToolbarDef.uri, - "start": img.dataset.cmsMdStart || null, - "end": img.dataset.cmsMdEnd || null - }, - "actions": [ - "replace", - "meta", - "focalPoint" - ] - }; - initToolbar(img, toolbarDefinition); -}; -export const initMediaToolbar = (img) => { - if (!isSameDomainImage(img)) { - return; - } - var toolbarDefinition = JSON.parse(img.dataset.cmsMediaToolbar || '{}'); - initToolbar(img, toolbarDefinition); -}; -export const initToolbar = (img, toolbarDefinition) => { - const toolbar = document.createElement('div'); - toolbar.classList.add("cms-ui-toolbar"); - toolbar.classList.add("cms-ui-toolbar-tl"); - if (toolbarDefinition.actions.includes('select')) { - const selectButton = document.createElement('button'); - selectButton.innerHTML = IMAGE_ICON; - selectButton.setAttribute("title", "Select media"); - selectButton.addEventListener('click', (event) => { - selectMedia(toolbarDefinition.options.element, toolbarDefinition.options.uri); - }); - toolbar.appendChild(selectButton); - } - if (toolbarDefinition.actions.includes('replace')) { - const replaceButton = document.createElement('button'); - replaceButton.innerHTML = IMAGE_ICON; - replaceButton.setAttribute("title", "Replace media"); - replaceButton.addEventListener('click', (event) => { - replaceMedia(toolbarDefinition.options.start, toolbarDefinition.options.end, toolbarDefinition.options.element, toolbarDefinition.options.uri); - }); - toolbar.appendChild(replaceButton); - } - if (toolbarDefinition.actions.includes('meta')) { - const metaButton = document.createElement('button'); - metaButton.setAttribute('data-cms-action', 'editMediaForm'); - metaButton.setAttribute('data-cms-media-form', 'meta'); - metaButton.innerHTML = EDIT_ATTRIBUTES_ICON; - metaButton.setAttribute("title", "Edit attributes"); - metaButton.addEventListener('click', (event) => { - editMediaForm("meta", img.src); - }); - toolbar.appendChild(metaButton); - } - if (toolbarDefinition.actions.includes('focalPoint')) { - const metaButton = document.createElement('button'); - metaButton.setAttribute('data-cms-action', 'editFocalPoint'); - metaButton.setAttribute('data-cms-media-form', 'meta'); - metaButton.innerHTML = MEDIA_CROP_ICON; - metaButton.setAttribute("title", "Edit focal point"); - metaButton.addEventListener('click', (event) => { - focalPoint(img.src); - }); - toolbar.appendChild(metaButton); - } - document.body.appendChild(toolbar); - const positionToolbar = () => { - const rect = img.getBoundingClientRect(); - toolbar.style.top = `${window.scrollY + rect.top}px`; - toolbar.style.left = `${window.scrollX + rect.left}px`; - }; - img.addEventListener('mouseenter', () => { - positionToolbar(); - //toolbar.style.display = 'block'; - toolbar.classList.add('visible'); - }); - img.addEventListener('mouseleave', (event) => { - const related = event.relatedTarget; - if (!event.relatedTarget || !toolbar.contains(related)) { - //toolbar.style.display = 'none'; - toolbar.classList.remove('visible'); - } - }); - toolbar.addEventListener('mouseleave', (event) => { - if (!event.relatedTarget || event.relatedTarget !== img) { - //toolbar.style.display = 'none'; - toolbar.classList.remove('visible'); - } - }); - window.addEventListener('scroll', () => { - if (toolbar.style.visibility === 'visible') - positionToolbar(); - }); - window.addEventListener('resize', () => { - if (toolbar.style.visibility === 'visible') - positionToolbar(); - }); -}; -const replaceMedia = (start, end, metaElement, uri) => { - var command = { - type: 'edit', - payload: { - editor: "replace", - element: "image", - options: { - metaElement: metaElement, - uri: uri, - start: start, - end: end - } - } - }; - frameMessenger.send(window.parent, command); -}; -const selectMedia = (metaElement, uri) => { - var command = { - type: 'edit', - payload: { - editor: "select", - element: "image", - options: { - metaElement: metaElement, - uri: uri - } - } - }; - frameMessenger.send(window.parent, command); -}; -const focalPoint = (uri) => { - var command = { - type: 'edit', - payload: { - editor: "focal-point", - element: "image", - options: { - uri: uri - } - } - }; - frameMessenger.send(window.parent, command); -}; -const editMediaForm = (form, image) => { - var command = { - type: 'edit', - payload: { - editor: "form", - element: "image", - options: { - form: form, - image: image - } - } - }; - frameMessenger.send(window.parent, command); -}; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/manager/toolbar-icons.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/manager/toolbar-icons.d.ts deleted file mode 100644 index 37904af59..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/manager/toolbar-icons.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -export declare const EDIT_PAGE_ICON = "\n\n \n \n"; -export declare const EDIT_ATTRIBUTES_ICON = "\n\n \n\n"; -export declare const SECTION_SORT_ICON = "\n\n \n \n\n"; -export declare const SECTION_ADD_ICON = "\n\n \n\n"; -export declare const SECTION_DELETE_ICON = "\n\n \n \n\n"; -export declare const IMAGE_ICON = "\n\n \n \n\n"; -export declare const SECTION_PUBLISHED_ICON = "\n\n \n \n\n"; -export declare const SECTION_UNPUBLISHED_ICON = "\n\n \n \n\n"; -export declare const MEDIA_CROP_ICON = "\n\n \n\n"; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/manager/toolbar-icons.js b/modules/ui-module/src/main/ts/dist/js/modules/manager/toolbar-icons.js deleted file mode 100644 index 715aa464c..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/manager/toolbar-icons.js +++ /dev/null @@ -1,70 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -export const EDIT_PAGE_ICON = ` - - - -`; -export const EDIT_ATTRIBUTES_ICON = ` - - - -`; -export const SECTION_SORT_ICON = ` - - - - -`; -export const SECTION_ADD_ICON = ` - - - -`; -export const SECTION_DELETE_ICON = ` - - - - -`; -export const IMAGE_ICON = ` - - - - -`; -export const SECTION_PUBLISHED_ICON = ` - - - - -`; -export const SECTION_UNPUBLISHED_ICON = ` - - - - -`; -export const MEDIA_CROP_ICON = ` - - - -`; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/manager/toolbar.inject.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/manager/toolbar.inject.d.ts deleted file mode 100644 index 6e3a61bf4..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/manager/toolbar.inject.d.ts +++ /dev/null @@ -1 +0,0 @@ -export declare const initToolbar: (container: HTMLElement) => void; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/manager/toolbar.inject.js b/modules/ui-module/src/main/ts/dist/js/modules/manager/toolbar.inject.js deleted file mode 100644 index b3d8c6743..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/manager/toolbar.inject.js +++ /dev/null @@ -1,212 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import frameMessenger from "@cms/modules/frameMessenger.js"; -import { EDIT_ATTRIBUTES_ICON, EDIT_PAGE_ICON, SECTION_ADD_ICON, SECTION_DELETE_ICON, SECTION_SORT_ICON, SECTION_UNPUBLISHED_ICON } from "@cms/modules/manager/toolbar-icons"; -const addSection = (event) => { - var toolbar = event.target.closest('[data-cms-toolbar]'); - var toolbarDefinition = JSON.parse(toolbar.dataset.cmsToolbar || '{}'); - var command = { - type: 'add-sectionEntry', - payload: { - section: toolbarDefinition.section, - } - }; - frameMessenger.send(window.parent, command); -}; -const deleteSection = (event) => { - var toolbar = event.target.closest('[data-cms-toolbar]'); - var toolbarDefinition = JSON.parse(toolbar.dataset.cmsToolbar || '{}'); - var command = { - type: 'delete-sectionEntry', - payload: { - sectionUri: toolbarDefinition.uri - } - }; - frameMessenger.send(window.parent, command); -}; -const setPublishForSection = (event) => { - var toolbar = event.target.closest('[data-cms-toolbar]'); - var toolbarDefinition = JSON.parse(toolbar.dataset.cmsToolbar || '{}'); - var action = event.currentTarget.getAttribute('data-cms-action'); - var command = { - type: 'section-set-published', - payload: { - sectionUri: toolbarDefinition.uri, - published: action === "publish" - } - }; - frameMessenger.send(window.parent, command); -}; -const orderSections = (event) => { - var toolbar = event.target.closest('[data-cms-toolbar]'); - var toolbarDefinition = JSON.parse(toolbar.dataset.cmsToolbar || '{}'); - var command = { - type: 'edit-sections', - payload: { - section: toolbarDefinition.section - } - }; - frameMessenger.send(window.parent, command); -}; -const editContent = (event) => { - var toolbar = event.target.closest('[data-cms-toolbar]'); - var toolbarDefinition = JSON.parse(toolbar.dataset.cmsToolbar || '{}'); - var command = { - type: 'edit', - payload: { - editor: "markdown", - element: "content" - } - }; - if (toolbarDefinition.uri) { - command.payload.uri = toolbarDefinition.uri; - } - frameMessenger.send(window.parent, command); -}; -const editAttributes = (event) => { - var toolbar = event.target.closest('[data-cms-toolbar]'); - var toolbarDefinition = JSON.parse(toolbar.dataset.cmsToolbar || '{}'); - var command = { - type: 'edit', - payload: { - editor: "form", - element: "meta", - form: toolbarDefinition.form ? toolbarDefinition.form : "attributes", - type: toolbarDefinition.type - } - }; - if (toolbarDefinition.uri) { - command.payload.uri = toolbarDefinition.uri; - } - // legay old style to collect all meta elements for the form editor - /* - var elements = [] - toolbar.parentNode.querySelectorAll("[data-cms-editor]").forEach(($elem : HTMLElement) => { - var toolbar = $elem.dataset.cmsToolbar ? JSON.parse($elem.dataset.cmsToolbar) : {}; - if ($elem.dataset.cmsElement === "meta" - && (!toolbar.id || toolbar.id === toolbarDefinition.id) - ) { - elements.push({ - name: $elem.dataset.cmsMetaElement, - editor: $elem.dataset.cmsEditor, - options: $elem.dataset.cmsEditorOptions ? JSON.parse($elem.dataset.cmsEditorOptions) : {} - }) - } - }) - command.payload.metaElements = elements - */ - frameMessenger.send(window.parent, command); -}; -export const initToolbar = (container) => { - var toolbarDefinition = JSON.parse(container.dataset.cmsToolbar || '{}'); - if (!toolbarDefinition.actions) { - return; - } - if (toolbarDefinition.type === "sectionEntry") { - container.classList.add("cms-ui-editable-sections"); - } - else { - container.classList.add("cms-ui-editable"); - } - const toolbar = document.createElement('div'); - toolbar.className = 'cms-ui-toolbar'; - if (toolbarDefinition.type === "sectionEntry") { - toolbar.classList.add("cms-ui-toolbar-tl"); - } - else { - toolbar.classList.add("cms-ui-toolbar-tr"); - } - toolbar.classList.add("cms-ui-toolbar"); - toolbar.addEventListener('mouseover', () => { - toolbar.classList.add('visible'); - }); - toolbar.addEventListener('mouseleave', (event) => { - if (!event.relatedTarget || !toolbar.contains(event.relatedTarget)) { - toolbar.classList.remove('visible'); - } - }); - toolbarDefinition.actions.forEach((action) => { - if (action === "editContent") { - const button = document.createElement('button'); - button.setAttribute('data-cms-action', 'edit'); - button.innerHTML = EDIT_PAGE_ICON; - button.setAttribute("title", "Edit content"); - button.addEventListener('click', editContent); - toolbar.appendChild(button); - } - else if (action === "editAttributes") { - const button = document.createElement('button'); - button.setAttribute('data-cms-action', 'editAttributes'); - button.innerHTML = EDIT_ATTRIBUTES_ICON; - button.setAttribute("title", "Edit attributes"); - button.addEventListener('click', editAttributes); - toolbar.appendChild(button); - } - else if (action === "orderSectionEntries") { - const button = document.createElement('button'); - button.setAttribute('data-cms-action', 'editSections'); - button.innerHTML = SECTION_SORT_ICON; - button.setAttribute("title", "Order"); - button.addEventListener('click', orderSections); - toolbar.appendChild(button); - } - else if (action === "addSectionEntry") { - const button = document.createElement('button'); - button.setAttribute('data-cms-action', 'addSection'); - button.innerHTML = SECTION_ADD_ICON; - button.setAttribute("title", "Add"); - button.addEventListener('click', addSection); - toolbar.appendChild(button); - } - else if (action === "deleteSectionEntry") { - const button = document.createElement('button'); - button.setAttribute('data-cms-action', 'deleteSection'); - button.innerHTML = SECTION_DELETE_ICON; - button.setAttribute("title", "Delete"); - button.addEventListener('click', deleteSection); - toolbar.appendChild(button); - } - }); - if (toolbarDefinition.type === "sectionEntry") { - const button = document.createElement('button'); - button.setAttribute('data-cms-action', 'publish'); - button.setAttribute('data-cms-section-uri', toolbarDefinition.uri); - button.classList.add('cms-unpublished'); - button.innerHTML = SECTION_UNPUBLISHED_ICON; - button.setAttribute("title", "Publish"); - button.addEventListener('click', setPublishForSection); - toolbar.appendChild(button); - } - container.insertBefore(toolbar, container.firstChild); - container.addEventListener('mouseover', () => { - toolbar.classList.add('visible'); - }); - container.addEventListener('mouseleave', (event) => { - if (!event.relatedTarget || !container.contains(event.relatedTarget)) { - toolbar.classList.remove('visible'); - } - }); - toolbar.addEventListener('mouseleave', (event) => { - if (!event.relatedTarget || !container.contains(event.relatedTarget)) { - toolbar.classList.remove('visible'); - } - }); -}; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/modal.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/modal.d.ts deleted file mode 100644 index a6bc8574c..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/modal.d.ts +++ /dev/null @@ -1 +0,0 @@ -export function openModal(optionsParam: any): any; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/modal.js b/modules/ui-module/src/main/ts/dist/js/modules/modal.js deleted file mode 100644 index b973d2257..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/modal.js +++ /dev/null @@ -1,141 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { i18n } from "@cms/modules/localization.js"; -const defaultOptions = { - validate: () => true -}; -const openModal = (optionsParam) => { - const modalId = 'fullscreenModal_' + Date.now(); - const options = { - ...defaultOptions, - ...optionsParam - }; - let fullscreen = ""; - if (options.fullscreen) { - fullscreen = "modal-fullscreen"; - } - let size = ""; - if (options.size) { - size = "modal-" + options.size; - } - const modalHtml = ` - `; - const container = document.getElementById('modalContainer'); - const modalDiv = document.createElement('div'); - modalDiv.innerHTML = modalHtml.trim(); - const modalNode = modalDiv.firstChild; - container.appendChild(modalNode); - const modalElement = document.getElementById(modalId); - // Prüfe ob eine Offcanvas offen ist - const openOffcanvas = document.querySelector('.offcanvas.show'); - const hasOpenOffcanvas = openOffcanvas !== null; - // Z-Index höher setzen wenn Offcanvas offen ist - const modalZIndex = hasOpenOffcanvas ? 1080 : 1060; - const backdropZIndex = hasOpenOffcanvas ? 1070 : 1055; - modalElement.style.zIndex = modalZIndex; - modalElement.style.pointerEvents = 'auto'; - const modalInstance = new bootstrap.Modal(modalElement, { - backdrop: 'static', - keyboard: true, - focus: true - }); - modalElement.addEventListener('shown.bs.modal', function (event) { - // Backdrop z-index anpassen - const backdrops = document.querySelectorAll('.modal-backdrop'); - const latestBackdrop = backdrops[backdrops.length - 1]; - if (latestBackdrop) { - latestBackdrop.style.zIndex = backdropZIndex; - latestBackdrop.style.pointerEvents = 'none'; - } - // Offcanvas temporär nach hinten schieben - if (hasOpenOffcanvas) { - openOffcanvas.style.zIndex = '1050'; - openOffcanvas.style.pointerEvents = 'none'; - const offcanvasBackdrop = document.querySelector('.offcanvas-backdrop'); - if (offcanvasBackdrop) { - offcanvasBackdrop.style.zIndex = '1045'; - offcanvasBackdrop.style.pointerEvents = 'none'; - } - } - // Modal und Content explizit aktivieren - modalElement.style.pointerEvents = 'auto'; - const modalContent = modalElement.querySelector('.modal-content'); - if (modalContent) { - modalContent.style.pointerEvents = 'auto'; - } - // Form ERST initialisieren wenn Modal sichtbar ist - if (options.form) { - options.form.init(`#${modalId}_bodyContainer`); - } - if (options.onShow) { - options.onShow(modalElement); - } - }); - modalInstance.show(); - // Event-Handler - document.getElementById(`${modalId}_cancelBtn`).addEventListener('click', () => { - modalInstance.hide(); - if (typeof options.onCancel === 'function') - options.onCancel(); - }); - document.getElementById(`${modalId}_okBtn`).addEventListener('click', () => { - if (options.validate()) { - modalInstance.hide(); - if (typeof options.onOk === 'function') - options.onOk(); - } - }); - // Clean-up nach Schließen - modalElement.addEventListener('hidden.bs.modal', () => { - // Offcanvas z-index und pointer-events wiederherstellen - if (hasOpenOffcanvas && openOffcanvas) { - openOffcanvas.style.zIndex = ''; - openOffcanvas.style.pointerEvents = ''; - const offcanvasBackdrop = document.querySelector('.offcanvas-backdrop'); - if (offcanvasBackdrop) { - offcanvasBackdrop.style.zIndex = ''; - offcanvasBackdrop.style.pointerEvents = ''; - } - } - modalNode.remove(); - if (options.onClose) { - options.onClose(); - } - }); - return modalInstance; -}; -export { openModal }; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/node.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/node.d.ts deleted file mode 100644 index ade17f827..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/node.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Retrieves a nested value from an object using a dot-notated path like "meta.title" - * @param {object} sourceObj - The object to retrieve the value from - * @param {string} path - Dot-notated string path, e.g., "meta.title" - * @returns {*} - The value found at the given path, or undefined if not found - */ -export function getValueByPath(sourceObj: object, path: string): any; -/** - * Builds a values object from an array of form fields - * @param {Array} fields - Array of form field objects, each with a .name property - * @param {object} sourceObj - The source object to extract the values from - * @returns {object} values - An object mapping field names to their corresponding values - */ -export function buildValuesFromFields(fields: any[], sourceObj: object): object; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/node.js b/modules/ui-module/src/main/ts/dist/js/modules/node.js deleted file mode 100644 index 0bd7846c9..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/node.js +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -/** - * Retrieves a nested value from an object using a dot-notated path like "meta.title" - * @param {object} sourceObj - The object to retrieve the value from - * @param {string} path - Dot-notated string path, e.g., "meta.title" - * @returns {*} - The value found at the given path, or undefined if not found - */ -export function getValueByPath(sourceObj, path) { - return path.split('.').reduce((acc, part) => acc?.[part], sourceObj); -} -; -/** - * Builds a values object from an array of form fields - * @param {Array} fields - Array of form field objects, each with a .name property - * @param {object} sourceObj - The source object to extract the values from - * @returns {object} values - An object mapping field names to their corresponding values - */ -export function buildValuesFromFields(fields, sourceObj) { - const values = {}; - for (const field of fields) { - if (!field.name) - continue; - values[field.name] = getValueByPath(sourceObj, field.name); - } - return values; -} -; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/preview.history.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/preview.history.d.ts deleted file mode 100644 index 19f953414..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/preview.history.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -export namespace PreviewHistory { - export { init }; - export { navigatePreview }; -} -declare function init(defaultUrl?: null): void; -declare function navigatePreview(url: any, usePush?: boolean): void; -export {}; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/preview.history.js b/modules/ui-module/src/main/ts/dist/js/modules/preview.history.js deleted file mode 100644 index 8343d00c8..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/preview.history.js +++ /dev/null @@ -1,119 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -export const PreviewHistory = (() => { - const iframeId = "contentPreview"; - const storageKey = "cms-previewHistoryStack"; - let lastUrl = null; - function getIframe() { - return document.getElementById(iframeId); - } - function getStack() { - try { - return JSON.parse(sessionStorage.getItem(storageKey)) || []; - } - catch (e) { - return []; - } - } - function setStack(stack) { - sessionStorage.setItem(storageKey, JSON.stringify(stack)); - } - function getIndexFromHash() { - const hash = location.hash; - const index = parseInt(hash.replace("#", ""), 10); - return isNaN(index) ? null : index; - } - function setIndexInHash(index) { - history.pushState({ iframeIndex: index }, "", `#${index}`); - } - function navigatePreview(url, usePush = true) { - const iframe = getIframe(); - if (!iframe) - return; - const stack = getStack(); - stack.push(url); - setStack(stack); - const index = stack.length - 1; - iframe.src = url; - lastUrl = url; - if (usePush) { - setIndexInHash(index); - } - } - function restoreFromStack() { - const iframe = getIframe(); - if (!iframe) - return; - const stack = getStack(); - const index = getIndexFromHash(); - if (index !== null && stack[index]) { - iframe.src = stack[index]; - lastUrl = stack[index]; - } - else if (stack.length > 0) { - const lastIndex = stack.length - 1; - iframe.src = stack[lastIndex]; - lastUrl = stack[lastIndex]; - setIndexInHash(lastIndex); - } - } - function handlePopState(event) { - restoreFromStack(); - } - function setupOnloadFallback() { - const iframe = getIframe(); - if (!iframe) - return; - iframe.onload = () => { - try { - const current = iframe.contentWindow.location.href; - if (current !== lastUrl) { - const stack = getStack(); - stack.push(current); - setStack(stack); - const index = stack.length - 1; - setIndexInHash(index); - lastUrl = current; - } - } - catch (e) { - // Cross-origin – nichts tun - } - }; - } - function init(defaultUrl = null) { - window.addEventListener("popstate", handlePopState); - window.addEventListener("load", () => { - const stack = getStack(); - if (stack.length === 0 && defaultUrl) { - navigatePreview(defaultUrl); - } - else { - restoreFromStack(); - } - setupOnloadFallback(); - }); - } - return { - init, - navigatePreview, - }; -})(); diff --git a/modules/ui-module/src/main/ts/dist/js/modules/preview.utils.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/preview.utils.d.ts deleted file mode 100644 index 24beb8ecc..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/preview.utils.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export function activatePreviewOverlay(): void; -export function deActivatePreviewOverlay(): void; -export function getPreviewUrl(): any; -export function reloadPreview(): void; -export function loadPreview(url: any): void; -export function getPreviewFrame(): HTMLElement | null; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/preview.utils.js b/modules/ui-module/src/main/ts/dist/js/modules/preview.utils.js deleted file mode 100644 index efc5be27a..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/preview.utils.js +++ /dev/null @@ -1,78 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { EventBus } from "@cms/modules/event-bus.js"; -//PreviewHistory.init(); -// close overlay on preview loaded -EventBus.on("preview:loaded", (data) => { - deActivatePreviewOverlay(); -}); -export const activatePreviewOverlay = () => { - const overlay = document.getElementById("previewOverlay"); - if (overlay) { - overlay.style.display = "flex"; - } -}; -export const deActivatePreviewOverlay = () => { - const overlay = document.getElementById("previewOverlay"); - if (overlay) { - overlay.style.display = "none"; - } -}; -const getPreviewFrame = () => { - return document.getElementById("contentPreview"); -}; -const getPreviewUrl = () => { - try { - return getPreviewFrame().contentWindow.location.href; - } - catch (e) { - console.warn("Konnte iframe-URL nicht auslesen", e); - return ""; - } -}; -const reloadPreview = () => { - activatePreviewOverlay(); - getPreviewFrame().contentDocument.location.reload(true); -}; -const loadPreview = (url) => { - activatePreviewOverlay(); - try { - // Fallback-Host für relative URLs, damit URL-Parsing funktioniert - const dummyBase = window.location.origin; - const parsedUrl = new URL(url, dummyBase); - // Wenn "preview" bereits gesetzt ist, nicht erneut hinzufügen - if (!parsedUrl.searchParams.has("preview")) { - parsedUrl.searchParams.append("preview", "manager"); - } - parsedUrl.searchParams.delete("preview-token"); - //parsedUrl.searchParams.append("preview-token", window.manager.previewToken); - parsedUrl.searchParams.delete("nocache"); - parsedUrl.searchParams.append("nocache", Date.now()); - // Setze zusammengesetzten Pfad + Query zurück in das iframe - const result = parsedUrl.pathname + parsedUrl.search; - document.getElementById("contentPreview").src = result; - //PreviewHistory.navigatePreview(result); - } - catch (e) { - console.error("Ungültige URL:", url, e); - } -}; -export { getPreviewUrl, reloadPreview, loadPreview, getPreviewFrame }; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/rpc/rpc-content.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/rpc/rpc-content.d.ts deleted file mode 100644 index 500f28b21..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/rpc/rpc-content.d.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { RPCResponse } from '@cms/modules/rpc/rpc.js'; -declare const getContentNode: (options: any) => Promise; -declare const getContent: (options: any) => Promise; -declare const setContent: (options: any) => Promise; -export interface ReplaceContent { - error: boolean | null; - uri: string; -} -export interface ReplaceContentOptions { - uri: string; - content: string; - start: number; - end: number; -} -declare const replaceContent: (options: ReplaceContentOptions) => Promise>; -declare const setMeta: (options: any) => Promise; -declare const setMetaBatch: (options: any) => Promise; -declare const addSection: (options: any) => Promise; -declare const deleteSection: (options: any) => Promise; -export { getContentNode, getContent, setContent, replaceContent, setMeta, setMetaBatch, addSection, deleteSection }; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/rpc/rpc-content.js b/modules/ui-module/src/main/ts/dist/js/modules/rpc/rpc-content.js deleted file mode 100644 index e0a97a880..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/rpc/rpc-content.js +++ /dev/null @@ -1,78 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { executeRemoteCall } from '@cms/modules/rpc/rpc.js'; -const getContentNode = async (options) => { - var data = { - method: "content.node", - parameters: options - }; - return await executeRemoteCall(data); -}; -const getContent = async (options) => { - var data = { - method: "content.get", - parameters: options - }; - return await executeRemoteCall(data); -}; -const setContent = async (options) => { - var data = { - method: "content.set", - parameters: options - }; - return await executeRemoteCall(data); -}; -const replaceContent = async (options) => { - var data = { - method: "content.replace", - parameters: options - }; - return await executeRemoteCall(data); -}; -const setMeta = async (options) => { - var data = { - method: "meta.set", - parameters: options - }; - return await executeRemoteCall(data); -}; -const setMetaBatch = async (options) => { - var data = { - method: "meta.set.batch", - parameters: options - }; - return await executeRemoteCall(data); -}; -const addSection = async (options) => { - var data = { - method: "content.sectionEntry.add", - parameters: options - }; - return await executeRemoteCall(data); -}; -const deleteSection = async (options) => { - var data = { - method: "content.sectionEntry.delete", - parameters: options - }; - return await executeRemoteCall(data); -}; -export { getContentNode, getContent, setContent, replaceContent, setMeta, setMetaBatch, addSection, deleteSection }; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/rpc/rpc-files.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/rpc/rpc-files.d.ts deleted file mode 100644 index 19350eb0f..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/rpc/rpc-files.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -declare const listFiles: (options: any) => Promise; -declare const deleteFile: (options: any) => Promise; -declare const deleteFolder: (options: any) => Promise; -declare const createFolder: (options: any) => Promise; -declare const createFile: (options: any) => Promise; -declare const renameFile: (options: any) => Promise; -export { listFiles, deleteFile, createFolder, createFile, deleteFolder, renameFile }; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/rpc/rpc-files.js b/modules/ui-module/src/main/ts/dist/js/modules/rpc/rpc-files.js deleted file mode 100644 index afccfd692..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/rpc/rpc-files.js +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { executeRemoteCall } from '@cms/modules/rpc/rpc.js'; -const listFiles = async (options) => { - var data = { - method: "files.list", - parameters: options - }; - return await executeRemoteCall(data); -}; -const deleteFile = async (options) => { - var data = { - method: "files.delete", - parameters: options - }; - return await executeRemoteCall(data); -}; -const deleteFolder = async (options) => { - var data = { - method: "files.delete", - parameters: options - }; - return await executeRemoteCall(data); -}; -const createFolder = async (options) => { - var data = { - method: "folders.create", - parameters: options - }; - return await executeRemoteCall(data); -}; -const createFile = async (options) => { - var data = { - method: "files.create", - parameters: options - }; - return await executeRemoteCall(data); -}; -const renameFile = async (options) => { - var data = { - method: "files.rename", - parameters: options - }; - return await executeRemoteCall(data); -}; -export { listFiles, deleteFile, createFolder, createFile, deleteFolder, renameFile }; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/rpc/rpc-i18n.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/rpc/rpc-i18n.d.ts deleted file mode 100644 index 97184c7b3..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/rpc/rpc-i18n.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -declare const loadLocalizations: (options: any) => Promise; -export { loadLocalizations }; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/rpc/rpc-i18n.js b/modules/ui-module/src/main/ts/dist/js/modules/rpc/rpc-i18n.js deleted file mode 100644 index b7dbfe50e..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/rpc/rpc-i18n.js +++ /dev/null @@ -1,28 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { executeRemoteCall } from '@cms/modules/rpc/rpc.js'; -const loadLocalizations = async (options) => { - var data = { - method: "i18n.load" - }; - return await executeRemoteCall(data); -}; -export { loadLocalizations }; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/rpc/rpc-manager.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/rpc/rpc-manager.d.ts deleted file mode 100644 index 09de5e435..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/rpc/rpc-manager.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -declare const getSectionEntryTemplates: (options: any) => Promise; -declare const getPageTemplates: (options: any) => Promise; -declare const getListItemTypes: (options: any) => Promise; -declare const getMediaForm: (options: any) => Promise; -declare const createCSRFToken: (options: any) => Promise; -export declare enum Format { - WEBP = 0, - JPEG = 1, - PNG = 2 -} -export interface MediaFormat { - name: string; - height?: number; - width?: number; - format: Format; - compression: boolean; - cropped: boolean; -} -export interface MediaFormatsResponse { - result: MediaFormat[]; -} -declare const getMediaFormats: (options: any) => Promise; -declare const getShortCodeNames: (options: any) => Promise; -export { getSectionEntryTemplates, getPageTemplates, getMediaForm, getShortCodeNames, getMediaFormats, getListItemTypes, createCSRFToken }; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/rpc/rpc-manager.js b/modules/ui-module/src/main/ts/dist/js/modules/rpc/rpc-manager.js deleted file mode 100644 index d9c29286f..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/rpc/rpc-manager.js +++ /dev/null @@ -1,77 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { executeRemoteCall } from '@cms/modules/rpc/rpc.js'; -const getSectionEntryTemplates = async (options) => { - var data = { - method: "manager.contentTypes.sectionEntries", - parameters: options || {} - }; - return await executeRemoteCall(data); -}; -const getPageTemplates = async (options) => { - var data = { - method: "manager.contentTypes.pages", - parameters: options || {} - }; - return await executeRemoteCall(data); -}; -const getListItemTypes = async (options) => { - var data = { - method: "manager.contentTypes.listItemTypes", - parameters: options || {} - }; - return await executeRemoteCall(data); -}; -const getMediaForm = async (options) => { - var data = { - method: "manager.media.form", - parameters: options || {} - }; - return await executeRemoteCall(data); -}; -const createCSRFToken = async (options) => { - var data = { - method: "manager.token.createCSRF", - parameters: options || {} - }; - return await executeRemoteCall(data); -}; -export var Format; -(function (Format) { - Format[Format["WEBP"] = 0] = "WEBP"; - Format[Format["JPEG"] = 1] = "JPEG"; - Format[Format["PNG"] = 2] = "PNG"; -})(Format || (Format = {})); -const getMediaFormats = async (options) => { - var data = { - method: "manager.media.formats", - parameters: options - }; - return await executeRemoteCall(data); -}; -const getShortCodeNames = async (options) => { - var data = { - method: "manager.content.shortCodes", - parameters: options - }; - return await executeRemoteCall(data); -}; -export { getSectionEntryTemplates, getPageTemplates, getMediaForm, getShortCodeNames, getMediaFormats, getListItemTypes, createCSRFToken }; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/rpc/rpc-media.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/rpc/rpc-media.d.ts deleted file mode 100644 index e2f3eb480..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/rpc/rpc-media.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -declare const getMediaMetaData: (options: any) => Promise; -declare const setMediaMetaData: (options: any) => Promise; -export { getMediaMetaData, setMediaMetaData }; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/rpc/rpc-media.js b/modules/ui-module/src/main/ts/dist/js/modules/rpc/rpc-media.js deleted file mode 100644 index 9ffca53d8..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/rpc/rpc-media.js +++ /dev/null @@ -1,36 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { executeRemoteCall } from '@cms/modules/rpc/rpc.js'; -const getMediaMetaData = async (options) => { - var data = { - method: "media.meta.get", - parameters: options - }; - return await executeRemoteCall(data); -}; -const setMediaMetaData = async (options) => { - var data = { - method: "media.meta.set", - parameters: options - }; - return await executeRemoteCall(data); -}; -export { getMediaMetaData, setMediaMetaData }; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/rpc/rpc-page.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/rpc/rpc-page.d.ts deleted file mode 100644 index 5e9c6f05a..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/rpc/rpc-page.d.ts +++ /dev/null @@ -1,39 +0,0 @@ -export interface CreatePageOptions { - uri: string; - name: string; - contentType: string; -} -export interface CreatePageResponse { - result: { - uri?: string; - error?: string; - }; -} -declare const createPage: (options: CreatePageOptions) => Promise; -export interface FilterPagesOptions { - where?: Field[]; - page?: number; - size?: number; -} -export interface Field { - field: string; - operator: string; - value: any; -} -export interface ItemDto { - uri: string; - meta?: any; -} -export interface PageDto { - totalItems: number; - pageSize: number; - totalPages: number; - page: number; - items: ItemDto[]; -} -export interface FilterPagesResponse { - result: PageDto; -} -declare const filterPages: (options: FilterPagesOptions) => Promise; -declare const deletePage: (options: any) => Promise; -export { createPage, deletePage, filterPages }; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/rpc/rpc-page.js b/modules/ui-module/src/main/ts/dist/js/modules/rpc/rpc-page.js deleted file mode 100644 index 5976bf42e..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/rpc/rpc-page.js +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { executeRemoteCall } from '@cms/modules/rpc/rpc.js'; -const createPage = async (options) => { - var data = { - method: "page.create", - parameters: options - }; - return await executeRemoteCall(data); -}; -const filterPages = async (options) => { - var data = { - method: "pages.filter", - parameters: options - }; - return await executeRemoteCall(data); -}; -const deletePage = async (options) => { - var data = { - method: "page.delete", - parameters: options - }; - return await executeRemoteCall(data); -}; -export { createPage, deletePage, filterPages }; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/rpc/rpc-translation.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/rpc/rpc-translation.d.ts deleted file mode 100644 index 0f2b8e64a..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/rpc/rpc-translation.d.ts +++ /dev/null @@ -1,33 +0,0 @@ -export interface GetTranslationsOptions { - uri: string; -} -export interface TranslationDto { - site: string; - lang: string; - country: string; - url?: string; - managerDeepLink?: string; -} -declare const getTranslations: (options: GetTranslationsOptions) => Promise<{ - translations: TranslationDto[]; -}>; -export interface AddTranslationOptions { - uri: string; - language: string; - translationUri: string; -} -export interface AddTranslationResult { - uri: string; - error?: boolean; -} -declare const addTranslation: (options: AddTranslationOptions) => Promise; -export interface RemoveTranslationOptions { - uri: string; - lang: string; -} -export interface RemoveTranslationResult { - uri: string; - error?: boolean; -} -declare const removeTranslation: (options: RemoveTranslationOptions) => Promise; -export { getTranslations, addTranslation, removeTranslation }; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/rpc/rpc-translation.js b/modules/ui-module/src/main/ts/dist/js/modules/rpc/rpc-translation.js deleted file mode 100644 index 805cb9f60..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/rpc/rpc-translation.js +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { executeRemoteCall } from '@cms/modules/rpc/rpc.js'; -const getTranslations = async (options) => { - var data = { - method: "translations.get", - parameters: options - }; - return (await executeRemoteCall(data)).result; -}; -const addTranslation = async (options) => { - var data = { - method: "translations.add", - parameters: options - }; - return (await executeRemoteCall(data)).result; -}; -const removeTranslation = async (options) => { - var data = { - method: "translations.add", - parameters: options - }; - return (await executeRemoteCall(data)).result; -}; -export { getTranslations, addTranslation, removeTranslation }; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/rpc/rpc.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/rpc/rpc.d.ts deleted file mode 100644 index 121bc30e4..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/rpc/rpc.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -interface Options { - method: string; - parameters?: any; -} -export interface RPCResponse { - result: T; -} -declare const executeRemoteCall: (options: Options) => Promise; -declare const executeRemoteMethodCall: (method: string, parameters: any) => Promise; -export { executeRemoteCall, executeRemoteMethodCall }; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/rpc/rpc.js b/modules/ui-module/src/main/ts/dist/js/modules/rpc/rpc.js deleted file mode 100644 index d1598ff2a..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/rpc/rpc.js +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { i18n } from "@cms/modules/localization.js"; -import { getCSRFToken } from "../utils"; -const executeRemoteCall = async (options) => { - return executeRemoteMethodCall(options.method, options.parameters); -}; -const executeRemoteMethodCall = async (method, parameters) => { - var data = { - method: method, - parameters: parameters - }; - const csrfToken = getCSRFToken(); - var response = await fetch(window.manager.baseUrl + "/rpc", { - method: "POST", - headers: { - 'Content-Type': 'application/json', - ...(csrfToken && { 'X-CSRF-Token': csrfToken }) - }, - body: JSON.stringify(data) - }); - if (response.status === 403) { - alert(i18n.t("ui.redirect.login", "You where logged out due to inactivity. Please log in again.")); - window.location.href = window.manager.baseUrl + "/login"; - throw new Error("Unauthorized"); - } - return await response.json(); -}; -export { executeRemoteCall, executeRemoteMethodCall }; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/sidebar.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/sidebar.d.ts deleted file mode 100644 index 268aae235..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/sidebar.d.ts +++ /dev/null @@ -1 +0,0 @@ -export function openSidebar(options: any): void; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/sidebar.js b/modules/ui-module/src/main/ts/dist/js/modules/sidebar.js deleted file mode 100644 index 3885c4f4e..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/sidebar.js +++ /dev/null @@ -1,140 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -const openSidebar = (options) => { - const sidebarId = 'offcanvasSidebar_' + Date.now(); - const position = ['start', 'end', 'top', 'bottom'].includes(options.position) - ? options.position - : 'end'; - const isResizable = position === 'end' && (options.resizable === true); - const sidebarHtml = ` -
- ${isResizable ? '
' : ''} -
-
${options.title || 'Sidebar Title'}
- -
-
- ${options.body || '

Sidebar content

'} -
- -
- `; - const container = document.getElementById('sidebarContainer'); - container.innerHTML = sidebarHtml; - if (options.form) { - options.form.init("#sidebarBodyContainer"); - } - const sidebarElement = document.getElementById(sidebarId); - // Setze initiale Breite nur für resizable sidebar - if (isResizable) { - sidebarElement.style.width = (options.initialWidth || 400) + 'px'; - } - const sidebarInstance = new bootstrap.Offcanvas(sidebarElement, { - backdrop: 'static', - keyboard: options.keyboard ?? false - }); - sidebarInstance.show(); - // Fix für Modals über Offcanvas - const handleModalShow = (e) => { - const modal = e.target; - const modalBackdrop = document.querySelector('.modal-backdrop:last-of-type'); - // Setze höhere z-index Werte - modal.style.zIndex = '1080'; - if (modalBackdrop) { - modalBackdrop.style.zIndex = '1070'; - } - // Reduziere Offcanvas z-index temporär - sidebarElement.style.zIndex = '1050'; - const offcanvasBackdrop = document.querySelector('.offcanvas-backdrop'); - if (offcanvasBackdrop) { - offcanvasBackdrop.style.zIndex = '1045'; - } - }; - const handleModalHide = () => { - // Stelle Offcanvas z-index wieder her - sidebarElement.style.zIndex = ''; - const offcanvasBackdrop = document.querySelector('.offcanvas-backdrop'); - if (offcanvasBackdrop) { - offcanvasBackdrop.style.zIndex = ''; - } - }; - // Event Listener für alle Modals - document.addEventListener('show.bs.modal', handleModalShow); - document.addEventListener('hidden.bs.modal', handleModalHide); - // Buttons - document.getElementById(`${sidebarId}_cancelBtn`).addEventListener('click', () => { - sidebarInstance.hide(); - if (typeof options.onCancel === 'function') - options.onCancel(); - }); - document.getElementById(`${sidebarId}_okBtn`).addEventListener('click', () => { - sidebarInstance.hide(); - if (typeof options.onOk === 'function') - options.onOk(); - }); - // Resize-Funktion (nur bei "end"-Position UND resizable === true) - let mouseMoveHandler, mouseUpHandler; - if (isResizable) { - const handle = sidebarElement.querySelector('.cms-resize-handle'); - let isResizing = false; - const mouseDownHandler = (e) => { - isResizing = true; - sidebarElement.classList.add('is-resizing'); - document.body.classList.add('resizing-sidebar'); - }; - mouseMoveHandler = (e) => { - if (!isResizing) - return; - const newWidth = window.innerWidth - e.clientX; - const clampedWidth = Math.min(Math.max(newWidth, 250), window.innerWidth * 0.9); - sidebarElement.style.width = clampedWidth + 'px'; - }; - mouseUpHandler = () => { - if (isResizing) { - isResizing = false; - sidebarElement.classList.remove('is-resizing'); - document.body.classList.remove('resizing-sidebar'); - } - }; - handle.addEventListener('mousedown', mouseDownHandler); - document.addEventListener('mousemove', mouseMoveHandler); - document.addEventListener('mouseup', mouseUpHandler); - } - // Cleanup - sidebarElement.addEventListener('hidden.bs.offcanvas', () => { - // Entferne Modal Event-Listener - document.removeEventListener('show.bs.modal', handleModalShow); - document.removeEventListener('hidden.bs.modal', handleModalHide); - // Entferne Resize Event-Listener - if (mouseMoveHandler) - document.removeEventListener('mousemove', mouseMoveHandler); - if (mouseUpHandler) - document.removeEventListener('mouseup', mouseUpHandler); - // Cleanup body classes - document.body.classList.remove('resizing-sidebar'); - // Cleanup DOM - container.innerHTML = ''; - }); -}; -export { openSidebar }; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/state.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/state.d.ts deleted file mode 100644 index 7d224a238..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/state.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -declare class State { - constructor(initialState?: {}); - state: {}; - observers: any[]; - observe(observer: any): void; - unobserve(observer: any): void; -} diff --git a/modules/ui-module/src/main/ts/dist/js/modules/state.js b/modules/ui-module/src/main/ts/dist/js/modules/state.js deleted file mode 100644 index a0988236f..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/state.js +++ /dev/null @@ -1,67 +0,0 @@ -"use strict"; -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -class State { - constructor(initialState = {}) { - this.state = initialState; - this.observers = []; - return new Proxy(this, { - get: (target, prop) => { - if (prop in target.state) { - return target.state[prop]; - } - return target[prop]; - }, - set: (target, prop, value) => { - if (prop in target.state) { - if (target.state[prop] !== value) { - target.state[prop] = value; - this.observers.forEach(({ observer, dependencies }) => { - if (dependencies.has(prop)) { - observer(this.state); - } - }); - } - } - else { - target[prop] = value; - } - }, - }); - } - observe(observer) { - const dependencies = new Set(); - const proxy = new Proxy(this.state, { - get: (target, prop) => { - dependencies.add(prop); - return target[prop]; - }, - }); - observer(proxy); - this.observers.push({ observer, dependencies }); - } - unobserve(observer) { - const index = this.observers.findIndex(entry => entry.observer === observer); - if (index !== -1) { - this.observers.splice(index, 1); - } - } -} diff --git a/modules/ui-module/src/main/ts/dist/js/modules/toast.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/toast.d.ts deleted file mode 100644 index 0fcd8a129..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/toast.d.ts +++ /dev/null @@ -1 +0,0 @@ -export function showToast(options: any): void; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/toast.js b/modules/ui-module/src/main/ts/dist/js/modules/toast.js deleted file mode 100644 index 6a5f4a036..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/toast.js +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { i18n } from '@cms/modules/localization.js'; -const showToast = (options) => { - const toastId = 'toast_' + Date.now(); - // Fallbacks - const title = options.title || i18n.t("toast.title", "Note"); - const message = options.message || ''; - const type = options.type || 'info'; // info, success, warning, error - const timeout = typeof options.timeout === 'number' ? options.timeout : 5000; - // Toast-Container erstellen, falls nicht vorhanden - let container = document.getElementById('toastContainer'); - if (!container) { - container = document.createElement('div'); - container.id = 'toastContainer'; - container.className = 'toast-container position-fixed top-0 end-0 p-3'; - document.body.appendChild(container); - } - const colorClasses = { - info: 'bg-info text-white', - success: 'bg-success text-white', - warning: 'bg-warning text-dark', - error: 'bg-danger text-white' - }; - const toastHtml = ` - `; - container.insertAdjacentHTML('beforeend', toastHtml); - const toastElement = document.getElementById(toastId); - const toastInstance = new bootstrap.Toast(toastElement, { - autohide: true, - delay: timeout - }); - toastInstance.show(); - toastElement.addEventListener('hidden.bs.toast', () => { - toastElement.remove(); - if (typeof options.onClose === 'function') { - options.onClose(); - } - }); -}; -export { showToast }; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/ui-state.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/ui-state.d.ts deleted file mode 100644 index d064b5d45..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/ui-state.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -export namespace UIStateManager { - function setTabState(key: any, value: any): void; - function getTabState(key: any, defaultValue?: null): any; - function setLocale(locale: any): void; - function getLocale(): any; - function removeTabState(key: any): void; - function setAuthToken(token: any): void; - function getAuthToken(): string | null; - function clearAuthToken(): void; -} diff --git a/modules/ui-module/src/main/ts/dist/js/modules/ui-state.js b/modules/ui-module/src/main/ts/dist/js/modules/ui-state.js deleted file mode 100644 index b0b34fd1c..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/ui-state.js +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -// state-manager.js -import { EventBus } from "@cms/modules/event-bus.js"; -const TAB_ID_KEY = "cms-tab-id"; -const AUTH_KEY = "cms-auth-token"; -export const UIStateManager = { - // Save generic tab-specific state - setTabState(key, value) { - sessionStorage.setItem(key, JSON.stringify(value)); - }, - getTabState(key, defaultValue = null) { - const raw = sessionStorage.getItem(key); - return raw ? JSON.parse(raw) : defaultValue; - }, - setLocale(locale) { - this.setTabState("cms-locale", locale); - EventBus.emit("ui:localeChanged", { - locale: locale - }); - }, - getLocale() { - return this.getTabState("cms-locale"); - }, - removeTabState(key) { - sessionStorage.removeItem(key); - }, - // Save shared auth state - setAuthToken(token) { - localStorage.setItem(AUTH_KEY, token); - }, - getAuthToken() { - return localStorage.getItem(AUTH_KEY); - }, - clearAuthToken() { - localStorage.removeItem(AUTH_KEY); - }, -}; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/upload.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/upload.d.ts deleted file mode 100644 index 760c8f380..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/upload.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -export function uploadFileWithProgress({ uploadEndpoint, file, uri, onProgress, onSuccess, onError }: { - uploadEndpoint: any; - file: any; - uri: any; - onProgress: any; - onSuccess: any; - onError: any; -}): void; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/upload.js b/modules/ui-module/src/main/ts/dist/js/modules/upload.js deleted file mode 100644 index cf76cbfcb..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/upload.js +++ /dev/null @@ -1,63 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { getCSRFToken } from "./utils"; -// uploadFileWithProgress.js -export function uploadFileWithProgress({ uploadEndpoint, file, uri, onProgress, onSuccess, onError }) { - if (!file) { - onError?.("No file selected."); - return; - } - const MAX_FILE_SIZE_BYTES = 10 * 1024 * 1024; // 10 MB - if (file.size > MAX_FILE_SIZE_BYTES) { - onError?.(`File is too large. Maximum size is ${MAX_FILE_SIZE_BYTES} bytes.`); - return; - } - const formData = new FormData(); - formData.append("file", file); - formData.append("uri", uri); - const xhr = new XMLHttpRequest(); - xhr.open("POST", uploadEndpoint ?? "/manager/upload", true); - xhr.setRequestHeader("X-CSRF-Token", getCSRFToken()); - xhr.upload.onprogress = (event) => { - if (event.lengthComputable && typeof onProgress === "function") { - const percent = Math.round((event.loaded / event.total) * 100); - onProgress(percent); - } - }; - xhr.onload = () => { - if (xhr.status === 200) { - try { - const json = JSON.parse(xhr.responseText); - onSuccess?.(json); // Übergibt das JSON an den Callback - } - catch (e) { - onError?.("Response is not valid JSON."); - } - } - else { - onError?.(`Upload failed: ${xhr.status} ${xhr.statusText}`); - } - }; - xhr.onerror = () => { - onError?.("Upload error occurred."); - }; - xhr.send(formData); -} diff --git a/modules/ui-module/src/main/ts/dist/js/modules/utils.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/utils.d.ts deleted file mode 100644 index 73eff8a4d..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/utils.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export declare function getCSRFToken(): string | null; -export declare function setCSRFToken(token: string): void; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/utils.js b/modules/ui-module/src/main/ts/dist/js/modules/utils.js deleted file mode 100644 index ea91e10fb..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/utils.js +++ /dev/null @@ -1,33 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -export function getCSRFToken() { - const meta = document.querySelector('meta[name="csrf-token"]'); - return meta ? meta.getAttribute('content') : null; -} -export function setCSRFToken(token) { - let meta = document.querySelector('meta[name="csrf-token"]'); - if (!meta) { - meta = document.createElement('meta'); - meta.setAttribute('name', 'csrf-token'); - document.head.appendChild(meta); - } - meta.setAttribute('content', token); -} diff --git a/modules/ui-module/src/main/ts/dist/js/modules/wizard.d.ts b/modules/ui-module/src/main/ts/dist/js/modules/wizard.d.ts deleted file mode 100644 index 13b63e736..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/wizard.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export function openWizard(optionsParam: any): { - wizardId: string; - modalInstance: any; - goToStep: (index: any) => void; - getCurrentStep: () => number; -}; diff --git a/modules/ui-module/src/main/ts/dist/js/modules/wizard.js b/modules/ui-module/src/main/ts/dist/js/modules/wizard.js deleted file mode 100644 index 688b9529f..000000000 --- a/modules/ui-module/src/main/ts/dist/js/modules/wizard.js +++ /dev/null @@ -1,207 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { i18n } from "@cms/modules/localization.js"; -const defaultOptions = { - title: 'Wizard', - fullscreen: false, - size: null, - showStepIndicator: true, - nextLabel: () => i18n.t('wizard.buttons.next', 'Next'), - prevLabel: () => i18n.t('wizard.buttons.previous', 'Previous'), - finishLabel: () => i18n.t('wizard.buttons.finish', 'Finish'), - cancelLabel: () => i18n.t('wizard.buttons.cancel', 'Cancel'), - validateStep: () => true, -}; -const renderStepBody = (step, containerId) => { - const container = document.getElementById(containerId); - if (!container) - return; - container.innerHTML = ''; - if (typeof step.body === 'function') { - const bodyResult = step.body(); - if (typeof bodyResult === 'string') { - container.innerHTML = bodyResult; - } - else if (bodyResult instanceof HTMLElement) { - container.appendChild(bodyResult); - } - else if (bodyResult && typeof bodyResult.then === 'function') { - bodyResult.then((result) => { - container.innerHTML = typeof result === 'string' ? result : ''; - if (result instanceof HTMLElement) { - container.appendChild(result); - } - }); - } - } - else if (step.body instanceof HTMLElement) { - container.appendChild(step.body); - } - else { - container.innerHTML = step.body || ''; - } -}; -const renderStepIndicator = (steps, currentStep, indicatorContainer) => { - if (!indicatorContainer) - return; - indicatorContainer.innerHTML = ''; - steps.forEach((step, index) => { - const stepNode = document.createElement('div'); - stepNode.className = `wizard-step-item ${index === currentStep ? 'active' : index < currentStep ? 'completed' : ''}`; - stepNode.innerHTML = ` -
${index + 1}
-
${step.title || i18n.t('wizard.step', 'Step')} ${index + 1}
- `; - indicatorContainer.appendChild(stepNode); - }); -}; -const openWizard = (optionsParam) => { - const wizardId = 'wizard_' + Date.now(); - const options = { - ...defaultOptions, - ...optionsParam, - }; - const steps = Array.isArray(options.steps) ? options.steps : []; - let currentStep = 0; - let fullscreen = ''; - if (options.fullscreen) { - fullscreen = 'modal-fullscreen'; - } - let size = ''; - if (options.size) { - size = 'modal-' + options.size; - } - const modalHtml = ` - `; - const container = document.getElementById('modalContainer'); - const modalDiv = document.createElement('div'); - modalDiv.innerHTML = modalHtml.trim(); - const modalNode = modalDiv.firstChild; - container.appendChild(modalNode); - const modalElement = document.getElementById(wizardId); - const modalInstance = new bootstrap.Modal(modalElement, { - backdrop: 'static', - keyboard: true, - focus: true, - }); - const prevBtn = document.getElementById(`${wizardId}_prevBtn`); - const nextBtn = document.getElementById(`${wizardId}_nextBtn`); - const cancelBtn = document.getElementById(`${wizardId}_cancelBtn`); - const stepTitle = document.getElementById(`${wizardId}_stepTitle`); - const stepIndicator = options.showStepIndicator ? document.getElementById(`${wizardId}_stepIndicator`) : null; - const bodyContainerId = `${wizardId}_bodyContainer`; - const updateButtons = () => { - prevBtn.style.display = currentStep === 0 ? 'none' : ''; - nextBtn.textContent = currentStep === steps.length - 1 ? options.finishLabel() : options.nextLabel(); - }; - const renderStep = () => { - const step = steps[currentStep] || {}; - const titleText = step.title || `${i18n.t('wizard.step', 'Step')} ${currentStep + 1}`; - if (stepTitle) { - stepTitle.textContent = titleText; - } - renderStepBody(step, bodyContainerId); - if (options.showStepIndicator && stepIndicator) { - renderStepIndicator(steps, currentStep, stepIndicator); - } - updateButtons(); - if (typeof step.onShow === 'function') { - step.onShow(modalElement); - } - }; - const goToStep = (index) => { - const step = steps[currentStep] || {}; - if (typeof step.validate === 'function' && !step.validate()) { - return; - } - if (typeof options.validateStep === 'function' && !options.validateStep(currentStep)) { - return; - } - if (currentStep !== index && typeof step.onHide === 'function') { - step.onHide(modalElement); - } - currentStep = Math.max(0, Math.min(index, steps.length - 1)); - renderStep(); - if (typeof options.onStepChange === 'function') { - options.onStepChange(currentStep); - } - }; - prevBtn.addEventListener('click', () => goToStep(currentStep - 1)); - cancelBtn.addEventListener('click', () => { - modalInstance.hide(); - if (typeof options.onCancel === 'function') { - options.onCancel(); - } - }); - nextBtn.addEventListener('click', () => { - const step = steps[currentStep] || {}; - const valid = typeof step.validate === 'function' ? step.validate() : true; - if (!valid) { - return; - } - if (currentStep === steps.length - 1) { - modalInstance.hide(); - if (typeof options.onFinish === 'function') { - options.onFinish(); - } - return; - } - goToStep(currentStep + 1); - }); - modalElement.addEventListener('shown.bs.modal', () => { - renderStep(); - if (typeof options.onShow === 'function') { - options.onShow(modalElement); - } - }); - modalElement.addEventListener('hidden.bs.modal', () => { - modalNode.remove(); - if (typeof options.onClose === 'function') { - options.onClose(); - } - }); - modalInstance.show(); - return { - wizardId, - modalInstance, - goToStep, - getCurrentStep: () => currentStep, - }; -}; -export { openWizard }; diff --git a/modules/ui-module/src/main/ts/dist/js/ui-actions.d.ts b/modules/ui-module/src/main/ts/dist/js/ui-actions.d.ts deleted file mode 100644 index cb0ff5c3b..000000000 --- a/modules/ui-module/src/main/ts/dist/js/ui-actions.d.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/modules/ui-module/src/main/ts/dist/js/ui-actions.js b/modules/ui-module/src/main/ts/dist/js/ui-actions.js deleted file mode 100644 index b7485aa8e..000000000 --- a/modules/ui-module/src/main/ts/dist/js/ui-actions.js +++ /dev/null @@ -1,71 +0,0 @@ -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -import { EventBus } from '@cms/modules/event-bus.js'; -import { i18n, localizeUi } from '@cms/modules/localization.js'; -import { executeHookAction, executeScriptAction } from '@cms/js/manager-globals'; -window.addEventListener("DOMContentLoaded", async () => { - /* - await i18n.init() - await localizeUi(); - var langSelect = document.querySelector(`[data-cms-i18n-lang='${i18n.getLocale()}']`) - if (langSelect) { - langSelect.classList.add("active"); - } - */ - document.querySelectorAll(".cms-lang-selector").forEach($elem => { - $elem.addEventListener("click", async () => { - i18n.setLocale($elem.getAttribute("data-cms-i18n-lang")); - await localizeUi(); - document.querySelectorAll(".cms-lang-selector").forEach(el => { - el.classList.remove("active"); - }); - $elem.classList.add("active"); - const dropdown = bootstrap.Dropdown.getInstance($elem.closest('.dropdown')) - || new bootstrap.Dropdown($elem.closest('.dropdown').querySelector('[data-bs-toggle="dropdown"]')); - dropdown.hide(); - }); - }); - EventBus.on("ui:localeChanged", (data) => { - }); - const actionElements = document.querySelectorAll('[data-cms-action-definition]'); - actionElements.forEach(element => { - try { - element.addEventListener("click", (action) => { - const definition = element.getAttribute('data-cms-action-definition'); - try { - const action = JSON.parse(definition); - if (action.type === "hook") { - executeHookAction(action); - } - else if (action.type === "script") { - executeScriptAction(action); - } - } - catch (e) { - console.error('error parsing error definition', e); - } - }); - } - catch (e) { - console.error('', e); - } - }); -}); diff --git a/modules/ui-module/src/main/ts/dist/public/manager-login.d.ts b/modules/ui-module/src/main/ts/dist/public/manager-login.d.ts deleted file mode 100644 index 5b5817d8a..000000000 --- a/modules/ui-module/src/main/ts/dist/public/manager-login.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -declare const ui: { - state: string; -}; -declare const setWarningMessage: (message: string) => void; -declare const clearMessage: () => void; -declare const signIn: (e: Event) => void; -declare const validate: (e: Event) => void; -declare const formSubmit: (e: Event) => void; diff --git a/modules/ui-module/src/main/ts/dist/public/manager-login.js b/modules/ui-module/src/main/ts/dist/public/manager-login.js deleted file mode 100644 index 24aa077ae..000000000 --- a/modules/ui-module/src/main/ts/dist/public/manager-login.js +++ /dev/null @@ -1,118 +0,0 @@ -"use strict"; -/*- - * #%L - * UI Module - * %% - * Copyright (C) 2023 - 2026 CondationCMS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * #L% - */ -const ui = { - state: "login" -}; -const setWarningMessage = (message) => { - const alert = document.querySelector("#loginMessage"); - if (alert) { - alert.innerHTML = message; - alert.classList.add("alert-warning"); - } -}; -const clearMessage = () => { - const alert = document.querySelector("#loginMessage"); - if (alert) { - alert.innerHTML = ""; - alert.classList.remove("alert-warning"); - } -}; -const signIn = (e) => { - e.preventDefault(); - clearMessage(); - fetch(window.ui.login_url, { - method: "POST", - headers: { - "Content-Type": "application/json" - }, - body: JSON.stringify({ - command: "login", - data: { - username: document.querySelector("#inputUsername")?.value, - password: document.querySelector("#inputPassword")?.value - } - }) - }) - .then(response => response.json()) - .then(result => { - if (result.status === "2fa_required") { - document.querySelector("#signIn")?.classList.toggle("hidden"); - document.querySelector("#validate")?.classList.toggle("hidden"); - ui.state = "validate"; - } - else if (result.status === "ok") { - window.location.href = result.redirect || window.ui.manager_url; - } - else { - setWarningMessage("Login failed, maybe your credentials are incorrect. Please try again or contact your admin."); - } - }); -}; -const validate = (e) => { - e.preventDefault(); - clearMessage(); - // 2FA-Feld anzeigen oder ist schon sichtbar - const code = document.querySelector("#inputCode")?.value; - fetch(window.ui.login_url, { - method: "POST", - headers: { - "Content-Type": "application/json" - }, - body: JSON.stringify({ - command: "validate", - data: { - code: code - } - }) - }) - .then(response => response.json()) - .then(validateResult => { - if (validateResult.status === "ok") { - window.location.href = validateResult.redirect || window.ui.manager_url; - } - else { - setWarningMessage("Validation of the login code failed. Please try again or contact your admin."); - } - }); -}; -const formSubmit = (e) => { - e.preventDefault(); - if (ui.state === "login") { - signIn(e); - } - else { - validate(e); - } -}; -if (document.querySelector("#resetButton")) { - document.querySelector("#resetButton")?.addEventListener("click", (e) => { - ui.state = "login"; - document.querySelector("#loginForm").reset(); - document.querySelector("#signIn")?.classList.remove("hidden"); - document.querySelector("#validate")?.classList.add("hidden"); - }); -} -if (document.querySelector("#validateButton")) { - document.querySelector("#validateButton")?.addEventListener("click", validate); -} -document.querySelector("#signInButton")?.addEventListener("click", signIn); -document.querySelector("#loginForm")?.addEventListener("submit", formSubmit); diff --git a/modules/ui-module/src/main/ts/package.json b/modules/ui-module/src/main/ts/package.json index 601d608d7..7b9c98d3b 100644 --- a/modules/ui-module/src/main/ts/package.json +++ b/modules/ui-module/src/main/ts/package.json @@ -3,9 +3,9 @@ "author": "CondationCMS", "version": "0.2.0", "scripts": { - "build": "tsc" + "build": "tsc && node scripts/copy-dist.mjs" }, "devDependencies": { "typescript": "^6.0.3" } -} +} \ No newline at end of file diff --git a/modules/ui-module/src/main/ts/scripts/copy-dist.mjs b/modules/ui-module/src/main/ts/scripts/copy-dist.mjs new file mode 100644 index 000000000..309461c69 --- /dev/null +++ b/modules/ui-module/src/main/ts/scripts/copy-dist.mjs @@ -0,0 +1,26 @@ +import { cp, mkdir, rm } from "node:fs/promises"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); + +const sourceRoot = path.resolve(__dirname, "../dist"); +const targetRoot = path.resolve(__dirname, "../../resources/manager"); + +const folders = ["actions", "js", "public"]; + +for (const folder of folders) { + const source = path.join(sourceRoot, folder); + const target = path.join(targetRoot, folder); + + await rm(target, { recursive: true, force: true }); + await mkdir(targetRoot, { recursive: true }); + await cp(source, target, { recursive: true }); + + console.log(`Copied ${source} to ${target}`); +} + +// dist erst löschen, wenn alles erfolgreich kopiert wurde +await rm(sourceRoot, { recursive: true, force: true }); + +console.log(`Deleted ${sourceRoot}`); \ No newline at end of file diff --git a/modules/ui-module/src/main/ts/src/actions/media/select-content-media.ts b/modules/ui-module/src/main/ts/src/actions/media/select-content-media.ts index 0914c8f19..e8fbc5532 100644 --- a/modules/ui-module/src/main/ts/src/actions/media/select-content-media.ts +++ b/modules/ui-module/src/main/ts/src/actions/media/select-content-media.ts @@ -19,7 +19,7 @@ * #L% */ -import { openFileBrowser } from "@cms/modules/filebrowser.js"; +import { openMediaBrowser } from "@cms/modules/media/mediabrowser.js"; import { i18n } from "@cms/modules/localization.js"; import { getPreviewUrl, reloadPreview } from "@cms/modules/preview.utils.js"; import { getContentNode, replaceContent, ReplaceContentOptions } from "@cms/modules/rpc/rpc-content.js"; @@ -39,7 +39,7 @@ export async function runAction(params : any) { uri = contentNode.result.uri } - openFileBrowser({ + openMediaBrowser({ type: "assets", filter : (file: any) => { return file.media || file.directory; diff --git a/modules/ui-module/src/main/ts/src/actions/media/select-media.ts b/modules/ui-module/src/main/ts/src/actions/media/select-media.ts index 08cbb96b2..869ec094f 100644 --- a/modules/ui-module/src/main/ts/src/actions/media/select-media.ts +++ b/modules/ui-module/src/main/ts/src/actions/media/select-media.ts @@ -19,7 +19,7 @@ * #L% */ -import { openFileBrowser } from "@cms/modules/filebrowser.js"; +import { openMediaBrowser } from "@cms/modules/media/mediabrowser.js"; import { i18n } from "@cms/modules/localization.js"; import { getPreviewUrl, reloadPreview } from "@cms/modules/preview.utils.js"; import { getContentNode, setMeta } from "@cms/modules/rpc/rpc-content.js"; @@ -38,7 +38,7 @@ export async function runAction(params : any) { uri = contentNode.result.uri } - openFileBrowser({ + openMediaBrowser({ type: "assets", filter : (file: any) => { return file.media || file.directory; diff --git a/modules/ui-module/src/main/ts/src/actions/page/manage-assets.js b/modules/ui-module/src/main/ts/src/actions/page/manage-assets.js index 84cc2078d..fd8860d56 100644 --- a/modules/ui-module/src/main/ts/src/actions/page/manage-assets.js +++ b/modules/ui-module/src/main/ts/src/actions/page/manage-assets.js @@ -18,11 +18,14 @@ * along with this program. If not, see . * #L% */ -import {openFileBrowser} from '@cms/modules/filebrowser.js' +import {openMediaBrowser} from '@cms/modules/media/mediabrowser.js' // hook.js export async function runAction(params) { - openFileBrowser({ - type: "assets" + openMediaBrowser({ + type: "assets", + filter : (file) => { + return file.media || file.directory; + }, }) } diff --git a/modules/ui-module/src/main/ts/src/js/modules/form/field.markdown.ts b/modules/ui-module/src/main/ts/src/js/modules/form/field.markdown.ts index 4256f19c9..b8b9a2403 100644 --- a/modules/ui-module/src/main/ts/src/js/modules/form/field.markdown.ts +++ b/modules/ui-module/src/main/ts/src/js/modules/form/field.markdown.ts @@ -21,7 +21,7 @@ import { createID } from "@cms/modules/form/utils.js"; import { i18n } from "@cms/modules/localization.js" import { getMediaFormats, getShortCodeNames } from "@cms/modules/rpc/rpc-manager.js"; -import { openFileBrowser } from "@cms/modules/filebrowser.js"; +import { openMediaBrowser } from "@cms/modules/media/mediabrowser.js"; import { alertSelect } from "@cms/modules/alerts.js"; import { FieldOptions, FormContext, FormField } from "@cms/modules/form/forms.js"; import { patchPathWithContext } from "@cms/js/manager-globals"; @@ -181,7 +181,7 @@ const cmsImageSelection = window.Cherry.createMenuHook("Image", { name: any, event: any) => { - openFileBrowser({ + openMediaBrowser({ type: "assets", fullscreen: false, filter: (file: any) => { diff --git a/modules/ui-module/src/main/ts/src/js/modules/form/field.media.ts b/modules/ui-module/src/main/ts/src/js/modules/form/field.media.ts index 76a0a242c..8b98b5851 100644 --- a/modules/ui-module/src/main/ts/src/js/modules/form/field.media.ts +++ b/modules/ui-module/src/main/ts/src/js/modules/form/field.media.ts @@ -21,7 +21,7 @@ import { createID } from "@cms/modules/form/utils.js"; import { i18n } from "@cms/modules/localization.js" import { uploadFileWithProgress } from "@cms/modules/upload.js"; -import { openFileBrowser } from "@cms/modules/filebrowser.js"; +import { openMediaBrowser } from "@cms/modules/media/mediabrowser.js"; import { FieldOptions, FormContext, FormField } from "@cms/modules/form/forms.js"; import { patchPathWithContext } from "@cms/js/manager-globals"; @@ -138,7 +138,7 @@ const init = (context : FormContext) => { // Handle MediaManager button robust: remove old handler, use onclick openMediaManager.onclick = null; openMediaManager.onclick = () => { - openFileBrowser({ + openMediaBrowser({ type: "assets", filter : (file : any) => { return file.media || file.directory; diff --git a/modules/ui-module/src/main/ts/src/js/modules/media/mediabrowser.actions.js b/modules/ui-module/src/main/ts/src/js/modules/media/mediabrowser.actions.js new file mode 100644 index 000000000..f634e0c87 --- /dev/null +++ b/modules/ui-module/src/main/ts/src/js/modules/media/mediabrowser.actions.js @@ -0,0 +1,211 @@ +/*- + * #%L + * UI Module + * %% + * Copyright (C) 2023 - 2026 CondationCMS + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * #L% + */ + +import { createFolder, createFile, renameFile } from '@cms/modules/rpc/rpc-files.js' +import { createPage } from '@cms/modules/rpc/rpc-page.js' + +import { i18n } from '@cms/modules/localization.js'; +import { alertConfirm, alertPrompt } from '@cms/modules/alerts.js' +import { showToast } from '@cms/modules/toast.js' + +export async function renameFileAction({ state, getTargetFolder, filename }) { + const newName = await alertPrompt({ + title: i18n.t("filebrowser.rename.title", "Rename file"), + label: i18n.t("filebrowser.rename.label", "New name"), + placeholder: filename + }); + var extraOptions = {} + if (state.options.siteId) { + extraOptions.siteId = state.options.siteId; + } + if (newName) { + var response = await renameFile({ + uri: getTargetFolder(), + name: filename, + newName: newName, + type: state.options.type, + ...extraOptions + }); + if (response.error) { + showToast({ + title: i18n.t("filebrowser.rename.error.title", 'Error renaming file'), + message: response.error.message, + type: 'error', + timeout: 3000 + }); + } else { + showToast({ + title: i18n.t("filebrowser.rename.success.title", 'File renamed'), + message: i18n.t("filebrowser.rename.success.message", "File renamed successfully"), + type: 'info', + timeout: 3000 + }); + } + } +} + +export async function deleteElementAction({ elementName, state, deleteFN, getTargetFolder }) { + + var confimred = await alertConfirm({ + title: i18n.t("filebrowser.delete.confirm.title", "Are you sure?"), + message: i18n.t("filebrowser.delete.confirm.message", "You won't be able to revert this!"), + confirmText: i18n.t("filebrowser.delete.confirm.yes", "Yes, delete it!"), + cancelText: i18n.t("filebrowser.delete.confirm.no", "No, cancel!") + }); + if (!confimred) { + return; + } + + var extraOptions = {} + if (state.options.siteId) { + extraOptions.siteId = state.options.siteId; + } + + var response = await deleteFN({ + uri: getTargetFolder(), + name: elementName, + type: state.options.type, + ...extraOptions + }) + if (response.error) { + showToast({ + title: 'Error deleting', + message: response.error.message, + type: 'error', // optional: info | success | warning | error + timeout: 3000 + }); + } else { + showToast({ + title: 'Element deleted', + message: "Element deleted", + type: 'success', // optional: info | success | warning | error + timeout: 3000 + }); + } +} + +export async function createFolderAction({ state, getTargetFolder }) { + const folderName = await alertPrompt({ + title: i18n.t("filebrowser.createFolder.title", "Create new folder"), + label: i18n.t("filebrowser.createFolder.label", "Folder name"), + placeholder: i18n.t("filebrowser.createFolder.placeholder", "New Folder") + }); + if (folderName) { + + var extraOptions = {} + if (state.options.siteId) { + extraOptions.siteId = state.options.siteId; + } + + var response = await createFolder({ + uri: getTargetFolder(), + name: folderName, + type: state.options.type, + ...extraOptions + }); + if (response.error) { + showToast({ + title: i18n.t("filebrowser.createFolder.error.title", 'Error creating folder'), + message: response.error.message, + type: 'error', // optional: info | success | warning | error + timeout: 3000 + }); + } else { + showToast({ + title: i18n.t("filebrowser.createFolder.success.title", 'Folder created'), + message: i18n.t("filebrowser.createFolder.success.message", "Folder created successfully"), + type: 'success', // optional: info | success | warning | error + timeout: 3000 + }); + } + } +} + +export async function createFileAction({ state, getTargetFolder }) { + const fileName = await alertPrompt({ + title: i18n.t("filebrowser.createFile.title", "Create new file"), + label: i18n.t("filebrowser.createFile.label", "File name"), + placeholder: i18n.t("filebrowser.createFile.placeholder", "New File") + }); + if (fileName) { + var extraOptions = {} + if (state.options.siteId) { + extraOptions.siteId = state.options.siteId; + } + var response = await createFile({ + uri: getTargetFolder(), + name: fileName, + type: state.options.type, + ...extraOptions + }); + if (response.error) { + showToast({ + title: i18n.t("filebrowser.createFile.error.title", 'Error creating file'), + message: response.error.message, + type: 'error', // optional: info | success | warning | error + timeout: 3000 + }); + } else { + showToast({ + title: i18n.t("filebrowser.createFile.success.title", 'File created'), + message: i18n.t("filebrowser.createFile.success.message", "File created successfully"), + type: 'success', // optional: info | success | warning | error + timeout: 3000 + }); + } + } +} + +export async function createPageActionOfContentType({state, getTargetFolder, contentType }) { + const pageName = await alertPrompt({ + title: i18n.t("filebrowser.createPage.title", "Create new page"), + label: i18n.t("filebrowser.createPage.label", "Page name"), + placeholder: i18n.t("filebrowser.createPage.placeholder", "New Page") + }); + + if (!pageName || !contentType) return; + + var extraOptions = {} + if (state.options.siteId) { + extraOptions.siteId = state.options.siteId; + } + let response = await createPage({ + uri: getTargetFolder(), + name: pageName, + contentType: contentType, + ...extraOptions + }); + if (response.error) { + showToast({ + title: i18n.t("filebrowser.createPage.error.title", 'Error creating page'), + message: response.error.message, + type: 'error', + timeout: 3000 + }); + } else { + showToast({ + title: i18n.t("filebrowser.createPage.success.title", 'Page created'), + message: i18n.t("filebrowser.createPage.success.message", 'Page successfuly created'), + type: 'success', + timeout: 3000 + }); + } +} diff --git a/modules/ui-module/src/main/ts/src/js/modules/media/mediabrowser.create.js b/modules/ui-module/src/main/ts/src/js/modules/media/mediabrowser.create.js new file mode 100644 index 000000000..d208eec66 --- /dev/null +++ b/modules/ui-module/src/main/ts/src/js/modules/media/mediabrowser.create.js @@ -0,0 +1,175 @@ +/*- + * #%L + * UI Module + * %% + * Copyright (C) 2023 - 2026 CondationCMS + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * #L% + */ + +import { listFiles } from '@cms/modules/rpc/rpc-files.js' +import { createPage } from '@cms/modules/rpc/rpc-page' +import { openModal } from '@cms/modules/modal.js' +import { i18n } from '@cms/modules/localization.js' +import { alertPrompt } from '@cms/modules/alerts.js' +import { showToast } from '@cms/modules/toast.js' +import { mediabrowserTemplate } from '@cms/modules/media/mediabrowser.template.js' +import { createFolderAction } from '@cms/modules/media/mediabrowser.actions.js' + +const defaultOptions = { + uri: "", + template: null, + contentType: null, + onCreate: null, + fullscreen: true, + title: i18n.t("filebrowser.create.title", "Create node"), + type: null, + siteId: null +}; + +const state = { + options: null, + currentFolder: "", + modal: null +}; + +const openCreateContentBrowser = async (params) => { + state.options = { ...defaultOptions, ...params }; + + state.modal = openModal({ + title: state.options.title, + body: '
', + fullscreen: state.options.fullscreen, + onOk: async () => { + const fileName = await alertPrompt({ + title: i18n.t("filebrowser.createFile.title", "Create new node"), + label: i18n.t("filebrowser.createFile.label", "Node name"), + placeholder: i18n.t("filebrowser.createFile.placeholder", "New Node") + }); + if (!fileName) return; + + const extraOptions = {}; + if (state.options.siteId) { + extraOptions.siteId = state.options.siteId; + } + + const response = await createPage({ + uri: getTargetFolder(), + name: fileName, + contentType: state.options.contentType, + type: state.options.type, + ...extraOptions + }); + + if (response.error) { + showToast({ + title: i18n.t("filebrowser.createFile.error.title", 'Error creating file'), + message: response.error.message, + type: 'error', + timeout: 3000 + }); + } else { + showToast({ + title: i18n.t("filebrowser.createFile.success.title", 'File created'), + message: i18n.t("filebrowser.createFile.success.message", "File created successfully"), + type: 'success', + timeout: 3000 + }); + if (state.options.onCreate) { + state.options.onCreate({ + uri : response.result.uri, + name: fileName + }); + } + } + }, + onShow: async () => { + initBrowser(state.options.uri); + } + }); +}; + +const initBrowser = async (uri) => { + state.currentFolder = uri ?? ""; + + const options = { + type: state.options.type, + uri: state.currentFolder + }; + if (state.options.siteId) { + options.siteId = state.options.siteId; + } + + const contentFiles = await listFiles(options); + const files = contentFiles.result.files; + + const directories = files.filter(f => f.directory); + + const browserElement = document.getElementById("cms-create-content-browser"); + if (!browserElement) return; + + browserElement.innerHTML = mediabrowserTemplate({ + files: directories, + filenameHeader: i18n.t("filebrowser.filename", "Filename"), + actionHeader: i18n.t("filebrowser.action", "Action"), + actions: [{ + id: "cms-create-content-action-createFolder", + name: i18n.t("filebrowser.create.folder", "Create folder") + }], + asset: false, + pageContentTypes: [] + }); + + makeDirectoriesClickable(); + wireActions(); + initBootstrapTooltips(); +}; + +const makeDirectoriesClickable = () => { + document.querySelectorAll("[data-cms-file-directory]").forEach((element) => { + element.addEventListener("dblclick", (event) => { + event.stopPropagation(); + const directory = element.getAttribute("data-cms-file-uri"); + if (directory) { + initBrowser(directory); + } + }); + }); +}; + +const wireActions = () => { + const createFolderBtn = document.getElementById("cms-create-content-action-createFolder"); + if (createFolderBtn) { + createFolderBtn.addEventListener("click", async () => { + await createFolderAction({ state, getTargetFolder }); + await initBrowser(state.currentFolder); + }); + } +}; + +const initBootstrapTooltips = () => { + document.querySelectorAll('[data-bs-toggle="tooltip"]').forEach((el) => { + new bootstrap.Tooltip(el); + }); +}; + +const getTargetFolder = () => { + if (state.currentFolder.startsWith("/")) { + return state.currentFolder.substring(1); + } + return state.currentFolder; +}; + +export { openCreateContentBrowser }; diff --git a/modules/ui-module/src/main/ts/src/js/modules/media/mediabrowser.js b/modules/ui-module/src/main/ts/src/js/modules/media/mediabrowser.js new file mode 100644 index 000000000..59a1d86c9 --- /dev/null +++ b/modules/ui-module/src/main/ts/src/js/modules/media/mediabrowser.js @@ -0,0 +1,279 @@ +/*- + * #%L + * UI Module + * %% + * Copyright (C) 2023 - 2026 CondationCMS + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * #L% + */ + +import { listFiles, deleteFile, deleteFolder, } from '@cms/modules/rpc/rpc-files.js' +import { deletePage } from '@cms/modules/rpc/rpc-page.js' +import { openModal } from '@cms/modules/modal.js' +import { loadPreview } from '@cms/modules/preview.utils.js' +import { i18n } from '@cms/modules/localization.js'; + +import { renameFileAction, deleteElementAction, createFolderAction, createFileAction, createPageActionOfContentType } from '@cms/modules/media/mediabrowser.actions.js' +import { initDragAndDropUpload, handleFileUpload } from '@cms/modules/media/mediabrowser.upload.js'; +import { EventBus } from '@cms/modules/event-bus.js'; +import { mediabrowserTemplate } from '@cms/modules/media/mediabrowser.template.js'; +import { getPageTemplates } from '@cms/modules/rpc/rpc-manager.js'; +import { showToast } from '@cms/modules/toast.js'; + +const defaultOptions = { + validate: () => true, + uri: "", + onSelect: null, + fullscreen: true, + title: i18n.t("mediabrowser.title", "Media Browser"), + filter : (file) => { + return true; // Default filter allows all files + } +}; + +const state = { + options: null, + currentFolder: "" +}; + +let cachedPageTemplates = null; + +EventBus.on("upload:success", (folder) => { + initMediaBrowser(state.currentFolder); +}); + +const openMediaBrowser = async (optionsParam) => { + state.options = { + ...defaultOptions, + ...optionsParam + }; + + state.modal = openModal({ + title: state.options.title, + body: '
', + fullscreen: state.options.fullscreen, + onOk: async (event) => { + const selectedRow = document.querySelector(".cms-media-card.selected[data-cms-file-uri]:not([data-cms-file-directory])"); + if (selectedRow && state.options.onSelect) { + const uri = selectedRow.getAttribute("data-cms-file-uri"); + const name = selectedRow.getAttribute("data-cms-file-name"); + state.options.onSelect({ uri, name }); + } + }, + onShow: async () => { + initMediaBrowser(state.options.uri); + } + }); +}; + +const initMediaBrowser = async (uri) => { + if (!state.options) return; + state.currentFolder = uri ? uri : ""; + + var options = { + type: state.options.type, + uri: state.currentFolder + } + if (state.options.siteId) { + options.siteId = state.options.siteId; + } + + const contentFiles = await listFiles(options); + + var files = contentFiles.result.files; + if (state.options.filter) { + files = files.filter(state.options.filter); + } + + const fileBrowserElement = document.getElementById("cms-file-browser"); + if (fileBrowserElement) { + fileBrowserElement.innerHTML = mediabrowserTemplate({ + files: files, + filenameHeader: i18n.t("filebrowser.filename", "Filename"), + actionHeader: i18n.t("filebrowser.action", "Action"), + actions: getActions(), + asset: state.options.type === "assets", + pageContentTypes: (cachedPageTemplates ??= (await getPageTemplates()).result) + }); + makeDirectoriesClickable(); + if (state.options.onSelect) { + makeFilesSelectableAndSelectable(); + } + + fileActions(); + initBootstrapTooltips(); + initDragAndDropUpload(); + } +}; +const initBootstrapTooltips = () => { + const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]'); + tooltipTriggerList.forEach((tooltipTriggerEl) => { + new bootstrap.Tooltip(tooltipTriggerEl); + }); +}; + +const makeFilesSelectableAndSelectable = () => { + const rows = document.querySelectorAll(".cms-media-card[data-cms-file-uri]:not([data-cms-file-directory])"); + rows.forEach((row) => { + row.addEventListener("dblclick", () => { + const uri = row.getAttribute("data-cms-file-uri"); + const name = row.getAttribute("data-cms-file-name"); + if (state.options.onSelect) { + state.options.onSelect({ uri, name }); + } + state.modal.hide(); + }); + row.addEventListener("click", () => { + rows.forEach(r => r.classList.remove("selected")); + row.classList.add("selected"); + }); + }); +}; + + +const getActions = () => [ + { + id: "cms-filebrowser-action-createFolder", + name: i18n.t("filebrowser.create.folder", "Create folder") + } +] + +const makeDirectoriesClickable = () => { + const elements = document.querySelectorAll("[data-cms-file-directory]"); + elements.forEach((element) => { + element.addEventListener("dblclick", (event) => { + event.stopPropagation(); + const directory = element.getAttribute("data-cms-file-uri"); + if (directory) { + initMediaBrowser(directory); + } + }); + }); +}; + +const fileActions = () => { + const elements = document.querySelectorAll("[data-cms-file-action]"); + elements.forEach((element) => { + element.addEventListener("click", async (event) => { + event.stopPropagation(); + const uri = element.getAttribute("data-cms-file-uri"); + const filename = element.closest("[data-cms-file-name]").dataset.cmsFileName + const action = element.getAttribute("data-cms-file-action"); + + if (action === "open") { + await loadPreview(uri); + state.modal.hide(); + } else if (action === "copyUrl") { + navigator.clipboard.writeText(uri).then( + () => { + showToast({ + title: i18n.t('filebrowser.actions.url.copy.title', "URL copied"), + message: i18n.t('filebrowser.actions.url.copy.message', "URL copied to clipboard"), + type: 'success', + timeout: 3000 + }); + }, + () => { + showToast({ + title: i18n.t('filebrowser.actions.url.copy.title.error', "Error copying URL"), + message: i18n.t('filebrowser.actions.url.copy.message.error', "Failed to copy URL"), + type: 'error', + timeout: 3000 + }); + }, + ); + } else if (action === "deletePage") { + deleteElementAction({ + elementName: filename, + state: state, + deleteFN: deletePage, + getTargetFolder: getTargetFolder + }).then(async () => { + await initMediaBrowser(state.currentFolder); + }); + } else if (action === "deleteFile") { + deleteElementAction({ + elementName: filename, + state: state, + deleteFN: deleteFile, + getTargetFolder: getTargetFolder + }).then(async () => { + await initMediaBrowser(state.currentFolder); + }); + } else if (action === "deleteFolder") { + deleteElementAction({ + elementName: filename, + state: state, + deleteFN: deleteFolder, + getTargetFolder: getTargetFolder + }).then(async () => { + await initMediaBrowser(state.currentFolder); + }); + } else if (action === "renameFile") { + renameFileAction({ + state: state, + getTargetFolder: getTargetFolder, + filename: filename + }).then(async () => { + await initMediaBrowser(state.currentFolder); + }); + } + }); + }); + + const createFolderBtn = document.getElementById("cms-filebrowser-action-createFolder"); + if (createFolderBtn) { + createFolderBtn.addEventListener("click", async (event) => { + createFolderAction({ + state: state, + getTargetFolder: getTargetFolder + }).then(async () => { + await initMediaBrowser(state.currentFolder); + }); + }); + } + + if (document.getElementById("cms-filebrowser-upload-button")) { + document.getElementById("cms-filebrowser-upload-button").addEventListener("click", async (event) => { + await handleFileUpload(); + }); + } + + document.querySelectorAll("[data-cms-filbrowser-ct-action='create']").forEach((element) => { + element.addEventListener("click", async (event) => { + event.preventDefault(); + const contentType = element.getAttribute("data-cms-contenttype"); + if (contentType) { + createPageActionOfContentType({ + state: state, + getTargetFolder: getTargetFolder, + contentType: contentType + }).then(async () => { + await initMediaBrowser(state.currentFolder); + }); + } + }); + }); + +}; + +const getTargetFolder = () => { + if (state.currentFolder.startsWith("/")) { + return state.currentFolder.substring(1); + } + return state.currentFolder; +}; + +export { openMediaBrowser, state }; diff --git a/modules/ui-module/src/main/ts/src/js/modules/media/mediabrowser.template.js b/modules/ui-module/src/main/ts/src/js/modules/media/mediabrowser.template.js new file mode 100644 index 000000000..7979453b9 --- /dev/null +++ b/modules/ui-module/src/main/ts/src/js/modules/media/mediabrowser.template.js @@ -0,0 +1,138 @@ +/*- + * #%L + * UI Module + * %% + * Copyright (C) 2023 - 2026 CondationCMS + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * #L% + */ + +import Handlebars from 'https://cdn.jsdelivr.net/npm/handlebars@4.7.8/+esm' +import { patchPathWithContext } from "@cms/js/manager-globals"; + +Handlebars.registerHelper("patchPathWithContext", patchPathWithContext); +Handlebars.registerHelper('concat', function (...args) { + args.pop(); + return args.join(''); +}); +Handlebars.registerHelper('ifNotEquals', function(arg1, arg2, options) { + return (arg1 !== arg2) ? options.fn(this) : options.inverse(this); +}); + +Handlebars.registerPartial('mediaBrowserContentActions', ` + {{#if pageTemplates}} + + {{/if}} +`); + +const template = Handlebars.compile(` +
+
+ + + {{#unless asset}} + {{> mediaBrowserContentActions pageTemplates=pageContentTypes }} + {{/unless}} +
+ +
+ {{#each files}} +
+
+ {{#if directory}} + + {{else if media}} + {{name}} + {{else}} + + {{/if}} +
+ +
+ {{/each}} +
+ + {{#if asset}} +
+ + + +
Drop files here
+
+ {{/if}} +
+`); + +export {template as mediabrowserTemplate}; diff --git a/modules/ui-module/src/main/ts/src/js/modules/media/mediabrowser.upload.js b/modules/ui-module/src/main/ts/src/js/modules/media/mediabrowser.upload.js new file mode 100644 index 000000000..c0a91bbdd --- /dev/null +++ b/modules/ui-module/src/main/ts/src/js/modules/media/mediabrowser.upload.js @@ -0,0 +1,139 @@ +/*- + * #%L + * UI Module + * %% + * Copyright (C) 2023 - 2026 CondationCMS + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * #L% + */ + +import { showToast } from '@cms/modules/toast.js' +import { i18n } from '@cms/modules/localization.js'; +import { state } from '@cms/modules/media/mediabrowser.js'; +import { uploadFileWithProgress} from '@cms/modules/upload.js' +import { EventBus } from '@cms/modules/event-bus.js'; + +const allowedMimeTypes = [ + "image/png", + "image/jpeg", + "image/gif", + "image/webp", + "image/svg+xml", + "image/tiff", + "image/avif" +]; + +export const initDragAndDropUpload = () => { + const dropZone = document.getElementById('drop-zone'); + const fileInput = document.getElementById('cms-fileupload'); + + if ( !dropZone || !fileInput ) { + return; + } + + // Prevent default drag behaviors; combine preventDefault+stopPropagation with per-event logic + dropZone.addEventListener('dragenter', e => { e.preventDefault(); e.stopPropagation(); }); + dropZone.addEventListener('dragover', e => { + e.preventDefault(); + e.stopPropagation(); + dropZone.classList.add('dragover'); + }); + dropZone.addEventListener('dragleave', e => { + e.preventDefault(); + e.stopPropagation(); + dropZone.classList.remove('dragover'); + }); + dropZone.addEventListener('drop', e => { + e.preventDefault(); + e.stopPropagation(); + dropZone.classList.remove('dragover'); + const files = e.dataTransfer.files; + fileInput.files = files; + uploadFile(files[0]); + }); +} + +export const handleFileUpload = async () => { + const fileInput = document.getElementById("cms-fileupload"); + if (fileInput.files.length === 0) { + showToast({ + title: i18n.t("filebrowser.file.upload.no.selection.title", 'No file selected'), + message: i18n.t("filebrowser.file.upload.no.selection.message", 'Please select a file to upload.'), + type: 'warning', + timeout: 3000 + }); + return; + } + + + const file = fileInput.files[0]; + uploadFile(file) +} + +const uploadFile = async (file) => { + if (!allowedMimeTypes.includes(file.type)) { + showToast({ + title: i18n.t("filebrowser.file.upload.wrong.type.title", 'Invalid file type'), + message: i18n.t("filebrowser.file.upload.wrong.type.message", `Only images (PNG, JPG, GIF, BMP, WEBP, TIFF, SVG, AVIF) are allowed. Selected: ${file.type}`), + type: 'error', + timeout: 4000 + }); + return; + } + + const targetFolder = getTargetFolder(); + uploadFileWithProgress({ + file, + uri: targetFolder, + onProgress: (percent) => { + updateProgressBar(percent); + }, + onSuccess: () => { + showToast({ + title: i18n.t("filebrowser.file.upload.success.title", 'Upload complete'), + message: i18n.t("filebrowser.file.upload.success.message", 'File uploaded successfully.'), + type: 'success' + }); + updateProgressBar(100); + EventBus.emit("upload:success", {}); + }, + onError: (message) => { + showToast({ + title: i18n.t("filebrowser.file.upload.error.title", "Upload failed"), + message, + type: 'error' + }); + updateProgressBar(0); + } + }); +} + +const updateProgressBar = (percent) => { + const progressBar = document.getElementById("cms-filebrowser-upload-progress"); + if (!progressBar) return; + + if (percent === 0) { + progressBar.textContent = ""; + } else { + progressBar.textContent = `Upload progress: ${percent}%`; + } +} + +const getTargetFolder = () => { + if (state.currentFolder.startsWith("/")) { + return state.currentFolder.substring(1); + } + return state.currentFolder; +};