This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository pollen. See https://gitlab.nuiton.org/chorem/pollen.git commit 5b124a40654d078684151b9ce1efca11f9208206 Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Mon Jun 26 11:51:49 2017 +0200 ajout de la réactivation des avertissements + style ref #63 --- .../org/chorem/pollen/rest/api/v1/ChoiceApi.java | 5 +- .../org/chorem/pollen/rest/api/v1/CommentApi.java | 5 +- .../org/chorem/pollen/rest/api/v1/PollApi.java | 5 +- pollen-rest-api/src/main/resources/mapping | 32 ++++---- .../pollen/services/service/ReportService.java | 26 +++--- pollen-ui-riot-js/src/main/web/css/main.css | 6 +- pollen-ui-riot-js/src/main/web/i18n.json | 2 + pollen-ui-riot-js/src/main/web/js/ChoiceService.js | 8 +- .../src/main/web/js/CommentService.js | 8 ++ pollen-ui-riot-js/src/main/web/js/Poll.js | 4 +- pollen-ui-riot-js/src/main/web/js/PollService.js | 8 +- .../src/main/web/tag/poll/Report.tag.html | 94 +++++----------------- .../src/main/web/tag/popup/Modal.tag.html | 13 +++ 13 files changed, 90 insertions(+), 126 deletions(-) diff --git a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/ChoiceApi.java b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/ChoiceApi.java index 8db3babf..ba5d78b3 100644 --- a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/ChoiceApi.java +++ b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/ChoiceApi.java @@ -23,7 +23,6 @@ package org.chorem.pollen.rest.api.v1; import org.chorem.pollen.persistence.entity.Choice; import org.chorem.pollen.persistence.entity.Poll; -import org.chorem.pollen.persistence.entity.Report; import org.chorem.pollen.services.bean.ChoiceBean; import org.chorem.pollen.services.bean.PollenEntityId; import org.chorem.pollen.services.bean.PollenEntityRef; @@ -84,9 +83,9 @@ public class ChoiceApi extends WebMotionController { return reportService.getChoiceReports(pollId.getEntityId(), choiceId.getEntityId()); } - public void ignoreReport(ReportService reportService, PollenEntityId<Poll> pollId, PollenEntityId<Choice> choiceId, PollenEntityId<Report> reportId) { + public void saveReport(ReportService reportService, PollenEntityId<Poll> pollId, PollenEntityId<Choice> choiceId, ReportBean report) { - reportService.ignoreChoiceReport(pollId.getEntityId(), choiceId.getEntityId(), reportId.getEntityId()); + reportService.saveChoiceReport(pollId.getEntityId(), choiceId.getEntityId(), report); } diff --git a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/CommentApi.java b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/CommentApi.java index f8d074e7..f1b8ef18 100644 --- a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/CommentApi.java +++ b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/CommentApi.java @@ -23,7 +23,6 @@ package org.chorem.pollen.rest.api.v1; import org.chorem.pollen.persistence.entity.Comment; import org.chorem.pollen.persistence.entity.Poll; -import org.chorem.pollen.persistence.entity.Report; import org.chorem.pollen.services.bean.CommentBean; import org.chorem.pollen.services.bean.PaginationParameterBean; import org.chorem.pollen.services.bean.PaginationResultBean; @@ -93,9 +92,9 @@ public class CommentApi extends WebMotionController { return reportService.getCommentReports(pollId.getEntityId(), commentId.getEntityId()); } - public void ignoreReport(ReportService reportService, PollenEntityId<Poll> pollId, PollenEntityId<Comment> commentId, PollenEntityId<Report> reportId) { + public void saveReport(ReportService reportService, PollenEntityId<Poll> pollId, PollenEntityId<Comment> commentId, ReportBean report) { - reportService.ignoreCommentReport(pollId.getEntityId(), commentId.getEntityId(), reportId.getEntityId()); + reportService.saveCommentReport(pollId.getEntityId(), commentId.getEntityId(), report); } diff --git a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollApi.java b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollApi.java index 4bc7d89f..64be44f9 100644 --- a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollApi.java +++ b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollApi.java @@ -24,7 +24,6 @@ package org.chorem.pollen.rest.api.v1; import com.google.common.collect.Lists; import org.chorem.pollen.persistence.entity.ChoiceType; import org.chorem.pollen.persistence.entity.Poll; -import org.chorem.pollen.persistence.entity.Report; import org.chorem.pollen.services.bean.ChoiceBean; import org.chorem.pollen.services.bean.PaginationParameterBean; import org.chorem.pollen.services.bean.PaginationResultBean; @@ -156,9 +155,9 @@ public class PollApi extends WebMotionController { return reportService.getPollReports(pollId.getEntityId()); } - public void ignoreReport(ReportService reportService, PollenEntityId<Poll> pollId, PollenEntityId<Report> reportId) { + public void saveReport(ReportService reportService, PollenEntityId<Poll> pollId, ReportBean report) { - reportService.ignorePollReport(pollId.getEntityId(), reportId.getEntityId()); + reportService.savePollReport(pollId.getEntityId(), report); } } diff --git a/pollen-rest-api/src/main/resources/mapping b/pollen-rest-api/src/main/resources/mapping index 4461cf0a..6239c1a9 100644 --- a/pollen-rest-api/src/main/resources/mapping +++ b/pollen-rest-api/src/main/resources/mapping @@ -61,12 +61,12 @@ POST,PUT /v1/resendValidation AuthApi.resendValidation # ChoiceApi -GET /v1/polls/{pollId}/choices ChoiceApi.getChoices -POST /v1/polls/{pollId}/choices ChoiceApi.addChoice -GET /v1/polls/{pollId}/choices/{choiceId} ChoiceApi.getChoice -POST /v1/polls/{pollId}/choices/{choiceId}/reports ChoiceApi.addReport -GET /v1/polls/{pollId}/choices/{choiceId}/reports ChoiceApi.getReports -GET /v1/polls/{pollId}/choices/{choiceId}/reports/{reportId}/ignore ChoiceApi.ignoreReport +GET /v1/polls/{pollId}/choices ChoiceApi.getChoices +POST /v1/polls/{pollId}/choices ChoiceApi.addChoice +GET /v1/polls/{pollId}/choices/{choiceId} ChoiceApi.getChoice +POST /v1/polls/{pollId}/choices/{choiceId}/reports ChoiceApi.addReport +GET /v1/polls/{pollId}/choices/{choiceId}/reports ChoiceApi.getReports +POST /v1/polls/{pollId}/choices/{choiceId}/reports/{reportId} ChoiceApi.saveReport #fix me POST,PUT /v1/polls/{pollId}/choices/{choiceId} ChoiceApi.editChoice @@ -75,15 +75,15 @@ DELETE /v1/polls/{pollId}/choices/{choiceId} ChoiceApi.deleteChoice # CommentApi -GET /v1/polls/{pollId}/comments CommentApi.getComments -POST /v1/polls/{pollId}/comments CommentApi.addComment -GET /v1/polls/{pollId}/comments/new CommentApi.getNewComment -GET /v1/polls/{pollId}/comments/{commentId} CommentApi.getComment -PUT,POST /v1/polls/{pollId}/comments/{commentId} CommentApi.editComment -DELETE /v1/polls/{pollId}/comments/{commentId} CommentApi.deleteComment -POST /v1/polls/{pollId}/comments/{commentId}/reports CommentApi.addReport -GET /v1/polls/{pollId}/comments/{commentId}/reports CommentApi.getReports -GET /v1/polls/{pollId}/comments/{commentId}/reports/{reportId}/ignore CommentApi.ignoreReport +GET /v1/polls/{pollId}/comments CommentApi.getComments +POST /v1/polls/{pollId}/comments CommentApi.addComment +GET /v1/polls/{pollId}/comments/new CommentApi.getNewComment +GET /v1/polls/{pollId}/comments/{commentId} CommentApi.getComment +PUT,POST /v1/polls/{pollId}/comments/{commentId} CommentApi.editComment +DELETE /v1/polls/{pollId}/comments/{commentId} CommentApi.deleteComment +POST /v1/polls/{pollId}/comments/{commentId}/reports CommentApi.addReport +GET /v1/polls/{pollId}/comments/{commentId}/reports CommentApi.getReports +POST /v1/polls/{pollId}/comments/{commentId}/reports/{reportId} CommentApi.saveReport # FavoriteListApi @@ -138,7 +138,7 @@ GET /v1/polls/{pollId}/feed PollApi.getFeedForPoll POST /v1/polls/{pollId}/reports PollApi.addReport GET /v1/polls/{pollId}/reports PollApi.getReports -GET /v1/polls/{pollId}/reports/{reportId}/ignore PollApi.ignoreReport +POST /v1/polls/{pollId}/reports/{reportId} PollApi.saveReport # PollenResourceApi diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/ReportService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/ReportService.java index 746db08e..d5cdfe17 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/ReportService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/ReportService.java @@ -42,12 +42,11 @@ public class ReportService extends PollenServiceSupport { } - public void ignorePollReport(String pollId, String reportId) { + public void savePollReport(String pollId, ReportBean reportBean) { checkNotNull(pollId); - checkNotNull(reportId); checkPermission(PermissionVerb.editPoll, pollId); - ignoreReport(reportId, pollId); + saveReport(reportBean, pollId); } public void addChoiceReport(String pollId, String choiceId, ReportBean reportBean) throws InvalidFormException { @@ -76,13 +75,11 @@ public class ReportService extends PollenServiceSupport { } - public void ignoreChoiceReport(String pollId, String choiceId, String reportId) { + public void saveChoiceReport(String pollId, String choiceId, ReportBean reportBean) { checkNotNull(pollId); - checkNotNull(choiceId); - checkNotNull(reportId); checkPermission(PermissionVerb.editPoll, pollId); - ignoreReport(reportId, choiceId); + saveReport(reportBean, choiceId); } public void addCommentReport(String pollId, String commentId, ReportBean reportBean) throws InvalidFormException { @@ -111,13 +108,11 @@ public class ReportService extends PollenServiceSupport { } - public void ignoreCommentReport(String pollId, String commentId, String reportId) { + public void saveCommentReport(String pollId, String commentId, ReportBean reportBean) { checkNotNull(pollId); - checkNotNull(commentId); - checkNotNull(reportId); checkPermission(PermissionVerb.editPoll, pollId); - ignoreReport(reportId, commentId); + saveReport(reportBean, commentId); } @@ -161,17 +156,18 @@ public class ReportService extends PollenServiceSupport { return errors; } - protected void ignoreReport(String reportId, String targetId) { + protected void saveReport(ReportBean reportBean, String targetId) { - checkNotNull(reportId); + checkNotNull(reportBean); + checkIsPersisted(reportBean); checkNotNull(targetId); Report report = getReportTopiaDao() - .forTopiaIdEquals(reportId) + .forTopiaIdEquals(reportBean.getEntityId()) .addEquals(Report.PROPERTY_TARGET_ID, targetId) .findUnique(); - report.setIgnore(true); + report.setIgnore(reportBean.isIgnore()); commit(); } diff --git a/pollen-ui-riot-js/src/main/web/css/main.css b/pollen-ui-riot-js/src/main/web/css/main.css index 8353d887..7f8d622c 100644 --- a/pollen-ui-riot-js/src/main/web/css/main.css +++ b/pollen-ui-riot-js/src/main/web/css/main.css @@ -209,13 +209,15 @@ ul { } .info-label { - font-size: 0.5em; + font-size: 0.8em; color: var(--info); + cursor: pointer; } .error-label { - font-size: 0.5em; + font-size: 0.8em; color: var(--error); + cursor: pointer; } /* Steps */ diff --git a/pollen-ui-riot-js/src/main/web/i18n.json b/pollen-ui-riot-js/src/main/web/i18n.json index 9ae584aa..12b985a2 100644 --- a/pollen-ui-riot-js/src/main/web/i18n.json +++ b/pollen-ui-riot-js/src/main/web/i18n.json @@ -483,6 +483,7 @@ "report_score": "Score", "report_reports_title": "Signalements", "report_toIgnore": "Ignorer", + "report_toEnable": "Ré-activer", "report_ignores": "Ignorés" }, "en": { @@ -957,6 +958,7 @@ "report_score": "Score", "report_reports_title": "Reports", "report_toIgnore": "Ignore", + "report_toEnable": "Enable", "report_ignores": "Ignores" } } diff --git a/pollen-ui-riot-js/src/main/web/js/ChoiceService.js b/pollen-ui-riot-js/src/main/web/js/ChoiceService.js index c48203f0..01c7975e 100644 --- a/pollen-ui-riot-js/src/main/web/js/ChoiceService.js +++ b/pollen-ui-riot-js/src/main/web/js/ChoiceService.js @@ -71,12 +71,12 @@ class ChoiceService extends FetchService { return this.getWithParams("/v1/polls/" + pollId + "/choices/" + choiceId + "/reports", args); } - ignoreReport(pollId, choiceId, reportId, permission) { - let args = {}; + saveReport(pollId, choiceId, report, permission) { + let url = "/v1/polls/" + pollId + "/choices/" + choiceId + "/reports/" + report.id; if (permission) { - args.permission = permission; + url += "?permission=" + permission; } - return this.getWithParams("/v1/polls/" + pollId + "/choices/" + choiceId + "/reports/" + reportId + "/ignore", args); + return this.form(url, {report: report}); } } diff --git a/pollen-ui-riot-js/src/main/web/js/CommentService.js b/pollen-ui-riot-js/src/main/web/js/CommentService.js index b9de087a..135a170e 100644 --- a/pollen-ui-riot-js/src/main/web/js/CommentService.js +++ b/pollen-ui-riot-js/src/main/web/js/CommentService.js @@ -86,6 +86,14 @@ class CommentService extends FetchService { } return this.getWithParams("/v1/polls/" + pollId + "/comments/" + commentId + "/reports/" + reportId + "/ignore", args); } + + saveReport(pollId, commentId, report, permission) { + let url = "/v1/polls/" + pollId + "/comments/" + commentId + "/reports/" + report.id; + if (permission) { + url += "?permission=" + permission; + } + return this.form(url, {report: report}); + } } module.exports = singleton(CommentService); diff --git a/pollen-ui-riot-js/src/main/web/js/Poll.js b/pollen-ui-riot-js/src/main/web/js/Poll.js index 0f5f7c05..25685df7 100644 --- a/pollen-ui-riot-js/src/main/web/js/Poll.js +++ b/pollen-ui-riot-js/src/main/web/js/Poll.js @@ -385,10 +385,10 @@ class Poll { return Promise.reject("Init poll after load reports"); } - ignoreReport(target, report) { + saveReport(target, report) { if (this.id) { let service = this._getService(target); - return service.ignoreReport(this.id, target.id, report.id, this.permission || ""); + return service.saveReport(this.id, target.id, report, this.permission || ""); } return Promise.reject("Init poll after ignore report"); } 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 3db34cca..4ecbc1d2 100644 --- a/pollen-ui-riot-js/src/main/web/js/PollService.js +++ b/pollen-ui-riot-js/src/main/web/js/PollService.js @@ -104,12 +104,12 @@ class PollService extends FetchService { return this.getWithParams("/v1/polls/" + pollId + "/reports", args); } - ignoreReport(pollId, targetId, reportId, permission) { - let args = {}; + saveReport(pollId, targetId, report, permission) { + let url = "/v1/polls/" + pollId + "/reports/" + report.id; if (permission) { - args.permission = permission; + url += "?permission=" + permission; } - return this.getWithParams("/v1/polls/" + pollId + "/reports/" + reportId + "/ignore", args); + return this.form(url, {report: report}); } } diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/Report.tag.html b/pollen-ui-riot-js/src/main/web/tag/poll/Report.tag.html index 689b518a..b3cc2ef7 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/Report.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/poll/Report.tag.html @@ -54,72 +54,18 @@ require("../popup/Modal.tag.html"); </modal> <modal ref="modalReports" header={__.reports_title} only-ok="true"> - <div show={hasReports(false, 'ILLEGAL')}> - <div class="c-card__item c-card__item--error">{parent.__.level_illegal}</div> - <div class="c-card__item"> - <div each={report in parent.filterReports(false, 'ILLEGAL')} class="report"> - <div class="report-email"> - {report.email} - </div> - <div onclick={parent.parent.ignoreReport(report)} title={parent.parent.__.toIgnore}> - <i class="fa fa-ban" aria-hidden="true"></i> - </div> - </div> - </div> - </div> - <div show={hasReports(false, 'SPAM')}> - <div class="c-card__item c-card__item--warning">{parent.__.level_spam}</div> - <div class="c-card__item"> - <div each={report in parent.filterReports(false, 'SPAM')} class="report"> - <div class="report-email"> - {report.email} - </div> - <div onclick={parent.parent.ignoreReport(report)} title={parent.parent.__.toIgnore}> - <i class="fa fa-ban" aria-hidden="true"></i> - </div> - </div> + <div each={level in parent.reportLevels}> + <div class="c-card__item c-card__item--{error : level == 'ILLEGAL', warning: level == 'SPAM', info : level == 'OFF_TOPIC'}"> + {parent.parent.__['level_' + level.toLowerCase()]} </div> - </div> - <div show={hasReports(false, 'OFF_TOPIC')}> - <div class="c-card__item c-card__item--info">{parent.__.level_off_topic}</div> <div class="c-card__item"> - <div each={report in parent.filterReports(false, 'OFF_TOPIC')} class="report"> + <div each={report in parent.parent.filterReports(level)} class="report {ignore : report.ignore}"> <div class="report-email"> {report.email} </div> - <div onclick={parent.parent.ignoreReport(report)} title={parent.parent.__.toIgnore}> - <i class="fa fa-ban" aria-hidden="true"></i> - </div> - </div> - </div> - </div> - <div class="c-card__item" - show={hasIgnoreReports()}> - {parent.__.ignores} : - <button type="button" - show={hasReports(true, 'ILLEGAL')} - onclick={parent.showIgnoreReports('ILLEGAL')} - class="c-button c-button--rounded c-button--error u-small"> - {parent.filterReports(true, 'ILLEGAL').length} - {parent.__.level_illegal} - </button> - <button type="button" - show={hasReports(true, 'SPAM')} - onclick={parent.showIgnoreReports('SPAM')} - class="c-button c-button--rounded c-button--warning u-small"> - {parent.filterReports(true, 'SPAM').length} - {parent.__.level_spam} - </button> - <button type="button" - show={hasReports(true, 'OFF_TOPIC')} - onclick={parent.showIgnoreReports('OFF_TOPIC')} - class="c-button c-button--rounded c-button--info u-small"> - {parent.filterReports(true, 'OFF_TOPIC').length} - {parent.__.level_off_topic} - </button> - <div each={report in parent.ignoreReports}> - <div class="report-email"> - {report.email} + <a onclick={parent.parent.parent.toggleIgnoreReport(report)} title={report.ignore ? parent.parent.parent.__.toEnable : parent.parent.parent.__.toIgnore}> + <i class="fa fa-{report.ignore ? 'bell' : 'bell-slash'}" aria-hidden="true"></i> + </a> </div> </div> </div> @@ -129,6 +75,7 @@ require("../popup/Modal.tag.html"); this.session = require("../../js/Session"); this.installBundle(this.session, "report"); this.poll = require("../../js/Poll.js"); + this.levels = ["ILLEGAL", "SPAM", "OFF_TOPIC"]; this.reports = []; this.ignoreReports = []; @@ -154,6 +101,7 @@ require("../popup/Modal.tag.html"); e.stopPropagation(); this.poll.getReports(this.opts.target).then(reports => { this.reports = reports; + this.reportLevels = this.levels.filter(level => reports.find(report => report.level === level)); this.refs.modalReports.open().then(() => { if (this.poll.isPoll(this.opts.target)) { this.poll.reloadPoll(); @@ -169,32 +117,30 @@ require("../popup/Modal.tag.html"); }); }; - this.ignoreReport = report => () => { - this.poll.ignoreReport(this.opts.target, report).then(() => { + this.toggleIgnoreReport = report => () => { + let report2 = Object.assign({}, report); + report2.ignore = !report2.ignore; + this.poll.saveReport(this.opts.target, report2).then(() => { this.poll.getReports(this.opts.target).then(reports => { this.reports = reports; + this.reportLevels = this.levels.filter(level => reports.find(report3 => report3.level === level)); this.update(); }); }); }; - this.hasReports = (ignore, level) => { - return this.filterReports(ignore, level).length > 0; + this.getReportLevels = () => { + this.levels.filter(level => this.reports.find(report => report.level === level)); }; - this.hasIgnoreReports = () => { - return this.reports.filter(report => report.ignore).length > 0; + this.hasReports = level => { + return this.filterReports(level).length > 0; }; - this.filterReports = (ignore, level) => { - return this.reports.filter(report => report.ignore === ignore && report.level === level); + this.filterReports = level => { + return this.reports.filter(report => report.level === level); }; - this.showIgnoreReports = (level) => () => { - this.ignoreReports = this.filterReports(true, level); - }; - - </script> <style> diff --git a/pollen-ui-riot-js/src/main/web/tag/popup/Modal.tag.html b/pollen-ui-riot-js/src/main/web/tag/popup/Modal.tag.html index e83bd0ae..11421365 100644 --- a/pollen-ui-riot-js/src/main/web/tag/popup/Modal.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/popup/Modal.tag.html @@ -77,6 +77,19 @@ .o-modal { width: auto; max-width: 90%; + max-height: 90% + } + + .c-card { + display:flex; + flex-direction: column; + max-height: 500px; + } + + .c-card__body { + flex-grow: 1; + flex-shrink: 1; + overflow-y: auto; } @media (max-width: 640px) { -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.