Tell users when a form has already been submitted

pull/1/head
yflory 3 years ago
parent f537d8f658
commit 7bbe9059a1

@ -1388,6 +1388,10 @@ define([
$el.prop('checked', true);
}
});
var selected = $tag.find('input:checked').length;
if (selected >= opts.max) {
$tag.find('input:not(:checked)').attr('disabled', 'disabled');
}
}
};
@ -2671,14 +2675,22 @@ define([
return;
}
// If the form is already submitted, show an info message
Messages.form_alreadyAnswered = "You've submitted answers to this form on {0}"; // XXX
if (answers) {
$container.prepend(h('div.alert.alert-info',
Messages._getKey('form_alreadyAnswered', [
new Date(answers._time).toLocaleString()])));
// XXX make the page read-only?
}
// In view mode, add "Submit" and "reset" buttons
$container.append(makeFormControls(framework, content, Boolean(answers), evOnChange));
// Embed mode is enforced so we add the title at the top and a CryptPad logo
// at the bottom
var title = framework._.title.title || framework._.title.defaultTitle;
$container.prepend(h('h1.cp-form-view-title', title));
$container.append(makeFormControls(framework, content, Boolean(answers), evOnChange));
var logo = h('div.cp-form-view-logo', [
h('img', {
src:'/customize/CryptPad_logo_grey.svg?'+ApiConfig.requireConf.urlArgs,
@ -2690,6 +2702,7 @@ define([
framework._.sfCommon.gotoURL('/drive/');
});
$container.append(logo);
if (!answers) {
$container.find('.cp-reset-button').attr('disabled', 'disabled');
}
@ -3156,7 +3169,7 @@ define([
}
// If the results are public and there is at least one doodle, fetch the results now
if (content.answers.privateKey && Object.keys(content.form).some(function (uid) {
if (0 && content.answers.privateKey && Object.keys(content.form).some(function (uid) {
return content.form[uid].type === "poll";
})) {
sframeChan.query("Q_FORM_FETCH_ANSWERS", {
@ -3186,6 +3199,7 @@ define([
var myAnswersObj = answers[curve1] || answers[curve2] || undefined;
if (myAnswersObj) {
myAnswers = myAnswersObj.msg;
myAnswers._time = myAnswersObj.time;
}
}
// If we have a non-anon answer, we can't answer anonymously later

@ -272,8 +272,10 @@ define([
my_private: Nacl.util.decodeBase64(myKeys.curvePrivate),
their_public: Nacl.util.decodeBase64(data.publicKey)
});
res.content._isAnon = answer.anonymous;
cb(JSON.parse(res.content));
var parsed = JSON.parse(res.content);
parsed._isAnon = answer.anonymous;
parsed._time = messages[0].time;
cb(parsed);
});
});

Loading…
Cancel
Save