def _get_config_entry(config, domain): return Entry( command=Command( id='reports.{}'.format(config.uuid), text=Text(locale=Locale(id=id_strings.report_name(config.uuid)), ), ), datums=[ SessionDatum( detail_select=MobileSelectFilterHelpers.get_select_detail_id( config, filter_slug), id=MobileSelectFilterHelpers.get_datum_id(config, filter_slug), nodeset=MobileSelectFilterHelpers.get_options_nodeset( config, filter_slug), value='./@value', ) for filter_slug, f in MobileSelectFilterHelpers.get_filters( config, domain) ] + [ SessionDatum( detail_confirm=_get_summary_detail_id(config), detail_select=_get_select_detail_id(config), id='report_id_{}'.format(config.uuid), nodeset="instance('reports')/reports/report[@id='{}']".format( config.uuid), value='./@id', autoselect="true"), ])
def build_remote_request_datums(self): return [ SessionDatum( id=self.case_session_var, function=QuerySessionXPath(self.case_session_var).instance(), ) ]
def _build_remote_request_datums(self): details_helper = DetailsHelper(self.app) if self.module.case_details.short.custom_xml: short_detail_id = 'case_short' long_detail_id = 'case_long' else: short_detail_id = 'search_short' long_detail_id = 'search_long' nodeset = CaseTypeXpath( self.module.case_type).case(instance_name=RESULTS_INSTANCE) if self.module.search_config.search_filter and toggles.USH_CASE_CLAIM_UPDATES.enabled( self.app.domain): nodeset = f"{nodeset}[{interpolate_xpath(self.module.search_config.search_filter)}]" return [ SessionDatum( id=self.module.search_config.case_session_var, nodeset=nodeset, value='./@case_id', detail_select=details_helper.get_detail_id_safe( self.module, short_detail_id), detail_confirm=details_helper.get_detail_id_safe( self.module, long_detail_id), ) ]
def get_report_context_tile_datum(): return SessionDatum( id='tile_holder', nodeset="instance('commcare-reports:index')/report_index/reports", value='./@last_update', detail_persistent=MOBILE_UCR_TILE_DETAIL_ID, autoselect="true", )
def _build_remote_request_datums(self): details_helper = DetailsHelper(self.app) return [SessionDatum( id='case_id', nodeset=(CaseTypeXpath(self.module.case_type) .case(instance_name=RESULTS_INSTANCE)), value='./@case_id', detail_select=details_helper.get_detail_id_safe(self.module, 'case_short'), detail_confirm=details_helper.get_detail_id_safe(self.module, 'case_long'), )]
def _get_config_entry(self, config): if self.new_mobile_ucr_restore: nodeset = "instance('commcare-reports:{}')/rows".format( config.instance_id) else: nodeset = "instance('reports')/reports/report[@id='{}']".format( config.uuid) datums = [] if self.report_module.report_context_tile: datums.append(get_report_context_tile_datum()) datums += [ SessionDatum( detail_select=MobileSelectFilterHelpers.get_select_detail_id( config, filter_slug), id=MobileSelectFilterHelpers.get_datum_id(config, filter_slug), nodeset=MobileSelectFilterHelpers.get_options_nodeset( config, filter_slug, self.new_mobile_ucr_restore), value='./@value', ) for filter_slug, f in MobileSelectFilterHelpers.get_filters( config, self.domain) ] + [ SessionDatum(detail_confirm=_get_summary_detail_id(config), detail_select=_get_select_detail_id(config), id='report_id_{}'.format(config.uuid), nodeset=nodeset, value='./@id', autoselect="true"), ] return Entry( command=Command( id='reports.{}'.format(config.uuid), text=Text( locale=Locale(id=id_strings.report_name(config.uuid)), ), ), datums=datums, )
def _build_remote_request_datums(self): details_helper = DetailsHelper(self.app) if self.module.case_details.short.custom_xml: short_detail_id = 'case_short' else: short_detail_id = 'search_short' nodeset = CaseTypeXpath(self.module.case_type).case(instance_name=RESULTS_INSTANCE) if self.module.search_config.search_filter: nodeset = f"{nodeset}[{interpolate_xpath(self.module.search_config.search_filter)}]" return [SessionDatum( id='case_id', nodeset=nodeset, value='./@case_id', detail_select=details_helper.get_detail_id_safe(self.module, short_detail_id), detail_confirm=details_helper.get_detail_id_safe(self.module, 'case_long'), )]
def get_module_contributions(self, module): if module_offers_search(module): domain = self.app.domain details_helper = DetailsHelper(self.app) remote_request = RemoteRequest( post=RemoteRequestPost( url=absolute_reverse('claim_case', args=[domain]), relevant=module.search_config.relevant, data=[ QueryData( key='case_id', ref=QuerySessionXPath('case_id').instance(), # e.g. instance('querysession')/session/data/case_id ), ]), command=Command( id=id_strings.search_command(module), display=Display(text=Text( locale_id=id_strings.case_search_locale(module)), ), ), instances=[ Instance(id=SESSION_INSTANCE, src='jr://instance/session'), Instance(id='casedb', src='jr://instance/casedb'), ], session=RemoteRequestSession( queries=[ RemoteRequestQuery( url=absolute_reverse('remote_search', args=[domain]), storage_instance=RESULTS_INSTANCE, data=[ QueryData(key='case_type', ref="'{}'".format(module.case_type)), ], prompts=[ QueryPrompt( key=p.name, display=Display( text=Text(locale_id=id_strings. search_property_locale( module, p.name)), ), ) for p in module.search_config.properties ]) ], data=[ SessionDatum( id='case_id', nodeset=(CaseTypeXpath(module.case_type).case( instance_name=RESULTS_INSTANCE).select( u'@status', u'open', quote=True)), value='./@case_id', detail_select=details_helper.get_detail_id_safe( module, 'case_short'), detail_confirm=details_helper.get_detail_id_safe( module, 'case_long'), ) ], ), stack=Stack(), ) frame = CreateFrame() # Open first form in module frame.add_command(XPath.string(id_strings.menu_id(module))) frame.add_datum( StackDatum(id='case_id', value=QuerySessionXPath('case_id').instance())) remote_request.stack.add_frame(frame) return [remote_request] return []