Compare commits
2 Commits
c5178056c6
...
2370033541
Author | SHA1 | Date |
---|---|---|
|
2370033541 | |
|
5ae0590155 |
|
@ -22,7 +22,7 @@ module JobsHelper
|
||||||
{
|
{
|
||||||
name: "history",
|
name: "history",
|
||||||
label: "History",
|
label: "History",
|
||||||
onclick: 'showJobHistory("history", this.href)',
|
onclick: 'showIssueHistory("history", this.href)',
|
||||||
partial: "jobs/tabs/history",
|
partial: "jobs/tabs/history",
|
||||||
locals: {
|
locals: {
|
||||||
job: @job,
|
job: @job,
|
||||||
|
@ -33,7 +33,7 @@ module JobsHelper
|
||||||
tabs << {
|
tabs << {
|
||||||
name: "notes",
|
name: "notes",
|
||||||
label: "Notes",
|
label: "Notes",
|
||||||
onclick: 'showJobHistory("notes", this.href)',
|
onclick: 'showIssueHistory("notes", this.href)',
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -101,12 +101,9 @@ module JobsHelper
|
||||||
when 'due_date', 'start_date'
|
when 'due_date', 'start_date'
|
||||||
value = format_date(detail.value.to_date) if detail.value
|
value = format_date(detail.value.to_date) if detail.value
|
||||||
old_value = format_date(detail.old_value.to_date) if detail.old_value
|
old_value = format_date(detail.old_value.to_date) if detail.old_value
|
||||||
|
when 'project_id', 'category_id'
|
||||||
when 'project_id', 'status_id', 'tracker_id', 'assigned_to_id',
|
|
||||||
'priority_id', 'category_id', 'fixed_version_id'
|
|
||||||
value = find_name_by_reflection(field, detail.value)
|
value = find_name_by_reflection(field, detail.value)
|
||||||
old_value = find_name_by_reflection(field, detail.old_value)
|
old_value = find_name_by_reflection(field, detail.old_value)
|
||||||
|
|
||||||
when 'description'
|
when 'description'
|
||||||
show_diff = true
|
show_diff = true
|
||||||
end
|
end
|
||||||
|
@ -195,7 +192,7 @@ module JobsHelper
|
||||||
return nil if id.blank?
|
return nil if id.blank?
|
||||||
|
|
||||||
@detail_value_name_by_reflection ||= Hash.new do |hash, key|
|
@detail_value_name_by_reflection ||= Hash.new do |hash, key|
|
||||||
association = Issue.reflect_on_association(key.first.to_sym)
|
association = Job.reflect_on_association(key.first.to_sym)
|
||||||
name = nil
|
name = nil
|
||||||
if association
|
if association
|
||||||
record = association.klass.find_by_id(key.last)
|
record = association.klass.find_by_id(key.last)
|
||||||
|
@ -207,4 +204,8 @@ module JobsHelper
|
||||||
end
|
end
|
||||||
@detail_value_name_by_reflection[[field, id]]
|
@detail_value_name_by_reflection[[field, id]]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def render_notes(issue, journal, options={})
|
||||||
|
content_tag('div', textilizable(journal, :notes), :id => "journal-#{journal.id}-notes", :class => "wiki")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -87,6 +87,19 @@ class Job < ActiveRecord::Base
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# tracker and subject are used to make Job quack like an issue so the diff view
|
||||||
|
# built into Redmine will work
|
||||||
|
def tracker
|
||||||
|
OpenStruct.new(
|
||||||
|
name: name,
|
||||||
|
to_s: "Job",
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
def subject
|
||||||
|
name
|
||||||
|
end
|
||||||
|
|
||||||
def self.fields_for_order_statement
|
def self.fields_for_order_statement
|
||||||
"jobs.name"
|
"jobs.name"
|
||||||
end
|
end
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
<p>
|
<p>
|
||||||
<%= f.label :description %>
|
<%= f.label :description %>
|
||||||
<%= f.text_area :description, required: true, cols: 60, rows: 15, class: "wiki-edit",
|
<%= f.text_area :description, required: true, cols: 60, rows: 15, class: "wiki-edit",
|
||||||
data: { auto_complete: true }, id: "job_description" %>
|
data: { auto_complete: true }, id: "job_description" %>
|
||||||
|
|
||||||
<%= f.hidden_field :project_id, value: @job.project.id %>
|
<%= f.hidden_field :project_id, value: @job.project.id %>
|
||||||
|
|
||||||
|
@ -35,14 +35,17 @@
|
||||||
<%= ff.hidden_field :_destroy, value: false %>
|
<%= ff.hidden_field :_destroy, value: false %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<%= wikitoolbar_for 'job_description' %>
|
<%= wikitoolbar_for 'job_description' %>
|
||||||
|
|
||||||
|
|
||||||
|
<% unless @job.new_record? %>
|
||||||
|
<fieldset id="add_notes">
|
||||||
|
<legend>Notes</legend>
|
||||||
|
<%= f.text_area :notes, cols: 60, rows: 15, class: "wiki-edit",
|
||||||
|
data: { auto_complete: true }, id: "job_notes" %>
|
||||||
|
<%= wikitoolbar_for 'job_notes' %>
|
||||||
|
</fieldset>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% unless @job.new_record? %>
|
|
||||||
<%= f.text_area :notes, cols: 60, rows: 15, class: "wiki-edit",
|
|
||||||
data: { auto_complete: true }, id: "job_notes" %>
|
|
||||||
<%= wikitoolbar_for 'job_notes' %>
|
|
||||||
<% end %>
|
|
||||||
<%= f.submit %>
|
<%= f.submit %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
<% reply_links = job.notes_addable? %>
|
<% reply_links = job.notes_addable? %>
|
||||||
<% journals.each_with_index do |journal, indice| %>
|
<% journals.each_with_index do |journal, indice| %>
|
||||||
<div id="change-<%= journal.id %>" class="journal has-notes">
|
<div id="change-<%= journal.id %>" class="<%= journal.css_classes %>">
|
||||||
<div id="note-<%= indice %>" class="note">
|
<div id="note-<%= indice %>" class="note">
|
||||||
<div class="contextual">
|
<div class="contextual">
|
||||||
<span class="journal-actions">
|
<span class="journal-actions">
|
||||||
|
@ -17,7 +17,6 @@
|
||||||
<%= avatar(journal.user) %>
|
<%= avatar(journal.user) %>
|
||||||
<%= authoring journal.created_on, journal.user, label: :label_updated_time_by %>
|
<%= authoring journal.created_on, journal.user, label: :label_updated_time_by %>
|
||||||
</h4>
|
</h4>
|
||||||
<%= journal.notes %>
|
|
||||||
|
|
||||||
<% if journal.details.any? %>
|
<% if journal.details.any? %>
|
||||||
<ul class="details">
|
<ul class="details">
|
||||||
|
@ -26,6 +25,8 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
<%= render_notes(job, journal) unless journal.notes.blank? %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
2
init.rb
2
init.rb
|
@ -12,10 +12,10 @@ Redmine::Plugin.register :jobs do
|
||||||
User.safe_attributes 'time_budget_category_id'
|
User.safe_attributes 'time_budget_category_id'
|
||||||
|
|
||||||
Rails.application.config.before_initialize do
|
Rails.application.config.before_initialize do
|
||||||
Rails.logger.info "Patch Jobs"
|
|
||||||
TimeEntryQuery.send(:include, TimeEntryQueryPatch)
|
TimeEntryQuery.send(:include, TimeEntryQueryPatch)
|
||||||
TimeEntry.send(:include, TimeEntryPatch)
|
TimeEntry.send(:include, TimeEntryPatch)
|
||||||
Project.send(:include, ProjectPatch)
|
Project.send(:include, ProjectPatch)
|
||||||
|
JournalsController.send(:include, JournalsControllerPatch)
|
||||||
Redmine::Helpers::TimeReport.send(:include, TimeReportHelperPatch)
|
Redmine::Helpers::TimeReport.send(:include, TimeReportHelperPatch)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require_dependency 'journals_controller'
|
||||||
|
|
||||||
|
module JournalsControllerPatch
|
||||||
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
|
included do
|
||||||
|
include InstanceMethods
|
||||||
|
|
||||||
|
alias_method :original_diff, :diff
|
||||||
|
alias_method :diff, :new_diff
|
||||||
|
alias_method :original_find_journal, :find_journal
|
||||||
|
alias_method :find_journal, :new_find_journal
|
||||||
|
end
|
||||||
|
|
||||||
|
module InstanceMethods
|
||||||
|
def new_diff
|
||||||
|
@journalized = @journal.journalized
|
||||||
|
if params[:detail_id].present?
|
||||||
|
@detail = @journal.details.find_by_id(params[:detail_id])
|
||||||
|
else
|
||||||
|
@detail = @journal.details.detect {|d| d.property == 'attr' && d.prop_key == 'description'}
|
||||||
|
end
|
||||||
|
unless @journalized && @detail
|
||||||
|
render_404
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
if @detail.property == 'cf'
|
||||||
|
unless @detail.custom_field && @detail.custom_field.visible_by?(@journalized.project, User.current)
|
||||||
|
raise ::Unauthorized
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@diff = Redmine::Helpers::Diff.new(@detail.value, @detail.old_value)
|
||||||
|
end
|
||||||
|
|
||||||
|
# The find_journal method in the controller assumes journalized is an Issue, so we need
|
||||||
|
# to be a bit silly about it.
|
||||||
|
def new_find_journal
|
||||||
|
@journal = Journal.find(params[:id])
|
||||||
|
if @journal.journalized.is_a?(Issue)
|
||||||
|
original_find_journal and return
|
||||||
|
end
|
||||||
|
|
||||||
|
@project = @journal.journalized.project
|
||||||
|
@issue = @journal.journalized
|
||||||
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
render_404
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue