mirror of
				https://github.com/pierre42100/ComunicWeb
				synced 2025-11-03 19:54:14 +00:00 
			
		
		
		
	Block creation of new choices
This commit is contained in:
		@@ -4,6 +4,10 @@
 | 
				
			|||||||
 * @author Pierre HUBERT
 | 
					 * @author Pierre HUBERT
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.txt-center {
 | 
				
			||||||
 | 
					    text-align: center;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * <a> elements
 | 
					 * <a> elements
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -229,6 +229,17 @@ const PostsInterface = {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Prevent new choices from being created
 | 
				
			||||||
 | 
						 * 
 | 
				
			||||||
 | 
						 * @param {number} postID The ID of the target post
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						blockNewSurveyChoices: async function(postID) {
 | 
				
			||||||
 | 
							await api("survey/block_new_choices_creation", {
 | 
				
			||||||
 | 
								postID: postID
 | 
				
			||||||
 | 
							}, true);
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	_registerCount: {},
 | 
						_registerCount: {},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -880,6 +880,33 @@ ComunicWeb.components.posts.ui = {
 | 
				
			|||||||
					}
 | 
										}
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									// If the user is the owner of the survey, offer him to close it
 | 
				
			||||||
 | 
									if(info.data_survey.userID == userID() && info.data_survey.allowNewChoices) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										const link = createElem2({
 | 
				
			||||||
 | 
											appendTo: surveyResponse,
 | 
				
			||||||
 | 
											type: "div",
 | 
				
			||||||
 | 
											class: "a txt-center",
 | 
				
			||||||
 | 
											innerHTML: tr("Block creation of new choices")
 | 
				
			||||||
 | 
										});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										link.addEventListener("click", async () => {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
											try {
 | 
				
			||||||
 | 
												if(!await showConfirmDialog(tr("Do you want to prevent new choices from being created? This can not be reverted!")))
 | 
				
			||||||
 | 
													return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
												await PostsInterface.blockNewSurveyChoices(info.ID);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
												//Reload post
 | 
				
			||||||
 | 
												ComunicWeb.components.posts.actions.reload_post(info.ID, postRoot);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
											} catch(e) {
 | 
				
			||||||
 | 
												notify(tr("Could not block new choices from being created!"), "danger");
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
										});
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user