Merge remote-tracking branch 'origin/staging' into staging

pull/1/head
David Benqué 4 years ago
commit f7d3f7e787

@ -1,7 +1,7 @@
define(['/api/config'], function (ApiConfig) { define(['/api/config'], function (ApiConfig) {
var Module = {}; var Module = {};
var apps = ['code', 'slide', 'pad', 'kanban', 'whiteboard', 'sheet', 'poll', 'teams']; var apps = ['code', 'slide', 'pad', 'kanban', 'whiteboard', 'sheet', 'poll', 'teams', 'form'];
var app = window.location.pathname.slice(1, -1); // remove "/" at the beginnin and the end var app = window.location.pathname.slice(1, -1); // remove "/" at the beginnin and the end
var suffix = apps.indexOf(app) !== -1 ? '-'+app : ''; var suffix = apps.indexOf(app) !== -1 ? '-'+app : '';

@ -531,7 +531,7 @@
} }
} }
} }
.cp-form-sort-hint { .cp-form-sort-hint, .cp-poll-hint {
margin-bottom: 10px; margin-bottom: 10px;
} }
.cp-form-type-sort { .cp-form-type-sort {

@ -905,6 +905,9 @@ define([
icon: h('i.cptools.cptools-form-page-break') icon: h('i.cptools.cptools-form-page-break')
}, },
}; };
Messages.form_poll_hint = "<i></i>: Yes, <i></i>: No, <i></i>: Acceptable"; // XXX
var TYPES = { var TYPES = {
input: { input: {
defaultOpts: { defaultOpts: {
@ -1580,7 +1583,21 @@ define([
var total = makePollTotal(answers, opts, addLine, evOnChange); var total = makePollTotal(answers, opts, addLine, evOnChange);
if (total) { lines.push(h('div', total)); } if (total) { lines.push(h('div', total)); }
var tag = h('div.cp-form-type-poll-container', h('div.cp-form-type-poll', lines)); var pollHint = UI.setHTML(h('div.cp-form-poll-hint'), Messages.form_poll_hint);
var classes = [
'fa fa-check cp-yes',
'fa fa-times cp-no',
'cptools cptools-form-poll-maybe cp-maybe',
];
$(pollHint).find('i').each(function (index) {
this.setAttribute('class', classes[index]);
// XXX accessibility options?
});
var tag = h('div.cp-form-type-poll-container', [
pollHint,
h('div.cp-form-type-poll', lines)
]);
var $tag = $(tag); var $tag = $(tag);
var cursorGetter; var cursorGetter;
@ -1851,6 +1868,7 @@ define([
console.error(err || data.error); console.error(err || data.error);
return void UI.warn(Messages.error); return void UI.warn(Messages.error);
} }
evOnChange.fire(false, true);
window.onbeforeunload = undefined; window.onbeforeunload = undefined;
if (!update) { if (!update) {
// Add results button // Add results button
@ -1930,9 +1948,13 @@ define([
var _answers = Util.clone(answers || {}); var _answers = Util.clone(answers || {});
delete _answers._proof; delete _answers._proof;
delete _answers._userdata; delete _answers._userdata;
evOnChange.reg(function (noBeforeUnload) { evOnChange.reg(function (noBeforeUnload, isSave) {
if (noBeforeUnload) { return; } if (noBeforeUnload) { return; }
var results = getFormResults(); var results = getFormResults();
if (isSave) {
answers = Util.clone(results || {});
_answers = Util.clone(answers);
}
if (!answers || Sortify(_answers) !== Sortify(results)) { if (!answers || Sortify(_answers) !== Sortify(results)) {
window.onbeforeunload = function () { window.onbeforeunload = function () {
return true; return true;
@ -2051,6 +2073,9 @@ define([
h('span.cp-form-block-question-number', (n++)+'.'), h('span.cp-form-block-question-number', (n++)+'.'),
h('span', block.q || Messages.form_default) h('span', block.q || Messages.form_default)
]); ]);
// Static blocks don't have questions ("q" is not used) so we can decrement n
if (isStatic) { n--; }
var editButtons, editContainer; var editButtons, editContainer;
APP.formBlocks.push(data); APP.formBlocks.push(data);

Loading…
Cancel
Save