mirror of
				https://github.com/pierre42100/ComunicWeb
				synced 2025-11-04 04:04:20 +00:00 
			
		
		
		
	Can reload a single comment
This commit is contained in:
		@@ -717,6 +717,13 @@ var ComunicWeb = {
 | 
				
			|||||||
				//TODO : implement
 | 
									//TODO : implement
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								/**
 | 
				
			||||||
 | 
								 * Comment actions
 | 
				
			||||||
 | 
								 */
 | 
				
			||||||
 | 
								actions: {
 | 
				
			||||||
 | 
									//TODO : implement
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			/**
 | 
								/**
 | 
				
			||||||
			 * Comments interface
 | 
								 * Comments interface
 | 
				
			||||||
			 */
 | 
								 */
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										40
									
								
								assets/js/components/comments/actions.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								assets/js/components/comments/actions.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,40 @@
 | 
				
			|||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Comments actions
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * @author Pierre HUBERT
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					ComunicWeb.components.comments.actions = {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Reload a single comment
 | 
				
			||||||
 | 
						 * 
 | 
				
			||||||
 | 
						 * @param {number} commentID The ID of the comment to reload
 | 
				
			||||||
 | 
						 * @param {HTMLElement} target The target of the reloaded comment
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						reload: function(commentID, target){
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							//Hide the comment to reload
 | 
				
			||||||
 | 
							target.style.visibility = "hidden";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							//Get informations about the comment on the API server
 | 
				
			||||||
 | 
							ComunicWeb.components.comments.interface.get_single(commentID, function(result){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								//Display again the comment to update
 | 
				
			||||||
 | 
								target.style.visibility = "visible";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								//Check for errors
 | 
				
			||||||
 | 
								if(result.error){
 | 
				
			||||||
 | 
									ComunicWeb.common.notificationSystem.showNotification("Couldn't get informations about a comment !", "danger");
 | 
				
			||||||
 | 
									return;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								//Apply new informations about the comment
 | 
				
			||||||
 | 
								//Display new comment informations
 | 
				
			||||||
 | 
								ComunicWeb.components.comments.ui.display_comment(result, target);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
@@ -31,7 +31,8 @@ ComunicWeb.components.comments.editor = {
 | 
				
			|||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				//Else perform next actions
 | 
									//Else perform next actions
 | 
				
			||||||
				
 | 
									//Reload the comment
 | 
				
			||||||
 | 
									ComunicWeb.components.comments.actions.reload(infos.ID, root);
 | 
				
			||||||
			});
 | 
								});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -57,6 +57,30 @@ ComunicWeb.components.comments.ui = {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Display a single comment
 | 
				
			||||||
 | 
						 * 
 | 
				
			||||||
 | 
						 * @param {Object} infos Informations about the comment to display
 | 
				
			||||||
 | 
						 * @param {HTMLElement} target The target for the comment
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						display_comment: function(infos, target){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							//Get informations about the user
 | 
				
			||||||
 | 
							ComunicWeb.user.userInfos.getUserInfos(infos.userID, function(result){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								//Check for errors
 | 
				
			||||||
 | 
								if(result.error){
 | 
				
			||||||
 | 
									ComunicWeb.common.notificationSystem.showNotification("Couldn't get informations about a user!", "danger");
 | 
				
			||||||
 | 
									return;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								//Display the comment
 | 
				
			||||||
 | 
								ComunicWeb.components.comments.ui._show_comment(infos, result, target);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * Show a comment
 | 
						 * Show a comment
 | 
				
			||||||
	 * 
 | 
						 * 
 | 
				
			||||||
@@ -66,12 +90,23 @@ ComunicWeb.components.comments.ui = {
 | 
				
			|||||||
	 */
 | 
						 */
 | 
				
			||||||
	_show_comment: function(infos, user, target){
 | 
						_show_comment: function(infos, user, target){
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		//Create comment contener
 | 
							//Create comment contener (if required)
 | 
				
			||||||
		var commentContener = createElem2({
 | 
							if(target.className != "box-comment"){
 | 
				
			||||||
			appendTo: target,
 | 
					
 | 
				
			||||||
			type: "div",
 | 
								var commentContener = createElem2({
 | 
				
			||||||
			class: "box-comment"
 | 
									appendTo: target,
 | 
				
			||||||
		});
 | 
									type: "div",
 | 
				
			||||||
 | 
									class: "box-comment"
 | 
				
			||||||
 | 
								});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							//Empty comment contener
 | 
				
			||||||
 | 
							else {
 | 
				
			||||||
 | 
								emptyElem(target);
 | 
				
			||||||
 | 
								var commentContener = target;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		//Add user image
 | 
							//Add user image
 | 
				
			||||||
		createElem2({
 | 
							createElem2({
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -232,6 +232,7 @@ class Dev {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			//Comments component
 | 
								//Comments component
 | 
				
			||||||
			"js/components/comments/ui.js",
 | 
								"js/components/comments/ui.js",
 | 
				
			||||||
 | 
								"js/components/comments/actions.js",
 | 
				
			||||||
			"js/components/comments/interface.js",
 | 
								"js/components/comments/interface.js",
 | 
				
			||||||
			"js/components/comments/editor.js",
 | 
								"js/components/comments/editor.js",
 | 
				
			||||||
			"js/components/comments/utils.js",
 | 
								"js/components/comments/utils.js",
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user