Ver código fonte

added mark as read in UserMsgs

Piotr Labudda 10 anos atrás
pai
commit
1e578ca72b

+ 50 - 2
SE/se-lib/Route/UserMsgs.php

@@ -737,6 +737,7 @@ function tblMsgsLoadMoreRows(n) {
 		$uiTargetName = $msg['_raw']->uiTargetName;
 		$uiTargetType = $msg['_raw']->uiTargetType;
 		$replyLink = "index.php?_route=UserMsgs&_task=reply&uiTargetName={$uiTargetName}&uiTargetType={$uiTargetType}";
+		$markAsReadLink = "index.php?_route=UserMsgs&_task=markAsRead";
 		$message = $this->_convertMessageToJson($msg['_raw']);
 		if ($message->idThread > 0) {
 			$sqlLimit = 100;
@@ -893,7 +894,31 @@ function tblMsgsLoadMoreRows(n) {
 			.fail(function() {
 				callback(null, {message: 'Nie udało się wysłać wiadomości!', type: 'danger'});
 			});
-		}
+		},
+		markAsRead: function(idMsg, callback) {
+			//console.log('#widget-msg-tree/MsgThread::markAsRead: idMsg:', idMsg);
+			$.ajax({
+				url: '<?php echo $markAsReadLink; ?>&idMsg=' + idMsg,
+				method: 'GET',
+				dataType: 'json'
+			})
+			.done(function(data, textStatus, jqXHR) {
+				var returnData = {message: '', type: 'danger'};
+				if (data && data.record) {
+					returnData.msg = data.msg || 'Oznaczono wiadomość jako odczytaną';
+					returnData.record = data.record;
+					returnData.type = 'success';
+				} else {
+					returnData.msg = data.msg || 'Nie udało się oznaczyć wiadomości jako odczytanej!';
+					returnData.type = 'danger';
+				}
+				callback(null, returnData);
+			})
+			.fail(function() {
+				callback(null, {message: 'Nie udało się oznaczyć wiadomości jako odczytanej!', type: 'danger'});
+			});
+		},
+		dbg: false
 	});
 //	jQuery("#widget-msg-tree").on('change', function(e, data) {
 //		console.log('#widget-msg-tree/MsgThread::onChange: data:', data);
@@ -936,7 +961,11 @@ function tblMsgsLoadMoreRows(n) {
 		$message->toType = $rawMsg->userTargetType;
 		$message->author = $rawMsg->A_RECORD_CREATE_AUTHOR;
 		$message->created = $rawMsg->A_RECORD_CREATE_DATE;
-		$message->_read = false;//TODO: $msg['_read'];
+		$message->_read = ('WAITING' != $rawMsg->A_STATUS);
+		if ($message->_read) {
+			if (!empty($rawMsg->A_RECORD_UPDATE_DATE)) $message->_readDate = $rawMsg->A_RECORD_UPDATE_DATE;
+			if (!empty($rawMsg->A_RECORD_UPDATE_AUTHOR)) $message->_readBy = $rawMsg->A_RECORD_UPDATE_AUTHOR;
+		}
 		return $message;
 	}
 
@@ -986,6 +1015,25 @@ function tblMsgsLoadMoreRows(n) {
 		echo json_encode($response);
 	}
 
+	public function markAsReadAction() {
+		$usrLogin = User::getLogin();
+		try {
+			$idMsg = V::get('idMsg', '', $_GET, 'int');
+			$msg = $this->_getMsg($idMsg, $usrLogin);
+			$this->_markAsRead($msg);
+			$response = new stdClass();
+			//$response->msg = "";
+			$response->type = "success";
+			$msg = $this->_getMsg($idMsg, $usrLogin);
+			$response->record = $this->_convertMessageToJson($msg['_raw']);
+		} catch (Exception $e) {
+			$response = new stdClass();
+			$response->msg = "Wystąpiły błędy: " . $e->getMessage();
+			$response->type = 'danger';
+		}
+		echo json_encode($response);
+	}
+
 	public function _reply($uiTargetType, $uiTargetName, $args) {
 		$ds = DB::getDataSource();
 		$newMsg = array();

Diferenças do arquivo suprimidas por serem muito extensas
+ 0 - 0
SE/stuff/bundle.se_route_user_msgs.js


Diferenças do arquivo suprimidas por serem muito extensas
+ 0 - 0
SE/stuff/vendors.js


Alguns arquivos não foram mostrados porque muitos arquivos mudaram nesse diff