Changes between Version 1 and Version 2 of BluePrintSearch


Ignore:
Timestamp:
03/01/11 09:18:27 (11 years ago)
Author:
Dominic König
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • BluePrintSearch

    v1 v2  
    2020== Design ==
    2121
    22   - ''coming soon''
     22=== Introduction ===
     23
     24The '''S3Find''' class implements the '''[wiki:S3XRC/S3Method S3Method]''' interface, and is connected to the {{{search}}} URL method:
     25
     26{{{
     27http://localhost:8000/eden/hms/hospital/search
     28}}}
     29
     30'''S3Find''' implements both, interactive and non-interactive search methods. Currently supported formats are:
     31
     32  - HTML
     33  - JSON
     34
     35=== Interactive search methods ===
     36
     37For interactive search, '''S3Find''' can be configured per resource, using instances of classes implementing the '''S3SearchWidget''' interface to create search forms.
     38
     39Two interactive search forms can be configured (both of which are optional): '''simple''' and '''advanced''', where the user can toggle between these forms (if both are defined).
     40
     41{{{
     42    # Use a variable to hold the S3Find instance
     43    hms_hospital_search = s3base.S3Find(
     44
     45        # Simple search form as a tuple of widgets:
     46        simple=(
     47                  # simple full-text search widget:
     48                  s3base.S3SearchSimpleWidget(
     49                    name="hospital_search_advanced",             # widget name must be specified and unique in the form!
     50                    label=T("Name and/or ID"),                   # Label for the search field
     51                    comment=T("To search for a hospital, ..."),  # Tooltip text for the search field
     52                    field=["paho_uuid",                          # Names of fields to search in
     53                           "gov_uuid",
     54                           "name",
     55                           "aka1",
     56                           "aka2",
     57                          ]
     58                  ),
     59        ),
     60
     61        # Advanced search form as a tuple of widgets:
     62        advanced=(
     63
     64                  # simple full-text search widget:
     65                  s3base.S3SearchSimpleWidget(
     66                    name="hospital_search_advanced",
     67                    label=T("Name, Org and/or ID"),
     68                    comment=T("To search for a hospital, ..."),
     69                    field=["paho_uuid",
     70                           "gov_uuid",
     71                           "name",
     72                           "aka1",
     73                           "aka2",
     74                           "contact.name",                       # "." separator: search in component
     75                           "organisation_id$name",               # "$" separator: search in records referenced by organisation_id
     76                           "organisation_id$acronym"
     77                          ]
     78                  ),
     79
     80                  # MinMax search widget to filter for a range of values:
     81                  s3base.S3SearchMinMaxWidget(
     82                    name="hospital_search_bedcount",
     83                    method="range",                              # widget-specific attribute "method"
     84                    label=T("Total Beds"),
     85                    comment=T("Select a range for the ..."),
     86                    field="total_beds"                           # most widgets only support one search field
     87                  )
     88        ))
     89
     90    # Set as standard search method for this resource
     91    s3xrc.model.configure(db.hms_hospital, search_method=hms_hospital_search)
     92
     93}}}
     94
     95The {{{simple}}} form usually consists of a {{{S3SearchSimpleWidget}}} which performs a simple full-text search through various fields of the resource. However, the {{{simple}}} form may also be configured with other search widgets. In the same manner, the {{{advanced}}} form can include the {{{S3SearchSimpleWidget}}}.
     96
     97When calling the {{{search}}} method, the {{{simple}}} form will be opened first, while the {{{advanced}}} form is hidden (if only the advanced form is defined, then it will of course not be hidden). By clicking the ''Advanced Search'' link below the form, the user can switch to the {{{advanced}}} form, and vice versa. The forms are independent, i.e. the user can only submit one of them.
    2398
    2499== Implementation ==
    25100
    26   - ''coming soon''
     101  - {{{modules/s3/s3find.py}}}
    27102
    28103----