Skip to content
Snippets Groups Projects
Commit 33a497da authored by Florian Spreckelsen's avatar Florian Spreckelsen
Browse files

FIX: Ignore auto_focus for elements without form tags

parent 9c48fb07
No related branches found
No related tags found
2 merge requests!139FIX: Set horizontal scroll of property names to auto,!138FIX: auto_focus on forms without forms
Pipeline #53292 passed
......@@ -8,7 +8,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added ###
- GRPC Entity Service can be enabled with `BUILD_MODULE_EXT_GRPC_ENTIY_SERVICE=ENABLED`. Defaults to `DISABLED`. More info on this module under `src/doc/extension/grpc-entity-service.rst`. <https://docs.indiscale.com/caosdb-webui/extension/grpc-entity-service.html>
- GRPC Entity Service can be enabled with
`BUILD_MODULE_EXT_GRPC_ENTIY_SERVICE=ENABLED`. Defaults to
`DISABLED`. More info on this module under
`src/doc/extension/grpc-entity-service.rst`. <https://docs.indiscale.com/caosdb-webui/extension/grpc-entity-service.html>
### Changed ###
......@@ -22,6 +25,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
different link to parent dir more visible.
- [#255](https://gitlab.com/linkahead/linkahead-webui/-/issues/255) Remove
disabled scroll bar under property names that would show on some browsers.
- [#258](https://gitlab.com/linkahead/linkahead-webui/-/issues/258)
Ignore `auto_focus` when `create_show_form_callback` is called on an
element without HTML `form` elements.
### Security ###
......
......@@ -26,7 +26,7 @@
* form_panel module for creating a panel below the navbar where forms can be
* placed.
*/
var form_panel = new function () {
var form_panel = new function() {
const logger = log.getLogger("form_panel");
this.version = "0.1";
this.dependencies = ["log", "caosdb_utils", "markdown", "bootstrap"];
......@@ -38,7 +38,7 @@ var form_panel = new function () {
* 1. Creates the form panel if it does not exist.
* 2. Removes the welcome panel if present.
*/
this.get_form_panel = function (panel_id, title) {
this.get_form_panel = function(panel_id, title) {
// remove welcome
$(".caosdb-f-welcome-panel").remove();
$(".caosdb-v-welcome-panel").remove();
......@@ -60,7 +60,7 @@ var form_panel = new function () {
/**
* Remove the form panel from the DOM tree.
*/
this.destroy_form_panel = function (panel) {
this.destroy_form_panel = function(panel) {
$(panel).remove();
};
......@@ -75,22 +75,22 @@ var form_panel = new function () {
* The first input element will be focused unless you specify `false` as
* fifths parameter.
*/
this.create_show_form_callback = function (
panel_id, title, form_config, form_creator=undefined, auto_focus=true
this.create_show_form_callback = function(
panel_id, title, form_config, form_creator = undefined, auto_focus = true
) {
return (e) => {
logger.trace("enter show_form_panel", e);
const panel = $(form_panel.get_form_panel(panel_id, title));
if (panel.find("form").length === 0) {
if (form_config != undefined && form_creator!=undefined){
if (form_config != undefined && form_creator != undefined) {
throw new Error("create_show_form_callback takes either a FormConfig or a function that creates the form");
}
var form;
if (form_config != undefined ){
if (form_config != undefined) {
form = form_elements.make_form(form_config);
} else if (form_creator != undefined ){
} else if (form_creator != undefined) {
form = form_creator();
} else {
throw new Error("create_show_form_callback takes a FormConfig or a function that creates the form");
......@@ -104,17 +104,18 @@ var form_panel = new function () {
);
}
if (typeof auto_focus === "undefined" || !!auto_focus === true) {
if (panel.find("form")[0].length>0) {
if (panel.find("form").length > 0 && panel.find("form")[0].length > 0) {
panel.find("form")[0][0].focus();
} else {
logger.debug("create_show_form_callback was called with auto_focus = true (default), but no form is given.");
}
}
}
};
this.init = function () {
}
this.init = function() {}
}
$(document).ready(function () {
$(document).ready(function() {
caosdb_modules.register(form_panel);
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment