diff --git a/tethysapp/app_store/begin_install.py b/tethysapp/app_store/begin_install.py index ad2c477..ee89b2b 100755 --- a/tethysapp/app_store/begin_install.py +++ b/tethysapp/app_store/begin_install.py @@ -11,6 +11,7 @@ from .helpers import check_all_present, logger, send_notification from .resource_helpers import get_resource, get_app_instance_from_path +from tethys_apps.base.workspace import TethysWorkspace def handle_property_not_present(prop): @@ -92,9 +93,14 @@ def detect_app_dependencies(app_name, channel_layer, notification_method=send_no if custom_settings: notification_method("Processing App's Custom Settings....", channel_layer) for setting in custom_settings: + default = setting.default + if isinstance(default, TethysWorkspace): + default = default.path + setting = {"name": setting.name, "description": setting.description, - "default": str(setting.default), + "required": setting.required, + "default": str(default), } custom_settings_json.append(setting) diff --git a/tethysapp/app_store/public/js/main.js b/tethysapp/app_store/public/js/main.js index 6150de1..dd42ff3 100755 --- a/tethysapp/app_store/public/js/main.js +++ b/tethysapp/app_store/public/js/main.js @@ -18,6 +18,7 @@ const settingsHelper = { if (settingsData) { if (settingsData.length > 0) { $("#skipConfigButton").click(function() { + $(".setting_warning").hide() ws.send( JSON.stringify({ data: { @@ -42,11 +43,13 @@ const settingsHelper = { let formDataElement = $("#custom-settings-container").children("form") settingsData.forEach((setting) => { let defaultValue = setting.default ? setting.default : "" + let requiredClass = setting.required ? "required_setting" : "" let newElement = `
- - + +

${setting.description}

+
` formDataElement.append(newElement) }) @@ -55,8 +58,10 @@ const settingsHelper = { `` ) formDataElement.submit(function(event) { + $(".setting_warning").hide() event.preventDefault() let formData = { settings: {} } + let has_errors = false if ("app_py_path" in completeMessage) { formData["app_py_path"] = completeMessage["app_py_path"] } @@ -64,9 +69,17 @@ const settingsHelper = { .children("form") .find(".form-control") .each(function() { + if ($(this).hasClass("required_setting") && $(this).val() == "") { + let setting_name = $(this)[0].id + $(`#${setting_name}_warningMessage`).show() + has_errors = true + } formData.settings[$(this).attr("id")] = $(this).val() }) - + + if (has_errors) { + return + } ws.send( JSON.stringify({ data: formData, diff --git a/tethysapp/app_store/templates/app_store/modals/addToWarehouse.html b/tethysapp/app_store/templates/app_store/modals/addToWarehouse.html index b5d5e00..2fe8d33 100644 --- a/tethysapp/app_store/templates/app_store/modals/addToWarehouse.html +++ b/tethysapp/app_store/templates/app_store/modals/addToWarehouse.html @@ -16,7 +16,7 @@