This is an automated email from the git hooks/post-receive script. New commit to branch feature/component_choice_editor in repository pollen. See https://gitlab.nuiton.org/chorem/pollen.git commit 38c722b57699ee42e4fed86a84339e6b2e4fb7ab Author: Kevin Morin <morin@codelutin.com> Date: Thu Mar 9 16:42:57 2017 +0100 - enrgistrement des choix de type date, datetime et resource - affichage des choix de types resources --- pollen-ui-riot-js/package.json | 1 + pollen-ui-riot-js/src/main/web/js/FetchService.js | 7 +- pollen-ui-riot-js/src/main/web/js/PollForm.js | 85 +++++++++------- .../src/main/web/js/ResourceService.js | 44 +++++++++ .../main/web/tag/components/date-picker.tag.html | 106 +++++++------------- .../main/web/tag/components/time-picker.tag.html | 83 +++++----------- .../src/main/web/tag/poll/Choice.tag.html | 110 +++++++++++++-------- .../src/main/web/tag/poll/CreatePoll.tag.html | 2 +- .../src/main/web/tag/poll/Votes.tag.html | 18 +++- 9 files changed, 246 insertions(+), 210 deletions(-) diff --git a/pollen-ui-riot-js/package.json b/pollen-ui-riot-js/package.json index 6f91f7a..0009670 100644 --- a/pollen-ui-riot-js/package.json +++ b/pollen-ui-riot-js/package.json @@ -38,6 +38,7 @@ "blaze": "^3.2.0", "font-awesome": "4.7.0", "moment": "^2.17.1", + "remarkable": "^1.7.1", "riot": "^3.0.5", "riot-route": "^2.5.0" } diff --git a/pollen-ui-riot-js/src/main/web/js/FetchService.js b/pollen-ui-riot-js/src/main/web/js/FetchService.js index 4ce553c..b7d4589 100644 --- a/pollen-ui-riot-js/src/main/web/js/FetchService.js +++ b/pollen-ui-riot-js/src/main/web/js/FetchService.js @@ -99,15 +99,18 @@ class FetchService { return this.fetch(url, "DELETE", null, body); } - form(url, data) { + form(url, data, doNotStringify) { let formData = null; + console.log(data); if (data) { formData = new FormData(); let keys = Object.keys(data); keys.forEach((key) => { let value = data[key]; - if (typeof value === "object") { + console.log(key); + console.log(value); + if (!doNotStringify && (typeof value === "object")) { formData.set(key, JSON.stringify(value)); } else { formData.set(key, value); diff --git a/pollen-ui-riot-js/src/main/web/js/PollForm.js b/pollen-ui-riot-js/src/main/web/js/PollForm.js index 3b4ea42..cc44013 100644 --- a/pollen-ui-riot-js/src/main/web/js/PollForm.js +++ b/pollen-ui-riot-js/src/main/web/js/PollForm.js @@ -32,7 +32,8 @@ class PollForm { "options", "voters" ]; - this.service = require("./PollService"); + this.pollService = require("./PollService"); + this.resourceService = require("./ResourceService"); this.FormHelper = require("./FormHelper"); this.step = -1; this.isInit = false; @@ -51,7 +52,7 @@ class PollForm { this.choiceType = choiceType; console.info("init form"); - return this.service.empty(this.choiceType).then((poll) => { + return this.pollService.empty(this.choiceType).then((poll) => { this.model = poll; console.info("empty poll"); console.info(this.model); @@ -69,45 +70,63 @@ class PollForm { this.model.participant = []; switch (this.choiceType) { - case "DATE": - this.model.choiceType = "DATE"; - this.choices = [ - new Choice(this.model.choiceType, "2017-01-31T13:45", "Requiem is so powerfull"), - new Choice(this.model.choiceType, "2017-02-01T03:45", "Truit is so nice"), - new Choice(this.model.choiceType, "2017-02-02", "So deep, so dark...") - ]; - break; - - case "IMAGE": - this.model.choiceType = "RESOURCE"; - break; - - default: // "TEXT" - this.model.choiceType = "TEXT"; - this.choices = [ - new Choice(this.model.choiceType, "Mozart", "Requiem is so powerfull"), - new Choice(this.model.choiceType, "Schubert", "Truit is so nice"), - new Choice(this.model.choiceType, "Malher", "So deep, so dark...") - ]; - break; + case "DATE": + this.model.choiceType = "DATE"; + this.choices = [ + new Choice(this.model.choiceType, "2017-01-31T13:45", "Requiem is so powerfull"), + new Choice(this.model.choiceType, "2017-02-01T03:45", "Truit is so nice"), + new Choice(this.model.choiceType, "2017-02-02", "So deep, so dark...") + ]; + break; + + case "IMAGE": + this.model.choiceType = "RESOURCE"; + break; + + default: // "TEXT" + this.model.choiceType = "TEXT"; + this.choices = [ + new Choice(this.model.choiceType, "Mozart", "Requiem is so powerfull"), + new Choice(this.model.choiceType, "Schubert", "Truit is so nice"), + new Choice(this.model.choiceType, "Malher", "So deep, so dark...") + ]; + break; } this.isInit = true; this.step = 0; }); } - create() { + create(success) { console.info("form before create"); console.info(this.form); - return this.service.create(this.model, this.choices).then((result) => { - console.info("Poll created"); - console.info(result); - this.model.id = result.id; - this.model.permission = result.permission; - }).catch((error) => { - console.error("Could not create poll"); - console.error(error); - return Promise.reject(error); + + // if the choice is of type resource, then upload the file and set its id as choice value + let fileUploadPromises = []; + this.choices.forEach((choice, index) => { + if (choice.choiceType === "RESOURCE") { + let promise = new Promise((resolve, reject) => { + this.resourceService.create(choice.choiceValue).then((result) => { + choice.choiceValue = result.id; + resolve(result.id); + }); + }); + fileUploadPromises.push(promise); + } + }); + Promise.all(fileUploadPromises).then(() => { + this.pollService.create(this.model, this.choices).then((result) => { + console.info("Poll created"); + console.info(result); + this.model.id = result.id; + this.model.permission = result.permission; + }) + .then(success) + .catch((error) => { + console.error("Could not create poll"); + console.error(error); + Promise.reject(error); + }); }); } diff --git a/pollen-ui-riot-js/src/main/web/js/ResourceService.js b/pollen-ui-riot-js/src/main/web/js/ResourceService.js new file mode 100644 index 0000000..767a3e3 --- /dev/null +++ b/pollen-ui-riot-js/src/main/web/js/ResourceService.js @@ -0,0 +1,44 @@ +/*- + * #%L + * Pollen :: UI (Riot Js) + * %% + * Copyright (C) 2009 - 2017 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +let singleton = require("./Singleton"); +let FetchService = require("./FetchService"); + +class ResourceService extends FetchService { + + create(resource) { + console.log(resource); + return this.form("/v1/resources", {resource: resource}, true); + } + + getResource(resourceId) { + return this.get("/v1/resources/" + resourceId); + } + + getPreview(resourceId) { + return this.get("/v1/resources/" + resourceId + "/preview"); + } + + delete(resourceId) { + return this.doDelete("/v1/resources/" + resourceId); + } +} + +module.exports = singleton(ResourceService); diff --git a/pollen-ui-riot-js/src/main/web/tag/components/date-picker.tag.html b/pollen-ui-riot-js/src/main/web/tag/components/date-picker.tag.html index 7c2d35a..e16d174 100644 --- a/pollen-ui-riot-js/src/main/web/tag/components/date-picker.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/components/date-picker.tag.html @@ -1,7 +1,7 @@ <date-picker> <input type="date" class="calendar-field" onclick="{open}" value="{opts.date.date.format(format)}" readonly="{!session.dateInputSupported}" /> - <div class="c-calendar c-calendar--higher" if="{opts.date.isvisible && !session.dateInputSupported}"> + <div class="c-calendar c-calendar--higher" if="{opts.date.isVisible && !session.dateInputSupported}"> <button type="button" class="c-calendar__control" disabled="{ opts.date.min && opts.date.min.isSame(opts.date.date, 'year') }" onclick="{ prevYear }">‹</button> <div class="c-calendar__header">{ opts.date.date.format(yearFormat) }</div> <button type="button" class="c-calendar__control" disabled="{ opts.date.max && opts.date.max.isSame(opts.date.date, 'year') }" onclick="{ nextYear }">›</button> @@ -59,11 +59,11 @@ return { date: dateObj, - selected: opts.date.date.isSame(dayDate, "day"), + selected: this.opts.date.date.isSame(dayDate, "day"), today: this.moment().isSame(dayDate, "day"), disabled: ( - opts.date.min && opts.date.min.isAfter(dayDate) || - opts.date.max && opts.date.max.isBefore(dayDate) + this.opts.date.min && this.opts.date.min.isAfter(dayDate) || + this.opts.date.max && this.opts.date.max.isBefore(dayDate) ) }; }; @@ -78,9 +78,9 @@ this.startBuffer = []; this.endBuffer = []; - const begin = this.moment(opts.date.date).startOf("month"); - const daysInMonth = this.moment(opts.date.date).daysInMonth(); - const end = this.moment(opts.date.date).endOf("month"); + const begin = this.moment(this.opts.date.date).startOf("month"); + const daysInMonth = this.moment(this.opts.date.date).daysInMonth(); + const end = this.moment(this.opts.date.date).endOf("month"); for (let i = begin.isoWeekday() - 1; i > 0; i -= 1) { const d = this.moment(begin).subtract(i, "days"); @@ -96,120 +96,84 @@ const d = this.moment(end).add(i - end.isoWeekday(), "days"); this.endBuffer.push(dayObj(d)); } - }; + }; this.on("mount", () => { - if (!opts.date) { - opts.date = {date: this.moment()}; + if (!this.opts.date) { + this.opts.date = {date: this.moment()}; } - if (!opts.date.date) { - opts.date.date = this.moment(); + if (!this.opts.date.date) { + this.opts.date.date = this.moment(); } - opts.date.date = toMoment(opts.date.date); + this.opts.date.date = toMoment(this.opts.date.date); - if (opts.date.min) { - opts.date.min = toMoment(opts.date.min); + if (this.opts.date.min) { + this.opts.date.min = toMoment(this.opts.date.min); - if (opts.date.min.isAfter(this.moment(), "day")) { - opts.date.date = this.moment(opts.date.min); + if (this.opts.date.min.isAfter(this.moment(), "day")) { + this.opts.date.date = this.moment(this.opts.date.min); } } - if (opts.date.max) { - opts.date.max = toMoment(opts.date.max); + if (this.opts.date.max) { + this.opts.date.max = toMoment(this.opts.date.max); - if (opts.date.max.isBefore(this.moment(), "day")) { - opts.date.date = this.moment(opts.date.max); + if (this.opts.date.max.isBefore(this.moment(), "day")) { + this.opts.date.date = this.moment(this.opts.date.max); } } this.on("update", () => { - opts.date.date = toMoment(opts.date.date); + this.opts.date.date = toMoment(this.opts.date.date); buildCalendar(); - positionDropdown(); + this.positionDropdown(this.opts.date.isVisible, ".calendar"); }); document.addEventListener("click", handleClickOutside); this.update(); - }); + }); this.on("unmount", () => { document.removeEventListener("click", handleClickOutside); }); this.open = () => { - opts.date.isvisible = true; + this.opts.date.isVisible = true; this.trigger("open"); }; this.close = () => { - if (opts.date.isvisible) { - opts.date.isvisible = false; + if (this.opts.date.isVisible) { + this.opts.date.isVisible = false; this.trigger("close"); } }; this.select = e => { - opts.date.date = e.item.day.date; - this.trigger('select', opts.date.date); + this.opts.date.date = e.item.day.date; + this.trigger('select', this.opts.date.date); }; this.setToday = () => { - opts.date.date = this.moment(); - this.trigger("select", opts.date.date); + this.opts.date.date = this.moment(); + this.trigger("select", this.opts.date.date); }; this.prevYear = () => { - opts.date.date = opts.date.date.subtract(1, "year"); + this.opts.date.date = this.opts.date.date.subtract(1, "year"); }; this.nextYear = () => { - opts.date.date = opts.date.date.add(1, "year"); + this.opts.date.date = this.opts.date.date.add(1, "year"); }; this.prevMonth = () => { - opts.date.date = opts.date.date.subtract(1, "month"); + this.opts.date.date = this.opts.date.date.subtract(1, "month"); }; this.nextMonth = () => { - opts.date.date = opts.date.date.add(1, "month"); + this.opts.date.date = this.opts.date.date.add(1, "month"); }; - function getWindowDimensions() { - var w = window, - d = document, - e = d.documentElement, - g = d.getElementsByTagName("body")[0], - x = w.innerWidth || e.clientWidth || g.clientWidth, - y = w.innerHeight || e.clientHeight || g.clientHeight; - return { width: x, height: y }; - }; - - const positionDropdown = () => { - const w = getWindowDimensions(); - const m = this.root.querySelector(".calendar"); - if (!m) { - return; - } - if (!opts.date.isvisible) { - // Reset position - m.style.marginTop = ""; - m.style.marginLeft = ""; - return; - } - const pos = m.getBoundingClientRect(); - if (w.width < pos.left + pos.width) { - // menu is off the right hand of the page - m.style.marginLeft = (w.width - (pos.left + pos.width) - 20) + "px"; - } - if (pos.left < 0) { - // menu is off the right hand of the page - m.style.marginLeft = "20px"; - } - if (w.height < pos.top + pos.height) { - // Popup is off the bottom of the page - m.style.marginTop = (w.height - (pos.top + pos.height) - 20) + "px"; - } - }; </script> <style scoped> diff --git a/pollen-ui-riot-js/src/main/web/tag/components/time-picker.tag.html b/pollen-ui-riot-js/src/main/web/tag/components/time-picker.tag.html index 8c9f9d1..188b84c 100644 --- a/pollen-ui-riot-js/src/main/web/tag/components/time-picker.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/components/time-picker.tag.html @@ -1,7 +1,7 @@ <time-picker> - <input type="time" class="calendar-field" onclick="{open}" value="{opts.time.time.format('HH:mm')}" readonly="{!session.timeInputSupported}" /> + <input type="time" class="calendar-field" onclick="{open}" value="{opts.time.time.format('LT')}" readonly="{!session.timeInputSupported}" /> - <div class="c-calendar c-calendar--higher" if="{opts.time.isvisible && !session.timeInputSupported}"> + <div class="c-calendar c-calendar--higher" if="{opts.time.isVisible && !session.timeInputSupported}"> <div class="time"> <div class="prev action-prev" onclick={nextHour}></div> @@ -20,12 +20,11 @@ </div> <script type="es6"> - let session = require("../../js/Session"); - + this.session = require("../../js/Session"); this.moment = require("moment"); - this.moment.locale(session.locale); + this.moment.locale(this.session.locale); - this.installBundle(session, "time-picker", locale => { + this.installBundle(this.session, "time-picker", locale => { this.opts.time.time.locale(locale); this.moment.locale(locale); }); @@ -48,89 +47,57 @@ }; this.on("mount", () => { - if (!opts.time) { - opts.time = {time: this.moment()}; + if (!this.opts.time) { + this.opts.time = {time: this.moment()}; } - if (!opts.time.time) { - opts.time.time = this.moment(); + if (!this.opts.time.time) { + this.opts.time.time = this.moment(); } - opts.time.time = toMoment(opts.time); + this.opts.time.time = toMoment(this.opts.time.time); + this.on("update", () => { + this.opts.time.time = toMoment(this.opts.time.time); + this.positionDropdown(this.opts.time.isVisible, ".calendar"); + }); document.addEventListener("click", handleClickOutside); - }); + this.update(); + }); this.on("unmount", () => { document.removeEventListener("click", handleClickOutside); }); this.open = () => { - opts.time.isvisible = true; + this.opts.time.isVisible = true; this.trigger("open"); }; this.close = () => { - if (opts.time.isvisible) { - opts.time.isvisible = false; + if (this.opts.time.isVisible) { + this.opts.time.isVisible = false; this.trigger("close"); } }; this.select = e => { - opts.time.time = e.item.day.date; - this.trigger('select', opts.time.time); + this.opts.time.time = e.item.day.date; + this.trigger("select", this.opts.time.time); }; this.prevHour = () => { - opts.time.time = opts.time.time.subtract(1, "hour"); + this.opts.time.time = this.opts.time.time.subtract(1, "hour"); }; this.nextHour = () => { - opts.time.time = opts.time.time.add(1, "hour"); + this.opts.time.time = this.opts.time.time.add(1, "hour"); }; this.prevMinute = () => { - opts.time.time = opts.time.time.subtract(1, "minute"); + this.opts.time.time = this.opts.time.time.subtract(1, "minute"); }; this.nextMinute = () => { - opts.time.time = opts.time.time.add(1, "minute"); - }; - - function getWindowDimensions() { - var w = window, - d = document, - e = d.documentElement, - g = d.getElementsByTagName("body")[0], - x = w.innerWidth || e.clientWidth || g.clientWidth, - y = w.innerHeight || e.clientHeight || g.clientHeight; - return { width: x, height: y }; - }; - - const positionDropdown = () => { - const w = getWindowDimensions(); - const m = this.root.querySelector(".calendar"); - if (!m) { - return; - } - if (!opts.time.isvisible) { - // Reset position - m.style.marginTop = ""; - m.style.marginLeft = ""; - return; - } - const pos = m.getBoundingClientRect(); - if (w.width < pos.left + pos.width) { - // menu is off the right hand of the page - m.style.marginLeft = (w.width - (pos.left + pos.width) - 20) + "px"; - } - if (pos.left < 0) { - // menu is off the right hand of the page - m.style.marginLeft = "20px"; - } - if (w.height < pos.top + pos.height) { - // Popup is off the bottom of the page - m.style.marginTop = (w.height - (pos.top + pos.height) - 20) + "px"; - } + this.opts.time.time = this.opts.time.time.add(1, "minute"); }; </script> diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/Choice.tag.html b/pollen-ui-riot-js/src/main/web/tag/poll/Choice.tag.html index 22a40b1..ac65191 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/Choice.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/poll/Choice.tag.html @@ -3,18 +3,24 @@ require("../components/time-picker.tag.html"); <Choice> <div class="choice-container"> <button type="button" class="c-button fa fa-pencil" alt="texte" onclick="{setTextType}"/> - <input type="text" ref="choiceText" class="{choiceType === 'TEXT' ? 'selected' : 'hidden'}" value="{choiceType === 'TEXT' ? choice.choiceValue : null}"/> + <input type="text" ref="choiceText" class="{choice.choiceType === 'TEXT' ? 'selected' : 'hidden'}" value="{this.opts.choice.choiceType === 'TEXT' ? this.opts.choice.choiceValue : null}"/> - <button type="button" class="c-button fa fa-image" alt="image" onclick="{setImageType}"/> - <input type="file" ref="choiceImage" class="{choiceType === 'RESOURCE' ? 'selected' : 'hidden'}"/> + <button type="button" class="c-button fa fa-image" alt="resource" onclick="{setImageType}"/> + <span if="{originalFile}" class="original-file {choice.choiceType === 'RESOURCE' ? 'selected' : 'hidden'}"> + <span>{originalFile.name}</span><i class="fa fa-remove" onclick="{deleteFile}"/> + </span> + <input type="file" ref="choiceResource" class="{choice.choiceType === 'RESOURCE' ? 'selected' : 'hidden'}" if="{!originalFile}"/> <button type="button" class="c-button fa fa-calendar" alt="date" onclick="{setDateType}"/> - <date-picker ref="choiceDate" class="{choiceType.startsWith('DATE') ? 'selected' : 'hidden'}" date="{date}"/> + <date-picker ref="choiceDate" class="{choice.choiceType.startsWith('DATE') ? 'selected' : 'hidden'}" date="{date}"/> - <button type="button" class="c-button fa fa-clock-o {!choiceType.startsWith('DATE') ? 'hidden' : ''}" alt="heure" onclick="{toggleTime}"/> - <time-picker ref="choiceTime" class="{choiceType === 'DATETIME' ? 'selected' : 'hidden'}" time="{time}"/> + <button type="button" class="c-button fa fa-clock-o {!choice.choiceType.startsWith('DATE') ? 'hidden' : ''}" alt="heure" onclick="{toggleTime}"/> + <time-picker ref="choiceTime" class="{choice.choiceType === 'DATETIME' ? 'selected' : 'hidden'}" time="{time}"/> - <input type="hidden" ref="description" value="{choice.description}"/> + <button type="button" class="c-button" alt="description" onclick="{toggleDescription}">...</button> + </div> + <div if="{showDescription}"> + <textarea ref="description" placeholder="{__.description_placeholder}" value="{choice.description}"/> </div> <script type="es6"> @@ -28,79 +34,89 @@ require("../components/time-picker.tag.html"); }); this.number = parseInt(this.opts.number, 10); - this.mode = this.opts.mode; - this.edit = this.opts.mode === "create" || this.opts.mode === "edit"; + //this.mode = this.opts.mode; + //this.edit = this.opts.mode === "create" || this.opts.mode === "edit"; + this.originalFile = this.opts.choice.choiceType === 'RESOURCE' ? this.opts.choice.choiceValue : null; + this.showDescription = false; - if (this.opts.choiceType) { - this.choiceType = this.opts.choiceType; - } else { - this.choiceType = "TEXT"; - } Object.assign(this.choice = {}, this.opts.choice); - if (this.choiceType === "DATE") { + if (this.choice.choiceType.startsWith("DATE")) { this.date = { - date: moment(this.opts.choice.choiceValue) - }; - this.time = { - time: moment() - }; - } else if (this.choiceType === "DATETIME") { - this.time = { - time: moment(this.opts.choice.choiceValue) - }; - this.date = { - date: moment() + date: moment(parseInt(this.opts.choice.choiceValue, 10)) }; } else { this.date = { - date: moment() + date: moment().startOf('day') + }; + } + + if (this.choice.choiceType === "DATETIME") { + this.time = { + time: moment(parseInt(this.opts.choice.choiceValue, 10)) }; + } else { this.time = { - time: moment() + time: moment().startOf('day') }; } - this.on("mount", () => { + /*this.on("mount", () => { if (this.number === 0 || this.mode === "edit") { //this.refs.choice.required = "required"; } if (this.mode === "edit") { //this.refs.edit_choice.classList.add("choice-view"); } - }); + });*/ this.setTextType = () => { - this.choiceType = "TEXT"; + this.choice.choiceType = "TEXT"; }; this.setImageType = () => { - this.choiceType = "RESOURCE"; + this.choice.choiceType = "RESOURCE"; }; this.setDateType = () => { - if (!this.choiceType.startsWith("DATE")) { - this.choiceType = "DATE"; + if (!this.choice.choiceType.startsWith("DATE")) { + this.choice.choiceType = "DATE"; } }; this.toggleTime = () => { - if (this.choiceType === "DATE") { - this.choiceType = "DATETIME"; - } else if (this.choiceType === "DATETIME") { - this.choiceType = "DATE"; + if (this.choice.choiceType === "DATE") { + this.choice.choiceType = "DATETIME"; + } else if (this.choice.choiceType === "DATETIME") { + this.choice.choiceType = "DATE"; } }; + this.deleteFile = () => { + delete this.originalFile; + }; + + this.toggleDescription = () => { + this.showDescription = !this.showDescription; + }; + this.getValue = () => { let choiceValue = {}; - if (this.choiceType === "TEXT") { - console.log("TEXT"); + if (this.choice.choiceType === "RESOURCE") { + choiceValue = this.originalFile ? this.originalFile : this.refs.choiceResource.files[0]; + + } else if (this.choice.choiceType.startsWith("DATE")) { + let selectedMoment = this.date.date; + if (this.choice.choiceType === "DATETIME") { + selectedMoment.set({hour: this.time.time.hour(), minute: this.time.time.minute()}); + } + choiceValue = selectedMoment.valueOf(); + + } else { choiceValue = this.refs.choiceText.value; - } else if (this.choiceType.startsWith("DATE")) { - choiceValue = this.refs.choiceDate.value; } console.log(choiceValue); - return new Choice(this.choiceType, choiceValue, this.refs.description.value, this.choice.id); + console.log(this.refs.description) + return new Choice(this.choice.choiceType, choiceValue, this.refs.description && this.refs.description.value, this.choice.id); }; /*this.onEditChoice = () => { @@ -189,6 +205,14 @@ require("../components/time-picker.tag.html"); max-width: 100px; } + .original-file.selected * { + padding: 10px; + } + + textarea { + width: 100%; + } + </style> </Choice> diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/CreatePoll.tag.html b/pollen-ui-riot-js/src/main/web/tag/poll/CreatePoll.tag.html index fd4e53d..26f4e86 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/CreatePoll.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/poll/CreatePoll.tag.html @@ -106,7 +106,7 @@ require("./Created.tag.html"); if (this.form.step !== this.form.steps.length - 1) { this.form.nextStep(); } else { - this.form.create().then(() => { + this.form.create(() => { let route = require("riot-route"); route("poll/" + this.form.model.id + "/vote/" + this.form.model.permission); }); diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/Votes.tag.html b/pollen-ui-riot-js/src/main/web/tag/poll/Votes.tag.html index 1e615aa..bdd817b 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/Votes.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/poll/Votes.tag.html @@ -24,8 +24,7 @@ </div> </div> <div each={choice in poll.choices} class="choice"> - <div class="choice-value"> - {choice.choiceValue} + <div id="{choice.id}" class="choice-value"> </div> <div class="current-choice"> <input if={poll.voteCountingTypeValue.renderType==='checkbox'} @@ -133,6 +132,9 @@ <script type="es6"> this.loaded = false; let session = require("../../js/Session"); + let Remarkable = require("remarkable"); + this.md = new Remarkable(); + this.installBundle(session, "poll_votes"); session.getUser().then(user => { this.userName = user && user.name; @@ -149,6 +151,18 @@ }).then(() => { this.loaded = true; this.update(); + this.choices.forEach(c => { + if (c.choiceType === "DATE") { + c.choiceValueStr = moment(parseInt(c.choiceValue, 10)).format("LL"); + } else if (c.choiceType === "DATETIME") { + c.choiceValueStr = moment(parseInt(c.choiceValue, 10)).format("LLL"); + } else if (c.choiceType === "RESOURCE") { + c.choiceValueStr = ""; + } else { + c.choiceValueStr = c.choiceValue; + } + document.getElementById(c.id).innerHTML = this.md.render(c.choiceValueStr); + }); }); this.voteId = null; -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.