Skip to content
This repository was archived by the owner on Apr 13, 2021. It is now read-only.

Commit 681f0f2

Browse files
authored
Merge pull request #69 from annikoff/develop
Version 1.0.0
2 parents 88f5258 + ff620b7 commit 681f0f2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+770
-415
lines changed

.hound.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ruby:
2+
config_file: .rubocop.yml

.rubocop.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
AllCops:
2+
Exclude:
3+
- 'db/**/*'
4+
DisplayCopNames: true
5+
DisplayStyleGuide: true
6+
7+
Metrics/AbcSize:
8+
Max: 30
9+
10+
Metrics/MethodLength:
11+
Max: 25
12+
13+
Style/ClassAndModuleChildren:
14+
Enabled: false
15+
16+
Style/Documentation:
17+
Enabled: false
18+
19+
Style/FrozenStringLiteralComment:
20+
Enabled: false
21+
22+
Style/PredicateName:
23+
Enabled: false
24+
25+
Lint/RescueException:
26+
Enabled: false

.travis.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
language: ruby
2+
3+
rvm:
4+
- 2.1
5+
6+
gemfile:
7+
- $REDMINE_PATH/Gemfile
8+
9+
env:
10+
- REDMINE_VER=3.3-stable
11+
- REDMINE_VER=3.2-stable
12+
- REDMINE_VER=3.1-stable
13+
- REDMINE_VER=3.0-stable
14+
- REDMINE_VER=2.6-stable
15+
16+
matrix:
17+
include:
18+
- rvm: 1.9.3
19+
env: REDMINE_VER=2.5-stable
20+
21+
before_install:
22+
- export PLUGIN_NAME=computed_custom_field
23+
- export REDMINE_PATH=$HOME/redmine
24+
- git clone -b "$REDMINE_VER" --single-branch https://github.com/redmine/redmine.git $REDMINE_PATH
25+
- ln -s $TRAVIS_BUILD_DIR $REDMINE_PATH/plugins/$PLUGIN_NAME
26+
- cp config/database.yml.travis $REDMINE_PATH/config/database.yml
27+
- if [[ $(ruby --version | awk '{print $2}') < 2.1 ]]; then
28+
echo "gem 'nokogiri', '= 1.5.11'" >> $REDMINE_PATH/Gemfile;
29+
sed -ri 's/("selenium-webdriver")/\1, "= 2.53.4"/' $REDMINE_PATH/Gemfile; fi
30+
- cd $REDMINE_PATH
31+
- if [[ $REDMINE_VER < '3.2-stable' ]]; then
32+
echo "$(curl http://www.redmine.org/projects/redmine/repository/revisions/14891/diff/trunk/lib/tasks/redmine.rake?format=diff)" > redmine.rake.patch;
33+
patch lib/tasks/redmine.rake redmine.rake.patch; fi
34+
- export DISPLAY=:99.0
35+
- sh -e /etc/init.d/xvfb start
36+
- phantomjs --webdriver 4444 &
37+
38+
install:
39+
- bundle install --without development
40+
41+
before_script:
42+
- bundle exec rake db:create
43+
- bundle exec rake db:migrate
44+
- bundle exec rake redmine:plugins:migrate
45+
46+
script:
47+
- bundle exec rake redmine:plugins:test NAME=$PLUGIN_NAME
48+
- bundle exec rake redmine:plugins:test:ui NAME=$PLUGIN_NAME
49+
50+
notifications:
51+
email: false

CHANGELOG.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# Change Log
2+
3+
## [1.0.0](https://github.com/annikoff/redmine_plugin_computed_custom_field/releases/tag/v1.0.0) - 2017-02-15
4+
### Added
5+
- New formula constructions `cfs[cf_id]`. Thanks to [ecanuto](https://github.com/ecanuto) for the idea.
6+
- Tests.
7+
- CHANGELOG.
8+
- Redmine 2.5.x support.
9+
10+
### Changed
11+
- Code has been rewritten from scratch.
12+
- No backward compatibility with older versions.
13+
- There is no separate computed format anymore. Custom field of any built-in format can be created as computed.
14+
- README.
15+
16+
### Removed
17+
- Old formula constructions `%{cf_id}`.
18+
- Output formats.
19+
20+
## [0.0.8](https://github.com/annikoff/redmine_plugin_computed_custom_field/releases/tag/v0.0.8) - 2016-11-27
21+
### Added
22+
- Error handling to prevent internal server errors. From [swiehr](https://github.com/swiehr).
23+
- zh translation from [archonwang](https://github.com/archonwang).
24+
25+
### Changed
26+
- README.
27+
28+
### Fixed
29+
- Link formatting.
30+
31+
## [0.0.7](https://github.com/annikoff/redmine_plugin_computed_custom_field/releases/tag/v0.0.7) - 2016-08-29
32+
### Added
33+
- Markdown link format support.
34+
- Grouping functionality for queries. From [plotterie](https://github.com/plotterie).
35+
36+
### Changed
37+
- README.
38+
39+
### Fixed
40+
- Typo in a custom field form. From [swiehr](https://github.com/swiehr).
41+
- Error when validating DateTime.
42+
43+
## [0.0.6](https://github.com/annikoff/redmine_plugin_computed_custom_field/releases/tag/v0.0.6) - 2016-01-15
44+
### Added
45+
- Totalable support for Redmine 3.x.
46+
47+
### Fixed
48+
- Error when trying to save iIssue from TimeEntry if Issue does not present.
49+
50+
## [0.0.5](https://github.com/annikoff/redmine_plugin_computed_custom_field/releases/tag/v0.0.5) - 2015-12-21
51+
### Added
52+
- Link output format.
53+
- pt-br translation from [Adriano Ceccarelli](https://github.com/aceccarelli).
54+
55+
### Changed
56+
- README.
57+
- Error message about formula computing.
58+
59+
### Fixed
60+
- Exclude Document class from list of classes for a patch.
61+
62+
## [0.0.4](https://github.com/annikoff/redmine_plugin_computed_custom_field/releases/tag/v0.0.4) - 2015-10-22
63+
### Added
64+
- Boolean and Percentage output formats.
65+
- TimeEntry callbacks to re-save Issue.
66+
- fr translation from [Atmis](https://github.com/Atmis).
67+
68+
### Removed
69+
- Tests examples
70+
71+
### Fixed
72+
- Bug when formula validation
73+
74+
## [0.0.3](https://github.com/annikoff/redmine_plugin_computed_custom_field/releases/tag/v0.0.3) - 2015-09-23
75+
### Added
76+
- String and Datetime output formats.
77+
- Query filter options.
78+
79+
### Fixed
80+
- Formula validation is evaluated in proper context.
81+
82+
## [0.0.2](https://github.com/annikoff/redmine_plugin_computed_custom_field/releases/tag/v0.0.2) - 2015-09-20
83+
### Added
84+
- Int and Float output formats.
85+
- en translation.
86+
- es translation from [lublasco](https://github.com/lublasco).
87+
- Formula validation.
88+
89+
### Changed
90+
- List of classes for a patch.
91+
- README.
92+
- Excluded CF own id from available fields list.
93+
94+
### Removed
95+
- Groups of custom fields from creation form.
96+
97+
### Fixed
98+
- Conversion error when formula computation
99+
100+
## [0.0.1](https://github.com/annikoff/redmine_plugin_computed_custom_field/releases/tag/v0.0.1) - 2015-08-13
101+
### Added
102+
- Base functionality.

PluginGemfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
group :development do
2+
gem 'rubocop', require: false
3+
end

README.md

Lines changed: 46 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,76 @@
11
### ComputedCustomField plugin for Redmine
22

3+
[![Build Status](https://travis-ci.org/annikoff/redmine_plugin_computed_custom_field.svg?branch=master)](https://travis-ci.org/annikoff/redmine_plugin_computed_custom_field)
4+
[![Code Climate](https://codeclimate.com/github/annikoff/redmine_plugin_computed_custom_field/badges/gpa.svg)](https://codeclimate.com/github/annikoff/redmine_plugin_computed_custom_field)
5+
36
### Description:
4-
This plugin adds a new type of Custom Field named "computed".
5-
The value of computed field can be set by formula.
6-
In formula constructions like %{cf_id} are replaced by IDs of custom fields.
7-
Valid formula is a valid Ruby code executed when customized object is updated.
7+
8+
This plugin provides a possibility to create a computed custom field.
9+
The value of computed field can be set by formula.
10+
In formula constructions like `cfs[cf_id]` are replaced by IDs of custom fields.
11+
Valid formula is a valid Ruby code executed when customized object is updated.
812
To put a field ID in the formula, double-click on an item in the list of available fields.
913

10-
![ComputedCustomField plugin for Redmine](https://raw.githubusercontent.com/annikoff/images/master/redmine_plugin_computed_custom_field.png "")
14+
15+
![ComputedCustomField plugin for Redmine](https://raw.githubusercontent.com/annikoff/images/master/redmine_plugin_computed_custom_field_v_1_0_0.png)
16+
17+
### Changelog:
18+
19+
Plugin's changelog is available [here](CHANGELOG.md).
20+
21+
### Important information
22+
23+
This is a new version of the plugin. Since version 1.0.0 it is not compatible with previous versions.
24+
The following constructions in formula `%{cf_id}` are no longer supported. Instead use `cfs[cf_id]`.
25+
If you need to upgrade from older versions, please check out migration section.
1126

1227
> ### Notes:
13-
> - %{cf_id} &mdash; must be an ID of existing custom field
14-
> - If format of Custom Field is Text, Long Text or List, you need to surround '%{cf_id}' with quotes
15-
> - Be careful with code in formula, if it would wrong your application can be crashed
16-
> - This plugin has been tested on Redmine v2.6.7 with RoR v3.2.22 and Redmine v3.1 with RoR v4.2.3
17-
> - There are six types of output format: "int", "float", "string", "link", "datetime", "bool", "percentage"
18-
> - If a computed custom field was created after creating of customized object you need to re-save an object to evaluate computations
19-
> - After updating of formula customized objects should be re-saved
28+
> - cfs[cf_id] &mdash; must be an ID of existing custom field.
29+
> - Be careful with code in formula, if it would wrong your application can be crashed.
30+
> - If a computed custom field was created after creating of customized object you need to re-save an object to evaluate computations.
31+
> - After updating of formula customized objects should be re-saved.
2032
2133
### Installation:
2234

2335
Clone from GitHub
2436
```sh
37+
# Latest version
2538
git clone https://github.com/annikoff/redmine_plugin_computed_custom_field.git computed_custom_field
2639
```
2740

2841
Or download [ZIP-archive](https://github.com/annikoff/redmine_plugin_computed_custom_field/archive/master.zip) and extract it into "computed_custom_field" directory.
2942

43+
Run migrations
44+
```sh
45+
rake redmine:plugins:migrate
46+
```
47+
48+
### Migration:
49+
- Navigate to plugin folder.
50+
- Run `git pull`
51+
- Run `rake redmine:plugins:migrate`
52+
- In computed CF's formulas replace `%{cf_id}` constructions by `cfs[cf_id]`.
53+
54+
### Compatibility
55+
56+
The plugins supports the following Redmine versions: 3.3.x, 3.2.x, 3.1.x, 3.0.x, 2.6.x, 2.5.x.
57+
3058
### Examples:
3159
```ruby
32-
%{cf_1}*2+%{cf_2}
60+
cfs[1]*2+cfs[2]
3361
# means
3462
# custom_field_value(1) * 2 + custom_field_value(2)
3563
```
3664

3765
```ruby
38-
(%{cf_1}/3.14).round(2)
66+
(cfs[1]/3.14).round(2)
3967
```
4068

4169
```ruby
42-
if %{cf_1}.zero?
43-
%{cf_2}/2
70+
if cfs[1].zero?
71+
cfs[2]/2
4472
else
45-
%{cf_3}/2
73+
cfs[3]/2
4674
end
4775
```
4876

@@ -56,21 +84,11 @@ end
5684
self.parent_id == 2
5785
```
5886

59-
```ruby
60-
# If format of Custom Field with ID 4 is Text, Long Text or List
61-
'%{cf_4}'
62-
```
63-
6487
```ruby
6588
# If format of Custom Field is Link
6689
"/projects/#{self.project_id.to_s}/issues/new?issue[subject]=Review+request+[##{self.id.to_s} #{self.subject}]&issue[tracker_id]=3"
6790
```
6891

69-
```ruby
70-
# If format of Custom Field is Link, and you need to set up a specific link caption
71-
"'Click here for more details':/projects/#{project.try(:identifier)}/wiki"
72-
```
73-
7492
To write formulas this documentation can be helpful:
7593
- [Issue](http://www.rubydoc.info/github/edavis10/redmine/Issue)
7694
- [Project](http://www.rubydoc.info/github/edavis10/redmine/Project)
@@ -81,4 +99,4 @@ To write formulas this documentation can be helpful:
8199
- [Document](http://www.rubydoc.info/github/edavis10/redmine/Document)
82100
- [TimeEntryActivity, IssuePriority, DocumentCategory](http://www.rubydoc.info/github/edavis10/redmine/Enumeration)
83101

84-
Licensed under the [MIT-LICENSE](https://raw.githubusercontent.com/annikoff/redmine_plugin_computed_custom_field/master/MIT-LICENSE)
102+
Licensed under the [MIT-LICENSE](MIT-LICENSE)

app/views/formats/_computed.html.erb

Lines changed: 0 additions & 55 deletions
This file was deleted.

app/views/hooks/_base_head.html.erb

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<% if custom_field.new_record? || custom_field.is_computed? %>
2+
<p><%= form.check_box :is_computed,
3+
data: { enables: '#custom_field_formula, #available_cfs' },
4+
disabled: !custom_field.new_record? %></p>
5+
<p><%= form.text_area :formula, rows: 7 %></p>
6+
<p>
7+
<%= label_tag l(:label_available_custom_fields) %>
8+
<%= render_computed_custom_fields_select custom_field %>
9+
</p>
10+
11+
<script type="text/javascript">
12+
(function() {
13+
$("#available_cfs").dblclick(function() {
14+
var formula = $("#custom_field_formula");
15+
$(this).find("option:selected").each(function() {
16+
formula.val(formula.val() + 'cfs[' + $(this).val() + ']');
17+
});
18+
});
19+
}())
20+
</script>
21+
<% end %>

0 commit comments

Comments
 (0)