diff --git a/app/system/survey/js/controller.js b/app/system/survey/js/controller.js index 665bf21de..32ac799cd 100644 --- a/app/system/survey/js/controller.js +++ b/app/system/survey/js/controller.js @@ -1340,6 +1340,11 @@ return { }}),true); }})); }, + searchInstance: function(ctxt){ + var name = opendatakit.getCurrentInstanceId(); + console.log(name); + }, + reset: function(ctxt,sameForm) { var that = this; ctxt.log('I','controller.reset'); diff --git a/app/system/survey/js/prompts.js b/app/system/survey/js/prompts.js index 6013c2a93..aed209c76 100644 --- a/app/system/survey/js/prompts.js +++ b/app/system/survey/js/prompts.js @@ -573,6 +573,7 @@ promptTypes.instances = promptTypes.base.extend({ valid: true, _cachedEvent: null, _protoDisplay: { + search_instance: 'search_instance', instances_survey_form_identification: 'survey_form_identification', new_button_label: 'instances_survey_create_button_label', instances_last_save_date_label: 'instances_last_save_date_label', @@ -584,7 +585,8 @@ promptTypes.instances = promptTypes.base.extend({ events: { "click .openInstance": "openInstance", "click .deleteInstance": "confirmDeleteInstance", - "click .createInstance": "createInstance" + "click .createInstance": "createInstance", + "click .searchInstance": "searchInstance" }, configureRenderContext: function(ctxt) { var that = this; @@ -710,8 +712,33 @@ promptTypes.instances = promptTypes.base.extend({ ctxt.failure(m); }})); } + }, + searchInstance: function (evt) { + var that= this + that._cachedEvent = evt; + const search = document.getElementById('searchBox'); + // if (that._cachedEvent === null || that._cachedEvent === undefined) { + // return; + // } + var instanceToSearch = $(evt.currentTarget).attr('display_value'); + + console.log(search) + if ( instanceToSearch !== null && instanceToSearch !== undefined ) { + var ctxt = that.controller.newContext(that._cachedEvent, that.type + ".searchInstance"); + that.controller.enqueueTriggeringContext($.extend({},ctxt,{success:function() { + odkCommon.log('D',"prompts." + that.type + ".searchInstance", "px: " + that.promptIdx); + that.controller.searchInstance(ctxt, instanceToSearch) + }})) + // search.addEventListener('keyup',(e)=>{ + // console.log(ctxt); + // }) + + } } + + }); + promptTypes.contents = promptTypes.base.extend({ type:"contents", hideInContents: true, diff --git a/app/system/survey/templates/instances.handlebars b/app/system/survey/templates/instances.handlebars index 1b70e08c3..ed64b127b 100644 --- a/app/system/survey/templates/instances.handlebars +++ b/app/system/survey/templates/instances.handlebars @@ -18,7 +18,16 @@
- + + + {{{localizeText display.instances_previously_created_instances_label}}}