Don’t show new annotation/comment form if allegations phase is not open

This commit is contained in:
Amaia Castro
2017-01-16 17:42:32 +01:00
parent 819c9efcc3
commit 65fcd83ee5
6 changed files with 24 additions and 19 deletions

View File

@@ -3,4 +3,5 @@
// * English: https://github.com/consul/consul/blob/master/CUSTOMIZE_EN.md#javascript
// * Spanish: https://github.com/consul/consul/blob/master/CUSTOMIZE_ES.md#javascript
//
//

View File

@@ -122,17 +122,6 @@ App.LegislationAnnotatable =
)
current_user_id = $('html').data('current-user-id')
if current_user_id == ""
annotator.ui.editor.Editor.template = [
'<div class="annotator-outer annotator-editor annotator-hide">',
' <form class="annotator-widget">',
' ' + _t('Unregistered'),
' <div class="annotator-controls">',
' <a href="#cancel" class="annotator-cancel">' + _t('Cancel') + '</a>',
' </div>',
' </form>',
'</div>'
].join('\n')
$(".legislation-annotatable").each ->
$this = $(this)

View File

@@ -8,7 +8,11 @@
<div class="comments-wrapper">
<div class="comment-input">
<% if user_signed_in? %>
<% if !@process.open_phase?(:allegations) %>
<div data-alert class="callout primary">
<%= t("legislation.annotations.form.phase_not_open") %>
</div>
<% elsif user_signed_in? %>
<%= form_for Legislation::Annotation.new, url: legislation_process_draft_version_annotations_path(@process, @draft_version), remote: true do |f| %>
<%= f.text_area :text %>
@@ -22,9 +26,9 @@
<% end %>
<% else %>
<div data-alert class="callout primary">
<%= t("debates.show.login_to_comment",
signin: link_to(t("votes.signin"), new_user_session_path),
signup: link_to(t("votes.signup"), new_user_registration_path)).html_safe %>
<%= t("legislation.annotations.form.login_to_comment",
signin: link_to(t("legislation.annotations.form.signin"), new_user_session_path),
signup: link_to(t("legislation.annotations.form.signup"), new_user_registration_path)).html_safe %>
</div>
<% end %>
</div>

View File

@@ -54,6 +54,7 @@
<section class="legislation-annotatable"
data-legislation-draft-version-id="<%= @draft_version.id %>"
data-legislation-annotatable-base-url="<%= legislation_process_draft_version_path(@process, @draft_version) %>"
data-legislation-open-phase="<%= @process.open_phase?(:allegations) %>"
>
<% end %>
<%= @draft_version.body_html.html_safe %>

View File

@@ -237,6 +237,11 @@ en:
other: "%{count} replies"
cancel: Cancel
publish_comment: Publish Comment
form:
phase_not_open: This phase is not open
login_to_comment: You must %{signin} or %{signup} to leave a comment.
signin: Sign in
signup: Sign up
index:
title: Comments
comments_about: Comments about

View File

@@ -237,6 +237,11 @@ es:
other: "%{count} respuestas"
cancel: Cancelar
publish_comment: Publicar Comentario
form:
phase_not_open: Esta fase del proceso no está abierta
login_to_comment: Necesitas %{signin} o %{signup} para comentar.
signin: iniciar sesión
signup: registrarte
index:
title: Comentarios
see_in_context: Ver en contexto