Skip to content

Commit

Permalink
Merge pull request akiko-pusu#370 from akiko-pusu/develop
Browse files Browse the repository at this point in the history
Update version to 1.1.0
  • Loading branch information
akiko-pusu authored Aug 5, 2020
2 parents add350b + f33ba3c commit 015a7da
Show file tree
Hide file tree
Showing 19 changed files with 19 additions and 260 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,14 @@ If you have any requests, bug reports, please use GitHub issues. <https://github

## Changelog

### 1.1.0

Drop off the feature to integrate with Checklist plugin, for maintenance reason.
Please see for more details: <https://github.com/akiko-pusu/redmine_issue_templates/issues/363>

### 1.0.5

Bugfix and filal release to support Checklist integration.
Bugfix and final release to support Checklist integration.
Please see: <https://github.com/akiko-pusu/redmine_issue_templates/issues/363>

* Bugfix: template_type is not defined error (GitHub: #364 / Thanks for reporting issue, @toku463ne)
Expand Down
14 changes: 1 addition & 13 deletions app/controllers/concerns/issue_templates_common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,28 +48,16 @@ def apply_all_projects?
plugin_setting['apply_global_template_to_all_projects'].to_s == 'true'
end

def checklists
template_params[:checklists].presence || []
end

def builtin_fields_json
value = template_params[:builtin_fields].blank? ? {} : JSON.parse(template_params[:builtin_fields])
return value if value.is_a?(Hash)

raise InvalidTemplateFormatError
end

def checklist_enabled?
Redmine::Plugin.registered_plugins.key? :redmine_checklists
rescue StandardError
false
end

def valid_params
# convert attribute name and data for checklist plugin supporting
attributes = template_params.except(:checklists, :builtin_fields)
attributes = template_params.except(:builtin_fields)
attributes[:builtin_fields_json] = builtin_fields_json if builtin_fields_enabled?
attributes[:checklist_json] = checklists.to_json if checklist_enabled?
attributes
end

Expand Down
4 changes: 2 additions & 2 deletions app/controllers/global_issue_templates_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def template_params
params.require(:global_issue_template)
.permit(:title, :tracker_id, :issue_title, :description, :note, :is_default, :enabled,
:author_id, :position, :related_link, :link_title, :builtin_fields,
project_ids: [], checklists: [])
project_ids: [])
end

def render_form_params
Expand All @@ -142,7 +142,7 @@ def render_form_params
.merge(custom_fields_map_by_tracker_id(tracker_id)).to_json

{ layout: !request.xhr?,
locals: { checklist_enabled: checklist_enabled?, trackers: trackers, apply_all_projects: apply_all_projects?,
locals: { trackers: trackers, apply_all_projects: apply_all_projects?,
issue_template: @global_issue_template, projects: projects, custom_fields: custom_fields.to_s,
builtin_fields_enable: builtin_fields_enabled? } }
end
Expand Down
5 changes: 2 additions & 3 deletions app/controllers/issue_templates_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,7 @@ def inherit_templates
def template_params
params.require(:issue_template).permit(:tracker_id, :title, :note, :issue_title, :description, :is_default,
:enabled, :author_id, :position, :enabled_sharing,
:related_link, :link_title, :builtin_fields,
checklists: [])
:related_link, :link_title, :builtin_fields)
end

def templates_exist?
Expand All @@ -231,7 +230,7 @@ def render_form_params

{ layout: !request.xhr?,
locals: { issue_template: template, project: @project, child_project_used_count: child_project_used_count,
checklist_enabled: checklist_enabled?, custom_fields: custom_fields.to_s, builtin_fields_enable: builtin_fields_enabled? } }
custom_fields: custom_fields.to_s, builtin_fields_enable: builtin_fields_enabled? } }
end

def loadable_trigger?
Expand Down
2 changes: 2 additions & 0 deletions app/models/concerns/issue_template/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ def <=>(other)
position <=> other.position
end

# Keep this method for a while, but this will be deprecated.
# Please see: https://github.com/akiko-pusu/redmine_issue_templates/issues/363
def checklist
return [] if checklist_json.blank?

Expand Down
1 change: 0 additions & 1 deletion app/models/global_issue_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class GlobalIssueTemplate < ActiveRecord::Base
'project_ids',
'position',
'author_id',
'checklist_json',
'related_link',
'link_title',
'builtin_fields_json'
Expand Down
1 change: 0 additions & 1 deletion app/models/issue_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class IssueTemplate < ActiveRecord::Base
'enabled_sharing',
'visible_children',
'position',
'checklist_json',
'related_link',
'link_title',
'builtin_fields_json'
Expand Down
23 changes: 0 additions & 23 deletions app/views/global_issue_templates/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,6 @@
required: true,
label: l(:issue_description), class: 'wiki-edit', style: 'overflow: auto;' %>
</p>
<!-- for Checklist -->
<% if checklist_enabled %>
<p id='checklist_form'>
<label>Checklist</label>
<input type='text' id='checklist_text' class='edit-box'>
<span class='icon icon-add checklist-new-only save-new-by-button' onclick='addCheckList()'></span>
<ul class='checklist' style='padding-left: 180px;'>
<% issue_template.checklist.each_with_index do |content, i| %>
<li id='checklist_<%= i %>'>
<span class='text'>
<%= content %>
<i class='icon icon-del' onclick='removeCheckList(this)'></i>
</span>
<input type='hidden' name='global_issue_template[checklists][]'
id='global_issue_template_checklist' value='<%= content %>'>
</li>
<% end %>
</ul>
</p>
<% end %>

<!-- for Builtin Fields -->
<!-- buildin field Generator -->
Expand Down Expand Up @@ -258,6 +238,3 @@
<%= javascript_include_tag('template_fields', plugin: 'redmine_issue_templates') %>
<% end %>

<% if checklist_enabled %>
<%= javascript_include_tag('template_checklists', plugin: 'redmine_issue_templates') %>
<% end %>
3 changes: 1 addition & 2 deletions app/views/global_issue_templates/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
html: { id: 'global_issue_template-form',
class: nil, multipart: false } do |f| %>

<%= render 'form', { f: f, checklist_enabled: checklist_enabled,
trackers: trackers, projects: projects,
<%= render 'form', { f: f, trackers: trackers, projects: projects,
issue_template: issue_template, apply_all_projects: apply_all_projects,
custom_fields: custom_fields, builtin_fields_enable: builtin_fields_enable } %>
<% end %>
2 changes: 1 addition & 1 deletion app/views/global_issue_templates/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
url: { controller: 'global_issue_templates', action: 'update', id: issue_template },
html: { id: 'global_issue_template-form', class: nil,
multipart: false } do |f| %>
<%= render 'form', { f: f, checklist_enabled: checklist_enabled, trackers: trackers,
<%= render 'form', { f: f, trackers: trackers,
issue_template: issue_template, projects: projects, apply_all_projects: apply_all_projects,
custom_fields: custom_fields, builtin_fields_enable: builtin_fields_enable } %>
<% end %>
23 changes: 0 additions & 23 deletions app/views/issue_templates/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,6 @@
required: true,
label: l(:issue_description), class: 'wiki-edit', style: 'overflow: auto;' %>
</p>
<!-- for Checklist -->
<% if checklist_enabled %>
<p id='checklist_form'>
<label>Checklist</label>
<input type='text' id='checklist_text' class='edit-box'>
<span class='icon icon-add checklist-new-only save-new-by-button' onclick='addCheckList()'></span>
<ul class='checklist' style='padding-left: 180px;'>
<% issue_template.checklist.each_with_index do |content, i| %>
<li id='checklist_<%= i %>'>
<span class='text'>
<%= content %>
<i class='icon icon-del' onclick='removeCheckList(this)'></i>
</span>
<input type='hidden' name='issue_template[checklists][]'
id='issue_template_checklist' value='<%= content %>'>
</li>
<% end %>
</ul>
</p>
<% end %>

<!-- for Builtin Fields -->
<!-- buildin field Generator -->
Expand Down Expand Up @@ -233,6 +213,3 @@
<%= javascript_include_tag('template_fields', plugin: 'redmine_issue_templates') %>
<% end %>

<% if checklist_enabled %>
<%= javascript_include_tag('template_checklists', plugin: 'redmine_issue_templates') %>
<% end %>
3 changes: 1 addition & 2 deletions app/views/issue_templates/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
url: { controller: 'issue_templates', action: 'create', project_id: project },
html: { id: 'issue_template-form', class: nil, multipart: false } do |f| %>

<%= render 'form', { f: f, checklist_enabled: checklist_enabled,
issue_template: issue_template, project: project, custom_fields: custom_fields,
<%= render 'form', { f: f, issue_template: issue_template, project: project, custom_fields: custom_fields,
builtin_fields_enable: builtin_fields_enable } %>
<div id='preview' class='wiki'></div>
<%= submit_tag l(:button_create) %>
Expand Down
18 changes: 1 addition & 17 deletions app/views/issue_templates/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@
project_id: project, id: issue_template },
html: { id: 'issue_template-form', class: nil, multipart: false } do |f| %>

<%= render 'form', { f: f, checklist_enabled: checklist_enabled,
issue_template: issue_template, project: project,
<%= render 'form', { f: f, issue_template: issue_template, project: project,
custom_fields: custom_fields, builtin_fields_enable: builtin_fields_enable } %>
<div id='preview' class='wiki'></div>
<%= submit_tag l(:button_save) %>
Expand Down Expand Up @@ -74,21 +73,6 @@
</p>

<div class='wiki issue_template'><%= textilizable(issue_template.description) %></div>
<!-- for Checklist -->
<% if checklist_enabled %>
<p id='checklist_form'>
<label>Checklist</label>
<ul class='checklist' style='padding-left: 180px;'>
<% issue_template.checklist.each do |content| %>
<li>
<span class='text'><%= content %></span>
<input type='hidden' name='issue_template[checklists][]'
id='issue_template_checklist' value='<%= content %>'>
</li>
<% end %>
</ul>
</p>
<% end %>

</fieldset>

Expand Down
22 changes: 0 additions & 22 deletions assets/javascripts/issue_templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ ISSUE_TEMPLATE.prototype = {
}

ns.setRelatedLink(obj)
ns.addCheckList(obj)
ns.builtinFields(obj)
ns.confirmToReplace = true
},
Expand Down Expand Up @@ -294,27 +293,6 @@ ISSUE_TEMPLATE.prototype = {
document.getElementById('issue_template').dispatchEvent(changeEvent)
})
},
addCheckList: function (obj) {
let list = obj.checklist
if (list == null) return false
let checklistForm = document.getElementById('checklist_form')
if (!checklistForm) return

// NOTE: If Checklist does not work fine, please confirm its version and the DOM element of
// checklist input field exists.
// If some difference, please report the issue or feedback to IssueTemplate's repository.
try {
for (let i = 0; i < list.length; i++) {
let node = document.querySelector('span.checklist-item.new > span.checklist-edit-box > input.edit-box')
if (node) {
node.value = list[i]
document.querySelector('span.checklist-item.new > span.icon.icon-add.checklist-new-only.save-new-by-button').click()
}
}
} catch (e) {
console.log(`NOTE: Checklist could not be applied due to this error. ${e.message} : ${e.message}`)
}
},
setRelatedLink: function (obj) {
let relatedLink = document.getElementById('issue_template_related_link')
if (obj.related_link != null && obj.related_link !== '') {
Expand Down
54 changes: 0 additions & 54 deletions assets/javascripts/template_checklists.js

This file was deleted.

2 changes: 1 addition & 1 deletion init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def template_menu_allowed?
name 'Redmine Issue Templates plugin'
author 'Akiko Takano'
description 'Plugin to generate and use issue templates for each project to assist issue creation.'
version '1.0.5'
version '1.1.0'
author_url 'http://twitter.com/akiko_pusu'
requires_redmine version_or_higher: '4.0'
url 'https://github.com/akiko-pusu/redmine_issue_templates'
Expand Down
17 changes: 0 additions & 17 deletions spec/controllers/concerns/issue_templates_common_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,6 @@ class FakesController < ApplicationController
end
let(:mock_controller) { FakesController.new }

describe '#checklist_enabled?' do
subject { mock_controller.checklist_enabled? }
context 'checklist plugin not registered' do
before do
allow(Redmine::Plugin).to receive(:registered_plugins).and_return({})
end
it { is_expected.to be_falsey }
end

context 'checklist plugin registered' do
before do
allow(Redmine::Plugin).to receive(:registered_plugins).and_return(redmine_checklists: 'mock data')
end
it { is_expected.to be_truthy }
end
end

describe '#log_action' do
subject { mock_controller.log_action }

Expand Down
23 changes: 0 additions & 23 deletions test/functional/global_issue_templates_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,6 @@ def test_update_template
assert_equal 'Update Test Global template2', global_issue_template.description
end

def test_update_template_when_checklist_enable
# Use stub to test with other plugin
mock = MiniTest::Mock.new
mock.expect(:call, true, [:redmine_checklists])
Redmine::Plugin.registered_plugins.stub(:key?, mock) do
checklists_param = %w[check1 check2]

num = GlobalIssueTemplate.count
# when title blank, validation bloks to save.
put :update, params: { id: 2, global_issue_template:
{ description: 'Update Test Global template2 with checklist param', checklists: checklists_param } }

assert_response :redirect # show
assert_equal(num, GlobalIssueTemplate.count)

global_issue_template = GlobalIssueTemplate.find(2)

assert_equal(checklists_param.to_json, global_issue_template.checklist_json)
assert_equal(checklists_param, global_issue_template.checklist)
end
mock.verify
end

def test_update_template_with_empty_title
put :update, params: { id: 2, global_issue_template:
{ title: '' } }
Expand Down
Loading

0 comments on commit 015a7da

Please sign in to comment.