From 5ec44c66965a12ee357e26c915243a823644404f Mon Sep 17 00:00:00 2001 From: Niklaus Giger Date: Wed, 27 Aug 2014 08:33:16 +0200 Subject: [PATCH] Fachinfo search: Debug output. Take 13 Signed-off-by: Niklaus Giger --- spec/fachinfo_search_spec.rb | 86 --------------- spec/interactions_spec.rb | 11 -- spec/searchbar_spec.rb | 151 ++++++++++++++++++++++++++ spec/spec_helper.rb | 11 ++ src/state/ajax/matches.rb | 3 + src/state/drugs/fachinfo_search.rb | 24 ++-- src/state/interactions/interaction_chooser.rb | 1 + src/util/oddbapp.rb | 2 +- src/util/session.rb | 1 + src/view/ajax/json.rb | 1 + src/view/ajax/swissmedic_cat.rb | 1 + src/view/drugs/fachinfo_search.rb | 11 +- src/view/drugs/feedbacks.rb | 4 + src/view/drugs/limitationtexts.rb | 4 + src/view/drugs/patinfos.rb | 4 + src/view/drugs/resultlimit.rb | 4 + src/view/drugs/sequences.rb | 4 + src/view/drugs/vaccines.rb | 4 + src/view/migel/feedbacks.rb | 4 + src/view/notify.rb | 4 + src/view/notify_confirm.rb | 4 + src/view/privatetemplate.rb | 1 + src/view/searchbar.rb | 47 ++++++-- src/view/substances/result.rb | 4 + 24 files changed, 275 insertions(+), 116 deletions(-) delete mode 100644 spec/fachinfo_search_spec.rb create mode 100644 spec/searchbar_spec.rb diff --git a/spec/fachinfo_search_spec.rb b/spec/fachinfo_search_spec.rb deleted file mode 100644 index 1fda478..0000000 --- a/spec/fachinfo_search_spec.rb +++ /dev/null @@ -1,86 +0,0 @@ -#!/usr/bin/env ruby -# encoding: utf-8 -# kate: space-indent on; indent-width 2; mixedindent off; indent-mode ruby; -require 'spec_helper' -require 'pp' -require 'tmpdir' -require "selenium-webdriver" - -describe "ch.oddb.org" do - - def enter_search_to_field_by_name(search_text, field_name) - idx = -2 - chooser = @browser.text_field(:name,field_name) - 0.upto(5).each{ - |idx| - break if chooser and chooser.present? - sleep 1 - chooser = @browser.text_field(:name,field_name) - } - unless chooser and chooser.present? - msg = "idx #{idx} could not find textfield prescription_searchbar in #{@browser.url}" - puts msg - # require 'pry'; binding.pry - raise msg - end - 0.upto(30).each{ |idx| - begin - chooser.set(search_text) - sleep idx*0.1 - chooser.send_keys(:down) - sleep idx*0.1 - chooser.send_keys(:enter) - sleep idx*0.1 - value = chooser.value - break unless /#{search_text}/.match(value) - sleep 0.5 - rescue StandardError => e - puts "in rescue" - createScreenshot(@browser, "rescue_#{search_text}_#{__LINE__}") - puts e.inspect - puts caller[0..5] - return - end - } - chooser.set(chooser.value + "\n") - puts "chooser set to #{chooser.value}" - createScreenshot(@browser, "_#{search_text}_#{__LINE__}") - end - - before :all do - $prescription_test_id = 1 - waitForOddbToBeReady(@browser, OddbUrl) - login - end - - before :each do - @timestamp = Time.now.strftime('%Y%m%d%H%M%S') - # puts "before #{$prescription_test_id} with #{@browser.windows.size} windows" - while @browser.windows.size > 1 - @browser.windows.first.use - @browser.windows.last.close if @browser.windows.last - end - @browser.goto OddbUrl - if @browser.link(:name=>'fachinfo_search').exists? - puts "Going to search FI erweitert" - @browser.link(:name=>'fachinfo_search').click - end - end - - after :each do - createScreenshot(@browser, '_'+$prescription_test_id.to_s) if @browser - $prescription_test_id += 1 - end - - - it "should show the chapter unwanted effects for Schwindel and show 61374 Quetiapin Sandoz:" do - @browser.select_list(:name, "fachinfo_search_type").select(/Unerw.Wirk/i) - # require 'pry'; binding.pry - @browser.checkbox(:name,'fachinfo_search_full_text').set - @browser.text_field(:name,'fachinfo_search_term').set('Gewichtszunahme') - enter_search_to_field_by_name('Quetiapin Sandoz', 'searchbar'); - @browser.button(:name, "search").click - @browser.text.should match /Sehr häufig: Gewichtszunahme/ - end - -end \ No newline at end of file diff --git a/spec/interactions_spec.rb b/spec/interactions_spec.rb index 835652e..63207b7 100644 --- a/spec/interactions_spec.rb +++ b/spec/interactions_spec.rb @@ -5,17 +5,6 @@ require 'spec_helper' require 'pp' @workThread = nil -for_running_in_irb = %( -require 'watir'; require 'pp' -homeUrl ||= "oddb-ci2.dyndns.org" -OddbUrl = homeUrl -@browser = Watir::Browser.new(:chrome) -@browser.goto OddbUrl -@browser.link(:text=>'Interaktionen').click -id = 'home_interactions' -medi = 'Losartan' -chooser = @browser.text_field(:id, id) -) DrugDescription = Struct.new(:name, :iksnr, :ean13, :atc_code, :wirkstoff) # http://oddb-ci2.dyndns.org/de/gcc/home_interactions/7680583920013,7680591310011,7680390530399,7680586430014 diff --git a/spec/searchbar_spec.rb b/spec/searchbar_spec.rb new file mode 100644 index 0000000..9fb6a33 --- /dev/null +++ b/spec/searchbar_spec.rb @@ -0,0 +1,151 @@ +#!/usr/bin/env ruby +# encoding: utf-8 +# kate: space-indent on; indent-width 2; mixedindent off; indent-mode ruby; +require 'spec_helper' +require 'pp' +require 'tmpdir' +require "selenium-webdriver" + +describe "ch.oddb.org" do + + def enter_search_to_field_by_name(search_text, field_name) + idx = -2 + chooser = @browser.text_field(:name,field_name) + 0.upto(2).each{ + |idx| + break if chooser and chooser.present? + sleep 1 + chooser = @browser.text_field(:name,field_name) + } + unless chooser and chooser.present? + msg = "idx #{idx} could not find textfield #{field_name} in #{@browser.url}" + puts msg + # require 'pry'; binding.pry + raise msg + end + 0.upto(30).each{ |idx| + begin + chooser.set(search_text) + sleep idx*0.1 + chooser.send_keys(:down) + sleep idx*0.1 + chooser.send_keys(:enter) + sleep idx*0.1 + value = chooser.value + break unless /#{search_text}/.match(value) + sleep 0.5 + rescue StandardError => e + puts "in rescue" + createScreenshot(@browser, "rescue_#{search_text}_#{__LINE__}") + puts e.inspect + puts caller[0..5] + return + end + } + chooser.set(chooser.value + "\n") + puts "chooser set to #{chooser.value}" + createScreenshot(@browser, "_#{search_text}_#{__LINE__}") + end + + before :all do + $prescription_test_id = 1 + waitForOddbToBeReady(@browser, OddbUrl) + login + end + + before :each do + @timestamp = Time.now.strftime('%Y%m%d%H%M%S') + # puts "before #{$prescription_test_id} with #{@browser.windows.size} windows" + while @browser.windows.size > 1 + @browser.windows.first.use + @browser.windows.last.close if @browser.windows.last + end + @browser.goto OddbUrl + end + + def enter_fachinfo_search + if @browser.link(:name=>'fachinfo_search').exists? + puts "Going to search FI erweitert" + @browser.link(:name=>'fachinfo_search').click + end + end + + after :each do + createScreenshot(@browser, '_'+$prescription_test_id.to_s) if @browser + $prescription_test_id += 1 + end + + it "should work with the privatetemplate searchbar" do + field_name = 'search_query' + @browser.links.find{ |item| item.href.match(/fachinfo\/swissmedic/) != nil}.click + @browser.text_field(:name => field_name).text.should == "" + @browser.text_field(:name => field_name).value.should == "HIER Suchbegriff eingeben" + @browser.text_field(:name => field_name).value = 'Aspirin' + @browser.text_field(:name => field_name).send_keys :enter + @browser.url.should match /search_query/ + @browser.url.should match /Aspirin/ + @browser.text.scan(/aspirin/i).count.should > 10 # was 17 in august 2014 + end if false + + # http://oddb-ci2.dyndns.org/de/gcc/fachinfo/reg/58868 + it "should show the chapter Dos./Anw for Kopfschmerzen and show 58868 Actemra :" do + enter_fachinfo_search + enter_search_to_field_by_name('Actemra', 'searchbar'); + + @browser.select_list(:name, "fachinfo_search_type").select(/Unerw.Wirk/i) + @browser.checkbox(:name,'fachinfo_search_full_text').set + @browser.text_field(:name => 'fachinfo_search_term').set('Kopfschmerzen') + @browser.text_field(:name => 'fachinfo_search_term').send_keys :tab + # require 'pry'; binding.pry + sleep 0.1 + @browser.button(:value,"Suchen").click + sleep(5) + @browser.text.should match /Kopfschmerzen/ + @browser.text.should match /Actemra/ + end +if false + pending "should work with the notify searchbar" do + false.should == true + end + + pending "should work with the migel/feedbacks searchbar" do + false.should == true + end + + pending "should work with the notify_confirm searchbar" do + false.should == true + end + + pending "should work with the drugs/fachinfos searchbar" do + false.should == true + end + + pending "should work with the drugs/vaccines searchbar" do + false.should == true + end + + pending "should work with the drugs/limitationtexts searchbar" do + false.should == true + end + + pending "should work with the drugs/feedbacks searchbar" do + false.should == true + end + + pending "should work with the drugs/patinfos searchbar" do + false.should == true + end + + pending "should work with the drugs/sequences searchbar" do + false.should == true + end + + pending "should work with the drugs/resultlimit searchbar" do + false.should == true + end + + pending "should work with the substances/result searchbar" do + false.should == true + end +end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b8c9f66..125b388 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -5,6 +5,17 @@ SimpleCov.start BreakIntoPry = true require 'pry' if BreakIntoPry +for_running_in_irb = %( +require 'watir'; require 'pp' +homeUrl ||= "oddb-ci2.dyndns.org" +OddbUrl = homeUrl +@browser = Watir::Browser.new(:chrome) +@browser.goto OddbUrl +@browser.link(:text=>'Interaktionen').click +id = 'home_interactions' +medi = 'Losartan' +chooser = @browser.text_field(:id, id) +) if RUBY_PLATFORM.match(/mingw/) require 'watir' diff --git a/src/state/ajax/matches.rb b/src/state/ajax/matches.rb index 4d7b012..568d48d 100644 --- a/src/state/ajax/matches.rb +++ b/src/state/ajax/matches.rb @@ -12,8 +12,10 @@ class Matches < Global def init @model = [] index = @session.user_input(:index_name) || 'sequence_index_exact' + $stdout.puts "State::Ajax::Matches index #{index} query #{@session.user_input(:search_query)} @model #{@model}" if (term = @session.user_input(:search_query)) && term.is_a?(String) terms = ODBA.cache.index_matches(index, term.downcase) + $stdout.puts "State::Ajax::Matches #{terms.size} terms: #{terms[0..3].inspect}" case index when 'oddb_package_name_with_size_company_name_and_ean13', 'oddb_package_name_with_size_company_name_ean13_fi' @@ -26,6 +28,7 @@ class Matches < Global { :search_query => term } end end + $stdout.puts "State::Ajax::Matches #{terms.size} results: #{terms[0..3].inspect}" @model.concat terms end end diff --git a/src/state/drugs/fachinfo_search.rb b/src/state/drugs/fachinfo_search.rb index 5418149..359045a 100644 --- a/src/state/drugs/fachinfo_search.rb +++ b/src/state/drugs/fachinfo_search.rb @@ -19,21 +19,22 @@ class FachinfoSearch < State::Drugs::Global VIEW = View::Drugs::FachinfoSearch @@ean13_form = /^(7680)(\d{5})(\d{3})(\d)$/u def init - $stdout.puts "FachinfoSearch #{@session.event.to_sym == self.class::DIRECT_EVENT} drugs #{@session.persistent_user_input(:drugs)}" + @drugs = @session.persistent_user_input(:fachinfo_drugs_2_search) + $stdout.puts "State::FachinfoSearch event #{@session.event.to_sym == self.class::DIRECT_EVENT} @drugs #{@drugs.inspect} path #{@session.request_path} user_input #{@session.user_input(:fachinfo_drugs_2_search)}" super end def ajax_add_drug - $stdout.puts "FachinfoSearch.ajax_add_drug #{@session.user_input(:ean)}" + $stdout.puts "State::FachinfoSearch.ajax_add_drug #{@session.user_input(:ean)}" check_model FachinfoSearchDrug.new(@session, @model) end def ajax_delete_drug - $stdout.puts "FachinfoSearch.ajax_delete_drug #{@session.user_input(:ean)}" + $stdout.puts "State::FachinfoSearch.ajax_delete_drug #{@session.user_input(:ean)}" check_model FachinfoSearchDrug.new(@session, @model) end def delete_all - $stdout.puts "FachinfoSearch.delete_all request_path #{@session.request_path}" + $stdout.puts "State::FachinfoSearch.delete_all request_path #{@session.request_path}" unless error? @model = [] end @@ -44,6 +45,7 @@ class FachinfoSearch < State::Drugs::Global self end def export_csv + $stdout.puts "State::FachinfoSearch.export_csv" @model = match_term if @model.empty? FachinfoSearch.new(@session, @model) @@ -52,6 +54,7 @@ class FachinfoSearch < State::Drugs::Global end end def search + $stdout.puts "State::FachinfoSearch.search" @model = match_term FachinfoSearch.new(@session, @model) end @@ -69,13 +72,20 @@ class FachinfoSearch < State::Drugs::Global end end def match_term + x = %( +match_term chapter term Gewichtszunahme is_full false +State::FachinfoSearch event false @drugs {"7680576730049"=>#} path /de/gcc user_input +) hits = [] - if @session.choosen_drugs + @drugs = @session.persistent_user_input(:fachinfo_drugs_2_search) + $stdout.puts"State::FachinfoSearch.match_term @drugs #{@drugs.inspect} user_input #{@session.user_input(:fachinfo_drugs_2_search)}" + if @drugs chapter = @session.user_input(:fachinfo_search_type).to_s.gsub(/^fi_/, '').intern term = @session.user_input(:fachinfo_search_term) is_full = (@session.user_input(:fachinfo_search_full_text) == "1") - @session.choosen_drugs.each do |ean13, pac| - $stdout.puts "match_term #{ean13} #{pac}" + $stdout.puts " match_term chapter #{chapter} term #{term} is_full #{is_full}" + @drugs.each do |ean13, pac| + $stdout.puts " match_term #{ean13} #{pac}" doc = pac.fachinfo.description(@session.language) if doc.respond_to?(chapter) desc = doc.send(chapter).to_s diff --git a/src/state/interactions/interaction_chooser.rb b/src/state/interactions/interaction_chooser.rb index ece0a2e..077d2ff 100644 --- a/src/state/interactions/interaction_chooser.rb +++ b/src/state/interactions/interaction_chooser.rb @@ -23,6 +23,7 @@ class InteractionChooser < State::Interactions::Global path = @session.request_path first = true eans = [] + $stdout.puts "interaction_chooser handle_drug_changes #{drugs}" @session.set_persistent_user_input(:drugs, drugs) drugs.each{|ean, pack| eans << pack.barcode } @session.lookandfeel._event_url(:home_interactions, [eans]) diff --git a/src/util/oddbapp.rb b/src/util/oddbapp.rb index c272161..1805701 100644 --- a/src/util/oddbapp.rb +++ b/src/util/oddbapp.rb @@ -100,7 +100,7 @@ class OddbPrevalence rebuild_atc_chooser() end def retrieve_from_index(index_name, query, result = nil) - # $stdout.puts "#{caller[0]}: #{index_name} #{query}"; $stdout.flush + $stdout.puts "#{caller[0]}: #{index_name} #{query}"; $stdout.flush ODBA.cache.retrieve_from_index(index_name, query, result) end # prevalence-methods ################################ diff --git a/src/util/session.rb b/src/util/session.rb index a59f673..8d82a47 100644 --- a/src/util/session.rb +++ b/src/util/session.rb @@ -243,6 +243,7 @@ module ODDB drugs[ean13] = pack if pack } drugs.merge!(persistent) if persistent + $stdout.puts "choosen_drugs returns #{drugs.keys.inspect}" drugs end def zsr_id diff --git a/src/view/ajax/json.rb b/src/view/ajax/json.rb index f25f7ef..0e7166f 100644 --- a/src/view/ajax/json.rb +++ b/src/view/ajax/json.rb @@ -13,6 +13,7 @@ class Json < HtmlGrid::Component 'Content-Type' => 'text/javascript; charset=UTF-8', } def to_html(context) + $stdout.puts "View::Ajax::Json.to_html #{context}" @model.to_json end end diff --git a/src/view/ajax/swissmedic_cat.rb b/src/view/ajax/swissmedic_cat.rb index 42b9f5c..843ad23 100644 --- a/src/view/ajax/swissmedic_cat.rb +++ b/src/view/ajax/swissmedic_cat.rb @@ -22,6 +22,7 @@ class SwissmedicCat < HtmlGrid::Composite :out_of_trade => HtmlGrid::BooleanValue, } def init + $stdout.puts "SwissmedicCat.init" @components = {} @css_map = {} reorganize_components if(@model) diff --git a/src/view/drugs/fachinfo_search.rb b/src/view/drugs/fachinfo_search.rb index cb7e659..304e659 100644 --- a/src/view/drugs/fachinfo_search.rb +++ b/src/view/drugs/fachinfo_search.rb @@ -31,6 +31,7 @@ class FachinfoSearchDrugHeader < HtmlGrid::Composite def init @drugs = @session.choosen_drugs @index = (@drugs ? @drugs.length : 0).to_s + $stdout.puts "View::FachinfoSearchDrugHeader #{@drugs.keys} #{@index}" super end def fachinfo(model, session=@session) @@ -84,6 +85,7 @@ class FachinfoSearchDrug < HtmlGrid::Composite CSS_MAP = {} CSS_CLASS = 'composite' def init + $stdout.puts "View::FachinfoSearchDrug #{@model}" if @model.is_a? ODDB::Package components.store([0,0], :drug) css_map.store([0,0], 'subheading') @@ -97,6 +99,7 @@ class FachinfoSearchDrug < HtmlGrid::Composite end class FachinfoSearchDrugDiv < HtmlGrid::Div def init + $stdout.puts "View::FachinfoSearchDrugDiv #{@session.choosen_drugs}" super @value = [] @drugs = @session.choosen_drugs @@ -241,6 +244,10 @@ class FachinfoSearchTermHitList < HtmlGrid::List OMIT_HEADER = true BACKGROUND_SUFFIX = '' LEGACY_INTERFACE = false + def init + $stdout.puts "View::FachinfoSearchTermHitList choosen_drugs #{@session.choosen_drugs.keys}" + super + end def drug(model, session=@session) drugs = @session.choosen_drugs if pac = drugs[model[:ean13]] @@ -294,8 +301,10 @@ class FachinfoSearch < View::PrivateTemplate SNAPBACK_EVENT = :home JAVASCRIPTS = ['admin'] def init + $stdout.puts "View::FachinfoSearch warmup"; $stdout.flush # warm up - @session.app.registrations.length + len = @session.app.registrations.length + $stdout.puts "View::FachinfoSearch has #{len} registrations"; $stdout.flush super end def backtracking(model, session=@session) diff --git a/src/view/drugs/feedbacks.rb b/src/view/drugs/feedbacks.rb index 7ab1beb..a1a39de 100644 --- a/src/view/drugs/feedbacks.rb +++ b/src/view/drugs/feedbacks.rb @@ -95,6 +95,10 @@ class FeedbacksComposite < HtmlGrid::Composite [1,2] => 'component border-left top' } LEGACY_INTERFACE = false + def init + $stdout.puts "View::FeedbacksComposite.init with View::SearchForm" + super + end def current_feedback(model) FeedbackForm.new(model.current_feedback, @session, self) end diff --git a/src/view/drugs/limitationtexts.rb b/src/view/drugs/limitationtexts.rb index 5ec6864..0d28363 100644 --- a/src/view/drugs/limitationtexts.rb +++ b/src/view/drugs/limitationtexts.rb @@ -60,6 +60,10 @@ class LimitationTextsComposite < HtmlGrid::Composite [0,2] => 2, } LEGACY_INTERFACE = false + def init + $stdout.puts "View::LimitationTextsComposite.init with View::SearchForm" + super + end def title_limitation_texts(model) unless(model.empty?) @lookandfeel.lookup(:title_limitation_texts, diff --git a/src/view/drugs/patinfos.rb b/src/view/drugs/patinfos.rb index 5b6eeeb..2da4d28 100644 --- a/src/view/drugs/patinfos.rb +++ b/src/view/drugs/patinfos.rb @@ -56,6 +56,10 @@ class PatinfosComposite < HtmlGrid::Composite [0,2] => 2, } LEGACY_INTERFACE = false + def init + $stdout.puts "View::PatinfosComposite.init with View::SearchForm" + super + end def title_patinfos(model) unless(model.empty?) @lookandfeel.lookup(:title_patinfos, diff --git a/src/view/drugs/resultlimit.rb b/src/view/drugs/resultlimit.rb index 538fb54..1983f39 100644 --- a/src/view/drugs/resultlimit.rb +++ b/src/view/drugs/resultlimit.rb @@ -90,6 +90,10 @@ class ResultLimitComposite < HtmlGrid::Composite [0,0] => 'right', [0,1] => 'right', } + def init + $stdout.puts "View::ResultLimitComposite.init with View::SearchForm" + super + end def export_csv(model) state = @session.state if(state.respond_to?(:package_count) && state.package_count.to_i > 0) diff --git a/src/view/drugs/sequences.rb b/src/view/drugs/sequences.rb index edadab6..5f132fe 100644 --- a/src/view/drugs/sequences.rb +++ b/src/view/drugs/sequences.rb @@ -109,6 +109,10 @@ class SequencesComposite < HtmlGrid::Composite [0,2] => 2, } LEGACY_INTERFACE = false + def init + $stdout.puts "View::SequencesComposite.init with View::SearchForm" + super + end def title_sequences(model) unless(model.empty?) @lookandfeel.lookup(:title_sequences, diff --git a/src/view/drugs/vaccines.rb b/src/view/drugs/vaccines.rb index 5203bee..e8db091 100644 --- a/src/view/drugs/vaccines.rb +++ b/src/view/drugs/vaccines.rb @@ -33,6 +33,10 @@ class VaccinesComposite < HtmlGrid::Composite [0,2] => 2, } LEGACY_INTERFACE = false + def init + $stdout.puts "View::VaccinesComposite.init with View::SearchForm" + super + end def title_vaccines(model) unless(model.empty?) @lookandfeel.lookup(:title_vaccines, diff --git a/src/view/migel/feedbacks.rb b/src/view/migel/feedbacks.rb index a48b837..bdb1cf2 100644 --- a/src/view/migel/feedbacks.rb +++ b/src/view/migel/feedbacks.rb @@ -69,6 +69,10 @@ class FeedbacksComposite < HtmlGrid::Composite [1,2] => 'component border-left top' } LEGACY_INTERFACE = false + def init + $stdout.puts "View::Migel::FeedbacksComposite.init with View::SearchForm" + super + end def current_feedback(model) FeedbackForm.new(model.current_feedback, @session, self) end diff --git a/src/view/notify.rb b/src/view/notify.rb index d51831a..3957017 100644 --- a/src/view/notify.rb +++ b/src/view/notify.rb @@ -114,6 +114,10 @@ module ODDB CSS_MAP = { [0,1] => 'th', } + def init + $stdout.puts "View::NotifyComposite.init with View::SearchForm" + super + end end class Notify < View::ResultTemplate CONTENT = View::NotifyComposite diff --git a/src/view/notify_confirm.rb b/src/view/notify_confirm.rb index 5b7aeea..4fee80c 100644 --- a/src/view/notify_confirm.rb +++ b/src/view/notify_confirm.rb @@ -23,6 +23,10 @@ class NotifyConfirmComposite < HtmlGrid::Composite [0,1] => 'th', [0,2] => 'confirm', } + def init + $stdout.puts "View::NotifyConfirmComposite.init with View::SearchForm" + super + end def notify_sent(model, session) last, *mails = model.notify_recipient.reverse string = if(mails.empty?) diff --git a/src/view/privatetemplate.rb b/src/view/privatetemplate.rb index 96023fc..a471d21 100644 --- a/src/view/privatetemplate.rb +++ b/src/view/privatetemplate.rb @@ -13,6 +13,7 @@ module ODDB include View::Snapback SEARCH_HEAD = View::SearchForm def init + $stdout.puts "View::PrivateTemplate.init with View::SearchForm" reorganize_components super end diff --git a/src/view/searchbar.rb b/src/view/searchbar.rb index e93c868..ba356c2 100644 --- a/src/view/searchbar.rb +++ b/src/view/searchbar.rb @@ -25,10 +25,10 @@ function get_to(url) { function get_to_via_top(url) { url = url.replace('//', '/') if (window.location.href == url || window.top.location.href == url) { - console.log('searchbar.get_to href nothing to do'); + console.log('searchbar.get_to_via_top href nothing to do'); return; } - console.log('get_to window.top.location.replace url '+ url); + console.log('get_to_via_top url '+ url); window.top.location.replace(url); } @@ -76,7 +76,8 @@ module InstantSearchBarMethods url = @session.create_search_url(:home_interactions) end val = @session.lookandfeel.lookup(:add_drug) - progressbar = "" + $stdout.puts "InstantSearchBarMethods.xhr_request_init #{@session.request_path} drugs #{@session.choosen_drugs} and #{@session.persistent_user_input(:fachinfo_drugs_2_search)}" + $stdout.puts "InstantSearchBarMethods.xhr_request_init id #{id} val #{val} -> #{url} #{@session.request_path} " if @container.respond_to?(:progress_bar) progressbar = "setTimeout('show_progressbar(\'#{id}\')', 10);" end @@ -124,6 +125,7 @@ function selectXhrRequest() { var searchbar = dojo.byId('#{id}'); if(popup && !popup.style.overflowX.match(/auto/) && searchbar.value != '') { #{progressbar} + console.log('selectXhrRequest popup: '+ popup + ' searchbar: ' + searchbar); if (searchbar && searchbar.value && window.location.href) { console.log('selectXhrRequest: window.location.href ' + window.location.href + ' searchbar: ' + searchbar.value); @@ -132,10 +134,13 @@ function selectXhrRequest() { if (path.match(/home_interactions/)) { if (path.match(/\\/$/)) { path = path + ean13; + console.log('selectXhrRequest: line #{__LINE__}: ' + path); } else if (path.match(/home_interactions$/)) { path = path + '/' + ean13; + console.log('selectXhrRequest: line #{__LINE__}: ' + path); } else { path = path + ',' + ean13; + console.log('selectXhrRequest: line #{__LINE__}: ' + path); } get_to(path.replace('?/','/') ); } else if (path.match(/fachinfo_search|rezept/)) @@ -143,15 +148,19 @@ function selectXhrRequest() { if (path.match(/ean/) == null) { if (path.match(/\\/$/)) { path = path + 'ean/' + ean13; + console.log('selectXhrRequest: line #{__LINE__}: ' + path); } else { path = path + '/ean/' + ean13; + console.log('selectXhrRequest: line #{__LINE__}: ' + path); } } else { path = path + ',' + ean13; + console.log('selectXhrRequest: line #{__LINE__}: ' + path); } searchbar.value = ''; get_to(path.replace('?/','/')); - } else { // neiter home_interactions, fachinfo_search nor rezept + } else { // neither home_interactions, fachinfo_search nor rezept + console.log('selectXhrRequest: line #{__LINE__}: neither home_interactions, fachinfo_search nor rezept '); xhrGet(searchbar.value); searchbar.value = ''; } @@ -177,16 +186,34 @@ require(['dojo/ready'], function(ready) { 'value' => @session.persistent_user_input(:search_query) end def to_html(context, *args) + $stdout.puts "to_html: context #{context} *args #{args.inspect} drugs #{@session.choosen_drugs.keys}" args = [] if @container.respond_to?(:index_name) && (index = @container.index_name) args.push :index_name, index end - target = @session.lookandfeel._event_url(:ajax_matches, args) - html = context.div 'data-dojo-type' => 'dojox.data.JsonRestStore', - 'jsId' => 'search_matches', - 'idAttribute' => 'drug', - 'target' => target - html << super(context) + @session.set_persistent_user_input(:fachinfo_drugs_2_search, @session.choosen_drugs) + if @session.request_path.match(/fachinfo_search/) + if false and @session.choosen_drugs.size > 0 + target = @session.lookandfeel._event_url(:fachinfo_search, [:ean, @session.choosen_drugs.keys, :ajax_matches, args ].flatten) + else + target = @session.lookandfeel._event_url(:ajax_matches, args) + end + $stdout.puts "to_html: target #{target} from args #{args.inspect}" + html = context.div 'data-dojo-type' => 'dojox.data.JsonRestStore', + 'jsId' => 'search_matches', + 'idAttribute' => 'drug', + 'target' => target + html << super(context) + else + target = @session.lookandfeel._event_url(:ajax_matches, args) + $stdout.puts "to_html: request_path #{@session.request_path} target #{target} from args #{args.inspect} drugs #{@session.choosen_drugs.keys}" + $stdout.puts "to_html: context #{context}" + html = context.div 'data-dojo-type' => 'dojox.data.JsonRestStore', + 'jsId' => 'search_matches', + 'idAttribute' => 'drug', + 'target' => target + html << super(context) + end end end class SearchBar < HtmlGrid::InputText diff --git a/src/view/substances/result.rb b/src/view/substances/result.rb index 1ed6534..2ce252d 100644 --- a/src/view/substances/result.rb +++ b/src/view/substances/result.rb @@ -22,6 +22,10 @@ class ResultComposite < HtmlGrid::Composite [0,1] => View::Substances::ResultList, } LEGACY_INTERFACE = false + def init + $stdout.puts "View::Substances::ResultComposite.init with View::SearchForm" + super + end def title_found(model) query = @session.persistent_user_input(:search_query) @lookandfeel.lookup(:title_found, query, @session.state.object_count) -- 2.1.0