title: real-estate-demo
caption: Real Estate Demo
tags: $:/tags/GeospatialDemo

\define default-display-filter() [<currentTiddler>get<fieldname>]
\define default-limit() 10

This is a list of all the tiddlers containing ~GeoJSON markers in this wiki (identified by the tag <<tag "$:/tags/GeoMarker">>) viewed as both a map and a table.

<$let
	schema={{real-estate-demo/schema}}
>
	<div>
		<$list filter="[<schema>jsonindexes[columns]]" variable="index">
			<$let
				config={{{ [<schema>jsonget[columns],<index>,[name]addprefix[$:/config/geospatial/demo/real-estate-demo/columns/]] }}}
			>
				<div>
					<$checkbox tiddler=<<config>> field="visible" checked="yes" unchecked="no" default="yes">
						<$text text={{{ [<schema>jsonget[columns],<index>,[caption]] }}}/>
					</$checkbox>
				</div>
			</$let>
		</$list>
	</div>
	<div>
		Sorting by
		<$select tiddler="$:/config/geospatial/demo/real-estate-demo/sort-field" default="title">
			<$list filter="[<schema>jsonindexes[columns]]" variable="index">
				<option value={{{ [<schema>jsonget[columns],<index>,[name]] }}}>
					<$text text={{{ [<schema>jsonget[columns],<index>,[caption]] }}}/>
				</option>
			</$list>
		</$select>
		<$checkbox tiddler="$:/config/geospatial/demo/real-estate-demo/sort-order" field="text" checked="reverse" unchecked="normal" default="normal">
			Reverse sort order
		</$checkbox>
	</div>
	<div>
	Search: <$edit-text tiddler="$:/config/geospatial/demo/real-estate-demo/search" tag="input"/>
	</div>
	<div>
	Limit: <$edit-text tiddler="$:/config/geospatial/demo/real-estate-demo/limit" tag="input" placeholder=<<default-limit>>/>
	</div>
	<table>
		<thead>
			<tr>
				<$list filter="[<schema>jsonindexes[columns]]" variable="index">
					<$let
						config={{{ [<schema>jsonget[columns],<index>,[name]addprefix[$:/config/geospatial/demo/real-estate-demo/columns/]] }}}
					>
						<$list filter="[<config>get[visible]else[yes]match[yes]]" variable="ignore">
							<th>
								<$text text={{{ [<schema>jsonget[columns],<index>,[caption]] }}}/>
							</th>
						</$list>
					</$let>
				</$list>
			</tr>
		</thead>
		<tbody>
			<$let
				sortField={{{ [[$:/config/geospatial/demo/real-estate-demo/sort-field]get[text]else[title]] }}}
				sortOrder={{{ [[$:/config/geospatial/demo/real-estate-demo/sort-order]get[text]else[normal]] }}}
				limit={{{ [[$:/config/geospatial/demo/real-estate-demo/limit]get[text]] :else[<default-limit>] }}}
			>
				<$list filter="[all[shadows+tiddlers]tag[$:/tags/GeoMarker]search:*{$:/config/geospatial/demo/real-estate-demo/search}nsort<sortField>order<sortOrder>limit<limit>]">
					<$let
						rowTiddler=<<currentTiddler>>
					>
						<$setmultiplevariables
							$names="[<schema>jsonindexes[variables]sort[]]"
							$values="[<schema>jsonindexes[variables]sort[]] :map[<schema>jsonget[variables],<currentTiddler>] :map[subfilter<currentTiddler>]"
						>
							<tr>
								<$list filter="[<schema>jsonindexes[columns]]" variable="index">
									<$let
										config={{{ [<schema>jsonget[columns],<index>,[name]addprefix[$:/config/geospatial/demo/real-estate-demo/columns/]] }}}
									>
										<$list filter="[<config>get[visible]else[yes]match[yes]]" variable="ignore">
											<td>
												<$let
													fieldname={{{ [<schema>jsonget[columns],<index>,[name]] }}}
													displayFilter={{{ [<schema>jsonget[columns],<index>,[display]] :else[<default-display-filter>] }}}
												>
													<$text text={{{ [subfilter<displayFilter>] }}}/>
												</$let>
											</td>
										</$list>
									</$let>
								</$list>
							</tr>
						</$setmultiplevariables>
					</$let>
				</$list>
			</$let>
		</tbody>
	</table>
</$let>
