eac_redmine_usability 0.3.4 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ef53f5f87605f6af004c3d5638dbbaa32b7815b6ea08a7c6eca2047270fe6366
4
- data.tar.gz: 18793d76896047efe62ed4280ce49552308aa1ac568dfb6cada96f9eee399a40
3
+ metadata.gz: 7a7c99238ed0fb6bfe88cbf78e012b839ffb31412c0b8cbd4a32225fb30ead28
4
+ data.tar.gz: 7e294ae121b3f5551b2ac047a1ee963928015c33544b0c6000c01ca44445df6c
5
5
  SHA512:
6
- metadata.gz: b78956dc9c64c235e337edffa28bae64237589c5fcb84dbecd62d9e8251c9c3f4688d67c08773877b08b030fa9b52a25da28db5f4995e049763b27683428856d
7
- data.tar.gz: c3312d614d22519945873a54c2b2cf6f414333eb6f6b7bde8bc14c8c488444c01f6b936531c6431c1b0a221827605f4d788ac99eb9068a41d2dfa83069ac982c
6
+ metadata.gz: 88fe90303c673f5368ac5641cc7c74e7199b2064bbb1e5e02d9b16bd17783e797f15762f89cf90ad40225977e0e808416422d304e8a68c8fa5e93906978ac4e2
7
+ data.tar.gz: 7cd22be51083a45167796b649ef5bd8c2edf245deafad1e41200aa07680dcdecab47e694980681dae1443b4ca7809c6c79a05d568790cce6f658a52e2106e331
@@ -0,0 +1,99 @@
1
+ class IssueDoneRatioAlternativeInput {
2
+ constructor(originalInputId, alternativeInputId, changerControlId, hiddenContentId) {
3
+ this.originalInputId = originalInputId;
4
+ this.alternativeInputId = alternativeInputId;
5
+ this.changerControlId = changerControlId;
6
+ this.hiddenContentId = hiddenContentId;
7
+ this.initialValue = this.alternativeInput().value;
8
+ this.originalInputSelected = true
9
+ }
10
+
11
+ alternativeInput() {
12
+ return $('#' + this.alternativeInputId);
13
+ }
14
+
15
+ changeInput() {
16
+ if (this.originalInputSelected) {
17
+ this.useAlternativeInput();
18
+ } else {
19
+ this.useOriginalInput();
20
+ }
21
+ }
22
+
23
+ changerControl() {
24
+ return $('#' + this.changerControlId);
25
+ }
26
+
27
+ hiddenContent() {
28
+ return $('#' + this.hiddenContentId);
29
+ }
30
+
31
+ init() {
32
+ if (this.originalInput().length > 0) {
33
+ this.initOriginalInput();
34
+ this.initAlternativeInput();
35
+ this.initChangerControl();
36
+ this.initContent();
37
+ }
38
+ }
39
+
40
+ initAlternativeInput() {
41
+ var THIS = this;
42
+ this.alternativeInput().change(function() {
43
+ THIS.onAlternativeValueChanged();
44
+ });
45
+ this.alternativeInput().attr('name', this.originalInput().attr('name'));
46
+ }
47
+
48
+ initChangerControl() {
49
+ var THIS = this;
50
+ this.changerControl().insertAfter(this.originalInput());
51
+ this.changerControl().click(function() {
52
+ THIS.changeInput();
53
+ return false;
54
+ });
55
+ }
56
+
57
+ initOriginalInput() {
58
+ var THIS = this;
59
+ this.onAlternativeValueChanged()
60
+ this.originalInput().change(function() {
61
+ THIS.onOriginalValueChanged();
62
+ });
63
+ }
64
+
65
+ initContent() {
66
+ $('body').append(this.hiddenContent());
67
+ if (this.originalInput().val() != this.alternativeInput().val()) {
68
+ this.useAlternativeInput();
69
+ }
70
+ }
71
+
72
+ onAlternativeValueChanged() {
73
+ this.originalInput().val(Math.round(this.alternativeInput().val() / 10) * 10);
74
+ }
75
+
76
+ onOriginalValueChanged() {
77
+ this.alternativeInput().val(this.originalInput().val());
78
+ }
79
+
80
+ originalInput() {
81
+ return $('#' + this.originalInputId);
82
+ }
83
+
84
+ useAlternativeInput() {
85
+ if (this.originalInputSelected) {
86
+ this.alternativeInput().insertBefore(this.changerControl());
87
+ this.originalInput().appendTo(this.hiddenContent());
88
+ this.originalInputSelected = false;
89
+ }
90
+ }
91
+
92
+ useOriginalInput() {
93
+ if (!this.originalInputSelected) {
94
+ this.originalInput().insertBefore(this.changerControl());
95
+ this.alternativeInput().appendTo(this.hiddenContent());
96
+ this.originalInputSelected = true;
97
+ }
98
+ }
99
+ }
@@ -0,0 +1 @@
1
+ //= require eac_redmine_usability/issue_done_ratio_alternative_input
@@ -0,0 +1,8 @@
1
+ #issue_done_ratio_alternative {
2
+ width: 95px;
3
+ }
4
+
5
+ #issue_done_ratio_changer {
6
+ margin-left: 0.3em;
7
+ color: green;
8
+ }
@@ -0,0 +1 @@
1
+ @import 'eac_redmine_usability/issue_done_ratio_alternative_input';
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_redmine_usability/hooks/done_ratio_alternative_input'
@@ -0,0 +1,2 @@
1
+ en:
2
+ issue_done_ratio_change_control: Change control
@@ -0,0 +1,2 @@
1
+ pt-BR:
2
+ issue_done_ratio_change_control: Alternar controle
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacRedmineUsability
4
+ module Hooks
5
+ class DoneRatioAlternativeInput < ::Redmine::Hook::ViewListener
6
+ attr_accessor :output_buffer
7
+
8
+ ORIGINAL_INPUT_ID = 'issue_done_ratio'
9
+ ALTERNATIVE_INPUT_ID = ORIGINAL_INPUT_ID + '_alternative'
10
+ CHANGER_CONTROL_ID = ORIGINAL_INPUT_ID + '_changer'
11
+ HIDDEN_CONTENT_ID = ORIGINAL_INPUT_ID + '_hidden_content'
12
+ ELEMENTS_IDS = [ORIGINAL_INPUT_ID, ALTERNATIVE_INPUT_ID, CHANGER_CONTROL_ID,
13
+ HIDDEN_CONTENT_ID].freeze
14
+
15
+ MINIMUM_VALUE = 0
16
+ MAXIMUM_VALUE = 100
17
+
18
+ # @param context [Hash]
19
+ # return [ActiveSupport::SafeBuffer]
20
+ def view_issues_form_details_bottom(context = {})
21
+ safe_join([hidden_content(context[:issue]), script_tag])
22
+ end
23
+
24
+ private
25
+
26
+ # return [ActiveSupport::SafeBuffer]
27
+ def alternative_input(issue)
28
+ tag(:input, id: ALTERNATIVE_INPUT_ID, type: 'number', value: issue.done_ratio,
29
+ min: MINIMUM_VALUE, max: MAXIMUM_VALUE)
30
+ end
31
+
32
+ # return [ActiveSupport::SafeBuffer]
33
+ def changer_control
34
+ link_to('', '#', id: CHANGER_CONTROL_ID, class: 'icon icon-move',
35
+ title: I18n.t('issue_done_ratio_change_control'))
36
+ end
37
+
38
+ # @return [String]
39
+ def elements_ids_argument_list
40
+ ELEMENTS_IDS.map { |id| "'#{id}'" }.join(', ')
41
+ end
42
+
43
+ # return [ActiveSupport::SafeBuffer]
44
+ def hidden_content(issue)
45
+ tag.div(id: HIDDEN_CONTENT_ID, style: 'display: none;') do
46
+ safe_join([alternative_input(issue), changer_control])
47
+ end
48
+ end
49
+
50
+ # return [String]
51
+ def script_content
52
+ <<~SCRIPT
53
+ $(document).ready(function() {
54
+ (new IssueDoneRatioAlternativeInput(#{elements_ids_argument_list})).init();
55
+ });
56
+ SCRIPT
57
+ end
58
+
59
+ # return [ActiveSupport::SafeBuffer]
60
+ def script_tag
61
+ javascript_tag script_content
62
+ end
63
+ end
64
+ end
65
+ end
@@ -25,11 +25,12 @@ module EacRedmineUsability
25
25
 
26
26
  module InstanceMethods
27
27
  def block_destroy
28
- return true if ::EacRedmineUsability::Undeletable.allow_destroy
28
+ return if ::EacRedmineUsability::Undeletable.allow_destroy
29
29
 
30
30
  errors.add :base, 'Este registro não pode ser removido. Em vez disso tente associá-lo a ' \
31
31
  'um status como "Rejeitado" ou "Depreciado".'
32
- false
32
+
33
+ throw(:abort)
33
34
  end
34
35
  end
35
36
  end
@@ -3,7 +3,7 @@
3
3
  module EacRedmineUsability
4
4
  SLUG = 'eac_redmine_usability'
5
5
  NAME = 'E.A.C.\'s Redmine Usability'
6
- VERSION = '0.3.4'
6
+ VERSION = '0.4.0'
7
7
  AUTHOR = 'Eduardo Henrique Bogoni'
8
8
  SUMMARY = ''
9
9
  end
@@ -1,18 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rake/testtask'
3
+ require 'redmine_plugins_helper/plugin_rake_task'
4
+ ::RedminePluginsHelper::PluginRakeTask.register(:eac_redmine_usability, :test)
4
5
 
5
6
  namespace :eac_redmine_usability do
6
- Rake::TestTask.new(test: 'db:test:prepare') do |t|
7
- plugin_root = ::File.dirname(::File.dirname(__dir__))
8
-
9
- t.description = 'Run plugin eac_redmine_usability\'s tests.'
10
- t.libs << 'test'
11
- t.test_files = FileList["#{plugin_root}/test/**/*_test.rb"]
12
- t.verbose = false
13
- t.warning = false
14
- end
15
-
16
7
  desc 'Close projects no longer used.'
17
8
  task :close_unused_projects, %i[expire_days confirm] => :environment do |_t, args|
18
9
  ::EacRedmineUsability::CloseUnusedProjects.new(
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eac_redmine_usability
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eduardo Henrique Bogoni
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-07 00:00:00.000000000 Z
11
+ date: 2023-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eac_ruby_utils
@@ -16,45 +16,47 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.95'
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: 0.95.1
19
+ version: '0.119'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
24
  - - "~>"
28
25
  - !ruby/object:Gem::Version
29
- version: '0.95'
30
- - - ">="
31
- - !ruby/object:Gem::Version
32
- version: 0.95.1
26
+ version: '0.119'
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: eac_ruby_gem_support
35
29
  requirement: !ruby/object:Gem::Requirement
36
30
  requirements:
37
31
  - - "~>"
38
32
  - !ruby/object:Gem::Version
39
- version: 0.5.1
33
+ version: 0.6.0
40
34
  type: :development
41
35
  prerelease: false
42
36
  version_requirements: !ruby/object:Gem::Requirement
43
37
  requirements:
44
38
  - - "~>"
45
39
  - !ruby/object:Gem::Version
46
- version: 0.5.1
40
+ version: 0.6.0
47
41
  description:
48
42
  email:
49
43
  executables: []
50
44
  extensions: []
51
45
  extra_rdoc_files: []
52
46
  files:
47
+ - app/assets/javascripts/eac_redmine_usability.js
48
+ - app/assets/javascripts/eac_redmine_usability/issue_done_ratio_alternative_input.js
49
+ - app/assets/stylesheets/eac_redmine_usability.css
50
+ - app/assets/stylesheets/eac_redmine_usability/issue_done_ratio_alternative_input.css
53
51
  - config/initializers/000_dependencies.rb
54
52
  - config/initializers/001_patches.rb
53
+ - config/initializers/002_hooks.rb
54
+ - config/locales/en.yml
55
+ - config/locales/pt-BR.yml
55
56
  - init.rb
56
57
  - lib/eac_redmine_usability/close_unused_projects.rb
57
58
  - lib/eac_redmine_usability/close_unused_projects/project_check.rb
59
+ - lib/eac_redmine_usability/hooks/done_ratio_alternative_input.rb
58
60
  - lib/eac_redmine_usability/patches/test_case.rb
59
61
  - lib/eac_redmine_usability/undeletable.rb
60
62
  - lib/eac_redmine_usability/version.rb