Commits

Thibaut Colar committed dfbbeb7

Enable user to pick search match type in doc pane (exact, startsWith, contains)

Comments (0)

Files changed (2)

src/brie/fan/DocWebMod.fan

   override Void onGet()
   {
     Sys sys := (Sys) Service.find(Sys#)
-    text := req.uri.toStr[1..-1]
+    text := req.uri.pathStr[1..-1]
+    query := req.uri.query
+    MatchKind matchKind := MatchKind.startsWith
+    if(query.containsKey("type"))
+    {
+      matchKind = MatchKind(query["type"])
+    }
+
     try
     {
       if(text.isEmpty)
         showDoc(req, itemDoc(sys, text))
       }
       else
-        showDoc(req, find(sys, text))
+        showDoc(req, find(sys, text, matchKind))
     }
     catch(Err e)
     {

src/brie/fan/widget/HelpPane.fan

 {
   WebBrowser? browser
   Text? search
+  Combo searchType := Combo{items = ["term*","*term*","exact"]}
   private Frame frame
   private Sys sys
 
       search = Text
       {
         text=""
-        prefCols = 15
         onAction.add |Event e|
         {
           render(search.text)
         }
       }
+
       top = EdgePane
       {
         top = GridPane
         {
-          numCols = 2
+          numCols = 3
+          expandCol = 3
           Button{image = gfx::Image(`fan://icons/x16/arrowLeft.png`);
           onAction.add |Event e|
             {
               browser.back
             }
           },
+          searchType,
           search,
         }
         center = EdgePane
     }
     text = text.trim
 
-    search.text = text.trim
+    search.text = text
 
+    if(! text.isEmpty)
+    {
+      if(searchType.selectedIndex == 1)
+        text += "?type=contains"
+      else if(searchType.selectedIndex == 2)
+        text += "?type=exact"
+    }
     browser.load(`http://127.0.0.1:${port}/$text`)
   }
 }