commit fbd394bbc9169581176778e9d7fea5d9eb7dcad0 Author: Rick Barrette Date: Tue Aug 25 20:46:19 2026 -0400 Add initial implementation of Subtask Field Copier plugin with MIT License diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..526207b --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 - 2026 Rick Barrette + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..7d8c8be --- /dev/null +++ b/README.md @@ -0,0 +1,57 @@ +# Redmine Subtask Field Copier + +A lightweight plugin for **Redmine** that automatically copies fields from a parent issue into a newly created subtask, saving time and reducing manual data entry. + +## Features + +* Automatically copies all Custom Field values from the parent issue to the new subtask. +* **Seamless Integrations:** Out-of-the-box support for the `redmine_qbo` and `redmine_qbo_vehicles` plugins (automatically copies Customer, Estimate and Vehicle fields). + +--- + +## Compatibility + +| Plugin Version | Redmine Version | +| :--- | :--- | +| **2026.8.0+** | Redmine 5.x | + +--- + +## Installation + +### 1. Clone the Plugin + +Install the plugin into your Redmine `plugins` directory. + +```bash +cd /path/to/redmine/plugins +git clone https://github.com/rickbarrette/subtask_field_copier.git +cd subtask_field_copier + +# Optional but recommended: Checkout a specific tagged release for stability +git checkout +``` + +### 2. Restart Redmine + +Because this plugin patches the core controller, no database migrations are required. Simply restart your Redmine application server (e.g., Puma, Passenger, or Unicorn) so the plugin and hooks are loaded. + +--- + +## Usage + +Once installed and the server is restarted, there is no configuration needed. Simply navigate to an existing issue, click the **Add Subtask** link, and the new subtask form will automatically be pre-populated with the parent issue's data. + +--- + +## License + +> The MIT License (MIT) +> +> Copyright (c) 2026 Rick Barrette +> +> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +> +> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +> +> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/init.rb b/init.rb new file mode 100644 index 0000000..f3cf348 --- /dev/null +++ b/init.rb @@ -0,0 +1,22 @@ +#The MIT License (MIT) +# +#Copyright (c) 2026 rick barrette +# +#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +# +#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +# +#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +Redmine::Plugin.register :subtask_field_copier do + name 'Redmine subtask field copier' + author 'Rick Barrette' + description 'Copies Issue attributes to subtasks' + version '2026.8.0' + url 'https://github.com/rickbarrette/subtask_field_copier' + author_url 'https://github.com/rickbarrette' + + # Require the core scheduler runner logic + requires_redmine version_or_higher: '5.0.0' +end + +SubtaskFieldCopier.setup \ No newline at end of file diff --git a/lib/subtask_field_copier.rb b/lib/subtask_field_copier.rb new file mode 100644 index 0000000..7d621a9 --- /dev/null +++ b/lib/subtask_field_copier.rb @@ -0,0 +1,18 @@ +#The MIT License (MIT) +# +#Copyright (c) 2026 rick barrette +# +#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +# +#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +# +#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +module SubtaskFieldCopier + + def self.setup + unless IssuesController.ancestors.include?(SubtaskFieldCopier::Patches::IssuesControllerPatch) + IssuesController.prepend SubtaskFieldCopier::Patches::IssuesControllerPatch + end + end +end \ No newline at end of file diff --git a/lib/subtask_field_copier/patches/issues_controller_patch.rb b/lib/subtask_field_copier/patches/issues_controller_patch.rb new file mode 100644 index 0000000..d8505e5 --- /dev/null +++ b/lib/subtask_field_copier/patches/issues_controller_patch.rb @@ -0,0 +1,48 @@ +#The MIT License (MIT) +# +#Copyright (c) 2026 rick barrette +# +#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +# +#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +# +#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +module SubtaskFieldCopier + module Patches + module IssuesControllerPatch + def build_new_issue_from_params + # 1. Run the original Redmine method to initialize @issue + super + + # 2. Only intervene for new subtasks explicitly created via the UI (GET request). + # This prevents overwriting user-submitted data if form validation fails on a POST request. + if request.get? && @issue.new_record? && @issue.parent_issue_id.present? + parent_issue = Issue.find_by_id(@issue.parent_issue_id) + + if parent_issue + # --- COPY CUSTOM FIELDS --- + # Extract all custom field values from the parent and assign them to the new issue + cf_values = {} + parent_issue.custom_field_values.each do |cfv| + cf_values[cfv.custom_field_id] = cfv.value + end + @issue.custom_field_values = cf_values + + # --- COPY CUSTOMER, VEHICLE & ESTIMATE--- + if @issue.respond_to?(:customer=) && parent_issue.respond_to?(:customer) + @issue.customer = parent_issue.customer + end + + if @issue.respond_to?(:vehicle=) && parent_issue.respond_to?(:vehicle) + @issue.vehicle = parent_issue.vehicle + end + + if @issue.respond_to?(:estimate=) && parent_issue.respond_to?(:estimate) + @issue.estimate = parent_issue.estimate + end + end + end + end + end + end +end \ No newline at end of file