Commit 84a944c7529957f90fc42442bcc5d9879d288654

Authored by totoro
1 parent 45e29b30

Add web session "page message" management with which was moved from Ptah ERP

Showing 1 changed file with 171 additions and 0 deletions   Show diff stats
web/CXM_page_message.anubis 0 → 100644
  1 +/*
  2 + * Created by PyramIDE.
  3 + * User: フランスのトトロ aka (David RENÉ)
  4 + * Date: 20/02/2017
  5 + * Time: 04:31
  6 + * © Calexium
  7 + */
  8 +
  9 +read calexium_lib/web/CXM_making_a_web_site.anubis
  10 +read calexium_lib/web/widgets/icons_set.anubis
  11 +
  12 +public type Alignment:
  13 + left,
  14 + center,
  15 + right.
  16 +
  17 +public type Page_Message:
  18 + no_message,
  19 + info(String message),
  20 + info_translate(String message),
  21 + ok(String message),
  22 + ok_translate(String message),
  23 + warning(String message),
  24 + warning_translate(String message),
  25 + error(String message, Alignment align),
  26 + error_translate(String message, Alignment align).
  27 +
  28 +public define One
  29 + set_Page_Message
  30 + (
  31 + Var(List(WEB_Session_Field)) fields,
  32 + Page_Message p_message
  33 + )=
  34 + with step = get_Int(fields, "AWS_SESSION_STEP",0),
  35 + replace_Int(fields, "PAGE_MESSAGE_TTL", step+1);
  36 + if p_message is
  37 + {
  38 + no_message then
  39 + replace_String(fields, "PAGE_STATUS", "NO_MESSAGE");
  40 + replace_String(fields, "PAGE_MESSAGE", "")
  41 + info(msg_str) then
  42 + replace_String(fields, "PAGE_STATUS", "PAGE_INFO");
  43 + replace_String(fields, "PAGE_MESSAGE", msg_str)
  44 + info_translate(msg_str) then
  45 + replace_String(fields, "PAGE_STATUS", "PAGE_INFO_T");
  46 + replace_String(fields, "PAGE_MESSAGE", msg_str)
  47 + ok(msg_str) then
  48 + replace_String(fields, "PAGE_STATUS", "PAGE_OK");
  49 + replace_String(fields, "PAGE_MESSAGE", msg_str)
  50 + ok_translate(msg_str) then
  51 + replace_String(fields, "PAGE_STATUS", "PAGE_OK_T");
  52 + replace_String(fields, "PAGE_MESSAGE", msg_str)
  53 + warning(msg_str) then
  54 + replace_String(fields, "PAGE_STATUS", "PAGE_WARNING");
  55 + replace_String(fields, "PAGE_MESSAGE", msg_str)
  56 + warning_translate(msg_str) then
  57 + replace_String(fields, "PAGE_STATUS", "PAGE_WARNING_T");
  58 + replace_String(fields, "PAGE_MESSAGE", msg_str)
  59 + error(msg_str, align) then
  60 + replace_String(fields, "PAGE_STATUS", "PAGE_ERROR");
  61 + replace_String(fields, "PAGE_MESSAGE", msg_str)
  62 + error_translate(msg_str, align) then
  63 + replace_String(fields, "PAGE_STATUS", "PAGE_ERROR_T");
  64 + replace_String(fields, "PAGE_MESSAGE", msg_str)
  65 + }
  66 +.
  67 +
  68 +public define Page_Message
  69 + error
  70 + (
  71 + String message
  72 + ) = error(message, left).
  73 +
  74 +public define Page_Message
  75 + error_translate
  76 + (
  77 + String message
  78 + ) = error_translate(message, left).
  79 +
  80 +public define Page_Message
  81 + get_Page_Message
  82 + (
  83 + Var(List(WEB_Session_Field)) fields,
  84 + (String) -> String _T
  85 + )=
  86 + with page_status = get_String(fields, "PAGE_STATUS", "NO_MESSAGE"),
  87 + page_string = get_String(fields, "PAGE_MESSAGE", ""),
  88 + page_ttl = get_Int(fields, "PAGE_MESSAGE_TTL", 0),
  89 + step = get_Int(fields, "AWS_SESSION_STEP", 0),
  90 +
  91 + //the page Message is TimeOut. We remove it
  92 + if page_ttl < step then
  93 + remove_Int(fields, "PAGE_MESSAGE_TTL");
  94 + replace_String(fields, "PAGE_STATUS", "NO_MESSAGE");
  95 + replace_String(fields, "PAGE_MESSAGE", "");
  96 + no_message
  97 + else
  98 +
  99 + if page_status = "NO_MESSAGE" then
  100 + no_message
  101 + else if page_status = "PAGE_INFO" then
  102 + info(page_string)
  103 + else if page_status = "PAGE_INFO_T" then
  104 + info(_T(page_string))
  105 + else if page_status = "PAGE_OK" then
  106 + ok(page_string)
  107 + else if page_status = "PAGE_OK_T" then
  108 + ok(_T(page_string))
  109 + else if page_status = "PAGE_WARNING" then
  110 + warning(page_string)
  111 + else if page_status = "PAGE_WARNING_T" then
  112 + warning(_T(page_string))
  113 + else if page_status = "PAGE_ERROR" then
  114 + error(page_string)
  115 + else if page_status = "PAGE_ERROR_T" then
  116 + error(_T(page_string))
  117 + else
  118 + no_message
  119 +.
  120 +
  121 +define List(CoreAttrs)
  122 + get_info_line_attrbs
  123 + (
  124 + String html_class,
  125 + Alignment align
  126 + ) =
  127 + if align is
  128 + {
  129 + left then [class(html_class)],
  130 + center then [class(html_class), style("margin-left: auto; margin-right: auto;")],
  131 + right then [class(html_class), style("margin-left: auto;")]
  132 + }.
  133 +
  134 +public define HTML_Off_Form hide_info_line_btn = div([event(onclick, "this.parentNode.style.display=&quot;none&quot;;"), style("width: 16px; height: 16px; background: transparent url(&quot;"+icn16_cross+"&quot;) no-repeat scroll center center; float: right; display: inline; cursor: pointer;")], literal("")).
  135 +
  136 +public define HTML_In_Form
  137 + display_info_line
  138 + (
  139 + String html_id,
  140 + String html_class,
  141 + String txt,
  142 + Alignment align
  143 + ) =
  144 + div(get_info_line_attrbs(html_class, align), sequence([partial(partial_content(hide_info_line_btn)), partial(partial_content(literal(txt)))])).
  145 +
  146 +public define HTML_Off_Form
  147 + display_info_line
  148 + (
  149 + String html_id,
  150 + String html_class,
  151 + String txt,
  152 + Alignment align
  153 + ) =
  154 + div(get_info_line_attrbs(html_class, align), sequence([hide_info_line_btn, partial(partial_content(literal(txt)))])).
  155 +
  156 +public define HTML_Off_Form
  157 + display_main_info_line
  158 + (
  159 + String html_class,
  160 + String txt,
  161 + Alignment align
  162 + ) =
  163 + display_info_line("informations", html_class, txt, align).
  164 +
  165 +public define HTML_Off_Form
  166 + display_main_info_line
  167 + (
  168 + String html_class,
  169 + String txt
  170 + ) =
  171 + display_info_line("informations", html_class, txt, left).