mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-12-24 18:08:50 +00:00
Block creation of new choices
This commit is contained in:
parent
9777a2a370
commit
237b40afab
@ -4,6 +4,10 @@
|
||||
* @author Pierre HUBERT
|
||||
*/
|
||||
|
||||
.txt-center {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/**
|
||||
* <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: {},
|
||||
|
||||
/**
|
||||
|
@ -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");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user