Skip to content
Snippets Groups Projects
Commit 3c47e687 authored by Henrik tom Wörden's avatar Henrik tom Wörden
Browse files

Merge branch 'f-doc-extention' into f-panel

parents 95b45d66 7962799e
No related branches found
No related tags found
2 merge requests!50Release v0.4.1,!46ENH: add a form_panel module that allows to create a panel for web forms
Pipeline #15380 passed
...@@ -45,6 +45,36 @@ On submission, the function ``my_special_submit_handler`` is being called with t ...@@ -45,6 +45,36 @@ On submission, the function ``my_special_submit_handler`` is being called with t
As the generated form is a plain HTML form, the javascript form API can be used. However, there are special methods in the ``form_elements`` module e.g. :doc:`get_fields <../api/module-form_elements>` which are especially designed to interact with the forms generated by the ``make_form`` factory. As the generated form is a plain HTML form, the javascript form API can be used. However, there are special methods in the ``form_elements`` module e.g. :doc:`get_fields <../api/module-form_elements>` which are especially designed to interact with the forms generated by the ``make_form`` factory.
Placing the form in a panel below the navbar
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
There are functions in the `form_panel` module to make it easy to place forms at the typical location:
below the navbar. The following shows how the config (see above) is passed to
`init_show_form_panel_button` a direct call to `make_form` is no longer necessary.
.. code-block:: javascript
const title = "Upload CSV File"; // title of the form and text in the toolbox
const panel_id = "csv_upload_form_panel";
/**
* Add a button to the navbar, saying "Upload CSV File" which opens a
* form for file upload.
*/
const init_show_form_panel_button = function () {
navbar.add_tool(title, tool_box, {
callback: form_panel.create_show_form_callback(
panel_id,
title,
csv_form_config)
});
};
const init = function () {
init_show_form_panel_button();
}
Calling a server-side script Calling a server-side script
^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
......
...@@ -23,16 +23,14 @@ Create a new file in `src/core/js` starting with `ext_`. E.g. `ext_flight_previe ...@@ -23,16 +23,14 @@ Create a new file in `src/core/js` starting with `ext_`. E.g. `ext_flight_previe
* @requires somelibrary * @requires somelibrary
* (pass the dependencies as arguments) * (pass the dependencies as arguments)
*/ */
var ext_flight_preview = function (somelibrary) { const ext_flight_preview = function (libA, libB) {
var init = function (toolbox) { const init = function () {
/* initialization of the module */ /* initialization of the module */
} }
/** /* doc string */
* doc string const some_function = function (arg1, arg2) {
*/
var some_function = function (arg1, arg2) {
} }
/* the main function must return the initialization of the module */ /* the main function must return the initialization of the module */
...@@ -40,7 +38,7 @@ var ext_flight_preview = function (somelibrary) { ...@@ -40,7 +38,7 @@ var ext_flight_preview = function (somelibrary) {
init: init, init: init,
}; };
//pass the dependencies as arguments here as well //pass the dependencies as arguments here as well
}(somelibrary); }(libA, libB);
// this will be replaced by require.js in the future. // this will be replaced by require.js in the future.
$(document).ready(function() { $(document).ready(function() {
...@@ -52,16 +50,6 @@ $(document).ready(function() { ...@@ -52,16 +50,6 @@ $(document).ready(function() {
} }
}); });
``` ```
## Update xml
Add a section to `src/core/xsl/main.xsl` to include your new file.
```xsl
<xsl:element name="script">
<xsl:attribute name="src">
<xsl:value-of select="concat($basepath,'webinterface/${BUILD_NUMBER}/js/ext_sss_markdown.js')"/>
</xsl:attribute>
</xsl:element>
```
## Place Module in Load Order ## 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 the name of your module file to `build.properties.d/00_default.properties`, where the order is defined in which modules are loaded.
...@@ -70,6 +58,11 @@ Add the name of your module file to `build.properties.d/00_default.properties`, ...@@ -70,6 +58,11 @@ Add the name of your module file to `build.properties.d/00_default.properties`,
If you have unittests (and you should), you need to add a line in : If you have unittests (and you should), you need to add a line in :
`test/core/index.html`. `test/core/index.html`.
## 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
## Update the changelog ## Update the changelog
## Create a merge request ## Create a merge request
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment