From 7af8fe4ccfedc01e2203aff7b7fffb51b88d945c Mon Sep 17 00:00:00 2001 From: Timm Fitschen <t.fitschen@indiscale.com> Date: Thu, 4 Nov 2021 10:38:46 +0100 Subject: [PATCH] DOC: update doc for module installation --- src/core/js/form_elements.js | 38 +++++++++++++++++++++++----- src/doc/extension/module.md | 48 +++++++++++++++++++++++++++--------- 2 files changed, 68 insertions(+), 18 deletions(-) diff --git a/src/core/js/form_elements.js b/src/core/js/form_elements.js index d01b45ee..193235a2 100644 --- a/src/core/js/form_elements.js +++ b/src/core/js/form_elements.js @@ -100,14 +100,41 @@ var form_elements = new function () { this.version = "0.1"; this.dependencies = ["log", "caosdb_utils", "markdown", "bootstrap"]; this.logger = log.getLogger("form_elements"); + /** + * Event. On form cancel. + */ this.cancel_form_event = new Event("caosdb.form.cancel"); + /** + * Event. On form submit. + */ this.submit_form_event = new Event("caosdb.form.submit"); + /** + * Event. On field change. + */ this.field_changed_event = new Event("caosdb.field.changed"); + /** + * Event. On field enabled. + */ this.field_enabled_event = new Event("caosdb.field.enabled"); + /** + * Event. On field disabled. + */ this.field_disabled_event = new Event("caosdb.field.disabled"); + /** + * Event. On field ready (e.g. for reference drop downs) + */ this.field_ready_event = new Event("caosdb.field.ready"); + /** + * Event. On field error (e.g. for reference drop downs) + */ this.field_error_event = new Event("caosdb.field.error"); + /** + * Event. Form submitted successfully. + */ this.form_success_event = new Event("caosdb.form.success"); + /** + * Event. Error after form was submitted. + */ this.form_error_event = new Event("caosdb.form.error"); @@ -1266,7 +1293,10 @@ var form_elements = new function () { }, config.to); const from_input = this.make_form_field(from_config); + $(from_input).toggleClass("form-control", false); + const to_input = this.make_form_field(to_config); + $(to_input).toggleClass("form-control", false); const ret = $(this._make_field_wrapper(config.name)); if (config.label) { @@ -1277,12 +1307,8 @@ var form_elements = new function () { ret.append(to_input); // styling - $(from_input).toggleClass("form-control", false); - $(from_input).find(".col-sm-3").toggleClass("col-sm-3", false).toggleClass("col-sm-1"); - $(from_input).find(".col-sm-9").toggleClass("col-sm-9", false).toggleClass("col-sm-3"); - $(to_input).toggleClass("form-control", false); - $(to_input).find(".col-sm-3").toggleClass("col-sm-3", false).toggleClass("col-sm-1").toggleClass("col-sm-offset-1"); - $(to_input).find(".col-sm-9").toggleClass("col-sm-9", false).toggleClass("col-sm-3"); + $(from_input).toggleClass("col-sm-4", true); + $(to_input).toggleClass("col-sm-4", true); return ret[0]; } diff --git a/src/doc/extension/module.md b/src/doc/extension/module.md index 1c3ccd68..207d3fff 100644 --- a/src/doc/extension/module.md +++ b/src/doc/extension/module.md @@ -4,7 +4,14 @@ The CaosDB WebUI is organized in modules which can easily be added and on a modu There are a few steps necessary to create a new module. ## Create the module file -Create a new file in `src/core/js` starting with `ext_`. E.g. `ext_flight_preview.js`. This file should define one function that wraps every thing and which is enabled at the bottom of the file: + +Create a new file for each new module. We have the convention, that extensions +which are optional and should stay that way and also custom extensions for +special purposes to name the file starting with `ext_`. E.g. +`ext_flight_preview.js`. + +This file should define one function that wraps every thing and which is +enabled at the bottom of the file: ```js /* @@ -51,18 +58,35 @@ $(document).ready(function() { }); ``` -## 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. +## Install the module + +The new new file should be placed in `src/core/js` if it is intended to be merged into the main repository eventually. For development purposes and for custom extensions which are not to be published you may place it in `src/ext/js`. + +Everything inside `src/core/js` and `src/ext/js` will eventually being loaded. +So, if there are no other modules which depend on this particular new module, +you are done. + +Otherwise, when we need to configure the order in which the +module is being loaded. + + +### Dependency order + +#### For Upstream Code + +For modules which are about to be merged into the main or dev branch of this +repository, add the module's file to `build.properties.d/00_default.properties` +at the right location in the list of module files (Array +`MODULE_DEPENDENCIES`). The list defines the order in which module files are +being 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`. +#### For Custom Extensions -## Dependency order -Add the module to `build.properties.d/00_default.properties` at the right -location in the list of modules. The list defines the order in which modules are -loaded +For modules which will not be published and merged with the main repository you +may append all your module files in the desired order to the +`MODULE_DEPENDENCIES` array in a new `*.properties` file (e.g. +`build.properties.d/99_local_stuff`): -## Update the changelog + MODULE_DEPENDENCIES+=(libA.js libB.js ext_flight_preview.js) -## Create a merge request +In this example, `libA.js`, `libB.js` and `ext_flight_preview.js` are custom modules developed for this particular CaosDB webui instance. -- GitLab