Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

4.9 KB
Raw Blame
<%#-- copyright
OpenProject is an open source project management software.
Copyright (C) the OpenProject GmbH

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 3.

OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
Copyright (C) 2006-2013 Jean-Philippe Lang
Copyright (C) 2010-2013 the ChiliProject Team

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

See COPYRIGHT and LICENSE files for more details.

++#%>

<%=
  render Primer::OpenProject::PageHeader.new do |header|
    header.with_title { "#{avatar(@news.author)}  #{h @news.title}".html_safe }
    header.with_breadcrumbs(
      [
        ({ href: project_overview_path(@project.id), text: @project.name } if @project),
        ({ href: project_news_index_path(@project.id), text: t(:label_news_plural) } if @project),
        @news.title
      ].compact
    )
    if User.current.allowed_in_project?(:manage_news, @project)
      header.with_action_button(
        tag: :a,
        mobile_icon: :pencil,
        mobile_label: t(:button_edit),
        size: :medium,
        href: edit_news_path(@news),
        aria: { label: I18n.t(:button_edit) },
        title: I18n.t(:button_edit)
      ) do |button|
        csp_onclick('jQuery("#edit-news").show()', ".edit-news-button")
        button.with_leading_visual_icon(icon: :pencil)
        t(:button_edit)
      end
    end

    watcher_action_button(header, @news)

    if User.current.allowed_in_project?(:manage_news, @project)
      header.with_action_button(
        scheme: :danger,
        tag: :a,
        href: news_path(@news),
        mobile_icon: :trash,
        mobile_label: I18n.t("button_delete"),
        data: { turbo_confirm: t(:text_are_you_sure), turbo_method: :delete },
        aria: { label: I18n.t("button_delete") }
      ) do |button|
        button.with_leading_visual_icon(icon: :trash)
        I18n.t("button_delete")
      end
    end
  end
%>

<% if authorize_for('news', 'edit') %>
  <div id="edit-news" style="display:none;">
    <%= labelled_tabular_form_for @news, html: { id: "news-form" } do |f| %>
      <%= render partial: "form", locals: { f: f } %>
      <%= styled_button_tag t(:button_save), class: "-primary -with-icon icon-checkmark" %>
      <%= link_to_function t(:button_cancel), 'jQuery("#edit-news").hide()',
            class: "button -with-icon icon-cancel" %>
    <% end %>
  </div>
<% end %>
<% if @news.summary.present? %>
  <div class="summary">
    <%= format_text(@news, :summary) %>
  </div>
<% end %>
  <p class="author additional-information"><%= authoring @news.created_at, @news.author %></p>
<div class="op-uc-container">
  <%= format_text(@news, :description) %>
</div>
<br>
<div id="comments" class="news--comments comments">
  <h3 class="icon-context icon-quote"><%= t(:label_comment_plural) %></h3>
  <% @comments.each do |comment| %>
    <% next if comment.new_record? %>
      <div class="comment">
        <div class="contextual">
          <%= link_to_if_authorized icon_wrapper("icon-context icon-delete", t(:button_delete)),
                                    { controller: "/news/comments", action: "destroy", id: comment },
                                    data: { turbo_method: :delete, turbo_confirm: t(:text_are_you_sure) },
                                    class: "no-decoration-on-hover",
                                    title: t(:button_delete),
                                    alt: t(:button_delete) %>
        </div>
        <h4 class="author additional-information"><%= avatar(comment.author) %><%= authoring comment.created_at, comment.author %></h4>
        <%= format_text(comment, :comments) %>
      </div>
    <% end %>
  </div>
  <% if authorize_for 'news/comments', 'create' %>
    <%= form_for([@news, Comment.new], html: { id: "add_comment_form" }) do %>
      <div>
        <%= label_tag "comment_comments", Journal.human_attribute_name(:notes), class: "sr-only" %>
        <%= text_area "comment",
                      "comments",
                      class: "wiki-edit" %>
        <%= wikitoolbar_for "comment_comments", preview_context: preview_context(@news) %>
      </div>
      <p>
        <%= submit_tag t(:button_add_comment), class: "button -primary" %>
      </p>
    <% end %>
  <% end %>
  <% html_title h(@news.title) -%>