diff --git a/corehq/apps/app_manager/helpers/validators.py b/corehq/apps/app_manager/helpers/validators.py index 8f17aedb3f1d..38570a1b4c34 100644 --- a/corehq/apps/app_manager/helpers/validators.py +++ b/corehq/apps/app_manager/helpers/validators.py @@ -545,6 +545,11 @@ def validate_search_config(self): "module": self.get_module_info(), "property": prop.name, } + if search_config.search_on_clear and self.module.is_auto_select(): + yield { + "type": "search on clear with auto select", + "module": self.get_module_info(), + } def validate_case_list_field_actions(self): if hasattr(self.module, 'case_details'): diff --git a/corehq/apps/app_manager/models.py b/corehq/apps/app_manager/models.py index dbfd3f0540ed..4d0f4239ad60 100644 --- a/corehq/apps/app_manager/models.py +++ b/corehq/apps/app_manager/models.py @@ -2188,6 +2188,7 @@ class CaseSearch(DocumentSchema): description = LabelProperty(default={}) include_all_related_cases = BooleanProperty(default=False) dynamic_search = BooleanProperty(default=False) + search_on_clear = BooleanProperty(default=False) # case property referencing another case's ID custom_related_case_property = StringProperty(exclude_if_none=True) diff --git a/corehq/apps/app_manager/static/app_manager/js/details/case_claim.js b/corehq/apps/app_manager/static/app_manager/js/details/case_claim.js index 66f525e0b762..6d30544c7124 100644 --- a/corehq/apps/app_manager/static/app_manager/js/details/case_claim.js +++ b/corehq/apps/app_manager/static/app_manager/js/details/case_claim.js @@ -203,6 +203,7 @@ hqDefine("app_manager/js/details/case_claim", function () { 'title_label', 'description', 'search_button_display_condition', 'search_label', 'search_filter', 'additional_relevant', 'data_registry', 'data_registry_workflow', 'additional_registry_cases', 'custom_related_case_property', 'inline_search', 'instance_name', 'include_all_related_cases', + 'search_on_clear', ]; var searchConfigModel = function (options, lang, searchFilterObservable, saveButton) { hqImport("hqwebapp/js/assert_properties").assertRequired(options, searchConfigKeys); diff --git a/corehq/apps/app_manager/suite_xml/post_process/remote_requests.py b/corehq/apps/app_manager/suite_xml/post_process/remote_requests.py index da8034ea6683..1c200f827b58 100644 --- a/corehq/apps/app_manager/suite_xml/post_process/remote_requests.py +++ b/corehq/apps/app_manager/suite_xml/post_process/remote_requests.py @@ -207,19 +207,23 @@ def build_session(self): ) def build_remote_request_queries(self): + kwargs = { + "url": absolute_reverse('app_aware_remote_search', args=[self.app.domain, self.app._id]), + "storage_instance": self.storage_instance, + "template": 'case', + "title": self.build_title() if self.app.enable_case_search_title_translation else None, + "description": self.build_description() if self.module.search_config.description != {} else None, + "data": self._remote_request_query_datums, + "prompts": self.build_query_prompts(), + "prompt_groups": self.build_query_prompt_groups(), + "default_search": self.module.search_config.default_search, + "dynamic_search": self.app.split_screen_dynamic_search and not self.module.is_auto_select() + } + if self.module.search_config.search_on_clear and toggles.SPLIT_SCREEN_CASE_SEARCH.enabled(self.app.domain): + kwargs["search_on_clear"] = (self.module.search_config.search_on_clear + and not self.module.is_auto_select()) return [ - RemoteRequestQuery( - url=absolute_reverse('app_aware_remote_search', args=[self.app.domain, self.app._id]), - storage_instance=self.storage_instance, - template='case', - title=self.build_title() if self.app.enable_case_search_title_translation else None, - description=self.build_description() if self.module.search_config.description != {} else None, - data=self._remote_request_query_datums, - prompts=self.build_query_prompts(), - prompt_groups=self.build_query_prompt_groups(), - default_search=self.module.search_config.default_search, - dynamic_search=self.app.split_screen_dynamic_search and not self.module.is_auto_select(), - ) + RemoteRequestQuery(**kwargs) ] def build_remote_request_datums(self): diff --git a/corehq/apps/app_manager/suite_xml/xml_models.py b/corehq/apps/app_manager/suite_xml/xml_models.py index 0dfe6a511df1..8576a0e73470 100644 --- a/corehq/apps/app_manager/suite_xml/xml_models.py +++ b/corehq/apps/app_manager/suite_xml/xml_models.py @@ -593,6 +593,7 @@ class RemoteRequestQuery(OrderedXmlObject, XmlObject): prompt_groups = NodeListField('group', QueryPromptGroup) default_search = BooleanField("@default_search") dynamic_search = BooleanField("@dynamic_search") + search_on_clear = BooleanField("@search_on_clear", required=False) @property def id(self): diff --git a/corehq/apps/app_manager/templates/app_manager/partials/build_errors.html b/corehq/apps/app_manager/templates/app_manager/partials/build_errors.html index b91d248628c9..617ac182ba41 100644 --- a/corehq/apps/app_manager/templates/app_manager/partials/build_errors.html +++ b/corehq/apps/app_manager/templates/app_manager/partials/build_errors.html @@ -195,6 +195,11 @@

{% blocktrans with module_name=error.module.name|trans:langs %} The case list in {{ module_name }} can not use the same "search input instance name" as its Parent Select Menu. {% endblocktrans %} + {% case "search on clear with auto select" %} + {% blocktrans with module_name=error.module.name|trans:langs %} + The case list in {{ module_name }} uses both multi-select auto select and "Clearing search terms resets search results". + These two features are not compatible. + {% endblocktrans %} {% case "inline search to display only forms" %} {% blocktrans with module_name=error.module.name|trans:langs %} {{ module_name }} diff --git a/corehq/apps/app_manager/templates/app_manager/partials/modules/case_search_properties.html b/corehq/apps/app_manager/templates/app_manager/partials/modules/case_search_properties.html index 9bc44dbbe15b..3af572b67f55 100644 --- a/corehq/apps/app_manager/templates/app_manager/partials/modules/case_search_properties.html +++ b/corehq/apps/app_manager/templates/app_manager/partials/modules/case_search_properties.html @@ -466,11 +466,23 @@