diff --git a/build.properties.d/00_default.properties b/build.properties.d/00_default.properties index 65a2b9bc42f9e0f22dc0cd6ca6baac094e94eee7..df68f1012cd71b49538b073a4c9d17e85b2214e4 100644 --- a/build.properties.d/00_default.properties +++ b/build.properties.d/00_default.properties @@ -156,4 +156,5 @@ MODULE_DEPENDENCIES=( ext_cosmetics.js qrcode.js ext_qrcode.js + form_panel.js ) diff --git a/src/core/js/form_panel.js b/src/core/js/form_panel.js index ffe65112ffb96bd2b52144af7e44bbdba0eaa658..eda894371c99f15ac2c0464178547a5a294e712e 100644 --- a/src/core/js/form_panel.js +++ b/src/core/js/form_panel.js @@ -26,8 +26,8 @@ * placed. */ var form_panel = new function () { + const logger = log.getLogger("form_panel"); this.version = "0.1"; - // TODO (henrik) why are dependencies done differently here? this.dependencies = ["log", "caosdb_utils", "markdown", "bootstrap"]; /** @@ -68,7 +68,7 @@ var form_panel = new function () { */ this.create_show_form_callback = function (panel_id, title, form_config) { return (e) => { - form_panel.logger.trace("enter show_form_panel", e); + logger.trace("enter show_form_panel", e); const panel = $(form_panel.get_form_panel(panel_id, title)); if (panel.find("form").length === 0) { diff --git a/src/doc/extension/module.md b/src/doc/extension/module.md index d4f9b56db508d7c3be9dc0a52953de5c82bf310d..eb6a9bf8505c37a33b84db106fe850fbe7b80d96 100644 --- a/src/doc/extension/module.md +++ b/src/doc/extension/module.md @@ -63,10 +63,13 @@ Add a section to `src/core/xsl/main.xsl` to include your new file. </xsl:element> ``` +## Place Module in Load Order +Add the name of your module file to `build.properties.d/00_default.properties`, where the order is defined in which modules are loaded. + ## Add to index.html in test If you have unittests (and you should), you need to add a line in : `test/core/index.html`. ## Update the changelog -## Create a merge request \ No newline at end of file +## Create a merge request diff --git a/test/core/js/modules/form_panel.js.js b/test/core/js/modules/form_panel.js.js new file mode 100644 index 0000000000000000000000000000000000000000..bc8343d4a65233e025039e7476861fb998c2abbc --- /dev/null +++ b/test/core/js/modules/form_panel.js.js @@ -0,0 +1,63 @@ +/* + * ** header v3.0 + * This file is a part of the CaosDB Project. + * + * Copyright (C) 2021 IndiScale GmbH + * + * 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 Affero 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 <https://www.gnu.org/licenses/>. + * + * ** end header + */ + +'use strict'; + +QUnit.module("form_panel.js", { + before: function (assert) { + + }, + after: function (assert) { + } +}); + +QUnit.test("availability", function (assert) { + assert.ok(form_panel.init, "init available"); + assert.ok(form_panel.create_show_form_callback , "version available"); +}); + +QUnit.test("create_show_form_callback ", function (assert) { + const title = "Upload CSV File"; // title of the form and text in the toolbox + const panel_id = "csv_upload_form_panel"; + const server_side_script = "csv_script.py"; + const tool_box = "Tools"; // Name of the drop-down menu where the button is added in the navbar + const help_text = "something"; + const accepted_files_formats = [ ".csv", "text/tsv", ] // Mime types and file endings. + + const csv_form_config = { + script: server_side_script, + fields: [{ + type: "file", + name: "csv_file", + label: "CSV File", // label of the file selector in the form + required: true, + cached: false, + accept: accepted_files_formats.join(","), + help: help_text, + }, ], + }; + cb = form_panel.create_show_form_callback( panel_id, title, csv_form_config); + assert.equal(typeof cb, "function", "function created"); + cb() +}); + +