last updated: Sat 10/11/08 3:36pm

Search Criteria

How to populate the summary of the current search criteria.

Preview

Search criteria with almost all the stuff filled in. The sections should be expand/collapseable.

Search Criteria
Rock Type
Blueschist, Metaarkose, Mylonite, Slate
Location
North: -66.84726249697599
South: -83.61468904835162
East: 137.109375
West: 56.953125
Minerals
All Tectosilicates
Albites: Oligoclase, Andesine
All Oxides except Hamatite
Metamorphic Grade
Something, Some other thing, yup
Chemistry
5.0 < Al < 6.7 [%wt]
12.6 < CeO2 < 14.7 [%wt]
Other
Owner: Frank Spear
Collection Date: 10/2007 - 10/2008

Location

Since we decided that the user can choose a location either by entering coordinates or choosing a region/country combination (not both), the Location part will display only one of these:

Location
North: -66.84726249697599
South: -83.61468904835162
East: 137.109375
West: 56.953125
Location
Region: Valhalla Complex, British Columbia
Country: United States, Belgium

.

Minerals

This can get kinda crazy. I was trying to come up with ways to represent what the user has selected in a meaningful way that also fits in this tiny space. I decided that the hierarchy would have to be compromised a bit. By that I mean if a node has children, it is considered a top-level category, whether it has a parent node or not. This way, a summary can be built, with one "sentence" for each category of Mineral that has some or all children selected.

But, just like everything in life, there is an exception to this rule. The exception occurs when we do not want to "repeat" data. An example would be "All Tectosilicates". We would not want to also display "All Silica", because that is implied.

I think the following pseudo-code will help:

if category.selected == 0 || 
category.selected == category.total && category.hasparent && category.parent.selected > 1:
	do not show
else if category.selected == category.total:
	show "All [category]"
else if category.total > 6 && category.unselected <= 3:
	show "All [category] except [unselected1], [unselected2], [unselected3]"
else if category.selected > 1:
	show "[category]: [selected1], [selected2], ..., [selectedN]"

Other things to note: if a child has children, it is only considered 'selected' by its parent when it has all its children selected. Also, if some (but not all) of its children are selected, its display name should be prepended with "some " when being displayed inside its parent:

if category.hasparent && category.selected < category.total && category.selected > 0 && category.parent.selected > 1:
		in parent show "some [category]" 
		// (regardless of whether it is in an "except" statement or not)
		// valid example: "All Tectosilicates except some Silica"
		// valid example: "Tectosilicates: Sodalite, some Silica, Leucite"
		// invalid example: "Tectosilicates: some Silica"
			// instead, this should just be "Silica: Coesite, Quartz"