#1261: Move modified block into its own function for readability

Also avoid the double call to the sanity check as it's already called
upon first loading the page.
This commit is contained in:
Fabrice Mouhartem 2023-11-10 17:11:15 +01:00
parent 5ff4d4893b
commit ef694294ee

View File

@ -4534,13 +4534,8 @@ define([
});
});
// Private / public status
var resultsType = h('div.cp-form-results-type-container');
var resultsStr = h('div');
var $results = $(resultsType);
var refreshPublic = function () {
// Perform sanity check on refresh
// (for instance on template import)
// Perform a sanity check on refresh (for instance on template imports)
var checkAnswersValidity = function() {
if (APP.isEditor) {
if (!content.answers || !content.answers.channel || !content.answers.publicKey || !content.answers.validateKey) {
// Don't override other settings (anonymous, makeAnonymous, etc.) from templates
@ -4552,6 +4547,13 @@ define([
framework.localChange();
}
}
};
// Private / public status
var resultsType = h('div.cp-form-results-type-container');
var resultsStr = h('div');
var $results = $(resultsType);
var refreshPublic = function () {
$results.empty();
var makePublic = h('button.btn.btn-secondary', Messages.form_makePublic);
var makePublicDiv = h('div.cp-form-actions', makePublic);
@ -4882,6 +4884,7 @@ define([
};
refreshColorTheme();
evOnChange.reg(checkAnswersValidity);
evOnChange.reg(refreshPublic);
evOnChange.reg(refreshPrivacy);
evOnChange.reg(refreshAnon);