branch feature/pollen-riot-js updated (69819a2 -> 2dd6e4e)
This is an automated email from the git hooks/post-receive script. New change to branch feature/pollen-riot-js in repository pollen. See https://gitlab.nuiton.org/chorem/pollen.git from 69819a2 Renommage de tags + gestion des participants à un sondage new 2dd6e4e mise en place du linter pour le js et les tag riot et correction de ces fichiers The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 2dd6e4e171e6ceb15224ccd97c2114413dfc2761 Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Fri Feb 24 09:49:02 2017 +0100 mise en place du linter pour le js et les tag riot et correction de ces fichiers Summary of changes: .../org/chorem/pollen/services/bean/PollBean.java | 2 +- pollen-ui-riot-js/.eslintrc | 265 +++++++++++++++++++++ pollen-ui-riot-js/package.json | 4 +- pollen-ui-riot-js/pom.xml | 2 +- pollen-ui-riot-js/src/main/js/riotjs-loader.js | 40 ++-- pollen-ui-riot-js/src/main/web/js/AuthService.js | 4 +- pollen-ui-riot-js/src/main/web/js/Choice.js | 4 +- pollen-ui-riot-js/src/main/web/js/FetchService.js | 8 +- pollen-ui-riot-js/src/main/web/js/FormHelper.js | 18 +- pollen-ui-riot-js/src/main/web/js/I18nHelper.js | 10 +- pollen-ui-riot-js/src/main/web/js/Pagination.js | 2 +- pollen-ui-riot-js/src/main/web/js/PollForm.js | 97 ++++---- pollen-ui-riot-js/src/main/web/js/PollService.js | 10 +- pollen-ui-riot-js/src/main/web/js/Session.js | 16 +- pollen-ui-riot-js/src/main/web/js/Singleton.js | 4 +- .../src/main/web/js/VoteCountingTypeService.js | 6 +- pollen-ui-riot-js/src/main/web/tag/Footer.tag | 3 +- pollen-ui-riot-js/src/main/web/tag/Header.tag | 3 +- pollen-ui-riot-js/src/main/web/tag/HeaderI18n.tag | 14 +- pollen-ui-riot-js/src/main/web/tag/Home.tag | 8 +- pollen-ui-riot-js/src/main/web/tag/Pagination.tag | 40 ++-- pollen-ui-riot-js/src/main/web/tag/Pollen.tag | 30 +-- pollen-ui-riot-js/src/main/web/tag/SignCheck.tag | 8 +- pollen-ui-riot-js/src/main/web/tag/SignIn.tag | 14 +- pollen-ui-riot-js/src/main/web/tag/SignUp.tag | 10 +- pollen-ui-riot-js/src/main/web/tag/Users.tag | 79 +++--- .../src/main/web/tag/poll/ChoiceDate.tag | 58 ++--- .../src/main/web/tag/poll/ChoiceText.tag | 36 +-- .../src/main/web/tag/poll/Choices.tag | 160 ++++++------- .../src/main/web/tag/poll/CommentPopup.tag | 10 +- .../src/main/web/tag/poll/Comments.tag | 88 +++---- .../src/main/web/tag/poll/CreatePoll.tag | 30 +-- .../src/main/web/tag/poll/Created.tag | 10 +- .../src/main/web/tag/poll/Description.tag | 15 +- pollen-ui-riot-js/src/main/web/tag/poll/Poll.tag | 59 +++-- pollen-ui-riot-js/src/main/web/tag/poll/Polls.tag | 66 ++--- .../src/main/web/tag/poll/Results.tag | 42 ++-- .../src/main/web/tag/poll/Settings.tag | 84 +++---- pollen-ui-riot-js/src/main/web/tag/poll/Voters.tag | 52 ++-- pollen-ui-riot-js/src/main/web/tag/poll/Votes.tag | 129 +++++----- .../src/main/web/tag/popup/AccountCreated.tag | 6 +- .../src/main/web/tag/popup/NewPassword.tag | 8 +- .../src/main/web/tag/popup/ResendValidation.tag | 8 +- 43 files changed, 918 insertions(+), 644 deletions(-) create mode 100644 pollen-ui-riot-js/.eslintrc -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/pollen-riot-js in repository pollen. See https://gitlab.nuiton.org/chorem/pollen.git commit 2dd6e4e171e6ceb15224ccd97c2114413dfc2761 Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Fri Feb 24 09:49:02 2017 +0100 mise en place du linter pour le js et les tag riot et correction de ces fichiers --- .../org/chorem/pollen/services/bean/PollBean.java | 2 +- pollen-ui-riot-js/.eslintrc | 265 +++++++++++++++++++++ pollen-ui-riot-js/package.json | 4 +- pollen-ui-riot-js/pom.xml | 2 +- pollen-ui-riot-js/src/main/js/riotjs-loader.js | 40 ++-- pollen-ui-riot-js/src/main/web/js/AuthService.js | 4 +- pollen-ui-riot-js/src/main/web/js/Choice.js | 4 +- pollen-ui-riot-js/src/main/web/js/FetchService.js | 8 +- pollen-ui-riot-js/src/main/web/js/FormHelper.js | 18 +- pollen-ui-riot-js/src/main/web/js/I18nHelper.js | 10 +- pollen-ui-riot-js/src/main/web/js/Pagination.js | 2 +- pollen-ui-riot-js/src/main/web/js/PollForm.js | 97 ++++---- pollen-ui-riot-js/src/main/web/js/PollService.js | 10 +- pollen-ui-riot-js/src/main/web/js/Session.js | 16 +- pollen-ui-riot-js/src/main/web/js/Singleton.js | 4 +- .../src/main/web/js/VoteCountingTypeService.js | 6 +- pollen-ui-riot-js/src/main/web/tag/Footer.tag | 3 +- pollen-ui-riot-js/src/main/web/tag/Header.tag | 3 +- pollen-ui-riot-js/src/main/web/tag/HeaderI18n.tag | 14 +- pollen-ui-riot-js/src/main/web/tag/Home.tag | 8 +- pollen-ui-riot-js/src/main/web/tag/Pagination.tag | 40 ++-- pollen-ui-riot-js/src/main/web/tag/Pollen.tag | 30 +-- pollen-ui-riot-js/src/main/web/tag/SignCheck.tag | 8 +- pollen-ui-riot-js/src/main/web/tag/SignIn.tag | 14 +- pollen-ui-riot-js/src/main/web/tag/SignUp.tag | 10 +- pollen-ui-riot-js/src/main/web/tag/Users.tag | 79 +++--- .../src/main/web/tag/poll/ChoiceDate.tag | 58 ++--- .../src/main/web/tag/poll/ChoiceText.tag | 36 +-- .../src/main/web/tag/poll/Choices.tag | 160 ++++++------- .../src/main/web/tag/poll/CommentPopup.tag | 10 +- .../src/main/web/tag/poll/Comments.tag | 88 +++---- .../src/main/web/tag/poll/CreatePoll.tag | 30 +-- .../src/main/web/tag/poll/Created.tag | 10 +- .../src/main/web/tag/poll/Description.tag | 15 +- pollen-ui-riot-js/src/main/web/tag/poll/Poll.tag | 59 +++-- pollen-ui-riot-js/src/main/web/tag/poll/Polls.tag | 66 ++--- .../src/main/web/tag/poll/Results.tag | 42 ++-- .../src/main/web/tag/poll/Settings.tag | 84 +++---- pollen-ui-riot-js/src/main/web/tag/poll/Voters.tag | 52 ++-- pollen-ui-riot-js/src/main/web/tag/poll/Votes.tag | 129 +++++----- .../src/main/web/tag/popup/AccountCreated.tag | 6 +- .../src/main/web/tag/popup/NewPassword.tag | 8 +- .../src/main/web/tag/popup/ResendValidation.tag | 8 +- 43 files changed, 918 insertions(+), 644 deletions(-) diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/bean/PollBean.java b/pollen-services/src/main/java/org/chorem/pollen/services/bean/PollBean.java index c21198c..a9e5e45 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/bean/PollBean.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/bean/PollBean.java @@ -22,7 +22,7 @@ package org.chorem.pollen.services.bean; */ import com.google.common.base.Joiner; -import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.collections4.CollectionUtils; import org.chorem.pollen.persistence.entity.ChoiceType; import org.chorem.pollen.persistence.entity.CommentVisibility; import org.chorem.pollen.persistence.entity.Poll; diff --git a/pollen-ui-riot-js/.eslintrc b/pollen-ui-riot-js/.eslintrc new file mode 100644 index 0000000..260ac1b --- /dev/null +++ b/pollen-ui-riot-js/.eslintrc @@ -0,0 +1,265 @@ +{ + "globals": { + "console": false, + "debugger": false, + "confirm": true, + "define": true, + "require": true, + "Immutable": true, + "module": true, + "riot": true + }, + "env": { + "browser": true, + "node": false, + "es6": true, + "commonjs": false, + "mocha": false + }, + "plugins": [ "riot" ], + "rules" : { + + "comma-dangle": [ + 2, + "never" + ], + "no-comma-dangle": 0, + "no-cond-assign": 2, + "no-console": 1, + "no-constant-condition": 2, + "no-control-regex": 2, + "no-debugger": 1, + "no-dupe-keys": 2, + "no-empty": 2, + "no-empty-character-class": 2, + "no-ex-assign": 2, + "no-extra-boolean-cast": 2, + "no-extra-parens": [ + 2, + "functions" + ], + "no-extra-semi": 2, + "no-func-assign": 2, + "no-inner-declarations": [ + 0, + "both" + ], + "no-invalid-regexp": 2, + "no-irregular-whitespace": 2, + "no-negated-in-lhs": 2, + "no-obj-calls": 2, + "no-regex-spaces": 2, + "no-sparse-arrays": 2, + "no-unreachable": 2, + "use-isnan": 2, + "valid-jsdoc": 0, + "valid-typeof": 2, + "block-scoped-var": 0, + "complexity": 0, + "consistent-return": 2, + "curly": [ + 2, + "all" + ], + "default-case": 2, + "dot-notation": 2, + "eqeqeq": [ + 2, + "smart" + ], + "guard-for-in": 2, + "no-alert": 1, + "no-caller": 2, + "no-div-regex": 2, + "no-else-return": 2, + "no-eq-null": 0, + "no-eval": 2, + "no-extend-native": 2, + "no-extra-bind": 2, + "no-fallthrough": 2, + "no-floating-decimal": 2, + "no-implied-eval": 2, + "no-iterator": 2, + "no-lone-blocks": 2, + "no-loop-func": 2, + "no-multi-spaces": 1, + "no-multi-str": 2, + "no-native-reassign": 2, + "no-new": 2, + "no-new-func": 2, + "no-new-wrappers": 2, + "no-octal": 2, + "no-octal-escape": 2, + "no-process-env": 1, + "no-proto": 2, + "no-redeclare": 2, + "no-return-assign": 2, + "no-script-url": 2, + "no-self-compare": 2, + "no-sequences": 2, + "no-throw-literal": 1, + "no-unused-expressions": 0, + "no-void": 2, + "no-warning-comments": 0, + "no-with": 2, + "radix": 2, + "vars-on-top": 0, + "wrap-iife": [2, "inside"], + "yoda": 0, + "global-strict": 0, + "no-extra-strict": 0, + "strict": [ + 0, + "global" + ], + "no-catch-shadow": 2, + "no-delete-var": 2, + "no-label-var": 2, + "no-shadow": 2, + "no-shadow-restricted-names": 2, + "no-undef": 1, + "no-undef-init": 2, + "no-undefined": 0, + "no-unused-vars": [ + 1, + { + "vars": "local" + } + ], + "no-use-before-define": 2, + "indent": [ + 1, + 4 + ], + "brace-style": [ + 1, + "1tbs", + { + "allowSingleLine": true + } + ], + "camelcase": 1, + "comma-spacing": [ + 1, + { + "before": false, + "after": true + } + ], + "comma-style": [ + 1, + "last" + ], + "consistent-this": [ + 2, + "_this" + ], + "eol-last": 1, + "func-names": 0, + "func-style": 0, + "key-spacing": [ + 1, + { + "beforeColon": false, + "afterColon": true + } + ], + "max-nested-callbacks": [ + 2, + 5 + ], + "new-cap": 2, + "new-parens": 2, + "no-array-constructor": 2, + "no-inline-comments": 0, + "no-lonely-if": 2, + "no-mixed-spaces-and-tabs": 1, + "no-multiple-empty-lines": 1, + "no-nested-ternary": 2, + "no-new-object": 2, + "no-space-before-semi": 0, + "no-spaced-func": 1, + "no-ternary": 0, + "no-trailing-spaces": 1, + "no-underscore-dangle": 0, + "one-var": 0, + "operator-assignment": 0, + "padded-blocks": 0, + "quote-props": [ + 2, + "as-needed", {"keywords": true} + ], + "quotes": [ + 1, + "double" + ], + "semi": [ + 2, + "always" + ], + "semi-spacing": [ + 1, + { + "before": false, + "after": true + } + ], + "sort-vars": 0, + "space-after-function-name": 0, + "keyword-spacing": [2, {"before": true, "after": true, "overrides": {}}], + "space-before-blocks": [ + 1, + "always" + ], + "space-before-function-paren": [ + 1, + "never" + ], + "object-curly-spacing": [ + 1, + "never" + ], + "computed-property-spacing": [ + 1, + "never" + ], + "array-bracket-spacing": [ + 1, + "never" + ], + "space-in-parens": [ + 1, + "never" + ], + "space-infix-ops": 1, + "space-unary-ops": [ + 1, + { "words": true, "nonwords": false } + ], + "spaced-line-comment": 0, + "wrap-regex": 0, + "no-var": 0, + "generator-star-spacing": [ + 2, + "after" + ], + "max-depth": [ + 2, + 10 + ], + "max-len": [ + 1, + 180 + ], + "max-params": [ + 2, + 10 + ], + "max-statements": [ + 1, + 100 + ], + "no-bitwise": 0, + "no-plusplus": 0 + } +} diff --git a/pollen-ui-riot-js/package.json b/pollen-ui-riot-js/package.json index 8638b14..cdd5d79 100644 --- a/pollen-ui-riot-js/package.json +++ b/pollen-ui-riot-js/package.json @@ -23,6 +23,8 @@ "babel-core": "^6.17.0", "babel-loader": "^6.2.5", "copy-webpack-plugin": "^3.0.1", + "eslint": "^3.16.0", + "eslint-plugin-riot": "^0.1.6", "json-loader": "^0.5.4", "loader-utils": "^0.2.6", "riot-compiler": "^3.0.5", @@ -33,7 +35,7 @@ "fsevents": "^1.0.17" }, "dependencies": { - "font-awesome": "4.6.3", + "font-awesome": "4.7.0", "moment": "^2.17.1", "riot": "^3.0.5", "riot-route": "^2.5.0" diff --git a/pollen-ui-riot-js/pom.xml b/pollen-ui-riot-js/pom.xml index 31d6ee5..df01224 100644 --- a/pollen-ui-riot-js/pom.xml +++ b/pollen-ui-riot-js/pom.xml @@ -73,7 +73,7 @@ <plugin> <groupId>com.github.eirslett</groupId> <artifactId>frontend-maven-plugin</artifactId> - <version>0.0.22</version> + <version>1.3</version> <executions> <execution> diff --git a/pollen-ui-riot-js/src/main/js/riotjs-loader.js b/pollen-ui-riot-js/src/main/js/riotjs-loader.js index c4d318d..ab2e571 100644 --- a/pollen-ui-riot-js/src/main/js/riotjs-loader.js +++ b/pollen-ui-riot-js/src/main/js/riotjs-loader.js @@ -8,42 +8,44 @@ * 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% */ "use strict"; -let riot = require('riot-compiler'); -let loaderUtils = require('loader-utils'); +let riot = require("riot-compiler"); +let loaderUtils = require("loader-utils"); -module.exports = function (source) { +module.exports = function(source) { let content = source; let options = loaderUtils.parseQuery(this.query); - if (this.cacheable) this.cacheable(); + if (this.cacheable) { + this.cacheable(); + } - Object.keys(options).forEach(function (key) { + Object.keys(options).forEach(function(key) { switch (options[key]) { - case 'true': - options[key] = true; - break; - case 'false': - options[key] = false; - break; - case 'undefined': - options[key] = undefined; - break; - case 'null': - options[key] = null; - break; + case "true": + options[key] = true; + break; + case "false": + options[key] = false; + break; + case "null": + options[key] = null; + break; + default: // "undefined" + options[key] = undefined; + break; } }); diff --git a/pollen-ui-riot-js/src/main/web/js/AuthService.js b/pollen-ui-riot-js/src/main/web/js/AuthService.js index 312f1a6..568f081 100644 --- a/pollen-ui-riot-js/src/main/web/js/AuthService.js +++ b/pollen-ui-riot-js/src/main/web/js/AuthService.js @@ -8,12 +8,12 @@ * 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% diff --git a/pollen-ui-riot-js/src/main/web/js/Choice.js b/pollen-ui-riot-js/src/main/web/js/Choice.js index b8a26b2..adf0c35 100644 --- a/pollen-ui-riot-js/src/main/web/js/Choice.js +++ b/pollen-ui-riot-js/src/main/web/js/Choice.js @@ -8,12 +8,12 @@ * 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% 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 aff3396..5a6238e 100644 --- a/pollen-ui-riot-js/src/main/web/js/FetchService.js +++ b/pollen-ui-riot-js/src/main/web/js/FetchService.js @@ -8,12 +8,12 @@ * 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% @@ -74,7 +74,7 @@ class FetchService { let keys = Object.keys(params); keys.forEach((key) => { let value = params[key]; - if (typeof value === 'object') { + if (typeof value === "object") { value = JSON.stringify(value); } if (query.length > 1) { @@ -105,7 +105,7 @@ class FetchService { let keys = Object.keys(data); keys.forEach((key) => { let value = data[key]; - if (typeof value === 'object') { + if (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/FormHelper.js b/pollen-ui-riot-js/src/main/web/js/FormHelper.js index 04a6e9f..6d9b024 100644 --- a/pollen-ui-riot-js/src/main/web/js/FormHelper.js +++ b/pollen-ui-riot-js/src/main/web/js/FormHelper.js @@ -8,12 +8,12 @@ * 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% @@ -22,7 +22,7 @@ class FormHelper { static formToMap(form) { - let moment = require('moment'); + let moment = require("moment"); let result = {}; Array.prototype.forEach.call(form.elements, (e) => { @@ -31,8 +31,8 @@ class FormHelper { result[e.name] = !!e.checked; } else if (e.type === "datetime-local") { if (e.value !== "") { - result[e.name] = moment(e.value).format('YYYY-MM-DDTHH:mm'); - console.info('date::: '+e.value+" -- "+result[e.name]); + result[e.name] = moment(e.value).format("YYYY-MM-DDTHH:mm"); + console.info("date::: " + e.value + " -- " + result[e.name]); } } else if (e.type === "radio") { Array.prototype.forEach.call(form.elements[e.name], function(r) { @@ -59,7 +59,7 @@ class FormHelper { static fillForm(form, context, defaults = {}) { - let moment = require('moment'); + let moment = require("moment"); let formData = context._formData || context; Array.prototype.forEach.call(form.elements, (e) => { @@ -73,13 +73,13 @@ class FormHelper { e.checked = !!value; } else if (e.type === "datetime-local") { let d = new Date(value); - if (!isNaN( d.getTime() )) { - e.value = moment(d).format('YYYY-MM-DDThh:mm'); + if (!isNaN(d.getTime())) { + e.value = moment(d).format("YYYY-MM-DDThh:mm"); //e.value = d.toISOString().replace("Z", ""); } } else if (e.type === "radio") { Array.prototype.forEach.call(form.elements[e.name], function(r) { - if (r.value == value) { + if (r.value === value) { r.checked = true; } }); diff --git a/pollen-ui-riot-js/src/main/web/js/I18nHelper.js b/pollen-ui-riot-js/src/main/web/js/I18nHelper.js index 72b751c..40b4d91 100644 --- a/pollen-ui-riot-js/src/main/web/js/I18nHelper.js +++ b/pollen-ui-riot-js/src/main/web/js/I18nHelper.js @@ -8,19 +8,19 @@ * 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% */ module.exports = { - installBundle(session, value,callback) { + installBundle(session, value, callback) { this.bundle = session.i18n; this.debug = session.configuration.debugI18n; this.generateBundle(session.locale, value); @@ -53,8 +53,8 @@ module.exports = { }); }, - __(key, ...params) { - return this.format(__[key], ...params); + _l(key, ...params) { + return this.format(this.__[key], ...params); }, format(value, params) { diff --git a/pollen-ui-riot-js/src/main/web/js/Pagination.js b/pollen-ui-riot-js/src/main/web/js/Pagination.js index e2ac3ed..524eeb8 100644 --- a/pollen-ui-riot-js/src/main/web/js/Pagination.js +++ b/pollen-ui-riot-js/src/main/web/js/Pagination.js @@ -9,4 +9,4 @@ class Pagination { } -module.exports = Pagination; \ No newline at end of file +module.exports = Pagination; 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 3525e7a..3e1e226 100644 --- a/pollen-ui-riot-js/src/main/web/js/PollForm.js +++ b/pollen-ui-riot-js/src/main/web/js/PollForm.js @@ -8,25 +8,25 @@ * 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 Choice = require('./Choice'); +let Choice = require("./Choice"); let route = require("riot-route"); class PollForm { constructor() { - this.service = require('./PollService'); - this.FormHelper = require('./FormHelper'); + this.service = require("./PollService"); + this.FormHelper = require("./FormHelper"); this.step = 0; this.isInit = false; this.choiceType = null; @@ -60,25 +60,27 @@ class PollForm { this.model.participant = []; switch (this.choiceType) { - case '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; + 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; } }); } @@ -112,11 +114,9 @@ class PollForm { fromDom(form) { let map = this.FormHelper.formToMap(form); let voters = form.participants.value; - if (voters) { - map.participants = voters.split('/s'); - } + map.participants = voters ? voters.split("/s") : []; Object.assign(this.model, map); - console.info('dom to model'); + console.info("dom to model"); console.info(map); console.info(this.model); } @@ -124,21 +124,21 @@ class PollForm { toDom(form) { let map = this.FormHelper.formToMap(form); Object.assign(this.model, map); - console.info('model to dom'); + console.info("model to dom"); console.info(map); console.info(this.model); } fillForm(form) { - console.info('fill form from model'); + console.info("fill form from model"); console.info(this.model); this.FormHelper.fillForm(form, this.model); if (this.model.participants && this.model.participants.length) { - let participants = ''; + let participants = ""; this.model.participants.forEach(p=> { - participants+=' '+p; + participants += " " + p; }); - form.participants.value =participants.trim(); + form.participants.value = participants.trim(); } } @@ -149,24 +149,24 @@ class PollForm { let count = 0; Array.prototype.forEach.call(form.elements, (e) => { if (e.name && e.value) { - if (e.name.indexOf("choice") == 0) { + if (e.name.indexOf("choice") === 0) { map[e.name] = e.value; count++; } - if (e.name.indexOf("description") == 0) { + if (e.name.indexOf("description") === 0) { map[e.name] = e.value; } - if (e.name.indexOf("id") == 0) { + if (e.name.indexOf("id") === 0) { map[e.name] = e.value; } } }); for (let i = 0; i < count; i++) { - let text = map['choice' + i]; - let description = map['description' + i]; - let id = map['id' + i]; - if (this.type != 'add' || !id) { + let text = map["choice" + i]; + let description = map["description" + i]; + let id = map["id" + i]; + if (this.type !== "add" || !id) { choices.push(new Choice(this.model.choiceType, text, description, id)); } } @@ -176,28 +176,25 @@ class PollForm { } getTextChoice(form, index) { - let choices = []; - let map = {}; - let count = 0; + Array.prototype.forEach.call(form.elements, (e) => { if (e.name && e.value) { - if (e.name.indexOf("choice") == 0) { + if (e.name.indexOf("choice") === 0) { map[e.name] = e.value; - count++; } - if (e.name.indexOf("description") == 0) { + if (e.name.indexOf("description") === 0) { map[e.name] = e.value; } - if (e.name.indexOf("id") == 0) { + if (e.name.indexOf("id") === 0) { map[e.name] = e.value; } } }); - let text = map['choice' + index]; - let description = map['description' + index]; - let id = map['id' + index]; + let text = map["choice" + index]; + let description = map["description" + index]; + let id = map["id" + index]; return new Choice(this.model.choiceType, text, description, id); } diff --git a/pollen-ui-riot-js/src/main/web/js/PollService.js b/pollen-ui-riot-js/src/main/web/js/PollService.js index 06bb3e1..31b0a23 100644 --- a/pollen-ui-riot-js/src/main/web/js/PollService.js +++ b/pollen-ui-riot-js/src/main/web/js/PollService.js @@ -8,12 +8,12 @@ * 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% @@ -32,7 +32,7 @@ class PollService extends FetchService { } save(poll) { - return this.form("/v1/polls/edit?permission="+poll.permission, {poll: poll}); + return this.form("/v1/polls/edit?permission=" + poll.permission, {poll: poll}); } createdPolls(pagination) { @@ -52,7 +52,7 @@ class PollService extends FetchService { } closePoll(pollId, permission) { - let url = "/v1/polls/" + pollId + '/close'; + let url = "/v1/polls/" + pollId + "/close"; if (permission) { url += "?permission=" + permission; } @@ -60,7 +60,7 @@ class PollService extends FetchService { } reopenPoll(pollId, permission) { - let url = "/v1/polls/" + pollId + '/reopen'; + let url = "/v1/polls/" + pollId + "/reopen"; if (permission) { url += "?permission=" + permission; } diff --git a/pollen-ui-riot-js/src/main/web/js/Session.js b/pollen-ui-riot-js/src/main/web/js/Session.js index 9760c01..8136710 100644 --- a/pollen-ui-riot-js/src/main/web/js/Session.js +++ b/pollen-ui-riot-js/src/main/web/js/Session.js @@ -8,12 +8,12 @@ * 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% @@ -29,17 +29,17 @@ class Session { // pour contenir la locale à utiliser this.locale = null; // pour contenir la configuration - this.configuration = require('../conf.json'); + this.configuration = require("../conf.json"); // pour contenir les traductions - this.i18n = require('../i18n.json'); - // pour contenir l'utillisateur connecté + this.i18n = require("../i18n.json"); + // pour contenir l"utillisateur connecté this.user = null; let lang = navigator.language || navigator.userLanguage; - if (lang.indexOf('en') == 0) { - this.locale = 'en'; + if (lang.indexOf("en") === 0) { + this.locale = "en"; } else { - this.locale = 'fr'; + this.locale = "fr"; } this.onUnauthorize(() => { diff --git a/pollen-ui-riot-js/src/main/web/js/Singleton.js b/pollen-ui-riot-js/src/main/web/js/Singleton.js index fcbdd8b..05f422d 100644 --- a/pollen-ui-riot-js/src/main/web/js/Singleton.js +++ b/pollen-ui-riot-js/src/main/web/js/Singleton.js @@ -8,12 +8,12 @@ * 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% diff --git a/pollen-ui-riot-js/src/main/web/js/VoteCountingTypeService.js b/pollen-ui-riot-js/src/main/web/js/VoteCountingTypeService.js index 5253c6c..1cae426 100644 --- a/pollen-ui-riot-js/src/main/web/js/VoteCountingTypeService.js +++ b/pollen-ui-riot-js/src/main/web/js/VoteCountingTypeService.js @@ -24,12 +24,12 @@ let FetchService = require("./FetchService"); class VoteCountingTypeService extends FetchService { getVoteCountingType(voteCountingTypeId) { - return this.get("/v1/voteCountingTypes/"+voteCountingTypeId); - }; + return this.get("/v1/voteCountingTypes/" + voteCountingTypeId); + } getVoteCountingTypes() { return this.get("/v1/voteCountingTypes"); - }; + } } diff --git a/pollen-ui-riot-js/src/main/web/tag/Footer.tag b/pollen-ui-riot-js/src/main/web/tag/Footer.tag index a04b659..dfcd89a 100644 --- a/pollen-ui-riot-js/src/main/web/tag/Footer.tag +++ b/pollen-ui-riot-js/src/main/web/tag/Footer.tag @@ -27,7 +27,8 @@ <a href="http://www.gnu.org/licenses/agpl.html">{__.license}</a> <a href="http://www.codelutin.com/" target="_blank">Code Lutin</a> </div> - <script> + + <script type="es6"> let session = require("../js/Session"); this.installBundle(session, "footer"); </script> diff --git a/pollen-ui-riot-js/src/main/web/tag/Header.tag b/pollen-ui-riot-js/src/main/web/tag/Header.tag index 81979dc..807861e 100644 --- a/pollen-ui-riot-js/src/main/web/tag/Header.tag +++ b/pollen-ui-riot-js/src/main/web/tag/Header.tag @@ -56,7 +56,8 @@ require("./HeaderI18n.tag"); </div> <div class="header-separator"></div> <HeaderI18n/> - <script> + + <script type="es6"> let route = require("riot-route"); let authService = require("../js/AuthService"); let session = require("../js/Session"); diff --git a/pollen-ui-riot-js/src/main/web/tag/HeaderI18n.tag b/pollen-ui-riot-js/src/main/web/tag/HeaderI18n.tag index b343791..ee696b5 100644 --- a/pollen-ui-riot-js/src/main/web/tag/HeaderI18n.tag +++ b/pollen-ui-riot-js/src/main/web/tag/HeaderI18n.tag @@ -8,12 +8,12 @@ * 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% @@ -29,20 +29,20 @@ </div> </div> - <script> + <script type="es6"> let session = require("../js/Session"); this.locale = session.locale; this.installBundle(session, "header_i18n"); this.toEnglish = () => { - if ('en' != session.locale) { - session.changeLocale('en'); + if ("en" !== session.locale) { + session.changeLocale("en"); this.locale = session.locale; this.update(); } }; this.toFrench = () => { - if ('fr' != session.locale) { - session.changeLocale('fr'); + if ("fr" !== session.locale) { + session.changeLocale("fr"); this.locale = session.locale; this.update(); } diff --git a/pollen-ui-riot-js/src/main/web/tag/Home.tag b/pollen-ui-riot-js/src/main/web/tag/Home.tag index e79cbf6..9984363 100644 --- a/pollen-ui-riot-js/src/main/web/tag/Home.tag +++ b/pollen-ui-riot-js/src/main/web/tag/Home.tag @@ -28,7 +28,7 @@ </div> </div> - <script> + <script type="es6"> let session = require("../js/Session"); let form = require("../js/PollForm"); let route = require("riot-route"); @@ -37,7 +37,7 @@ this.createText = () => { session.getUser().then(user => { - form.init('TEXT', user).then(() => { + form.init("TEXT", user).then(() => { route("/poll/new/text/0"); }); }); @@ -45,14 +45,14 @@ }; this.createImage = () => { session.getUser().then(user => { - form.init('RESOURCE', user).then(() => { + form.init("RESOURCE", user).then(() => { route("/poll/new/image/0"); }); }); }; this.createDate = () => { session.getUser().then(user => { - form.init('DATE', user).then(() => { + form.init("DATE", user).then(() => { route("/poll/new/date/0"); }); }); diff --git a/pollen-ui-riot-js/src/main/web/tag/Pagination.tag b/pollen-ui-riot-js/src/main/web/tag/Pagination.tag index 6e2ebb1..33c9d01 100644 --- a/pollen-ui-riot-js/src/main/web/tag/Pagination.tag +++ b/pollen-ui-riot-js/src/main/web/tag/Pagination.tag @@ -28,12 +28,12 @@ </div> </div> - <script> + <script type="es6"> let session = require("../js/Session"); this.installBundle(session, "pagination"); - this.on('mount', () => { + this.on("mount", () => { this.refs.pageSize.value = this.pageSize; this.refresh(); }); @@ -42,11 +42,11 @@ this.pageNumber = 0; this.lastPageNumber = 0; this.pageSize = 5; - this.callback = opts.callback; - this.sortName = opts.sortName; - this.sortValue = opts.sortValue; + this.callback = this.opts.callback; + this.sortName = this.opts.sortName; + this.sortValue = this.opts.sortValue; - this.onContextChange = function (newContext) { + this.onContextChange = function(newContext) { this.paginationContext = newContext; let count = this.paginationContext.count; @@ -58,63 +58,63 @@ this.sortValue = !this.paginationContext.desc; }; - this.onSortChange = function (sortName, sortValue) { + this.onSortChange = function(sortName, sortValue) { this.pageNumber = 0; this.sortName = sortName; this.sortValue = sortValue; - console.info("on sort change: " + sortName + " --> " + sortValue); + // console.info("on sort change: " + sortName + " --> " + sortValue); this.refresh(); }; - this.onChangePageSize = function (e) { + this.onChangePageSize = function(e) { this.pageNumber = 0; if (e) { - console.info("Page size change: " + e.target.value); + // console.info("Page size change: " + e.target.value); this.pageSize = e.target.value; } this.refresh(); }; - this.onFirstPage = function () { + this.onFirstPage = function() { if (this.pageNumber > 0) { this.pageNumber = 0; this.refresh(); } }; - this.onLastPage = function () { + this.onLastPage = function() { if (this.pageNumber + 1 < this.lastPageNumber) { this.pageNumber = this.lastPageNumber - 1; this.refresh(); } }; - this.onPreviousPage = function () { + this.onPreviousPage = function() { if (this.pageNumber > 0) { this.pageNumber--; this.refresh(); } }; - this.onNextPage = function () { + this.onNextPage = function() { if (this.pageNumber + 1 < this.lastPageNumber) { this.pageNumber++; this.refresh(); } }; - this.refresh = function () { + this.refresh = function() { let pagination = { pageNumber: this.pageNumber, pageSize: this.pageSize, order: this.sortName, desc: this.sortValue }; - console.info("Request: "); - console.info(pagination); + // console.info("Request: "); + // console.info(pagination); this.callback(pagination).then((result) => { - console.info("update pagination"); - console.info(result.pagination); + // console.info("update pagination"); + // console.info(result.pagination); this.onContextChange(result.pagination); this.update(); }); @@ -162,4 +162,4 @@ } </style> -</Pagination> \ No newline at end of file +</Pagination> diff --git a/pollen-ui-riot-js/src/main/web/tag/Pollen.tag b/pollen-ui-riot-js/src/main/web/tag/Pollen.tag index 1ce83da..cac12cc 100644 --- a/pollen-ui-riot-js/src/main/web/tag/Pollen.tag +++ b/pollen-ui-riot-js/src/main/web/tag/Pollen.tag @@ -33,12 +33,12 @@ require("./Users.tag"); <div class="body-content" ref="content"></div> <Footer></Footer> - <script> + <script type="es6"> let session = require("../js/Session"); - session.start().then(user => { - console.info("session started"); + session.start().then(() => { + // console.info("session started"); }); this.installBundle(session, "main"); @@ -51,7 +51,7 @@ require("./Users.tag"); route("/signin", () => { riot.mount(this.refs.content, "signin"); }); - route("/signin..", (url) => { + route("/signin..", () => { let q = route.query(); riot.mount(this.refs.content, "signin", {url: q.url}); }); @@ -69,7 +69,7 @@ require("./Users.tag"); if (!session.isConnected()) { route("/signin?url=/poll/created"); } else { - riot.mount(this.refs.content, "polls", { method: "createdPolls", session: session}); + riot.mount(this.refs.content, "polls", {method: "createdPolls", session: session}); } }); @@ -92,34 +92,34 @@ require("./Users.tag"); }); route("/poll/*/choice", (pollId) => { - riot.mount(this.refs.content, "poll", {pollId: pollId, tabName: 'choices'}); + riot.mount(this.refs.content, "poll", {pollId: pollId, tabName: "choices"}); }); route("/poll/*/choice/*", (pollId, permission) => { - riot.mount(this.refs.content, "poll", {pollId: pollId, tabName: 'choices', permission: permission}); + riot.mount(this.refs.content, "poll", {pollId: pollId, tabName: "choices", permission: permission}); }); route("/poll/*/vote", (pollId) => { - riot.mount(this.refs.content, "poll", {pollId: pollId, tabName: 'votes'}); + riot.mount(this.refs.content, "poll", {pollId: pollId, tabName: "votes"}); }); route("/poll/*/vote/*", (pollId, permission) => { - riot.mount(this.refs.content, "poll", {pollId: pollId, tabName: 'votes', permission: permission}); + riot.mount(this.refs.content, "poll", {pollId: pollId, tabName: "votes", permission: permission}); }); route("/poll/*/comment", (pollId) => { - riot.mount(this.refs.content, "poll", {pollId: pollId, tabName: 'comments'}); + riot.mount(this.refs.content, "poll", {pollId: pollId, tabName: "comments"}); }); route("/poll/*/comment/*", (pollId, permission) => { - riot.mount(this.refs.content, "poll", {pollId: pollId, tabName: 'comments', permission: permission}); + riot.mount(this.refs.content, "poll", {pollId: pollId, tabName: "comments", permission: permission}); }); route("/poll/*/result", (pollId) => { - riot.mount(this.refs.content, "poll", {pollId: pollId, tabName: 'results'}); + riot.mount(this.refs.content, "poll", {pollId: pollId, tabName: "results"}); }); route("/poll/*/result/*", (pollId, permission) => { - riot.mount(this.refs.content, "poll", {pollId: pollId, tabName: 'results', permission: permission}); + riot.mount(this.refs.content, "poll", {pollId: pollId, tabName: "results", permission: permission}); }); route("/poll/*/settings", (pollId) => { - riot.mount(this.refs.content, "poll", {pollId: pollId, tabName: 'settings'}); + riot.mount(this.refs.content, "poll", {pollId: pollId, tabName: "settings"}); }); route("/poll/*/settings/*", (pollId, permission) => { - riot.mount(this.refs.content, "poll", {pollId: pollId, tabName: 'settings', permission: permission}); + riot.mount(this.refs.content, "poll", {pollId: pollId, tabName: "settings", permission: permission}); }); route("/poll/*", (pollId) => { diff --git a/pollen-ui-riot-js/src/main/web/tag/SignCheck.tag b/pollen-ui-riot-js/src/main/web/tag/SignCheck.tag index f914120..b9a447a 100644 --- a/pollen-ui-riot-js/src/main/web/tag/SignCheck.tag +++ b/pollen-ui-riot-js/src/main/web/tag/SignCheck.tag @@ -8,12 +8,12 @@ * 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% @@ -38,14 +38,14 @@ </div> - <script> + <script type="es6"> let authService = require("../js/AuthService"); let session = require("../js/Session"); this.installBundle(session, "signcheck"); this.message = this.__.validating; this.error = false; - authService.validateEmail(opts.id, opts.token) + authService.validateEmail(this.opts.id, this.opts.token) .then(() => { this.message = this.__.validating_success; this.update(); diff --git a/pollen-ui-riot-js/src/main/web/tag/SignIn.tag b/pollen-ui-riot-js/src/main/web/tag/SignIn.tag index 8501483..343ba84 100644 --- a/pollen-ui-riot-js/src/main/web/tag/SignIn.tag +++ b/pollen-ui-riot-js/src/main/web/tag/SignIn.tag @@ -8,12 +8,12 @@ * 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% @@ -42,7 +42,7 @@ require("./popup/NewPassword.tag"); <NewPassword ref="newPassword"/> - <script> + <script type="es6"> let authService = require("../js/AuthService"); let session = require("../js/Session"); let route = require("riot-route"); @@ -51,7 +51,7 @@ require("./popup/NewPassword.tag"); this.message = ""; this.newPassword = () => { - this.refs.newPassword.open(this.refs.login.value || ''); + this.refs.newPassword.open(this.refs.login.value || ""); }; this.signIn = (e) => { @@ -62,12 +62,12 @@ require("./popup/NewPassword.tag"); authService.signIn(this.refs.login.value, this.refs.password.value) .then(() => { - let back = opts.url || "/"; - console.info("After login url:" +back); + let back = this.opts.url || "/"; + // console.info("After login url:" +back); route(back); this.update(); }) - .catch((code) => { + .catch(() => { this.message = this.__.error_signin; this.update(); }); diff --git a/pollen-ui-riot-js/src/main/web/tag/SignUp.tag b/pollen-ui-riot-js/src/main/web/tag/SignUp.tag index 209c808..29d75f6 100644 --- a/pollen-ui-riot-js/src/main/web/tag/SignUp.tag +++ b/pollen-ui-riot-js/src/main/web/tag/SignUp.tag @@ -8,12 +8,12 @@ * 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% @@ -43,12 +43,12 @@ require("./popup/AccountCreated.tag"); <ResendValidation ref="resendValidation"/> <AccountCreated ref="accountCreated"/> - <script> + <script type="es6"> let authService = require("../js/AuthService"); let session = require("../js/Session"); let FormHelper = require("../js/FormHelper"); - this.on('mount', () => { + this.on("mount", () => { if (this.validate) { this.refs.resendValidation.open(); } @@ -78,7 +78,7 @@ require("./popup/AccountCreated.tag"); }); }; - if (opts.validate) { + if (this.opts.validate) { this.resendValidation(); } </script> diff --git a/pollen-ui-riot-js/src/main/web/tag/Users.tag b/pollen-ui-riot-js/src/main/web/tag/Users.tag index 80d6a59..f3a991f 100644 --- a/pollen-ui-riot-js/src/main/web/tag/Users.tag +++ b/pollen-ui-riot-js/src/main/web/tag/Users.tag @@ -1,4 +1,4 @@ -require('./Pagination.tag'); +require("./Pagination.tag"); <Users> <div class="body-container"> @@ -58,7 +58,7 @@ require('./Pagination.tag'); <tr> <th colspan="5"> <div> - <Pagination ref=pagination" sortName='{sortName}' sortValue='false' callback="{callback}"/> + <Pagination ref="pagination" sortName='{sortName}' sortValue='false' callback="{callback}"/> </div> </th> </tr> @@ -68,7 +68,7 @@ require('./Pagination.tag'); </div> - <script> + <script type="es6"> this.session = require("../js/Session"); let i18nCallback = (locale) => { this.moment.locale(locale); @@ -76,65 +76,65 @@ require('./Pagination.tag'); }; this.installBundle(this.session, "users", i18nCallback); - this.moment = require('moment'); + this.moment = require("moment"); this.moment.locale(this.session.locale); this.session.getUser().then(user=> { this.connectedUser = user; }); - this.sortName = 'name'; + this.sortName = "name"; this.sortValue = false; // means asc this.users = []; - let userService = require('../js/UserService'); + let userService = require("../js/UserService"); this.reloadPagination = ()=> { - this.pagination.onSortChange(this.sortOwner.getAttribute('sortName'), this.sortValue); + this.pagination.onSortChange(this.sortOwner.getAttribute("sortName"), this.sortValue); }; this.makeAdmin = e => { let userId = e.target.parentNode.id; - console.info('user id: ' + userId); - userService.makeAdmin(userId).then(result=> { + // console.info("user id: " + userId); + userService.makeAdmin(userId).then(()=> { this.reloadPagination(); }); }; this.unmakeAdmin = e => { let userId = e.target.parentNode.id; - console.info('user id: ' + userId); - userService.unmakeAdmin(userId).then(result=> { + // console.info("user id: " + userId); + userService.unmakeAdmin(userId).then(()=> { this.reloadPagination(); }); }; this.banUser = e => { let userId = e.target.parentNode.id; - console.info('user id: ' + userId); - userService.banUser(userId).then(result=> { + // console.info("user id: " + userId); + userService.banUser(userId).then(()=> { this.reloadPagination(); }); }; this.deleteUser = e => { let userId = e.target.parentNode.id; - console.info('user id: ' + userId); + // console.info("user id: " + userId); if (confirm(this.__deleteUserMessage)) { - userService.deleteUser(userId).then(result=> { + userService.deleteUser(userId).then(()=> { this.reloadPagination(); }); } }; this.callback = (pagination) => { - console.info("Request data with pagination::"); + // console.info("Request data with pagination::"); if (!pagination.order) { pagination.order = this.sortName; pagination.desc = this.sortValue; } - console.info(pagination); + // console.info(pagination); return userService.users(pagination).then((result) => { this.users = result.elements; - console.info('Users::'); - console.info(this.users); + // console.info("Users::"); + // console.info(this.users); this.refreshUsers(); this.update(); return result; @@ -143,44 +143,45 @@ require('./Pagination.tag'); this.refreshUsers = () => { this.users.forEach(u => { - let status = 'CREATED'; + let status = "CREATED"; if (!u.emailIsValidate) { - status = 'VALIDATION'; + status = "VALIDATION"; } if (u.isDisabled) { - status = 'DISABLE'; - }if (u.isBanned) { - status = 'BANNED'; + status = "DISABLE"; + } + if (u.isBanned) { + status = "BANNED"; } u.status = this.__[status]; }); }; - this.on('mount', () => { + this.on("mount", () => { this.pagination = this.tags.pagination; this.sortOwner = this.refs.sortName; - this.refs.sortName.setAttribute('sortName', 'name'); - this.refs.sortEmail.setAttribute('sortName', 'email'); + this.refs.sortName.setAttribute("sortName", "name"); + this.refs.sortEmail.setAttribute("sortName", "email"); }); this.toggleSort = (e) => { - console.info(this.refs.sortName); + // console.info(this.refs.sortName); if (this.sortOwner === e.target) { - this.sortOwner.classList.toggle('fa-sort-amount-asc'); - this.sortOwner.classList.toggle('fa-sort-amount-desc'); + this.sortOwner.classList.toggle("fa-sort-amount-asc"); + this.sortOwner.classList.toggle("fa-sort-amount-desc"); this.sortValue = !this.sortValue; } else { - this.sortOwner.classList.add('fa-sort'); - this.sortOwner.classList.add('disabled'); - this.sortOwner.classList.remove('fa-sort-amount-desc'); - this.sortOwner.classList.remove('fa-sort-amount-asc'); + this.sortOwner.classList.add("fa-sort"); + this.sortOwner.classList.add("disabled"); + this.sortOwner.classList.remove("fa-sort-amount-desc"); + this.sortOwner.classList.remove("fa-sort-amount-asc"); this.sortOwner = e.target; - this.sortOwner.classList.remove('disabled'); - this.sortOwner.classList.remove('fa-sort'); - this.sortOwner.classList.remove('fa-sort-amount-desc'); - this.sortOwner.classList.add('fa-sort-amount-asc'); + this.sortOwner.classList.remove("disabled"); + this.sortOwner.classList.remove("fa-sort"); + this.sortOwner.classList.remove("fa-sort-amount-desc"); + this.sortOwner.classList.add("fa-sort-amount-asc"); this.sortValue = true; } @@ -306,4 +307,4 @@ require('./Pagination.tag'); } </style> -</Users> \ No newline at end of file +</Users> diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/ChoiceDate.tag b/pollen-ui-riot-js/src/main/web/tag/poll/ChoiceDate.tag index 0d20d23..c0ad88c 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/ChoiceDate.tag +++ b/pollen-ui-riot-js/src/main/web/tag/poll/ChoiceDate.tag @@ -66,25 +66,26 @@ </div> </div> - <script> - this.installBundle(opts.session, "poll_choices"); - this.number = parseInt(opts.number); - this.mode = opts.mode; - this.edit = opts.mode == 'create' || opts.mode == 'edit'; - this.choice = opts.choice; - - opts.emitter.on('prepareSave', () => { + <script type="es6"> + this.installBundle(this.opts.session, "poll_choices"); + this.number = parseInt(this.opts.number, 10); + this.mode = this.opts.mode; + this.edit = this.opts.mode === "create" || this.opts.mode === "edit"; + this.choice = this.opts.choice; + + this.opts.emitter.on("prepareSave", () => { let choiceValue = this.refs.date.value; if (choiceValue && this.timed && this.refs.time.value) { - choiceValue += 'T' + this.refs.time.value; + choiceValue += "T" + this.refs.time.value; } this.refs.choice.value = choiceValue; }); let choiceValue = this.choice.choiceValue; + if (choiceValue) { - let index = choiceValue.indexOf('T'); - if (index == -1) { + let index = choiceValue.indexOf("T"); + if (index === -1) { this.choice.date = choiceValue; this.timed = false; } else { @@ -92,16 +93,16 @@ this.choice.time = choiceValue.substring(index + 1); this.timed = true; } - console.info('init choice: (' + this.timed + ')'); - console.info(this.choice); + // console.info("init choice: (" + this.timed + ")"); + // console.info(this.choice); } - this.on('mount', () => { - if (this.number == 0 || this.mode === 'edit') { + 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'); + if (this.mode === "edit") { + this.refs.edit_choice.classList.add("choice-view"); } }); @@ -112,34 +113,35 @@ this.prepareSave = () => { let date = this.refs.choice.value; let time = this.refs.time.value; - let choiceValue = date; + let choiceValue2 = date; if (this.timed) { - choiceValue += 'T' + time; + choiceValue2 += "T" + time; } this.$choice = { date: date, time: time, - choiceValue: choiceValue, + choiceValue: choiceValue2, description: this.refs.description.value }; }; + this.onEditChoice = () => { this.editing = true; - let ref = this.refs['edit_choice']; + let ref = this.refs.edit_choice; ref.classList.add("choice-edit"); ref.classList.remove("choice-view"); - this.trigger('editChoice', this.number); + this.trigger("editChoice", this.number); Object.assign(this.$choice = {}, this.choice); - console.info(this.$choice); + // console.info(this.$choice); }; this.cancelEditChoice = () => { if (this.editing) { - let ref = this.refs['edit_choice']; + let ref = this.refs.edit_choice; ref.classList.remove("choice-edit"); ref.classList.add("choice-view"); Object.assign(this.choice, this.$choice); - console.info(this.choice); + // console.info(this.choice); this.refs.choice.value = this.choice.date; this.refs.time.value = this.choice.time; this.timed = !!this.choice.time; @@ -147,12 +149,12 @@ } this.editing = false; - this.trigger('cancelEditChoice', this.number); + this.trigger("cancelEditChoice", this.number); }; this.deleteChoice = () => { - if (confirm('Delete choice?')) { - this.trigger('deleteChoice', this.number); + if (confirm("Delete choice?")) { + this.trigger("deleteChoice", this.number); } }; diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/ChoiceText.tag b/pollen-ui-riot-js/src/main/web/tag/poll/ChoiceText.tag index 7359bd1..475df0c 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/ChoiceText.tag +++ b/pollen-ui-riot-js/src/main/web/tag/poll/ChoiceText.tag @@ -56,18 +56,18 @@ </div> </div> - <script> - this.installBundle(opts.session, "poll_choices"); - this.number = parseInt(opts.number); - this.mode = opts.mode; - this.edit = opts.mode === 'create' || opts.mode === 'edit'; - this.choice = opts.choice; - this.on('mount', () => { - if (this.number == 0 || this.mode==='edit') { + <script type="es6"> + this.installBundle(this.opts.session, "poll_choices"); + this.number = parseInt(this.opts.number, 10); + this.mode = this.opts.mode; + this.edit = this.opts.mode === "create" || this.opts.mode === "edit"; + this.choice = this.opts.choice; + 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'); + if (this.mode === "edit") { + this.refs.edit_choice.classList.add("choice-view"); } }); @@ -79,32 +79,32 @@ }; this.onEditChoice = () => { this.editing = true; - let ref = this.refs['edit_choice']; + let ref = this.refs.edit_choice; ref.classList.add("choice-edit"); ref.classList.remove("choice-view"); - this.trigger('editChoice', this.number); + this.trigger("editChoice", this.number); Object.assign(this.$choice = {}, this.choice); - console.info(this.$choice); + // console.info(this.$choice); }; this.cancelEditChoice = () => { if (this.editing) { - let ref = this.refs['edit_choice']; + let ref = this.refs.edit_choice; ref.classList.remove("choice-edit"); ref.classList.add("choice-view"); Object.assign(this.choice, this.$choice); - console.info(this.choice); + // console.info(this.choice); this.refs.choice.value = this.choice.choiceValue; this.refs.description.value = this.choice.description; } this.editing = false; - this.trigger('cancelEditChoice', this.number); + this.trigger("cancelEditChoice", this.number); }; this.deleteChoice = () => { - if (confirm('Delete choice?')) { - this.trigger('deleteChoice', this.number); + if (confirm("Delete choice?")) { + this.trigger("deleteChoice", this.number); } }; diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/Choices.tag b/pollen-ui-riot-js/src/main/web/tag/poll/Choices.tag index f1d6fec..6db8d1d 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/Choices.tag +++ b/pollen-ui-riot-js/src/main/web/tag/poll/Choices.tag @@ -1,5 +1,5 @@ -require('./ChoiceText.tag'); -require('./ChoiceDate.tag'); +require("./ChoiceText.tag"); +require("./ChoiceDate.tag"); <Choices> <div if="{choicePeriod}" class="legend"> {__.choicePeriod} {choicePeriod} @@ -19,72 +19,70 @@ require('./ChoiceDate.tag'); <input type="submit" class="button mainColorBackground" value="{__.next}"> </div> </form> - <script> - if (opts.form) { - this.form = opts.form; + + <script type="es6"> + if (this.opts.form) { + this.form = this.opts.form; } else { - this.form = require('../../js/PollForm'); - this.form.model = opts.poll; - this.form.choiceType = (opts.poll.choiceType || 'text').toLowerCase(); - this.form.mode = 'view'; - if (opts.poll.choiceAddAllowed && opts.poll.status === 'ADDING_CHOICES') { + this.form = require("../../js/PollForm"); + this.form.model = this.opts.poll; + this.form.choiceType = (this.opts.poll.choiceType || "text").toLowerCase(); + this.form.mode = "view"; + if (this.opts.poll.choiceAddAllowed && this.opts.poll.status === "ADDING_CHOICES") { // can add choices - if (opts.poll.permission) { - this.form.mode = 'edit'; + if (this.opts.poll.permission) { + this.form.mode = "edit"; } else { - this.form.mode = 'add'; - } - } else { - - if (opts.poll.permission && opts.poll.voteCount == 0) { - this.form.mode = 'edit'; + this.form.mode = "add"; } + } else if (this.opts.poll.permission && this.opts.poll.voteCount === 0) { + this.form.mode = "edit"; } - console.info("form mode: " + this.form.mode); + // console.info("form mode: " + this.form.mode); this.form.choices = []; } - if (opts.choiceType) { - this.choiceType = opts.choiceType; + if (this.opts.choiceType) { + this.choiceType = this.opts.choiceType; } else { - this.choiceType = this.form.choiceType || 'text'; + this.choiceType = this.form.choiceType || "text"; } - console.info(this.choiceType); - console.info(this.form); + // console.info(this.choiceType); + // console.info(this.form); - this.session = opts.session; + this.session = this.opts.session; this.choiceTags = {}; - let moment = require('moment'); + let moment = require("moment"); this.i18nCallback = (locale) => { moment.locale(locale); - this.choicePeriod = ''; + this.choicePeriod = ""; if (this.form.model.beginChoiceDate) { - this.choicePeriod += moment(this.form.model.beginChoiceDate).format('LLL'); + this.choicePeriod += moment(this.form.model.beginChoiceDate).format("LLL"); } if (this.form.model.endChoiceDate) { - this.choicePeriod += ' - ' + moment(this.form.model.endChoiceDate).format('LLL'); + this.choicePeriod += " - " + moment(this.form.model.endChoiceDate).format("LLL"); } - if (this.choicePeriod != '') { - this.choicePeriod = '( ' + this.choicePeriod + ' )'; + if (this.choicePeriod !== "") { + this.choicePeriod = "( " + this.choicePeriod + " )"; } this.update({choicePeriod: this.choicePeriod}); }; - this.installBundle(opts.session, "poll_choices", this.i18nCallback); + this.installBundle(this.session, "poll_choices", this.i18nCallback); this.i18nCallback(); - let choiceService = require('../../js/ChoiceService'); + let choiceService = require("../../js/ChoiceService"); - this.on('mount', () => { + this.on("mount", () => { - if (opts.poll) { + if (this.opts.poll) { - let choiceService = require("../../js/ChoiceService"); - choiceService.getChoices(opts.poll.id).then(choices => { + let choiceService2 = require("../../js/ChoiceService"); + choiceService2.getChoices(this.opts.poll.id).then(choices => { this.form.choices = choices; - console.info("Choices::"); - console.info(this.form.choices); + // console.info("Choices::"); + // console.info(this.form.choices); this.finalizeInit(); }); @@ -98,24 +96,24 @@ require('./ChoiceDate.tag'); this.finalizeInit = () => { this.formDom = this.refs.formDom; this.choicesCount = this.form.choices.length - 1; - if (this.form.mode == 'create') { + if (this.form.mode === "create") { // must fill to obtain a 5-multiple - if (this.choicesCount == -1) { + if (this.choicesCount === -1) { this.choicesCount = 5; } - while (this.choicesCount % 5 != 0) { + while (this.choicesCount % 5 !== 0) { this.choicesCount++; } this.choicesCount--; } - console.info("init with " + this.form.choices.length + " choices"); - console.info(this.form.choices); - console.info("choicesCount:: " + this.choicesCount); + // console.info("init with " + this.form.choices.length + " choices"); + // console.info(this.form.choices); + // console.info("choicesCount:: " + this.choicesCount); for (let i = 0; i <= this.choicesCount; i++) { this.addChoice(i); @@ -124,7 +122,7 @@ require('./ChoiceDate.tag'); }; - this.addOneChoice = (e) => { + this.addOneChoice = () => { this.addChoice(); let choiceTag = this.choiceTags[this.choicesCount]; choiceTag.onEditChoice(); @@ -132,44 +130,44 @@ require('./ChoiceDate.tag'); }; this.addChoice = (choiceNumber) => { - if (!choiceNumber && choiceNumber != 0) { + if (!choiceNumber && choiceNumber !== 0) { this.choicesCount++; choiceNumber = this.choicesCount; } let choiceDom = document.createElement("div"); - choiceDom.id = 'choice_' + choiceNumber; + choiceDom.id = "choice_" + choiceNumber; this.refs.choicesContainer.appendChild(choiceDom); - let tag = riot.mount(choiceDom, 'choice' + this.form.choiceType, { + let tag = riot.mount(choiceDom, "choice" + this.form.choiceType, { number: choiceNumber, - choice: this.form.choices[choiceNumber] || {choiceValue: '', description: ''}, + choice: this.form.choices[choiceNumber] || {choiceValue: "", description: ""}, mode: this.form.mode, session: this.session, - emitter:this + emitter: this })[0]; this.choiceTags[choiceNumber] = tag; - tag.on('editChoice', choiceNumber => { - if (this.editChoiceNumber || this.editChoiceNumber == 0) { - console.info("remove old edit choice id " + this.editChoiceNumber); + tag.on("editChoice", choiceNumber2 => { + if (this.editChoiceNumber || this.editChoiceNumber === 0) { + // console.info("remove old edit choice id " + this.editChoiceNumber); let choiceTag = this.choiceTags[this.editChoiceNumber]; choiceTag.cancelEditChoice(); choiceTag.update(); } - this.editChoiceNumber = choiceNumber; + this.editChoiceNumber = choiceNumber2; this.editing = true; this.update({editing: this.editing}); }); - tag.on('cancelEditChoice', choiceNumber => { + tag.on("cancelEditChoice", choiceNumber2 => { if (!this.choiceTags[this.editChoiceNumber].choice.id) { // remove choice delete this.choiceTags[this.editChoiceNumber]; this.choicesCount--; - let dom = document.getElementById('choice_' + choiceNumber); + let dom = document.getElementById("choice_" + choiceNumber2); dom.parentNode.removeChild(dom); } this.editChoiceNumber = null; @@ -177,32 +175,32 @@ require('./ChoiceDate.tag'); this.update({editing: this.editing}); }); - tag.on('deleteChoice', choiceNumber => { + tag.on("deleteChoice", choiceNumber2 => { - let ref = this.choiceTags[choiceNumber]; + let ref = this.choiceTags[choiceNumber2]; let choiceId = ref.choice.id; - choiceService.deleteChoice(this.form.model.id, choiceId, this.form.model.permission).then(result => { + choiceService.deleteChoice(this.form.model.id, choiceId, this.form.model.permission).then(() => { - console.info('after delete choice ' + choiceNumber + " / " + this.choicesCount); + // console.info("after delete choice " + choiceNumber + " / " + this.choicesCount); - delete this.choiceTags[choiceNumber]; + delete this.choiceTags[choiceNumber2]; - this.form.choices.splice(choiceNumber, 1); + this.form.choices.splice(choiceNumber2, 1); - let dom = document.getElementById('choice_' + choiceNumber); + let dom = document.getElementById("choice_" + choiceNumber2); dom.parentNode.removeChild(dom); - while (choiceNumber < this.choicesCount) { - console.info("update choices for number: " + choiceNumber); - console.info(this.choiceTags); - let c = this.choiceTags[choiceNumber] = this.choiceTags[choiceNumber + 1]; + while (choiceNumber2 < this.choicesCount) { + // console.info("update choices for number: " + choiceNumber2); + // console.info(this.choiceTags); + let c = this.choiceTags[choiceNumber2] = this.choiceTags[choiceNumber2 + 1]; c.number--; c.update({number: c.number}); - delete this.choiceTags[choiceNumber + 1]; - choiceNumber++; + delete this.choiceTags[choiceNumber2 + 1]; + choiceNumber2++; } - this.trigger('count', this.choicesCount); + this.trigger("count", this.choicesCount); this.choicesCount--; }); @@ -215,7 +213,7 @@ require('./ChoiceDate.tag'); } }; - this.previousStep = (e) => { + this.previousStep = () => { this.form.fromDomToChoices(this.formDom); this.form.previousStep(); }; @@ -224,9 +222,9 @@ require('./ChoiceDate.tag'); e.preventDefault(); e.stopPropagation(); - this.trigger('prepareSave'); + this.trigger("prepareSave"); - if (this.form.mode == 'create') { + if (this.form.mode === "create") { this.form.fromDomToChoices(this.formDom); this.form.nextStep(); @@ -237,10 +235,10 @@ require('./ChoiceDate.tag'); if (choice.id) { // update - choiceService.updateChoice(this.form.model.id, choice, this.form.model.permission).then(result => { + choiceService.updateChoice(this.form.model.id, choice, this.form.model.permission).then(() => { - console.info('after update choice'); - console.info(result); + // console.info("after update choice"); + // console.info(result); let ref = this.choiceTags[this.editChoiceNumber]; ref.choice.description = choice.description; @@ -256,8 +254,8 @@ require('./ChoiceDate.tag'); // add choiceService.addChoice(this.form.model.id, choice, this.form.model.permission).then(result => { - console.info('after add choice'); - console.info(result); + // console.info("after add choice"); + // console.info(result); choice.id = result.id; let ref = this.choiceTags[this.editChoiceNumber]; @@ -271,7 +269,7 @@ require('./ChoiceDate.tag'); ref.update(); this.choicesCount++; - this.trigger('count', this.choicesCount); + this.trigger("count", this.choicesCount); }); } @@ -301,4 +299,4 @@ require('./ChoiceDate.tag'); margin: 5px; } </style> -</Choices> \ No newline at end of file +</Choices> diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/CommentPopup.tag b/pollen-ui-riot-js/src/main/web/tag/poll/CommentPopup.tag index e4801cf..3f7f43d 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/CommentPopup.tag +++ b/pollen-ui-riot-js/src/main/web/tag/poll/CommentPopup.tag @@ -38,7 +38,7 @@ </div> - <script> + <script type="es6"> let session = require("../../js/Session"); this.installBundle(session, "comment_popup"); @@ -66,7 +66,7 @@ document.body.appendChild(this.root); this.root.classList.toggle("close"); this.root.classList.toggle("open"); - } + }; this.close = () => { this.oldParent.appendChild(this.root); @@ -80,10 +80,10 @@ this.error = ""; this.comment.authorName = this.refs.author.value; this.comment.text = this.refs.text.value; - this.callback(this.comment).then(result => { + this.callback(this.comment).then(() => { this.close(); - }).catch((e) => { - this.error = e; + }).catch((error) => { + this.error = error; this.update(); }); }; diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/Comments.tag b/pollen-ui-riot-js/src/main/web/tag/poll/Comments.tag index f71dfeb..59e839e 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/Comments.tag +++ b/pollen-ui-riot-js/src/main/web/tag/poll/Comments.tag @@ -1,5 +1,5 @@ -require('../Pagination.tag'); -require('./CommentPopup.tag'); +require("../Pagination.tag"); +require("./CommentPopup.tag"); <Comments> <div class="comment-container"> @@ -8,8 +8,11 @@ require('./CommentPopup.tag'); </div> <div class="legend"> - {__.title} <a if="{comments.length > 0}" onclick="{toggleSort}"> <i ref="sortOwner" - class="fa fa-sort-amount-desc"></i></a> + {__.title} + <a if="{comments.length > 0}" onclick="{toggleSort}"> + + <i ref="sortOwner" class="fa fa-sort-amount-desc"></i> + </a> </div> <div show="{loaded}" class="body"> @@ -56,49 +59,48 @@ require('./CommentPopup.tag'); <CommentPopup ref="commentPopup"/> - <script> + <script type="es6"> this.loaded = false; let session = require("../../js/Session"); this.installBundle(session, "poll_comments", locale => { this.moment.locale(locale); this.comments.forEach(c => { - c.postDateStr = this.moment(c.postDate).format('LLLL'); + c.postDateStr = this.moment(c.postDate).format("LLLL"); }); }); let commentService = require("../../js/CommentService"); - this.pollId = opts.pollId; - this.permission = opts.permission; - console.info("permission:: " + this.permission); - this.on('mount', () => { + this.pollId = this.opts.pollId; + this.permission = this.opts.permission; + //console.info("permission:: " + this.permission); + this.on("mount", () => { this.pagination = this.tags.pagination; }); - this.moment = require('moment'); + this.moment = require("moment"); this.moment.locale(session.locale); - this.sortName = 'postDate'; + this.sortName = "postDate"; this.sortValue = true; // means desc this.comments = []; this.toggleSort = () => { - this.refs.sortOwner.classList.toggle('fa-sort-amount-desc'); - this.refs.sortOwner.classList.toggle('fa-sort-amount-asc'); + this.refs.sortOwner.classList.toggle("fa-sort-amount-desc"); + this.refs.sortOwner.classList.toggle("fa-sort-amount-asc"); this.sortValue = !this.sortValue; - this.pagination.onSortChange('postDate', this.sortValue); + this.pagination.onSortChange("postDate", this.sortValue); }; this.openAddComment = () => { let comment = { - authorName: '', - text: '' + authorName: "", + text: "" }; if (session.isConnected()) { session.getUser().then(user => { - comment.authorName = user.name; - this.refs.commentPopup.openForCreate(this.pollId, comment, this.addComment); - } - ); + comment.authorName = user.name; + this.refs.commentPopup.openForCreate(this.pollId, comment, this.addComment); + }); } else { this.refs.commentPopup.openForCreate(this.pollId, comment, this.addComment); } @@ -107,9 +109,9 @@ require('./CommentPopup.tag'); this.addComment = (comment) => { return commentService.createComment(this.pollId, comment) - .then((result) => { - console.info("created comment"); - console.info(result); + .then(() => { + // console.info("created comment"); + // console.info(result); this.pagination.refresh(); }); }; @@ -117,8 +119,8 @@ require('./CommentPopup.tag'); this.openEditComment = (e) => { let commentId = e.target.parentNode.parentNode.id; this.comments.forEach(comment => { - if (comment.id == commentId) { - console.info('edit comment ' + commentId); + if (comment.id === commentId) { + // console.info("edit comment " + commentId); this.refs.commentPopup.openForEdit(this.pollId, comment, this.editComment); } }); @@ -126,10 +128,10 @@ require('./CommentPopup.tag'); }; this.editComment = (comment) => { - return commentService.updateComment(this.pollId, comment, this.permission || comment.permission || '') - .then((result) => { - console.info("updated comment"); - console.info(result); + return commentService.updateComment(this.pollId, comment, this.permission || comment.permission || "") + .then(() => { + // console.info("updated comment"); + // console.info(result); this.pagination.refresh(); }); }; @@ -137,13 +139,13 @@ require('./CommentPopup.tag'); this.deleteComment = (e) => { let commentId = e.target.parentNode.parentNode.id; this.comments.forEach(comment => { - if (comment.id == commentId) { + if (comment.id === commentId) { let response = confirm(this.__deleteComment); if (response) { - return commentService.deleteComment(this.pollId, commentId, this.permission || comment.permission || '') - .then((result) => { - console.info("delete comment"); - console.info(result); + commentService.deleteComment(this.pollId, commentId, this.permission || comment.permission || "") + .then(() => { + // console.info("delete comment"); + // console.info(result); this.pagination.onChangePageSize(); }); } @@ -155,20 +157,20 @@ require('./CommentPopup.tag'); if (!this.pollId) { return Promise.resolve({elements: []}); } - console.info("Request data with pagination::"); + // console.info("Request data with pagination::"); if (!pagination.sortName) { pagination.order = this.sortName; pagination.desc = this.sortValue; } - console.info(pagination); + // console.info(pagination); return commentService.getComments(this.pollId, pagination, this.permission).then((result) => { this.comments = result.elements; - console.info("comments::"); - console.info(this.comments); + // console.info("comments::"); + // console.info(this.comments); this.comments.forEach(c => { - c.postDateStr = this.moment(c.postDate).format('LLLL'); + c.postDateStr = this.moment(c.postDate).format("LLLL"); }); - this.trigger('count', result.pagination.count); + this.trigger("count", result.pagination.count); this.loaded = true; this.update(); return result; @@ -187,7 +189,7 @@ require('./CommentPopup.tag'); } .comment-container { - width: 800px; + width: 100%; display: flex; flex-direction: column; justify-content: flex-start; @@ -240,4 +242,4 @@ require('./CommentPopup.tag'); } </style> -</Comments> \ No newline at end of file +</Comments> diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/CreatePoll.tag b/pollen-ui-riot-js/src/main/web/tag/poll/CreatePoll.tag index d6fb2a4..7c5a8bb 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/CreatePoll.tag +++ b/pollen-ui-riot-js/src/main/web/tag/poll/CreatePoll.tag @@ -121,28 +121,28 @@ require("./Created.tag"); </div> </div> - <script> + <script type="es6"> - console.info("Create poll"); + // console.info("Create poll"); this.form = require("../../js/PollForm"); this.session = require("../../js/Session"); - this.form.choiceType = opts.choiceType; + this.form.choiceType = this.opts.choiceType; this.steps = { - 0: 'description', - 1: 'choices', - 2: 'settings', - 3: 'voters', - 4: 'created' + 0: "description", + 1: "choices", + 2: "settings", + 3: "voters", + 4: "created" }; this.installBundle(this.session, "poll"); - this.goto0 = (e) => { + this.goto0 = () => { this.form.setStep(0); }; - this.goto1 = (e) => { + this.goto1 = () => { this.form.setStep(1); }; - this.goto2 = (e) => { + this.goto2 = () => { this.form.setStep(2); }; @@ -152,18 +152,18 @@ require("./Created.tag"); if (!this.form.isInit) { this.session.getUser().then(user => { - this.form.init(opts.choiceType, user).then(() => { + this.form.init(this.opts.choiceType, user).then(() => { this.form.setStep(0); this.finalizeInit(); }); }); } else { - if (opts.step) { - this.form.step = parseInt(opts.step); + if (this.opts.step) { + this.form.step = parseInt(this.opts.step, 10); } - this.on('mount', () => { + this.on("mount", () => { this.finalizeInit(); }); } diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/Created.tag b/pollen-ui-riot-js/src/main/web/tag/poll/Created.tag index 7cb86b5..a79081b 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/Created.tag +++ b/pollen-ui-riot-js/src/main/web/tag/poll/Created.tag @@ -37,11 +37,11 @@ </div> </div> - <script> - this.installBundle(opts.session, "poll_created"); - this.form = opts.form; - console.info("Created poll"); - console.info(this.form); + <script type="es6"> + this.installBundle(this.opts.session, "poll_created"); + this.form = this.opts.form; + // console.info("Created poll"); + // console.info(this.form); </script> <style> diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/Description.tag b/pollen-ui-riot-js/src/main/web/tag/poll/Description.tag index 4e3f599..f950120 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/Description.tag +++ b/pollen-ui-riot-js/src/main/web/tag/poll/Description.tag @@ -8,12 +8,12 @@ * 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% @@ -32,11 +32,12 @@ <input type="submit" class="button mainColorBackground" value="{__.next}"> </div> </form> - <script> - this.installBundle(opts.session, "poll_description", opts.emitter); - this.form = opts.form; - this.emitter = opts.emitter; - this.session = opts.session; + + <script type="es6"> + this.installBundle(this.opts.session, "poll_description", this.opts.emitter); + this.form = this.opts.form; + this.emitter = this.opts.emitter; + this.session = this.opts.session; this.model = this.form.model; let route = require("riot-route"); this.nextStep = (e) => { diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/Poll.tag b/pollen-ui-riot-js/src/main/web/tag/poll/Poll.tag index 414c398..4da7267 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/Poll.tag +++ b/pollen-ui-riot-js/src/main/web/tag/poll/Poll.tag @@ -1,8 +1,8 @@ -require('./Votes.tag'); -require('./Comments.tag'); -require('./Results.tag'); -require('./Choices.tag'); -require('./Settings.tag'); +require("./Votes.tag"); +require("./Comments.tag"); +require("./Results.tag"); +require("./Choices.tag"); +require("./Settings.tag"); <Poll> @@ -55,37 +55,37 @@ require('./Settings.tag'); <div ref="content" class="tab-content"/> </div> - <script> + <script type="es6"> this.poll = {title: ""}; - this.pollId = opts.pollId; - this.selectedTab = opts.tabName; - this.permission = opts.permission; - this.commentsCount = ' '; - this.votesCount = ' '; + this.pollId = this.opts.pollId; + this.selectedTab = this.opts.tabName; + this.permission = this.opts.permission; + this.commentsCount = " "; + this.votesCount = " "; this.withResults = true; let session = require("../../js/Session"); this.installBundle(session, "poll"); - let pollService = require('../../js/PollService'); - this.on('mount', () => { + let pollService = require("../../js/PollService"); + this.on("mount", () => { pollService.getPoll(this.pollId, this.permission).then(result => { this.poll = result; this.commentsCount = this.poll.commentCount; this.votesCount = this.poll.voteCount; this.choicesCount = this.poll.choiceCount; this.poll.$canVote = this.poll.canVote; - console.info("Poll::"); - console.info(this.poll); - if (this.selectedTab === 'settings' && !this.poll.permission) { + // console.info("Poll::"); + // console.info(this.poll); + if (this.selectedTab === "settings" && !this.poll.permission) { this.selectedTab = false; } if (!this.selectedTab) { - if (this.poll.status === 'VOTING' || this.poll.status === 'CREATED') { - this.selectedTab = 'votes'; - } else if (this.poll.status === 'ADDING_CHOICES') { - this.selectedTab = 'choices'; - } else if (this.poll.status === 'CLOSED') { - this.selectedTab = 'results'; + if (this.poll.status === "VOTING" || this.poll.status === "CREATED") { + this.selectedTab = "votes"; + } else if (this.poll.status === "ADDING_CHOICES") { + this.selectedTab = "choices"; + } else if (this.poll.status === "CLOSED") { + this.selectedTab = "results"; } } this.refresh(); @@ -100,13 +100,13 @@ require('./Settings.tag'); session: session, permission: this.permission }); - let countName = (this.selectedTab === 'results' || this.selectedTab === 'settings') ? '' : (this.selectedTab + 'Count'); + let countName = (this.selectedTab === "results" || this.selectedTab === "settings") ? "" : (this.selectedTab + "Count"); if (countName) { - tags[0].on('count', count => { + tags[0].on("count", count => { this[countName] = count; let args = {}; args[countName] = count; - console.info('update count on ' + countName + " = " + count); + // console.info("update count on " + countName + " = " + count); this.update(args); }); } @@ -153,14 +153,13 @@ require('./Settings.tag'); border: solid 2px #c8ccca; border-radius: 10px; padding: 15px 15px; - width: 90%; - margin-left: 20px; - margin-bottom: 10px; + margin: 0 20px 10px 20px; } .tab-content { margin-top: 20px; min-height: 300px; + width: 100%; } .legend { @@ -175,7 +174,7 @@ require('./Settings.tag'); } .tab-header { - width: 820px; + width: 100%; display: flex; flex-direction: row; /*padding-top: 20px;*/ @@ -242,4 +241,4 @@ require('./Settings.tag'); display: block; } </style> -</Poll> \ No newline at end of file +</Poll> diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/Polls.tag b/pollen-ui-riot-js/src/main/web/tag/poll/Polls.tag index 5a3fd6b..eff60c1 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/Polls.tag +++ b/pollen-ui-riot-js/src/main/web/tag/poll/Polls.tag @@ -1,4 +1,4 @@ -require('../Pagination.tag'); +require("../Pagination.tag"); <Polls> <div class="body-container"> @@ -48,7 +48,7 @@ require('../Pagination.tag'); <tr> <th colspan="7"> <div> - <Pagination ref=pagination" sortName='{sortName}' sortValue='false' callback="{callback}"/> + <Pagination ref="pagination" sortName="{sortName}" sortValue="false" callback="{callback}"/> </div> </th> </tr> @@ -58,34 +58,34 @@ require('../Pagination.tag'); </div> - <script> + <script type="es6"> let session = require("../../js/Session"); this.installBundle(session, "polls", locale => { this.moment.locale(locale); this.refreshPolls(); }); - this.moment = require('moment'); - this.moment.locale(opts.session.locale); + this.moment = require("moment"); + this.moment.locale(this.opts.session.locale); - this.sortName = 'title'; + this.sortName = "title"; this.sortValue = false; // means asc - this.method = opts.method; + this.method = this.opts.method; this.polls = null; - let pollService = require('../../js/PollService'); + let pollService = require("../../js/PollService"); this.callback = (pagination) => { - console.info("Request data with pagination::"); + // console.info("Request data with pagination::"); if (!pagination.order) { pagination.order = this.sortName; pagination.desc = this.sortValue; } - console.info(pagination); + // console.info(pagination); return pollService[this.method](pagination).then((result) => { this.polls = result.elements; - console.info('Polls::'); - console.info(this.polls); + // console.info("Polls::"); + // console.info(this.polls); this.refreshPolls(); this.update(); return result; @@ -94,48 +94,48 @@ require('../Pagination.tag'); this.refreshPolls = () => { this.polls.forEach(p => { - p.createDateStr = this.moment(p.createDate).format('llll'); - p.choiceDates = p.beginChoiceDate ? this.moment(p.beginChoiceDate).format('llll') : ''; + p.createDateStr = this.moment(p.createDate).format("llll"); + p.choiceDates = p.beginChoiceDate ? this.moment(p.beginChoiceDate).format("llll") : ""; if (p.endChoiceDate) { - p.choiceDates += ' -> ' + this.moment(p.endChoiceDate).format('llll'); + p.choiceDates += " -> " + this.moment(p.endChoiceDate).format("llll"); } - p.voteDates = p.beginDate ? this.moment(p.beginDate).format('llll') : ''; + p.voteDates = p.beginDate ? this.moment(p.beginDate).format("llll") : ""; if (p.endDate) { - p.voteDates += ' -> ' + this.moment(p.endDate).format('llll'); + p.voteDates += " -> " + this.moment(p.endDate).format("llll"); } p.statusStr = this.__[p.status]; }); }; - this.on('mount', () => { + this.on("mount", () => { this.pagination = this.tags.pagination; this.sortOwner = this.refs.sortName; - this.refs.sortName.setAttribute('sortName', 'title'); - this.refs.sortCreateDate.setAttribute('sortName', 'topiaCreateDate'); + this.refs.sortName.setAttribute("sortName", "title"); + this.refs.sortCreateDate.setAttribute("sortName", "topiaCreateDate"); }); this.toggleSort = (e) => { - console.info(this.refs.sortName); + // console.info(this.refs.sortName); if (this.sortOwner === e.target) { - this.sortOwner.classList.toggle('fa-sort-amount-asc'); - this.sortOwner.classList.toggle('fa-sort-amount-desc'); + this.sortOwner.classList.toggle("fa-sort-amount-asc"); + this.sortOwner.classList.toggle("fa-sort-amount-desc"); this.sortValue = !this.sortValue; } else { - this.sortOwner.classList.add('fa-sort'); - this.sortOwner.classList.add('disabled'); - this.sortOwner.classList.remove('fa-sort-amount-desc'); - this.sortOwner.classList.remove('fa-sort-amount-asc'); + this.sortOwner.classList.add("fa-sort"); + this.sortOwner.classList.add("disabled"); + this.sortOwner.classList.remove("fa-sort-amount-desc"); + this.sortOwner.classList.remove("fa-sort-amount-asc"); this.sortOwner = e.target; - this.sortOwner.classList.remove('disabled'); - this.sortOwner.classList.remove('fa-sort'); - this.sortOwner.classList.remove('fa-sort-amount-desc'); - this.sortOwner.classList.add('fa-sort-amount-asc'); + this.sortOwner.classList.remove("disabled"); + this.sortOwner.classList.remove("fa-sort"); + this.sortOwner.classList.remove("fa-sort-amount-desc"); + this.sortOwner.classList.add("fa-sort-amount-asc"); this.sortValue = true; } - this.pagination.onSortChange(this.sortOwner.getAttribute('sortName'), this.sortValue); + this.pagination.onSortChange(this.sortOwner.getAttribute("sortName"), this.sortValue); }; </script> @@ -210,4 +210,4 @@ require('../Pagination.tag'); font-size: 20px; } </style> -</Polls> \ No newline at end of file +</Polls> diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/Results.tag b/pollen-ui-riot-js/src/main/web/tag/poll/Results.tag index e5442c1..c801231 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/Results.tag +++ b/pollen-ui-riot-js/src/main/web/tag/poll/Results.tag @@ -12,7 +12,7 @@ <div if="{results.nbVotants>1}">{results.nbVotants} {__.voters}</div> <br/> <div class="result-content" each="{result in results.scores}"> - <div class='bold'>{result.choice}</div> + <div class="bold">{result.choice}</div> <div>{parent.__.rank} {result.scoreOrder + 1}</div> <div>{parent.__.votesCount} {result.scoreValue}</div> </div> @@ -20,7 +20,7 @@ </div> </div> - <script> + <script type="es6"> this.loaded = false; let session = require("../../js/Session"); this.installBundle(session, "poll_results"); @@ -28,41 +28,41 @@ let choiceService = require("../../js/ChoiceService"); let moment = require("moment"); - this.pollId = opts.pollId; - this.poll = opts.poll; - this.permission = opts.permission; - console.info("permission:: " + this.permission); + this.pollId = this.opts.pollId; + this.poll = this.opts.poll; + this.permission = this.opts.permission; + // console.info("permission:: " + this.permission); this.results = {nbVotants: 0, scores: []}; this.choices = []; this.scores = []; - this.on('mount', () => { + this.on("mount", () => { choiceService.getChoices(this.pollId, this.permission).then((result) => { - console.info("get choices"); - console.info(result); + // console.info("get choices"); + // console.info(result); this.choices = result; this.choices.forEach(c => { - if (c.choiceType==='DATE') { - if (c.choiceValue.indexOf('T')>-1) { - c.choiceValueStr = moment(c.choiceValue).format('LLL'); - }else { - c.choiceValueStr = moment(c.choiceValue).format('LL'); + if (c.choiceType === "DATE") { + if (c.choiceValue.indexOf("T") > -1) { + c.choiceValueStr = moment(c.choiceValue).format("LLL"); + } else { + c.choiceValueStr = moment(c.choiceValue).format("LL"); } } else { - c.choiceValueStr =c.choiceValue; + c.choiceValueStr = c.choiceValue; } }); - resultService.getResults(this.pollId, this.permission).then((result) => { - console.info("get results"); - console.info(result); - this.results = result; + resultService.getResults(this.pollId, this.permission).then((result2) => { + // console.info("get results"); + // console.info(result); + this.results = result2; this.results.scores.forEach(s => { this.choices.forEach(c => { - if (c.id == s.choiceId) { + if (c.id === s.choiceId) { s.choice = c.choiceValueStr; } }); @@ -105,4 +105,4 @@ } </style> -</Results> \ No newline at end of file +</Results> diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/Settings.tag b/pollen-ui-riot-js/src/main/web/tag/poll/Settings.tag index 158a328..b8c5b03 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/Settings.tag +++ b/pollen-ui-riot-js/src/main/web/tag/poll/Settings.tag @@ -312,32 +312,32 @@ </div> </form> - <script> - this.session = opts.session; - if (opts.form) { - this.mode = 'create'; - this.form = opts.form; + <script type="es6"> + this.session = this.opts.session; + if (this.opts.form) { + this.mode = "create"; + this.form = this.opts.form; this.showOptions = this.form.showOptions; } else { - this.mode = 'edit'; - this.form = require('../../js/PollForm'); - this.form.model = opts.poll; + this.mode = "edit"; + this.form = require("../../js/PollForm"); + this.form.model = this.opts.poll; this.showOptions = true; } - this.$private = this.form.model.pollType != 'FREE'; + this.$private = this.form.model.pollType !== "FREE"; - this.installBundle(opts.session, "poll_settings"); + this.installBundle(this.opts.session, "poll_settings"); this.showHelp = false; - let moment = require('moment'); - let pollService = require('../../js/PollService'); + let moment = require("moment"); + let pollService = require("../../js/PollService"); - this.toggleChoiceAddAllowed = e => { + this.toggleChoiceAddAllowed = () => { this.form.model.choiceAddAllowed = !this.form.model.choiceAddAllowed; }; - this.toggleLimitChoices = e => { + this.toggleLimitChoices = () => { this.form.model.limitChoices = !this.form.model.limitChoices; }; @@ -346,38 +346,38 @@ }; this.showVoteCountingTypeHelp = e => { - this.refs.voteCountingTypeHelp.innerHTML = e.target.getAttribute('help'); + this.refs.voteCountingTypeHelp.innerHTML = e.target.getAttribute("help"); }; this.publicPoll = () => { - if (this.form.model.pollType != 'FREE') { - this.form.model.pollType = 'FREE'; + if (this.form.model.pollType !== "FREE") { + this.form.model.pollType = "FREE"; this.form.model.withMe = false; this.$private = false; this.update(); } }; this.privatePoll = () => { - if (this.form.model.pollType != 'RESTRICTED') { - this.form.model.pollType = 'RESTRICTED'; + if (this.form.model.pollType !== "RESTRICTED") { + this.form.model.pollType = "RESTRICTED"; this.$private = true; this.update(); } }; - this.withMe = (e) => { + this.withMe = () => { this.form.model.withMe = !this.form.model.withMe; }; - this.help = e => { - let target = e.target; - let helpId = 'Help_' + target.parentNode.parentNode.id; - console.info(helpId); + this.help = () => { + // let target = e.target; + // let helpId = "Help_" + target.parentNode.parentNode.id; + // console.info(helpId); this.showHelp = true; this.update({showHelp: this.showHelp}); }; - this.closeHelp = e => { + this.closeHelp = () => { this.showHelp = false; this.update({showHelp: this.showHelp}); }; @@ -387,24 +387,24 @@ e.stopPropagation(); this.form.fromDom(this.refs.form); - if (this.mode === 'create') { + if (this.mode === "create") { this.form.nextStep(); } - if (this.mode === 'edit') { - pollService.save(this.form.model).then(result => { - console.info("poll settings updated"); - console.info(result); + if (this.mode === "edit") { + pollService.save(this.form.model).then(() => { + // console.info("poll settings updated"); + // console.info(result); }); } }; this.formatDate = (date) => { if (date) { - date = moment(date).format('YYYY-MM-DDThh:mm'); + date = moment(date).format("YYYY-MM-DDThh:mm"); } return date; }; - this.on('mount', () => { + this.on("mount", () => { let model = this.form.model; @@ -413,25 +413,25 @@ model.endDate = this.formatDate(model.endDate); model.endChoiceDate = this.formatDate(model.endChoiceDate); - let voteCountingTypeService = require('../../js/VoteCountingTypeService'); + let voteCountingTypeService = require("../../js/VoteCountingTypeService"); voteCountingTypeService.getVoteCountingTypes().then(result => { this.voteCountingTypes = result; this.update({voteCountingTypes: this.voteCountingTypes}); - console.info('voteCountingTypes'); - console.info(this.voteCountingTypes); + // console.info("voteCountingTypes"); + // console.info(this.voteCountingTypes); this.form.fillForm(this.refs.form); - this.showVoteCountingTypeHelp({target: this.refs['voteCountingType_' + model.voteCountingType]}); + this.showVoteCountingTypeHelp({target: this.refs["voteCountingType_" + model.voteCountingType]}); }); }); - this.previousStep = e => { + this.previousStep = () => { this.form.toDom(this.refs.form); this.form.previousStep(); }; - this.skip = e => { + this.skip = () => { this.form.nextStep(); }; @@ -439,9 +439,9 @@ e.preventDefault(); e.stopPropagation(); this.closeHelp(e); - let id = e.currentTarget.href.substring(e.currentTarget.href.indexOf('#') + 1); - if (id.indexOf('_') > -1) { - id = id.substring(0, id.indexOf('_')); + let id = e.currentTarget.href.substring(e.currentTarget.href.indexOf("#") + 1); + if (id.indexOf("_") > -1) { + id = id.substring(0, id.indexOf("_")); } document.getElementById(id).scrollIntoView(); }; @@ -450,7 +450,7 @@ <style> form { - width: 800px; + width: 100%; } textarea { diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/Voters.tag b/pollen-ui-riot-js/src/main/web/tag/poll/Voters.tag index f45c772..16af019 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/Voters.tag +++ b/pollen-ui-riot-js/src/main/web/tag/poll/Voters.tag @@ -8,12 +8,12 @@ * 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% @@ -60,62 +60,62 @@ </form> - <script> - this.installBundle(opts.session, "poll_voters"); - this.form = opts.form; - this.$private = this.form.model.pollType != 'FREE'; + <script type="es6"> + this.installBundle(this.opts.session, "poll_voters"); + this.form = this.opts.form; + this.$private = this.form.model.pollType !== "FREE"; this.participants = ""; - this.previousStep = (e) => { + this.previousStep = () => { this.form.previousStep(); }; - this.on('mount', () => { + this.on("mount", () => { if (this.$private) { - this.refs.privateType.checked='checked'; + this.refs.privateType.checked = "checked"; } else { - this.refs.publicType.checked='checked'; + this.refs.publicType.checked = "checked"; } if (this.form.model.withMe) { - this.refs.withMe.checked='checked'; + this.refs.withMe.checked = "checked"; } }); this.action = (e) => { e.preventDefault(); e.stopPropagation(); - this.form.model.participants = this.refs.participants.value.split(' '); - console.info('Poll form to save'); - console.info(this.form.model); - console.info('Poll choices to save'); - console.info(this.form.choices); + this.form.model.participants = this.refs.participants.value.split(" "); + // console.info("Poll form to save"); + // console.info(this.form.model); + // console.info("Poll choices to save"); + // console.info(this.form.choices); - this.form.create().catch(errors => { - console.info("Can't save poll"); - console.info(errors); + this.form.create().catch(() => { + // console.info("Can"t save poll"); + // console.info(errors); }); }; this.publicPoll = () => { - if (this.form.model.pollType != 'FREE') { - this.form.model.pollType = 'FREE'; + if (this.form.model.pollType !== "FREE") { + this.form.model.pollType = "FREE"; this.form.model.withMe = false; this.$private = false; this.update(); } }; this.privatePoll = () => { - if (this.form.model.pollType != 'RESTRICTED') { - this.form.model.pollType = 'RESTRICTED'; + if (this.form.model.pollType !== "RESTRICTED") { + this.form.model.pollType = "RESTRICTED"; this.$private = true; this.update(); } }; - this.withMe = (e) => { + this.withMe = () => { this.form.model.withMe = !this.form.model.withMe; }; this.participantsChanged = (e) => { this.participants = e.target.value; - console.info(this.participants); - } + // console.info(this.participants); + }; </script> <style> diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/Votes.tag b/pollen-ui-riot-js/src/main/web/tag/poll/Votes.tag index 56e17a7..5d10108 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/Votes.tag +++ b/pollen-ui-riot-js/src/main/web/tag/poll/Votes.tag @@ -87,32 +87,33 @@ </div> </div> - <script> + <script type="es6"> this.voteId = null; this.loaded = false; + let moment = require("moment"); this.i18nCallback = (locale) => { moment.locale(locale); - this.votePeriod = ''; + this.votePeriod = ""; if (this.poll.beginDate) { - this.votePeriod += moment(this.poll.beginDate).format('LLL'); + this.votePeriod += moment(this.poll.beginDate).format("LLL"); } if (this.poll.endDate) { - this.votePeriod += ' - ' + moment(this.poll.endDate).format('LLL'); + this.votePeriod += " - " + moment(this.poll.endDate).format("LLL"); } - if (this.votePeriod != '') { - this.votePeriod = '( ' + this.votePeriod + ' )'; + if (this.votePeriod !== "") { + this.votePeriod = "( " + this.votePeriod + " )"; } this.update({votePeriod: this.votePeriod}); this.choices.forEach(c => { - if (c.choiceType==='DATE') { - if (c.choiceValue.indexOf('T')>-1) { - c.choiceValueStr = moment(c.choiceValue).format('LLL'); - }else { - c.choiceValueStr = moment(c.choiceValue).format('LL'); + if (c.choiceType === "DATE") { + if (c.choiceValue.indexOf("T") > -1) { + c.choiceValueStr = moment(c.choiceValue).format("LLL"); + } else { + c.choiceValueStr = moment(c.choiceValue).format("LL"); } } else { - c.choiceValueStr =c.choiceValue; + c.choiceValueStr = c.choiceValue; } }); }; @@ -122,26 +123,26 @@ let voteService = require("../../js/VoteService"); let choiceService = require("../../js/ChoiceService"); let voteCountingTypeService = require("../../js/VoteCountingTypeService"); - let moment = require('moment'); - this.pollId = opts.pollId; - this.permission = opts.permission; - this.poll = opts.poll; - this.voting = this.poll.status === 'VOTING' || this.poll.status === 'CLOSED'; + this.pollId = this.opts.pollId; + this.permission = this.opts.permission; + this.poll = this.opts.poll; + + this.voting = this.poll.status === "VOTING" || this.poll.status === "CLOSED"; this.votes = []; this.choices = []; - this.on('mount', () => { + this.on("mount", () => { if (this.voting && session.isConnected() && this.poll.canVote) { session.getUser().then(user => { this.form.voterName.value = user.name; - }) + }); } voteCountingTypeService.getVoteCountingType(this.poll.voteCountingType).then(voteCountingType => { - console.info('voteCountingType'); - console.info(voteCountingType); + // console.info("voteCountingType"); + // console.info(voteCountingType); this.voteCountingType = voteCountingType; this.renderType = voteCountingType.renderType; this.update({renderType: this.renderType}); @@ -157,17 +158,17 @@ this.cancelEditVote = () => { let previousVoteId = this.voteId; this.voteId = null; - let tr = this.refs['vote_' + previousVoteId]; + let tr = this.refs["vote_" + previousVoteId]; tr.classList.remove("selected"); this.votes.forEach(v => { - if (previousVoteId == v.id) { + if (previousVoteId === v.id) { v.choice.forEach(c => { - if (this.renderType === 'text') { - this.form['vote_' + previousVoteId + "_" + c.choiceId].value = c.voteValue; + if (this.renderType === "text") { + this.form["vote_" + previousVoteId + "_" + c.choiceId].value = c.voteValue; } else { - this.form['vote_' + previousVoteId + "_" + c.choiceId].checked = c.voteValue == 1 ? 'checked' : ''; + this.form["vote_" + previousVoteId + "_" + c.choiceId].checked = c.voteValue === 1 ? "checked" : ""; } - }) + }); } }); @@ -175,21 +176,21 @@ this.onEditVote = (e) => { if (this.voteId) { - let tr = this.form['vote_' + this.voteId]; + let tr = this.form["vote_" + this.voteId]; tr.classList.remove("selected"); } this.voteId = e.target.parentNode.parentNode.id; let tr = e.target.parentNode.parentNode.parentNode.parentNode; tr.classList.add("selected"); this.votes.forEach(v => { - if (this.voteId == v.id) { - this.form['vote_' + this.voteId + "_voter"].value = v.voterName; + if (this.voteId === v.id) { + this.form["vote_" + this.voteId + "_voter"].value = v.voterName; } }); }; this.getChoiceVoteValue = (t) => { - if (this.renderType === 'text') { + if (this.renderType === "text") { return this.form[t].value; } return this.form[t].checked ? 1 : 0; @@ -212,7 +213,7 @@ vote.choice.push({ choiceId: c.id, - voteValue: this.getChoiceVoteValue(c.id + '.voteValue') + voteValue: this.getChoiceVoteValue(c.id + ".voteValue") }); }); @@ -220,47 +221,47 @@ } else { vote.id = this.voteId; - vote.voterName = this.form['vote_' + this.voteId + '_voter'].value; + vote.voterName = this.form["vote_" + this.voteId + "_voter"].value; this.votes.forEach(v => { - if (this.voteId == v.id) { + if (this.voteId === v.id) { v.choice.forEach(c => { vote.choice.push({ id: c.id, choiceId: c.choiceId, - voteValue: this.getChoiceVoteValue('vote_' + this.voteId + "_" + c.choiceId) + voteValue: this.getChoiceVoteValue("vote_" + this.voteId + "_" + c.choiceId) }); - }) + }); } }); } - console.info("Vote to send:"); - console.info(vote); + // console.info("Vote to send:"); + // console.info(vote); if (newVote) { voteService.addVote(this.pollId, vote) - .then((result) => { - console.info("created vote"); - console.info(result); + .then(() => { + // console.info("created vote"); + // console.info(result); this.refresh(); this.refs.voterName.value = null; let form = this.refs.form; this.choices.forEach(c => { - if (this.renderType === 'text') { - form[c.id + '.voteValue'].value = ''; + if (this.renderType === "text") { + form[c.id + ".voteValue"].value = ""; } else { - form[c.id + '.voteValue'].checked = ''; + form[c.id + ".voteValue"].checked = ""; } }); }); } else { - voteService.updateVote(this.pollId, vote, this.permission || vote.permission || '') - .then((result) => { - console.info("updated vote"); - console.info(result); + voteService.updateVote(this.pollId, vote, this.permission || vote.permission || "") + .then(() => { + // console.info("updated vote"); + // console.info(result); this.refresh(); this.cancelEditVote(); @@ -271,13 +272,13 @@ this.deleteVote = (e) => { let voteId = e.target.parentNode.parentNode.id; this.votes.forEach(vote => { - if (vote.id == voteId) { + if (vote.id === voteId) { let response = confirm(this.__delete); if (response) { - return voteService.deleteVote(this.pollId, voteId, this.permission || vote.permission || '') - .then((result) => { - console.info("delete vote"); - console.info(result); + voteService.deleteVote(this.pollId, voteId, this.permission || vote.permission || "") + .then(() => { + // console.info("delete vote"); + // console.info(result); this.refresh(); }); } @@ -291,9 +292,9 @@ } return voteService.getVotes(this.pollId, this.permission).then((result) => { this.votes = result; - console.info("Reload votes"); - console.info(this.votes); - this.trigger('count', result.length); + // console.info("Reload votes"); + // console.info(this.votes); + this.trigger("count", result.length); this.loaded = true; this.update(); return result; @@ -302,8 +303,8 @@ choiceService.getChoices(this.pollId, this.permission) .then((result) => { - console.info("get choices"); - console.info(result); + // console.info("get choices"); + // console.info(result); this.choices = result; this.i18nCallback(); @@ -343,7 +344,7 @@ } .vote-container { - width: 800px; + width: 100%; } .right { @@ -381,7 +382,7 @@ } .legend { - width: 800px; + width: 100%; } input.button { @@ -405,7 +406,6 @@ th:first-child { border-right: 1px solid #ddd; border-top: none; - width: 400px; } td:first-child { @@ -440,11 +440,14 @@ border-right: 1px solid #ddd; vertical-align: middle; height: 50px; + padding-left: 10px; + padding-right: 10px; } table { - width: 800px; border-spacing: 0; + margin-left: auto; + margin-right: auto; } .check { @@ -463,4 +466,4 @@ margin-top: 10px; } </style> -</Votes> \ No newline at end of file +</Votes> diff --git a/pollen-ui-riot-js/src/main/web/tag/popup/AccountCreated.tag b/pollen-ui-riot-js/src/main/web/tag/popup/AccountCreated.tag index 07b3308..f48711d 100644 --- a/pollen-ui-riot-js/src/main/web/tag/popup/AccountCreated.tag +++ b/pollen-ui-riot-js/src/main/web/tag/popup/AccountCreated.tag @@ -8,12 +8,12 @@ * 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% @@ -33,7 +33,7 @@ </div> </div> - <script> + <script type="es6"> let session = require("../../js/Session"); let route = require("riot-route"); diff --git a/pollen-ui-riot-js/src/main/web/tag/popup/NewPassword.tag b/pollen-ui-riot-js/src/main/web/tag/popup/NewPassword.tag index 35a65ee..445cb49 100644 --- a/pollen-ui-riot-js/src/main/web/tag/popup/NewPassword.tag +++ b/pollen-ui-riot-js/src/main/web/tag/popup/NewPassword.tag @@ -8,12 +8,12 @@ * 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% @@ -38,7 +38,7 @@ </div> - <script> + <script type="es6"> let session = require("../../js/Session"); let authService = require("../../js/AuthService"); @@ -76,7 +76,7 @@ this.update(); }) .catch(() => { - this.error = __.error_emailNotFound; + this.error = this.__.error_emailNotFound; this.update(); }); } diff --git a/pollen-ui-riot-js/src/main/web/tag/popup/ResendValidation.tag b/pollen-ui-riot-js/src/main/web/tag/popup/ResendValidation.tag index 4a173cb..191c8a8 100644 --- a/pollen-ui-riot-js/src/main/web/tag/popup/ResendValidation.tag +++ b/pollen-ui-riot-js/src/main/web/tag/popup/ResendValidation.tag @@ -8,12 +8,12 @@ * 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% @@ -38,7 +38,7 @@ </div> - <script> + <script type="es6"> let session = require("../../js/Session"); let authService = require("../../js/AuthService"); @@ -77,7 +77,7 @@ this.update(); }) .catch(() => { - this.error = __.error_emailNotFound; + this.error = this.__.error_emailNotFound; this.update(); }); } -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm