From ed96ddac989e1faa98066c3319540d59660bbc5c Mon Sep 17 00:00:00 2001 From: Lukas Matt Date: Tue, 25 Feb 2014 12:16:15 -0500 Subject: [PATCH] Display status when the user send a report --- app/assets/javascripts/app/views.js | 34 +++++++++++++------ app/assets/templates/comment_tpl.jst.hbs | 2 +- .../single-post-actions_tpl.jst.hbs | 2 +- .../templates/stream-element_tpl.jst.hbs | 2 +- config/locales/javascript/javascript.en.yml | 10 ++++-- 5 files changed, 34 insertions(+), 16 deletions(-) diff --git a/app/assets/javascripts/app/views.js b/app/assets/javascripts/app/views.js index 8ff682cc1..f65d04379 100644 --- a/app/assets/javascripts/app/views.js +++ b/app/assets/javascripts/app/views.js @@ -83,16 +83,30 @@ app.views.Base = Backbone.View.extend({ report: function(evt) { if(evt) { evt.preventDefault(); } - var msg = prompt(Diaspora.I18n.t('report_prompt'), Diaspora.I18n.t('report_prompt_default')); - if (msg !== null) { - var report = new app.models.Report(); - var id = this.model.id; - var type = $(evt.currentTarget).data("type"); - report.fetch({ - data: { id: id, type: type, text: msg }, - type: 'POST' - }); - } + var msg = prompt(Diaspora.I18n.t('report.prompt'), Diaspora.I18n.t('report.prompt_default')); + if (msg == null) return; + var report = new app.models.Report(); + var id = this.model.id; + var type = $(evt.currentTarget).data("type"); + + report.fetch({ + data: { id: id, type: type, text: msg }, + type: 'POST', + statusCode: { + 200: function(xhr) { + Diaspora.page.flashMessages.render({ + success: true, + notice: Diaspora.I18n.t('report.status.created') + }); + }, + 400: function(xhr) { + Diaspora.page.flashMessages.render({ + success: false, + notice: Diaspora.I18n.t('report.status.exists') + }); + } + } + }); }, destroyModel: function(evt) { diff --git a/app/assets/templates/comment_tpl.jst.hbs b/app/assets/templates/comment_tpl.jst.hbs index 71be0bd4e..de65d6d64 100644 --- a/app/assets/templates/comment_tpl.jst.hbs +++ b/app/assets/templates/comment_tpl.jst.hbs @@ -12,7 +12,7 @@
{{else}} - +
{{/if}} diff --git a/app/assets/templates/single-post-viewer/single-post-actions_tpl.jst.hbs b/app/assets/templates/single-post-viewer/single-post-actions_tpl.jst.hbs index 26fcd0822..2d188f6ac 100644 --- a/app/assets/templates/single-post-viewer/single-post-actions_tpl.jst.hbs +++ b/app/assets/templates/single-post-viewer/single-post-actions_tpl.jst.hbs @@ -23,7 +23,7 @@ {{/if}} {{/if}} - +
diff --git a/app/assets/templates/stream-element_tpl.jst.hbs b/app/assets/templates/stream-element_tpl.jst.hbs index 45a73f9a0..9a6952808 100644 --- a/app/assets/templates/stream-element_tpl.jst.hbs +++ b/app/assets/templates/stream-element_tpl.jst.hbs @@ -10,7 +10,7 @@ {{#if loggedIn}}