Improve Poll template for forms

pull/1/head
yflory 3 years ago
parent 26a25e012c
commit 83a1a2a337

@ -649,7 +649,7 @@ define([
if (!AppConfig.enableTemplates) { return; }
if (!common.isLoggedIn()) { return; }
button = $('<button>', {
'class': 'fa fa-bookmark cp-toolbar-icon-template',
'class': 'cptools cptools-new-template cp-toolbar-icon-template',
}).append($('<span>', {'class': 'cp-toolbar-drawer-element'}).text(Messages.saveTemplateButton));
if (data.rt) {
button
@ -2431,15 +2431,16 @@ define([
}
return b.used - a.used;
});
if (!appCfg.noTemplates) {
/*if (!appCfg.noTemplates) {
allData.unshift({
name: Messages.creation_newTemplate,
id: -1,
//icon: h('span.fa.fa-bookmark')
icon: h('span.cptools.cptools-new-template')
});
}
}*/
if (!privateData.newTemplate) {
Messages.creation_noTemplate = "Blank document"; // XXX update key
allData.unshift({
name: Messages.creation_noTemplate,
id: 0,

@ -3420,11 +3420,11 @@ define([
framework.localChange();
}
if (!content.answers || !content.answers.channel || !content.answers.publicKey || !content.answers.validateKey) {
content.answers = {
channel: Hash.createChannelId(),
publicKey: priv.form_public,
validateKey: priv.form_answerValidateKey
};
// Don't override other settings (anonymous, makeAnonymous, etc.) from templates
content.answers = content.answers || {};
content.answers.channel = Hash.createChannelId();
content.answers.publicKey = priv.form_public;
content.answers.validateKey = priv.form_answerValidateKey;
framework.localChange();
}
checkIntegrity();

@ -1,17 +1,40 @@
define([
'/customize/messages.js'
], function (Messages) {
Messages.form_type_poll = "Quick poll"; // XXX update key
var pollValues = [];
var d8 = new Date();
d8.setDate(d8.getDate() - d8.getDay()); // set sunday
d8.setHours(8);
d8.setMinutes(0);
d8.setSeconds(0);
d8.setMilliseconds(0);
var d14 = new Date(d8);
d14.setHours(14);
[0,1,2].forEach(function (el) {
d8.setDate(d8.getDate() + 1);
d14.setDate(d14.getDate() + 1);
pollValues.push(+d8);
pollValues.push(+d14);
});
return [{
id: 'a',
used: 1,
name: Messages.form_type_poll,
content: {
answers: {
anonymous: true,
},
form: {
"1": {
type: 'md'
},
"2": {
type: 'poll'
type: 'poll',
opts: {
type: 'time',
values: pollValues
}
}
},
order: ["1", "2"]

Loading…
Cancel
Save