From 979822f697ec100b4b96eff05ce3b39b462e7a7d Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Mon, 8 Apr 2013 21:34:38 +0100 Subject: [PATCH] Add a "Hide" button to notes when viewed by moderators --- app/assets/javascripts/index/notes.js.erb | 19 +++++++++++++------ .../javascripts/templates/notes/show.jst.ejs | 5 +++-- app/helpers/application_helper.rb | 1 + config/locales/en.yml | 1 + 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/index/notes.js.erb b/app/assets/javascripts/index/notes.js.erb index 9fb03bb0d..072890775 100644 --- a/app/assets/javascripts/index/notes.js.erb +++ b/app/assets/javascripts/index/notes.js.erb @@ -161,7 +161,8 @@ $(document).ready(function () { content.find("input[type=submit]").on("click", function (e) { e.preventDefault(); - updateNote(marker, e.target.form, $(e.target).data("url")); + var data = $(e.target).data(); + updateNote(marker, e.target.form, data.method, data.url); }); return content[0]; @@ -190,21 +191,27 @@ $(document).ready(function () { }); } - function updateNote(marker, form, url) { + function updateNote(marker, form, method, url) { $(form).find("input[type=submit]").prop("disabled", true); $.ajax({ url: url, - type: "POST", + type: method, oauth: true, data: { text: $(form.text).val() }, success: function (feature) { - var popupContent = createPopupContent(marker, feature.properties); + if (feature.properties.status == "hidden") { + noteLayer.removeLayer(marker); + + delete notes[feature.properties.id]; + } else { + var popupContent = createPopupContent(marker, feature.properties); - marker.setIcon(noteIcons[feature.properties.status]); - marker._popup.setContent(popupContent); + marker.setIcon(noteIcons[feature.properties.status]); + marker._popup.setContent(popupContent); + } } }); } diff --git a/app/assets/javascripts/templates/notes/show.jst.ejs b/app/assets/javascripts/templates/notes/show.jst.ejs index 7063090df..04cb6dfc1 100644 --- a/app/assets/javascripts/templates/notes/show.jst.ejs +++ b/app/assets/javascripts/templates/notes/show.jst.ejs @@ -25,8 +25,9 @@
- - + + +
<% } %> diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 3771acf37..b91710b9c 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -26,6 +26,7 @@ module ApplicationHelper css << ".hide_if_user_#{@user.id} { display: none !important }" if @user; css << ".show_if_user_#{@user.id} { display: inline !important }" if @user; css << ".hide_unless_administrator { display: none !important }" unless @user and @user.administrator?; + css << ".hide_unless_moderator { display: none !important }" unless @user and @user.moderator?; return content_tag(:style, css, :type => "text/css") end diff --git a/config/locales/en.yml b/config/locales/en.yml index 5d3e6bbae..01e4abecb 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2041,6 +2041,7 @@ en: closed_by_anonymous: "resolved by anonymous at %{time}" reopened_by: "reactivated by %{user} at %{time}" reopened_by_anonymous: "reactivated by anonymous at %{time}" + hide: Hide resolve: Resolve comment_and_resolve: Comment & Resolve comment: Comment -- 2.43.2