diff options
author | Lukas Matt <lukas@zauberstuhl.de> | 2014-02-25 21:16:15 +0400 |
---|---|---|
committer | Lukas Matt <lukas@zauberstuhl.de> | 2014-05-15 15:23:43 +0400 |
commit | ed96ddac989e1faa98066c3319540d59660bbc5c (patch) | |
tree | 1b86ab8deae31bae9d7121e6760f25b33e141694 | |
parent | d23f4a66da8783c9b4550f67261c8d9c16947264 (diff) |
Display status when the user send a report
-rw-r--r-- | app/assets/javascripts/app/views.js | 34 | ||||
-rw-r--r-- | app/assets/templates/comment_tpl.jst.hbs | 2 | ||||
-rw-r--r-- | app/assets/templates/single-post-viewer/single-post-actions_tpl.jst.hbs | 2 | ||||
-rw-r--r-- | app/assets/templates/stream-element_tpl.jst.hbs | 2 | ||||
-rw-r--r-- | 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 @@ <div alt="Deletelabel" class="icons-deletelabel" /> <a/> {{else}} - <a href="#" data-type="comment" class="comment_report" title="{{t "report"}}"> + <a href="#" data-type="comment" class="comment_report" title="{{t "report.name"}}"> <div class="icons-report control_icon"/> </a> {{/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}} - <a href="#" rel="auth-required" data-type="post" class="post_report" title="{{t "report"}}"> + <a href="#" rel="auth-required" data-type="post" class="post_report" title="{{t "report.name"}}"> <i class="entypo report gray large"/> </a> </div> 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}} <div class="controls"> {{#unless authorIsCurrentUser}} - <a href="#" rel="nofollow" data-type="post" class="post_report" title="{{t "report"}}"> + <a href="#" rel="nofollow" data-type="post" class="post_report" title="{{t "report.name"}}"> <div class="icons-report control_icon"/> </a> <a href="#" rel="nofollow" class="block_user" title="{{t "ignore"}}"> diff --git a/config/locales/javascript/javascript.en.yml b/config/locales/javascript/javascript.en.yml index e10959db6..a9647a999 100644 --- a/config/locales/javascript/javascript.en.yml +++ b/config/locales/javascript/javascript.en.yml @@ -6,11 +6,15 @@ en: javascripts: confirm_dialog: "Are you sure?" - report_prompt: "Please enter a reason:" - report_prompt_default: "offensive content" delete: "Delete" ignore: "Ignore" - report: "Report" + report: + prompt: "Please enter a reason:" + prompt_default: "offensive content" + name: "Report" + status: + created: "The report was successfully created" + exists: "The report already exists" ignore_user: "Ignore this user?" and: "and" comma: "," |