Skip to content

Commit

Permalink
[enhance] Table component: new display option for row and cell, and c…
Browse files Browse the repository at this point in the history
…lass added on cell based on the provided col_to_string
  • Loading branch information
cedricss committed Aug 22, 2011
1 parent fa9bc35 commit 09a7290
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions stdlib/components/table/table.opa
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ type CTable.config('a, 'state, 'row, 'col) = {
on_forall_closed : string -> void on_forall_closed : string -> void
prevent_empty_row_at_the_end : bool prevent_empty_row_at_the_end : bool
prevent_empty_col_at_the_end : bool prevent_empty_col_at_the_end : bool
row_display : string
cell_display : string
} }


type CTable.data_writer('a, 'state, 'row, 'col) = { type CTable.data_writer('a, 'state, 'row, 'col) = {
Expand Down Expand Up @@ -307,7 +309,7 @@ CTable = {{
if simple if simple
then WStyler.add(td_style,html) then WStyler.add(td_style,html)
else else
<td id="{cell_id}" style="display:none" class={[prefix_td(td_prefix)]}> <td id="{cell_id}" style="display:none" class={[prefix_td(td_prefix),config.col_to_string(col)]}>
{html} {html}
</td> </td>
|> WStyler.add(td_style,_) |> WStyler.add(td_style,_)
Expand Down Expand Up @@ -371,28 +373,31 @@ CTable = {{
<th style="display:none" id="{header_col_id}">{sort_html} {filter_html}</th> <th style="display:none" id="{header_col_id}">{sort_html} {filter_html}</th>
end end


/* /*
* Sow/Hide - Row/Cell * Sow/Hide - Row/Cell
*/ */
@private @private
dom_show_cell(_dur, dom, simple) = dom_show_cell(config)(_dur, dom, simple) =
if not(simple) if not(simple)
then ignore(Dom.set_style_property_unsafe(dom,"display","table-cell")) then ignore(Dom.set_style_property_unsafe(dom,"display",config.cell_display))


@private @private
dom_hide_cell(_dur, dom, _simple) = ignore(Dom.set_style_property_unsafe(dom,"display","none")) dom_hide_cell(_dur, dom, _simple) = ignore(Dom.set_style_property_unsafe(dom,"display","none"))

@private @private
dom_show_row(_dur, dom) = dom_show_row(config)(_dur, dom) =
_ = Dom.set_style_property_unsafe(dom,"display","table-row") _ = Dom.set_style_property_unsafe(dom,"display",config.row_display)
_ = Dom.add_class(dom, "table_row_show") _ = Dom.add_class(dom, "table_row_show")
_ = Dom.remove_class(dom, "table_row_hide") _ = Dom.remove_class(dom, "table_row_hide")
void void

@private @private
dom_hide_row(_dur, dom) = dom_hide_row(_dur, dom) =
_ = Dom.set_style_property_unsafe(dom,"display","none") _ = Dom.set_style_property_unsafe(dom,"display","none")
_ = Dom.remove_class(dom, "table_row_show") _ = Dom.remove_class(dom, "table_row_show")
_ = Dom.add_class(dom, "table_row_hide") _ = Dom.add_class(dom, "table_row_hide")
void void

/* /*
* Get next/previous unfiltered row * Get next/previous unfiltered row
*/ */
Expand Down Expand Up @@ -486,6 +491,9 @@ CTable = {{
then (col_table_size - 1) then (col_table_size - 1)
else r else r


dom_show_cell = dom_show_cell(config)
dom_show_row = dom_show_row(config)

/* /*
* Get the index of a key * Get the index of a key
*/ */
Expand Down Expand Up @@ -1005,7 +1013,7 @@ CTable = {{
// if List.mem(r,rows) // if List.mem(r,rows)
// then // then
// id_row = gen_row_id(table_id,config,r) // id_row = gen_row_id(table_id,config,r)
// do Dom.add_class(#{id_row},"selected") // do Dom.add_class(#{id_row},"selected")
// BMap.add(i,(r,f,true),map) // BMap.add(i,(r,f,true),map)
// else map // else map
// | {none} -> map // | {none} -> map
Expand All @@ -1019,7 +1027,7 @@ CTable = {{
// if List.mem(r,rows) // if List.mem(r,rows)
// then // then
// id_row = gen_row_id(table_id,config,r) // id_row = gen_row_id(table_id,config,r)
// do Dom.remove_class(#{id_row},"selected") // do Dom.remove_class(#{id_row},"selected")
// BMap.add(i,(r,f,false),map) // BMap.add(i,(r,f,false),map)
// else map // else map
// | {none} -> map // | {none} -> map
Expand Down Expand Up @@ -1463,6 +1471,9 @@ CTable = {{
rec val channel = Session.make(table_init_state, table_on_message(simple,id, config, callbacks,_,_,channel)) rec val channel = Session.make(table_init_state, table_on_message(simple,id, config, callbacks,_,_,channel))




dom_show_cell = dom_show_cell(config)
dom_show_row = dom_show_row(config)

show_displayed_cols(_rows, cols, display) = show_displayed_cols(_rows, cols, display) =
do for_iter(display.top_row_index, display_bottom)(i -> do for_iter(display.top_row_index, display_bottom)(i ->
(row, _, _) = BMap.get(i, row_map) ? @fail("should not happen") //OK (row, _, _) = BMap.get(i, row_map) ? @fail("should not happen") //OK
Expand Down Expand Up @@ -1622,6 +1633,8 @@ CTable = {{
on_forall_closed = default_on_forall_close on_forall_closed = default_on_forall_close
prevent_empty_row_at_the_end = true // TODO put false when prevent_empty_row is fixed prevent_empty_row_at_the_end = true // TODO put false when prevent_empty_row is fixed
prevent_empty_col_at_the_end = true prevent_empty_col_at_the_end = true
cell_display = "table-cell"
row_display = "table-row"
} }




Expand Down

0 comments on commit 09a7290

Please sign in to comment.