FEATURE: automatically close a poll on a given date and time

This commit is contained in:
Régis Hanol
2018-05-03 02:12:19 +02:00
parent de6dd2dc02
commit ba14c80b9c
15 changed files with 204 additions and 217 deletions

View File

@ -13,13 +13,11 @@ export default Ember.Controller.extend({
@computed("regularPollType", "numberPollType", "multiplePollType")
pollTypes(regularPollType, numberPollType, multiplePollType) {
let types = [];
types.push({ name: I18n.t("poll.ui_builder.poll_type.regular"), value: regularPollType });
types.push({ name: I18n.t("poll.ui_builder.poll_type.number"), value: numberPollType });
types.push({ name: I18n.t("poll.ui_builder.poll_type.multiple"), value: multiplePollType });
return types;
return [
{ name: I18n.t("poll.ui_builder.poll_type.regular"), value: regularPollType },
{ name: I18n.t("poll.ui_builder.poll_type.number"), value: numberPollType },
{ name: I18n.t("poll.ui_builder.poll_type.multiple"), value: multiplePollType },
];
},
@computed("pollType", "regularPollType")
@ -101,8 +99,8 @@ export default Ember.Controller.extend({
return this._comboboxOptions(1, (parseInt(pollMax) || 1) + 1);
},
@computed("isNumber", "showMinMax", "pollType", "publicPoll", "pollOptions", "pollMin", "pollMax", "pollStep")
pollOutput(isNumber, showMinMax, pollType, publicPoll, pollOptions, pollMin, pollMax, pollStep) {
@computed("isNumber", "showMinMax", "pollType", "publicPoll", "pollOptions", "pollMin", "pollMax", "pollStep", "autoClose", "date", "time")
pollOutput(isNumber, showMinMax, pollType, publicPoll, pollOptions, pollMin, pollMax, pollStep, autoClose, date, time) {
let pollHeader = '[poll';
let output = '';
@ -113,15 +111,15 @@ export default Ember.Controller.extend({
};
let step = pollStep;
if (step < 1) {
step = 1;
}
if (step < 1) { step = 1; }
if (pollType) pollHeader += ` type=${pollType}`;
if (pollMin && showMinMax) pollHeader += ` min=${pollMin}`;
if (pollMax) pollHeader += ` max=${pollMax}`;
if (isNumber) pollHeader += ` step=${step}`;
if (publicPoll) pollHeader += ' public=true';
if (publicPoll) pollHeader += ` public=true`;
if (autoClose) pollHeader += ` close=${moment(date + " " + time, "YYYY-MM-DD HH:mm").toISOString()}`;
pollHeader += ']';
output += `${pollHeader}\n`;
@ -186,7 +184,10 @@ export default Ember.Controller.extend({
pollOptions: '',
pollMin: 1,
pollMax: null,
pollStep: 1
pollStep: 1,
autoClose: false,
date: moment().add(1, "day").format("YYYY-DD-MM"),
time: moment().add(1, "hour").format("HH:mm"),
});
},