- Methods: All Methods Documented Methods Hide Methods
- Source: Display Source Hide Source
- Variables: Show Variables Hide Variables
Class ::xowiki::includelet::personal-notification-messages
::xowiki::includelet::personal-notification-messages create ... \
[ -__decoration (default "plain") ] \
[ -parameter_declaration (default " {-url_poll ""} {-url_dismiss ""} {-poll_interval 5000} ") ]
Defined in
Class Relations
::xotcl::Class create ::xowiki::includelet::personal-notification-messages \ -superclass ::xowiki::IncludeletMethods (to be applied on the object)
get_messages_response (scripted, public)
xowiki::includelet::personal-notification-messages get_messages_response \ [ -notification_id notification_id ] [ -user_id user_id ]Get all messages for the notification-id and the give user in form of an AJAX array.
- Switches:
- -notification_id (optional, integer)
- -user_id (optional, integer)
- Testcases:
- No testcase defined.
# # Get messages for this notification_id and user. This function # returns a JSON result. # # TODO: replace inclass_exam with personal_notifications if {[nsv_dict exists inclass_exam $notification_id $user_id]} { set msgs [nsv_dict get inclass_exam $notification_id $user_id] } else { set msgs {} } # # Convert the messages to JSON. The timestamp (ts) is used as an # ID for an individual message. # set json {} foreach {ts msgDict} $msgs { set msg [string map {\" {\"} \n {<br>}} [dict get $msgDict msg]] set from [string map {\" {\"} \n {<br>}} [::xo::get_user_name [dict get $msgDict from]]] set urgency [string map {\" {\"} \n {<br>}} [dict get $msgDict urgency]] lappend json [subst -nobackslash {{"text": "$msg","ts":$ts,"from":"$from","urgency":"$urgency"}}] } return [subst {\[[join $json ,]\]}]message_add (scripted, public)
xowiki::includelet::personal-notification-messages message_add \ [ -notification_id notification_id ] [ -to_user_id to_user_id ] \ -payload payloadSend the user a message. The payload has the form of a dict containing at least "msg" and "from" (in form of a user_id).
- Switches:
- -notification_id (optional, integer)
- -to_user_id (optional, integer)
- -payload (required)
- Testcases:
- No testcase defined.
# # Set the timestamp to [clock microseconds]. It is assumed that we have # at most one message per microsecond to this user. # foreach to_user_id $to_user_id { nsv_dict set inclass_exam $notification_id $to_user_id [clock microseconds] $payload }message_dismiss (scripted, public)
xowiki::includelet::personal-notification-messages message_dismiss \ [ -notification_id notification_id ] [ -user_id user_id ] \ [ -ts ts ]The user has dismissed a message. flush this message from the set of displayed messages.
- Switches:
- -notification_id (optional, integer)
- -user_id (optional, integer)
- -ts (optional, integer)
- Testcases:
- No testcase defined.
nsv_dict unset inclass_exam $notification_id $user_id $tsmodal_message_dialog (scripted, public)
xowiki::includelet::personal-notification-messages modal_message_dialog \ -to_user_id to_user_id [ -title title ] [ -adpicon adpicon ]Create a bootstrap3/5-compatible modal dialog
- Switches:
- -to_user_id (required, integer)
- -title (optional, defaults to
"#xowiki.Send_message_to#"
)- -adpicon (optional, defaults to
"pencil"
)- Testcases:
- No testcase defined.
if {[::template::CSS toolkit] eq "bootstrap5"} { set data_attribute "data-bs" set close_button_label "" set before_close "<h4 class='modal-title' id='configurationModalTitle'>$title</h4>" set after_close "" } else { set data_attribute "data" set close_button_label {<span aria-hidden="true">×</span>} set before_close "" set after_close "<h4 class='modal-title' id='configurationModalTitle'>$title</h4>" } if {[llength $to_user_id] == 1} { set id dialog-msg-$to_user_id set to_user_name [::xo::get_user_name $to_user_id] } else { set id dialog-msg-all set to_user_name " [llength $to_user_id] #xowiki.Participants#" } append title " " $to_user_name foreach to_user_id $to_user_id { append input_fields [subst {<input type="hidden" name="to_user_id" value="$to_user_id">}] } set btnDefault [::template::CSS class btn-default] return [list link [subst { <a href="#$id" title="$title" role="button" $data_attribute-toggle="modal" $data_attribute-keyboard="false"> <adp:icon name="$adpicon" aria-hidden="true"></span> }] dialog [subst { <div class="modal fade" id='$id' tabindex="-1" role="dialog"> <div class="modal-dialog" role="document"> <form role="form" class="form-vertical" method="post" action=""> <div class="modal-content"> <div class="modal-header"> $before_close<adp:button type="button" class="close" data-dismiss="modal" aria-label="Close">$close_button_label </adp:button>$after_close </div><!-- modal-header --> <div class="modal-body"> <div class="form-group"> <label for="msg"><adp:icon name="$adpicon"> #xowiki.Message#</label> <input class="form-control" id="msg" name="msg" placeholder="#xowiki.Enter_message#" required autofocus> </div> <div class="form-group"> #xowiki.Urgency# <label class="radio-inline" for="option1">#xowiki.urgency_low#</label> <input id="option1" name="urgency" value="info" type="radio"> <label class="radio-inline" for="option2">#xowiki.urgency_normal#</label> <input id="option2" name="urgency" value="warning" type="radio" checked> <label class="radio-inline" for="option3">#xowiki.urgency_high#</label> <input id="option3" name="urgency" value="danger" type="radio"> </div> <!--form-group--> $input_fields </div><!--modal-body--> <div class="modal-footer"> <adp:button type="button" class="btn btn-default" data-dismiss="modal">#acs-kernel.common_Close#</adp:button> <adp:button type="submit" class="btn btn-default submit" data-id="$id" data-dismiss="modal">#xowiki.Send#</adp:button> </div> </div> </form> </div><!--modal-dialog--> </div><!--modal--> }]]modal_message_dialog_register_submit (scripted, public)
xowiki::includelet::personal-notification-messages modal_message_dialog_register_submit \ -url urlRegister a submit callback for all bootstrap3 modal dialogs having an .submit class.
- Switches:
- -url (required)
- Testcases:
- create_test_items
template::add_body_script -script [subst { document.querySelectorAll('div.modal form .submit').forEach(function(e) { e.addEventListener('click', function(ev){ ev.preventDefault(); //console.log(ev.target.dataset.id); var form = document.querySelector('#' + ev.target.dataset.id + ' form'); var data = new FormData(form); var xhttp = new XMLHttpRequest(); xhttp.open('POST', '$url', true); xhttp.onload = function () { //console.log(this.responseText); }; xhttp.send(data); });}); }]
- Methods: All Methods Documented Methods Hide Methods
- Source: Display Source Hide Source
- Variables: Show Variables Hide Variables