mermaid update and journal controller
This commit is contained in:
parent
1d226d45a4
commit
2abae9dd52
@ -5,7 +5,7 @@ Changelog
|
|||||||
+++++
|
+++++
|
||||||
|
|
||||||
- Ruby 2.7 warnings fixed
|
- Ruby 2.7 warnings fixed
|
||||||
- Mermaid 8.11.0 support
|
- Mermaid 8.11.2 support
|
||||||
- D3 7.0.0 support
|
- D3 7.0.0 support
|
||||||
- Remove issue macro, which is now supported by Redmine core
|
- Remove issue macro, which is now supported by Redmine core
|
||||||
- new ticket message can be overwritten for projects
|
- new ticket message can be overwritten for projects
|
||||||
|
65
app/controllers/additionals_journals_controller.rb
Normal file
65
app/controllers/additionals_journals_controller.rb
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
# This file is a part of redmine_db,
|
||||||
|
# a Redmine plugin to manage custom database entries.
|
||||||
|
#
|
||||||
|
# Copyright (c) 2016-2021 AlphaNodes GmbH
|
||||||
|
# https://alphanodes.com
|
||||||
|
|
||||||
|
class AdditionalsJournalsController < ApplicationController
|
||||||
|
before_action :find_journal, only: %i[edit update diff]
|
||||||
|
before_action :authorize, only: %i[edit update]
|
||||||
|
|
||||||
|
helper :custom_fields
|
||||||
|
helper :journals
|
||||||
|
helper :additionals_journals
|
||||||
|
|
||||||
|
def diff
|
||||||
|
@entry = @journal.journalized
|
||||||
|
@detail =
|
||||||
|
if params[:detail_id].present?
|
||||||
|
@journal.details.find_by id: params[:detail_id]
|
||||||
|
else
|
||||||
|
@journal.details.detect { |d| d.property == 'attr' && d.prop_key == 'description' }
|
||||||
|
end
|
||||||
|
unless @entry && @detail
|
||||||
|
render_404
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
raise ::Unauthorized if @detail.property == 'cf' && !@detail.custom_field&.visible_by?(@entry.project, User.current)
|
||||||
|
|
||||||
|
@diff = Redmine::Helpers::Diff.new @detail.value, @detail.old_value
|
||||||
|
end
|
||||||
|
|
||||||
|
def edit
|
||||||
|
return render_403 unless @journal.editable_by? User.current
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
# TODO: implement non-JS journal update
|
||||||
|
format.js
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
return render_403 unless @journal.editable_by? User.current
|
||||||
|
|
||||||
|
@journal.safe_attributes = params[:journal]
|
||||||
|
@journal.save
|
||||||
|
@journal.destroy if @journal.details.empty? && @journal.notes.blank?
|
||||||
|
respond_to do |format|
|
||||||
|
format.html { redirect_after_update }
|
||||||
|
format.js
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def redirect_after_update
|
||||||
|
raise 'overwrite it'
|
||||||
|
end
|
||||||
|
|
||||||
|
def find_journal
|
||||||
|
raise 'overwrite it'
|
||||||
|
end
|
||||||
|
end
|
@ -124,6 +124,33 @@ module AdditionalsJournalsHelper
|
|||||||
end
|
end
|
||||||
# rubocop: enable Rails/OutputSafety
|
# rubocop: enable Rails/OutputSafety
|
||||||
|
|
||||||
|
def render_email_attributes(entry, html: false)
|
||||||
|
items = send "email_#{entry.class.name.underscore}_attributes", entry, html
|
||||||
|
if html
|
||||||
|
tag.ul class: 'details' do
|
||||||
|
items.map { |s| concat tag.li(s) }.join("\n")
|
||||||
|
end
|
||||||
|
else
|
||||||
|
items.map { |s| "* #{s}" }.join("\n")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def email_custom_field_values_attributes(entry, html)
|
||||||
|
items = []
|
||||||
|
entry.custom_field_values.each do |value|
|
||||||
|
cf_value = show_value value, false
|
||||||
|
next if cf_value.blank?
|
||||||
|
|
||||||
|
items << if html
|
||||||
|
tag.strong("#{value.custom_field.name}: ") + cf_value
|
||||||
|
else
|
||||||
|
"#{value.custom_field.name}: #{cf_value}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
items
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def entity_show_detail_prop(detail, options)
|
def entity_show_detail_prop(detail, options)
|
||||||
|
12
assets/javascripts/mermaid.min.js
vendored
12
assets/javascripts/mermaid.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -178,7 +178,7 @@ It provides :
|
|||||||
* `d3 7.0.0 <https://d3js.org/>`_
|
* `d3 7.0.0 <https://d3js.org/>`_
|
||||||
* `d3plus v2.0.0-alpha.30 <https://d3plus.org/>`_
|
* `d3plus v2.0.0-alpha.30 <https://d3plus.org/>`_
|
||||||
* `FontAwesome 5.15.3 <https://fontawesome.com/>`_
|
* `FontAwesome 5.15.3 <https://fontawesome.com/>`_
|
||||||
* `mermaid 8.11.0 <https://github.com/knsv/mermaid/>`_
|
* `mermaid 8.11.2 <https://github.com/knsv/mermaid/>`_
|
||||||
* `Select2 4.0.13 <https://select2.org/>`_
|
* `Select2 4.0.13 <https://select2.org/>`_
|
||||||
|
|
||||||
And a set of various Rails helper methods (see below).
|
And a set of various Rails helper methods (see below).
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
module Additionals
|
module Additionals
|
||||||
module EntityMethods
|
module EntityMethods
|
||||||
|
attr_reader :current_journal
|
||||||
|
|
||||||
def assignable_users(prj = nil)
|
def assignable_users(prj = nil)
|
||||||
prj = project if project.present?
|
prj = project if project.present?
|
||||||
users = prj.assignable_users_and_groups.to_a
|
users = prj.assignable_users_and_groups.to_a
|
||||||
@ -14,5 +16,29 @@ module Additionals
|
|||||||
users.uniq!
|
users.uniq!
|
||||||
users.sort
|
users.sort
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def last_notes
|
||||||
|
@last_notes ||= journals.where.not(notes: '').reorder(id: :desc).first.try(:notes)
|
||||||
|
end
|
||||||
|
|
||||||
|
def new_status
|
||||||
|
true if created_on == updated_on
|
||||||
|
end
|
||||||
|
|
||||||
|
# Returns the id of the last journal or nil
|
||||||
|
def last_journal_id
|
||||||
|
if new_record?
|
||||||
|
nil
|
||||||
|
else
|
||||||
|
journals.maximum :id
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Saves the changes in a Journal
|
||||||
|
# Called after_save
|
||||||
|
def create_journal
|
||||||
|
Additionals.debug current_journal.inspect
|
||||||
|
current_journal&.save
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user