diff --git a/src/doc/extension/forms.rst b/src/doc/extension/forms.rst index 1bced612b5f9517c5ec149871cbf53321b4671d4..e1891b8d7e571c4a273cec98fcc39e50398936f0 100644 --- a/src/doc/extension/forms.rst +++ b/src/doc/extension/forms.rst @@ -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. + +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 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/doc/extension/module.md b/src/doc/extension/module.md index eb6a9bf8505c37a33b84db106fe850fbe7b80d96..1c3ccd6872bee2dd7c824a23fed5656828566960 100644 --- a/src/doc/extension/module.md +++ b/src/doc/extension/module.md @@ -23,16 +23,14 @@ Create a new file in `src/core/js` starting with `ext_`. E.g. `ext_flight_previe * @requires somelibrary * (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 */ } - /** - * doc string - */ - var some_function = function (arg1, arg2) { + /* doc string */ + const some_function = function (arg1, arg2) { } /* the main function must return the initialization of the module */ @@ -40,7 +38,7 @@ var ext_flight_preview = function (somelibrary) { init: init, }; //pass the dependencies as arguments here as well -}(somelibrary); +}(libA, libB); // this will be replaced by require.js in the future. $(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 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`, If you have unittests (and you should), you need to add a line in : `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 ## Create a merge request