/* * Created by PyramIDE. * User: フランスのトトロ aka (David RENÉ) * Date: 13/02/2016 * Time: 11:19 * © Calexium */ read system/string.anubis read tools/basis.anubis read calexium_lib/web/CXM_making_a_web_site.anubis read calexium_lib/web/CXM_web_action.anubis read hayamiki_lib/types/hayamiki.anubis read icons.anubis read columns.anubis public define String to_HTML_cell_icon ( HK_Model_Column column, String data_name, String general_type_name )= "icon("+to_Icon(column, data_name, general_type_name)+")". public define String to_HTML_cell_text ( HK_Model_Column column, String data_name, String general_type_name )= "text("+to_String(column, data_name, general_type_name)+")". public define String to_HTML_cell_link ( HK_Model_Column column, String data_name, String general_type_name )= "link(to_String("+data_name+".id), "+to_String(column, data_name, general_type_name)+")". public define String to_HTML_cell_link_id_action ( HK_Model_Column column, String data_name, String general_type_name, WEB_Action_Name action_name )= "link_id_action(to_String("+data_name+".id), "+to_String(column, data_name, general_type_name)+", "+to_Anubis_Source(action_name)+")". public define String to_HTML_cell_link ( List(HK_Model_Column) columns, String column_name, String data_name, String general_type_name, WEB_Action_Name action_name )= if get_column_type_from_name(columns, column_name) is { failure then "column name "+column_name+"doesn't exist", success(column) then if action_name = no_action then to_HTML_cell_link(column, data_name, general_type_name) else to_HTML_cell_link_id_action(column, data_name, general_type_name, action_name) }. public define String to_HTML_cell ( List(HK_Model_Column) columns, String column_name, String data_name, String general_type_name )= if get_column_type_from_name(columns, column_name) is { failure then "column name "+column_name+"doesn't exist", success(column) then since column is hk_column(name, col_type, _, _), if col_type is { p_key then to_HTML_cell_link(column, data_name, general_type_name), boolean_field then to_HTML_cell_icon(column, data_name, general_type_name), date_field(attrs) then to_HTML_cell_text(column, data_name, general_type_name), time_field(attrs) then to_HTML_cell_text(column, data_name, general_type_name), datetime_field(attrs) then to_HTML_cell_text(column, data_name, general_type_name), foreign_key(app, foreign_table) then to_HTML_cell_text(column, data_name, general_type_name), integer_field(choices) then to_HTML_cell_text(column, data_name, general_type_name), float_field then to_HTML_cell_text(column, data_name, general_type_name), char_field(choices, size) then to_HTML_cell_text(column, data_name, general_type_name), password_field(min_size) then "text(\"********\")", //to_HTML_cell_text(column, data_name, general_type_name), text_field(attrs) then to_HTML_cell_text(column, data_name, general_type_name), } }. public define String make_list_view_row ( HK_Table table, //table to format String data_name, //name of data String indent, //indentation string to use HK_List_View list_view //list view to generate )= since table is hk_table(table_name, short, model, _), //get name and model of the table since model is hk_model( columns, _), //get all columns of table // since display is db_display(views, _), // with current_list_column = if list_view is { list_view_all then to_List_String(columns, false), //generate a list of columns string to view from columns model list_view(v_name, v_col, _) then v_col }, with action_name = if list_view is { list_view_all then no_action, list_view(_, _, an) then an }, if current_list_column is { [] then "", [h . t] then indent+join(",\n"+indent, //Make first column as link [to_HTML_cell_link(columns, h, data_name, table_name, action_name)] + //and the other set with list_view map((String column_name) |-> to_HTML_cell(columns, column_name, data_name, table_name), t) ) }.