Fix poll forms issues

pull/1/head
yflory 4 years ago
parent 6694d9df03
commit ee67035015

@ -241,6 +241,8 @@ define([
input.value = ""; input.value = "";
} }
v.type = val;
if (input._flatpickr) { if (input._flatpickr) {
input._flatpickr.destroy(); input._flatpickr.destroy();
delete input._flatpickr; delete input._flatpickr;
@ -263,6 +265,7 @@ define([
// "Add option" button handler // "Add option" button handler
$add = $(add).click(function () { $add = $(add).click(function () {
var txt = v.type ? '' : Messages.form_newOption;
$add.before(getOption(Messages.form_newOption, false)); $add.before(getOption(Messages.form_newOption, false));
var l = $container.find('input').length; var l = $container.find('input').length;
$(maxInput).attr('max', l); $(maxInput).attr('max', l);
@ -891,7 +894,6 @@ define([
var lines = makePollTable(answers, opts); var lines = makePollTable(answers, opts);
// Add form // Add form
// XXX only if not already answered!
var addLine = opts.values.map(function (data) { var addLine = opts.values.map(function (data) {
var cell = h('div.cp-poll-cell.cp-form-poll-choice', [ var cell = h('div.cp-poll-cell.cp-form-poll-choice', [
h('i.fa.fa-times.cp-no'), h('i.fa.fa-times.cp-no'),
@ -913,7 +915,7 @@ define([
return cell; return cell;
}); });
// Name input // Name input
var nameInput = h('input', { value: username }); var nameInput = h('input', { value: username || '' });
addLine.unshift(h('div.cp-poll-cell', nameInput)); addLine.unshift(h('div.cp-poll-cell', nameInput));
// XXX Submit button here? // XXX Submit button here?
lines.push(h('div', addLine)); lines.push(h('div', addLine));

Loading…
Cancel
Save