Skip to content

Instantly share code, notes, and snippets.

@jeppenejsum
Created April 3, 2010 15:46
Show Gist options
  • Save jeppenejsum/354604 to your computer and use it in GitHub Desktop.
Save jeppenejsum/354604 to your computer and use it in GitHub Desktop.
def itemListActionsTemplate : NodeSeq = <xml:group>
<a crud:edit_href="" title={S.??("edit")} class="ss_sprite ss_pencil" ></a>
<a crud:delete_href="" title={S.??("delete")} class="ss_sprite ss_delete"></a>
</xml:group>
def itemListActions(item: CrudType, in:NodeSeq):NodeSeq = {
bind("crud", in,
AttrBindParam("edit_href", Text(editItemPathString+"/"+ (obscurePrimaryKey(item))),"href"),
AttrBindParam("view_href", Text(viewPathString+"/"+(obscurePrimaryKey(item))),"href"),
AttrBindParam("delete_href", Text(deletePathString+"/"+ (obscurePrimaryKey(item))),"href")
)
}
def _showAllHeader : NodeSeq =
<ul class="butrow">
<li class="iconbut"><a class="ss_add" href={createPathString}>Opret ny</a></li>
</ul>
def _showAllTemplate:NodeSeq = <xml:group>
{renderOnLoad("#"+showAllId)}
<lift:crud.all>
{_showAllHeader}
<div class="search-wrapper">
<input name="filter" id="filter-box" type="text" accesskey="s" autocomplete="off" value="Søg..." maxlength="30" size="30"/>
<div id="filter-clear-button" onclick="$('#filter-clear-button').hide();">x</div>
</div>
<table id={showAllId} class={"tablesorter "+showAllClass}>
<thead>
<tr>
<th> </th>
<crud:header_item><th crud:style="" crud:class=""><crud:name/></th></crud:header_item>
</tr>
</thead>
<tbody>
<crud:row>
<tr>
<td nowrap="nowrap">{itemListActionsTemplate}</td>
<crud:row_item><td nowrap="nowrap" crud:style=""><crud:value/></td></crud:row_item>
</tr>
</crud:row>
</tbody>
</table>
<div id="pager" class="pager" >
<img src={"/" + LiftRules.resourceServerPath + "/tablesorter/addons/pager/icons/first.png"} class="first" alt="Første"/>
<img src={"/" + LiftRules.resourceServerPath + "/tablesorter/addons/pager/icons/prev.png"} class="prev" alt="Forrige"/>
<input type="text" class="pagedisplay"/>
<img src={"/" + LiftRules.resourceServerPath + "/tablesorter/addons/pager/icons/next.png"} class="next" alt="Næste"/>
<img src={"/" + LiftRules.resourceServerPath + "/tablesorter/addons/pager/icons/last.png"} class="last" alt="Sidste"/>
<select class="pagesize">
<option selected="selected" value="20">20</option>
<option value="50">50</option>
<option value="100">100</option>
<option value="500">500</option>
</select>
</div>
</lift:crud.all>
</xml:group>
def doCrudAll(in: NodeSeq): NodeSeq = {
val list = findAll(findForListParams : _*)
def doHeaderItems(in: NodeSeq): NodeSeq =
listFields(list.head).flatMap(f =>
bind("crud", in, "name" -> f.displayHtml,
AttrBindParam("style",_columnStyle(f), "style"),
AttrBindParam("class",if (isNumeric(f)) Text("{sorter: 'digit'}") else null, "class")
))
def doRows(in: NodeSeq): NodeSeq = list.flatMap{c =>
def doRowItem(in: NodeSeq): NodeSeq = listFields(c).flatMap(f =>
bind("crud", in, "value" -> f.asHtml,
AttrBindParam("style",_cellStyle(f), "style")))
itemListActions(c,bind("crud", in , "row_item" -> doRowItem _))
}
if (list.isEmpty)
_showAllHeader ++ <div>Der er ingen data.</div>
else
bind("crud", in, "header_item" -> doHeaderItems _,
"row" -> doRows _)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment