|
|
@@ -703,10 +703,43 @@ function tblMsgsLoadMoreRows(n) {
|
|
|
</div>
|
|
|
</div>
|
|
|
<?php
|
|
|
- if (V::get('DBG_VIEW', '', $_GET)) $this->_testViewMsg();
|
|
|
+ if (V::get('DBG_VIEW', '', $_GET)) $this->_testViewMsg($msg);
|
|
|
}
|
|
|
|
|
|
public function _testViewMsg($msg) {
|
|
|
+ /* $msg = {_raw: {A_RECORD_CREATE_AUTHOR: "plabudda",
|
|
|
+ A_RECORD_CREATE_DATE: "2015-10-26 12:20:05",
|
|
|
+ A_RECORD_DELETE_AUTHOR: "",
|
|
|
+ A_RECORD_DELETE_DATE: null,
|
|
|
+ A_RECORD_UPDATE_AUTHOR: "plabudda",
|
|
|
+ A_RECORD_UPDATE_DATE: "2015-11-02 12:44:59",
|
|
|
+ A_STATUS: "NORMAL",
|
|
|
+ ID: "67",
|
|
|
+ actionExecutedTime: "2015-11-02 12:44:59",
|
|
|
+ actionNotes: "",
|
|
|
+ app_className: "TableMsgs",
|
|
|
+ msg: "test Y",
|
|
|
+ msgType: "info",
|
|
|
+ uiTargetName: "TEST_PERMS.31",
|
|
|
+ uiTargetType: "default_db_table_record",
|
|
|
+ userTargetName: "plabudda",
|
|
|
+ userTargetType: "user"}
|
|
|
+ _read: true,
|
|
|
+ idRow: "31",
|
|
|
+ message: "test Y",
|
|
|
+ tblName: "TEST_PERMS",
|
|
|
+ type: "info",
|
|
|
+ usrLogin: "plabudda"} */
|
|
|
+ $message = new stdClass();
|
|
|
+ $message->id = $msg['_raw']->ID;
|
|
|
+ $message->idThread = $msg['_raw']->ID;// TODO: ID_THREAD
|
|
|
+ $message->idReplyTo = $msg['_raw']->ID;// TODO: ID_REPLY_TO
|
|
|
+ $message->message = $msg['_raw']->msg;
|
|
|
+ $message->type = $msg['_raw']->msgType;
|
|
|
+ $message->author = $msg['_raw']->A_RECORD_CREATE_AUTHOR;
|
|
|
+ $message->created = $msg['_raw']->A_RECORD_CREATE_DATE;
|
|
|
+ $message->_read = $msg['_read'];
|
|
|
+ $messageList = array($message);
|
|
|
?>
|
|
|
<link rel="stylesheet" href="./stuff/widget-select.css">
|
|
|
<style type="text/css">
|
|
|
@@ -738,8 +771,41 @@ function frmTestSubmit(frm) {
|
|
|
<script src="stuff/vendors.js"></script>
|
|
|
<script src="stuff/bundle.se_route_user_msgs.js"></script>
|
|
|
<script>
|
|
|
- jQuery("#widget-msg-tree").MsgTree({
|
|
|
+ var testNewRecordCounter = 0;
|
|
|
+ jQuery("#widget-msg-tree").MsgThread({
|
|
|
usrLogin: '<?php echo User::getLogin(); ?>',
|
|
|
+ idThread: <?php echo $message->idThread; ?>,
|
|
|
+ msgs: <?php echo json_encode($messageList); ?>,
|
|
|
+ fetchMessages: (function() {
|
|
|
+ var _msgsXhr = null;
|
|
|
+ return function(input, callback) {
|
|
|
+ if (_msgsXhr && _msgsXhr.state() === 'pending') {
|
|
|
+ _msgsXhr.abort();
|
|
|
+ _msgsXhr = null;
|
|
|
+ }
|
|
|
+ _msgsXhr = $.ajax({
|
|
|
+ url: 'index.php?_route=UserMsgs&_task=getMessagesById&id=<?php echo $message->id; ?>',
|
|
|
+ dataType: 'json'
|
|
|
+ });
|
|
|
+ _msgsXhr.done(function(data, textStatus, jqXHR) {
|
|
|
+ if (data && data.length > 0) {
|
|
|
+ var options = [];
|
|
|
+ data.forEach(function(item) {
|
|
|
+ options.push({value: item.id, label: item.name});
|
|
|
+ });
|
|
|
+ callback(null, {options: options});
|
|
|
+ } else {
|
|
|
+ callback(null, {options: []});//"Error no data!");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ _msgsXhr.fail(function() {
|
|
|
+ callback(null, {options: []});//"Error no data!");
|
|
|
+ });
|
|
|
+ _msgsXhr.always(function() {
|
|
|
+ _userXhr = null;
|
|
|
+ });
|
|
|
+ };
|
|
|
+ })(),
|
|
|
fetchOptionsForGroup: (function() {
|
|
|
var _groupXhr = null;
|
|
|
return function(input, callback) {
|
|
|
@@ -799,15 +865,38 @@ function frmTestSubmit(frm) {
|
|
|
_userXhr = null;
|
|
|
});
|
|
|
};
|
|
|
- })()
|
|
|
+ })(),
|
|
|
+ saveReply: function(data, callback) {
|
|
|
+ console.log('#widget-msg-tree/MsgThread::saveReply: data:', data, 'callback', callback);
|
|
|
+ // TODO: send data
|
|
|
+ setTimeout(function() {
|
|
|
+ console.log('#widget-msg-tree/MsgThread::saveReply: after 500ms data:', data, 'callback', callback);
|
|
|
+ var newId = 1000 + (testNewRecordCounter++),
|
|
|
+ newRecord = {
|
|
|
+ id: newId,
|
|
|
+ author: 'test13',
|
|
|
+ created: '2015-10-22 10:36:52',
|
|
|
+ to: 'plabudda',
|
|
|
+ metaInfo: 'do plabudda',
|
|
|
+ message: 'test added newId('+newId+')'
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ //callback(null, {message: 'Nie udało się zapisać wiadomości', type: 'danger'});
|
|
|
+ callback(null, {message: 'Saved', type: 'success', record: newRecord});
|
|
|
+ }, 500);
|
|
|
+ }
|
|
|
});
|
|
|
// jQuery("#widget-msg-tree").on('change', function(e, data) {
|
|
|
-// console.log('#widget-msg-tree/MsgTree::onChange: data:', data);
|
|
|
+// console.log('#widget-msg-tree/MsgThread::onChange: data:', data);
|
|
|
// });
|
|
|
</script>
|
|
|
<?php
|
|
|
}
|
|
|
|
|
|
+ public function getMessagesByIdAction() {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
public function removeMsgAction() {
|
|
|
$idMsg = V::get('id', 0, $_GET, 'int');
|
|
|
$usrLogin = V::get('usrLogin', 0, $_REQUEST, 'word');
|