From 84a944c7529957f90fc42442bcc5d9879d288654 Mon Sep 17 00:00:00 2001 From: totoro Date: Sat, 29 Apr 2017 09:02:04 +0900 Subject: [PATCH] Add web session "page message" management with which was moved from Ptah ERP --- web/CXM_page_message.anubis | 171 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 171 insertions(+), 0 deletions(-) create mode 100644 web/CXM_page_message.anubis diff --git a/web/CXM_page_message.anubis b/web/CXM_page_message.anubis new file mode 100644 index 0000000..d7caa0a --- /dev/null +++ b/web/CXM_page_message.anubis @@ -0,0 +1,171 @@ +/* + * Created by PyramIDE. + * User: フランスのトトロ aka (David RENÉ) + * Date: 20/02/2017 + * Time: 04:31 + * © Calexium + */ + +read calexium_lib/web/CXM_making_a_web_site.anubis +read calexium_lib/web/widgets/icons_set.anubis + +public type Alignment: + left, + center, + right. + +public type Page_Message: + no_message, + info(String message), + info_translate(String message), + ok(String message), + ok_translate(String message), + warning(String message), + warning_translate(String message), + error(String message, Alignment align), + error_translate(String message, Alignment align). + +public define One + set_Page_Message + ( + Var(List(WEB_Session_Field)) fields, + Page_Message p_message + )= + with step = get_Int(fields, "AWS_SESSION_STEP",0), + replace_Int(fields, "PAGE_MESSAGE_TTL", step+1); + if p_message is + { + no_message then + replace_String(fields, "PAGE_STATUS", "NO_MESSAGE"); + replace_String(fields, "PAGE_MESSAGE", "") + info(msg_str) then + replace_String(fields, "PAGE_STATUS", "PAGE_INFO"); + replace_String(fields, "PAGE_MESSAGE", msg_str) + info_translate(msg_str) then + replace_String(fields, "PAGE_STATUS", "PAGE_INFO_T"); + replace_String(fields, "PAGE_MESSAGE", msg_str) + ok(msg_str) then + replace_String(fields, "PAGE_STATUS", "PAGE_OK"); + replace_String(fields, "PAGE_MESSAGE", msg_str) + ok_translate(msg_str) then + replace_String(fields, "PAGE_STATUS", "PAGE_OK_T"); + replace_String(fields, "PAGE_MESSAGE", msg_str) + warning(msg_str) then + replace_String(fields, "PAGE_STATUS", "PAGE_WARNING"); + replace_String(fields, "PAGE_MESSAGE", msg_str) + warning_translate(msg_str) then + replace_String(fields, "PAGE_STATUS", "PAGE_WARNING_T"); + replace_String(fields, "PAGE_MESSAGE", msg_str) + error(msg_str, align) then + replace_String(fields, "PAGE_STATUS", "PAGE_ERROR"); + replace_String(fields, "PAGE_MESSAGE", msg_str) + error_translate(msg_str, align) then + replace_String(fields, "PAGE_STATUS", "PAGE_ERROR_T"); + replace_String(fields, "PAGE_MESSAGE", msg_str) + } +. + +public define Page_Message + error + ( + String message + ) = error(message, left). + +public define Page_Message + error_translate + ( + String message + ) = error_translate(message, left). + +public define Page_Message + get_Page_Message + ( + Var(List(WEB_Session_Field)) fields, + (String) -> String _T + )= + with page_status = get_String(fields, "PAGE_STATUS", "NO_MESSAGE"), + page_string = get_String(fields, "PAGE_MESSAGE", ""), + page_ttl = get_Int(fields, "PAGE_MESSAGE_TTL", 0), + step = get_Int(fields, "AWS_SESSION_STEP", 0), + + //the page Message is TimeOut. We remove it + if page_ttl < step then + remove_Int(fields, "PAGE_MESSAGE_TTL"); + replace_String(fields, "PAGE_STATUS", "NO_MESSAGE"); + replace_String(fields, "PAGE_MESSAGE", ""); + no_message + else + + if page_status = "NO_MESSAGE" then + no_message + else if page_status = "PAGE_INFO" then + info(page_string) + else if page_status = "PAGE_INFO_T" then + info(_T(page_string)) + else if page_status = "PAGE_OK" then + ok(page_string) + else if page_status = "PAGE_OK_T" then + ok(_T(page_string)) + else if page_status = "PAGE_WARNING" then + warning(page_string) + else if page_status = "PAGE_WARNING_T" then + warning(_T(page_string)) + else if page_status = "PAGE_ERROR" then + error(page_string) + else if page_status = "PAGE_ERROR_T" then + error(_T(page_string)) + else + no_message +. + +define List(CoreAttrs) + get_info_line_attrbs + ( + String html_class, + Alignment align + ) = + if align is + { + left then [class(html_class)], + center then [class(html_class), style("margin-left: auto; margin-right: auto;")], + right then [class(html_class), style("margin-left: auto;")] + }. + +public define HTML_Off_Form hide_info_line_btn = div([event(onclick, "this.parentNode.style.display="none";"), style("width: 16px; height: 16px; background: transparent url(""+icn16_cross+"") no-repeat scroll center center; float: right; display: inline; cursor: pointer;")], literal("")). + +public define HTML_In_Form + display_info_line + ( + String html_id, + String html_class, + String txt, + Alignment align + ) = + div(get_info_line_attrbs(html_class, align), sequence([partial(partial_content(hide_info_line_btn)), partial(partial_content(literal(txt)))])). + +public define HTML_Off_Form + display_info_line + ( + String html_id, + String html_class, + String txt, + Alignment align + ) = + div(get_info_line_attrbs(html_class, align), sequence([hide_info_line_btn, partial(partial_content(literal(txt)))])). + +public define HTML_Off_Form + display_main_info_line + ( + String html_class, + String txt, + Alignment align + ) = + display_info_line("informations", html_class, txt, align). + +public define HTML_Off_Form + display_main_info_line + ( + String html_class, + String txt + ) = + display_info_line("informations", html_class, txt, left). -- libgit2 0.21.4