├── .travis.yml ├── GPL.txt ├── README.md ├── app ├── controllers │ └── issue_checklists_controller.rb ├── helpers │ └── issue_checklists_helper.rb ├── models │ └── issue_checklist.rb └── views │ ├── issue_checklists │ ├── _checklist_item.html.erb │ └── done.js.erb │ ├── issues │ ├── _checklist.html.erb │ └── _checklist_form.html.erb │ └── settings │ └── _issue_checklist.html.erb ├── assets ├── javascripts │ ├── issue_checklist.jquery.js │ ├── issue_checklist.js │ ├── issue_checklist.prototype.js │ └── jquery.klass.js └── stylesheets │ └── issue_checklist.css ├── config ├── database-mysql-travis.yml ├── database-postgresql-travis.yml ├── locales │ ├── de.yml │ ├── en.yml │ ├── fr.yml │ ├── pt.yml │ ├── ru.yml │ ├── tr.yml │ └── zh.yml └── routes.rb ├── db └── migrate │ └── 20111010202847_create_issue_checklists.rb ├── doc ├── issue_checklist_1.png ├── issue_checklist_2.png ├── issue_checklist_3.png ├── issue_checklist_4.png └── issue_checklist_5.png ├── init.rb ├── lib └── redmine_issue_checklist │ ├── hooks │ ├── model_issue_hook.rb │ └── views_issues_hook.rb │ ├── patches │ ├── issue_patch.rb │ └── issues_controller_patch.rb │ └── redmine_issue_checklist.rb └── test ├── fixtures └── issue_checklists.yml ├── functional ├── issue_checklists_controller_test.rb └── redmine_issue_checklist │ └── settings_controller_test.rb ├── test_helper.rb └── unit └── issue_checklist_test.rb /.travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | 3 | services: 4 | - mysql 5 | - postgresql 6 | 7 | rvm: 8 | - 2.3.1 9 | 10 | gemfile: 11 | - $REDMINE_PATH/Gemfile 12 | 13 | env: 14 | - REDMINE_VER=3.1.7 DB=mysql 15 | - REDMINE_VER=3.2.4 DB=mysql 16 | - REDMINE_VER=3.3.1 DB=mysql 17 | - REDMINE_VER=3.1.7 DB=postgresql 18 | - REDMINE_VER=3.2.4 DB=postgresql 19 | - REDMINE_VER=3.3.1 DB=postgresql 20 | 21 | before_install: 22 | - export PLUGIN_NAME=redmine_issue_checklist 23 | - export REDMINE_PATH=$HOME/redmine 24 | - svn co http://svn.redmine.org/redmine/tags/$REDMINE_VER $REDMINE_PATH 25 | - ln -s $TRAVIS_BUILD_DIR $REDMINE_PATH/plugins/$PLUGIN_NAME 26 | - cp config/database-$DB-travis.yml $REDMINE_PATH/config/database.yml 27 | - cd $REDMINE_PATH 28 | 29 | before_script: 30 | - bundle exec rake db:create 31 | - bundle exec rake db:migrate 32 | - bundle exec rake redmine:plugins:migrate 33 | 34 | script: 35 | - bundle exec rake redmine:plugins:test NAME=$PLUGIN_NAME RUBYOPT="-W0" 36 | 37 | -------------------------------------------------------------------------------- /GPL.txt: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Redmine Issue Checklist Plugin 2 | 3 | [![Build Status](https://travis-ci.org/Restream/redmine_issue_checklist.svg?branch=master)](https://travis-ci.org/Restream/redmine_issue_checklist) 4 | [![Code Climate](https://codeclimate.com/github/Restream/redmine_issue_checklist/badges/gpa.svg)](https://codeclimate.com/github/Restream/redmine_issue_checklist) 5 | 6 | This plugin enables you to add checklists to Redmine issues. 7 | 8 | The initial author of the plugin is [Kirill Bezrukov](http://www.redminecrm.com/projects/checklist/pages/1) 9 | 10 | ## Compatibility 11 | 12 | This plugin version is compatible only with Redmine 3.0 and later. 13 | 14 | ## Installation 15 | 16 | 1. To install the plugin 17 | * Download the .ZIP archive, extract files and copy the plugin directory into #{REDMINE_ROOT}/plugins. 18 | 19 | Or 20 | 21 | * Change you current directory to your Redmine root directory: 22 | 23 | cd {REDMINE_ROOT} 24 | 25 | Copy the plugin from GitHub using the following commands: 26 | 27 | git clone https://github.com/Restream/redmine_issue_checklist.git plugins/redmine_issue_checklist 28 | 29 | 2. Update the Gemfile.lock file by running the following commands: 30 | 31 | bundle install 32 | 33 | 3. This plugin requires a migration. Run the following command to upgrade your database (make a database backup before): 34 | 35 | bundle exec rake redmine:plugins:migrate RAILS_ENV=production 36 | 37 | 4. Restart Redmine. 38 | 39 | Now you should be able to see the plugin in **Administration > Plugins**. 40 | 41 | ## Usage 42 | 43 | The Redmine Issue Checklist plugin enables you to add checklists to Redmine issues. 44 | 45 | You can configure the plugin to track the checklist changes in the issue log and change the issue done ratio based on the checklist progress. To do this, go to **Administration > Plugins**, clik**Configure** and select the corresponding check boxes. 46 | ![plugin settings](doc/issue_checklist_1.png) 47 | 48 | To add a checklist to an issue, enter the checklist item text into the the **Checklist** field in the issue description and click the **+** button. 49 | ![checklist item](doc/issue_checklist_2.png) 50 | 51 | You can add as many checklist items as you need. To rearrange the checklist, drag and drop the items in the desired order. To delete an item, click the trash bin icon. 52 | ![checklist item](doc/issue_checklist_3.png) 53 | 54 | To mark the completed checklist items, select the corresponding check boxes. The plugin will display the changes in the issue log and change the issue done ratio, if you have configured it accordingly. 55 | ![progress](doc/issue_checklist_4.png) 56 | 57 | To manage checklist-related permissions, go to **Administration > Roles and permissions**, click the role name and select or clear the required check boxes. 58 | ![permissions](doc/issue_checklist_5.png) 59 | 60 | ## Testing 61 | 62 | Run tests using the following command: 63 | 64 | rake redmine:plugins:test NAME=redmine_issue_checklist RAILS_ENV=test_sqlite3 65 | 66 | ## Maintainers 67 | 68 | Danil Tashkinov, [github.com/nodecarter](https://github.com/nodecarter) 69 | 70 | ## License 71 | 72 | Redmine Checklist plugin is open source and released under the terms of the GNU General Public License v2 (GPL). 73 | -------------------------------------------------------------------------------- /app/controllers/issue_checklists_controller.rb: -------------------------------------------------------------------------------- 1 | class IssueChecklistsController < ApplicationController 2 | 3 | before_action :find_checklist_item 4 | 5 | def done 6 | (render_403; return false) unless User.current.allowed_to?(:done_checklists, @checklist_item.issue.project) 7 | 8 | old_checklist_item = @checklist_item.dup 9 | @checklist_item.is_done = !@checklist_item.is_done 10 | 11 | if @checklist_item.save 12 | if RedmineIssueChecklist.settings[:save_log] && old_checklist_item.info != @checklist_item.info 13 | journal = Journal.new(journalized: @checklist_item.issue, user: User.current) 14 | journal.details << JournalDetail.new( 15 | property: 'attr', 16 | prop_key: 'checklist', 17 | # old_value: old_checklist_item.info, 18 | value: @checklist_item.info) 19 | journal.save 20 | end 21 | 22 | if (Setting.issue_done_ratio == 'issue_field') && RedmineIssueChecklist.settings[:issue_done_ratio] 23 | done_checklist = @checklist_item.issue.checklist.map { |c| c.is_done ? 1 : 0 } 24 | @checklist_item.issue.done_ratio = (done_checklist.count(1) * 10) / done_checklist.count * 10 25 | @checklist_item.issue.save 26 | end 27 | end 28 | respond_to do |format| 29 | format.js 30 | format.html { redirect_to :back } 31 | end 32 | 33 | end 34 | 35 | def delete 36 | (render_403; return false) unless User.current.allowed_to?(:edit_checklists, @checklist_item.issue.project) 37 | 38 | @checklist_item.delete 39 | respond_to do |format| 40 | format.js do 41 | render :update do |page| 42 | page["checklist_item_#{@checklist_item.id}"].visual_effect :fade 43 | end 44 | end 45 | format.html { redirect_to :back } 46 | end 47 | 48 | end 49 | 50 | private 51 | 52 | def find_checklist_item 53 | @checklist_item = IssueChecklist.find(params[:checklist_item_id]) 54 | @project = @checklist_item.issue.project 55 | end 56 | 57 | end 58 | -------------------------------------------------------------------------------- /app/helpers/issue_checklists_helper.rb: -------------------------------------------------------------------------------- 1 | module IssueChecklistsHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/models/issue_checklist.rb: -------------------------------------------------------------------------------- 1 | class IssueChecklist < ActiveRecord::Base 2 | belongs_to :issue 3 | belongs_to :author, class_name: 'User', foreign_key: 'author_id' 4 | has_one :comment, as: :commented, dependent: :delete 5 | acts_as_list 6 | 7 | attr_accessible :is_done, :subject 8 | attr_protected :id 9 | 10 | validates_presence_of :subject 11 | 12 | # after_save :recalc_issue_done_ratio 13 | 14 | def editable_by?(usr=User.current) 15 | usr && (usr.allowed_to?(:edit_checklists, project) || (self.author == usr && usr.allowed_to?(:edit_own_checklists, project))) 16 | end 17 | 18 | def project 19 | self.issue.project if self.issue 20 | end 21 | 22 | def info 23 | "[#{self.is_done ? 'x' : ' ' }] #{self.subject.strip}" 24 | end 25 | 26 | def recalc_issue_done_ratio 27 | return false if (Setting.issue_done_ratio != 'issue_field') || !RedmineIssueChecklist.settings[:issue_done_ratio] 28 | done_checklist = issue.checklist.map { |c| c.is_done ? 1 : 0 } 29 | issue.done_ratio = (done_checklist.count(1) * 10) / done_checklist.count * 10 30 | issue.save 31 | end 32 | 33 | end 34 | -------------------------------------------------------------------------------- /app/views/issue_checklists/_checklist_item.html.erb: -------------------------------------------------------------------------------- 1 |
  • > 2 | <%= check_box_tag 'checklist_item', '1', checklist_item.is_done, 3 | disabled: !User.current.allowed_to?(:done_checklists, checklist_item.issue.project), 4 | onclick: "checklist_item_done(this,'#{url_for({ controller: 'issue_checklists', action: 'done', checklist_item_id: checklist_item.id, is_done: (checklist_item.is_done == false) })}','#{checklist_item.id}')" 5 | %> 6 | <%= textilizable(checklist_item, :subject).gsub(/<\/?(p|h\d+|li|ul)>/, '').strip.html_safe %> 7 |
  • 8 | -------------------------------------------------------------------------------- /app/views/issue_checklists/done.js.erb: -------------------------------------------------------------------------------- 1 | $("#checklist_item_<%= @checklist_item.id %>").toggleClass('is-done-checklist-item') -------------------------------------------------------------------------------- /app/views/issues/_checklist.html.erb: -------------------------------------------------------------------------------- 1 | <% if !@issue.blank? && @issue.checklist.any? && User.current.allowed_to?(:view_checklists, @project) %> 2 | 3 |
    4 |
    5 |

    <%= l(:label_issue_checklist_plural) %>

    6 | 7 |
      8 | <% @issue.checklist.each do |checklist_item| %> 9 | <%= render partial: 'issue_checklists/checklist_item', object: checklist_item %> 10 | <% end %> 11 |
    12 |
    13 | 14 | <% end %> 15 | 16 | <% content_for :header_tags do %> 17 | <% if Redmine::VERSION::MAJOR == 3 || (Redmine::VERSION::MAJOR == 2 && Redmine::VERSION::MINOR >= 1) %> 18 | <%= javascript_include_tag 'jquery.klass.js', plugin: 'redmine_issue_checklist' %> 19 | <%= javascript_include_tag 'issue_checklist.jquery.js', plugin: 'redmine_issue_checklist' %> 20 | <% else %> 21 | <%= javascript_include_tag 'issue_checklist.prototype.js', plugin: 'redmine_issue_checklist' %> 22 | <% end %> 23 | <%= stylesheet_link_tag :issue_checklist, plugin: 'redmine_issue_checklist' %> 24 | <% end %> 25 | -------------------------------------------------------------------------------- /app/views/issues/_checklist_form.html.erb: -------------------------------------------------------------------------------- 1 | <%= fields_for :issue, issue do |f| -%> 2 |
    3 |

    4 | 5 | 6 | <%= text_field_tag 'new_checklist', '', 7 | id: 'add_checklist_item_input' %> 8 | <%= link_to '', '#', 9 | id: 'add_checklist_item_button', 10 | class: 'tag-add icon icon-add' %> 11 | <%= file_field_tag 'import_checklist', 12 | id: 'import_checklist_items_input', 13 | accept: 'text/plain' %> 14 | 15 | <%= javascript_tag "observeIssueChecklistField('checklist_form_items', 'add_checklist_item_input', 'add_checklist_item_button', 'import_checklist_items_input');" %> 16 | <%= javascript_tag "createIssueChecklist(#{@issue.checklist.collect { |cli| { is_done: cli.is_done, subject: cli.subject, id: cli.id } }.to_json.html_safe});" %> 17 |

    18 |
    19 | <% end if User.current.allowed_to?(:edit_checklists, @project) -%> 20 | 21 | 22 | <% content_for :header_tags do %> 23 | <% if Redmine::VERSION::MAJOR == 3 || (Redmine::VERSION::MAJOR == 2 && Redmine::VERSION::MINOR >= 1) %> 24 | <%= javascript_include_tag 'jquery.klass.js', plugin: 'redmine_issue_checklist' %> 25 | <%= javascript_include_tag 'issue_checklist.jquery.js', plugin: 'redmine_issue_checklist' %> 26 | <% else %> 27 | <%= javascript_include_tag 'issue_checklist.prototype.js', plugin: 'redmine_issue_checklist' %> 28 | <% end %> 29 | <%= stylesheet_link_tag :issue_checklist, plugin: 'redmine_issue_checklist' %> 30 | <% end %> 31 | -------------------------------------------------------------------------------- /app/views/settings/_issue_checklist.html.erb: -------------------------------------------------------------------------------- 1 | <% @settings = {} unless @settings.is_a? Hash %> 2 |

    3 | 4 | <%= check_box_tag 'settings[save_log]', 1, @settings[:save_log] %> 5 |

    6 | 7 | <% if Setting.issue_done_ratio == 'issue_field' %> 8 |

    9 | 10 | <%= check_box_tag 'settings[issue_done_ratio]', 1, @settings[:issue_done_ratio] %> 11 |

    12 | <% end %> 13 | -------------------------------------------------------------------------------- /assets/javascripts/issue_checklist.jquery.js: -------------------------------------------------------------------------------- 1 | window.onload = function() { 2 | $('#checklist_form_items').sortable(); 3 | }; 4 | 5 | var Redmine = Redmine || {}; 6 | 7 | $.fn.issue_check_list = function(element, input, button, fileInput) {}; 8 | 9 | Redmine.IssueChecklist = jQuery.klass({ 10 | init: function(element, input, button, fileInput) { 11 | this.element = $('#' + element); 12 | this.input = $('#' + input); 13 | this.button = $('#' + button); 14 | this.fileInput = $('#' + fileInput); 15 | this.checklist = {}; 16 | this.button.click($.proxy(this.readChecklist, this)); 17 | this.fileInput.on('change', $.proxy(this.onFileInputChange, this)); 18 | this.input.keypress($.proxy(this.onKeyPress, this)); 19 | this.input.on('dragover', $.proxy(this.onDragOver, this)); 20 | this.input.on('drop', $.proxy(this.onDrop, this)); 21 | }, 22 | 23 | readChecklist: function(event) { 24 | this.addChecklistItem(this.input.val()); 25 | this.input.val(''); 26 | event.preventDefault(); 27 | }, 28 | 29 | onKeyPress: function(event) { 30 | if (13 == event.keyCode) { 31 | this.readChecklist(event); 32 | event.preventDefault(); 33 | } 34 | }, 35 | 36 | addChecklistItem: function(сhecklistItem, isDone, id) { 37 | if ($.isEmptyObject(сhecklistItem)) { 38 | return; 39 | } 40 | 41 | isDone = isDone || false; 42 | 43 | var hidden = $(document.createElement('input')); 44 | hidden.attr({'type': 'hidden', 'name': 'check_list_items[][subject]', 'value':$.trim(сhecklistItem)}); 45 | var button = $(document.createElement('span')); 46 | button.attr({'href': '#', 'class': 'delete icon icon-del' }); 47 | var checkbox = $(document.createElement('input')); 48 | checkbox.attr({'type': 'checkbox', 'name': 'check_list_items[][is_done]', 'value': '1', 'id': 'checklist_item_checkbox_'+id}); 49 | var label = $(document.createElement('span')); 50 | label.attr({ 'class': 'checklist-item' }).append(hidden).append(checkbox).append($.trim(сhecklistItem)).append(button); 51 | 52 | if (isDone == true) { 53 | checkbox.attr('checked', 'checked'); 54 | label.addClass('is-done-checklist-item'); 55 | } 56 | 57 | this.checklist[сhecklistItem] = 1; 58 | this.element.append(label); 59 | 60 | button.click($.proxy(function(){ 61 | this.checklist[сhecklistItem] = null; 62 | label.remove(); 63 | // Event.stop(event); 64 | }, this)); 65 | 66 | checkbox.click($.proxy(function(){ 67 | if (checkbox.is(':checked')) { 68 | label.addClass('is-done-checklist-item'); 69 | } else { 70 | label.removeClass('is-done-checklist-item'); 71 | }; 72 | }, this)); 73 | 74 | }, 75 | 76 | addChecklist: function(checklist) { 77 | for (var i = 0; i < checklist.length; i++) { 78 | this.addChecklistItem(checklist[i]['subject'], checklist[i]['is_done'], checklist[i]['id']); 79 | } 80 | }, 81 | 82 | getChecklist: function() { 83 | return this.checklist; 84 | }, 85 | 86 | onDragOver: function(event) { 87 | event.stopPropagation(); 88 | event.preventDefault(); 89 | event.originalEvent.dataTransfer.dropEffect = 'copy'; 90 | }, 91 | 92 | onDrop: function(event) { 93 | var file = event.dataTransfer.files[0]; 94 | 95 | event.stopPropagation(); 96 | event.preventDefault(); 97 | 98 | if (file) { 99 | this.parseMultiLineFile(file); 100 | } 101 | }, 102 | 103 | onFileInputChange: function(event) { 104 | var file = event.target.files[0]; 105 | if (file) { 106 | this.parseMultiLineFile(file); 107 | } 108 | }, 109 | 110 | parseMultiLineFile: function (file) { 111 | if (!(window.File && window.FileReader) || !file || 112 | !file.type.match('text.*')) { 113 | return false; 114 | } 115 | 116 | var _this = this; 117 | var reader = new window.FileReader(); 118 | 119 | reader.onload = function(event) { 120 | var result = event.target.result; 121 | var lines = result.split("\n").filter(function(el) { 122 | return !$.isEmptyObject(el); 123 | }); 124 | 125 | if (lines.length && window.confirm('Import ' + lines.length + ' checklist items?')) { 126 | lines.forEach(function(line) { 127 | _this.addChecklistItem(line); 128 | }); 129 | }; 130 | }; 131 | 132 | reader.readAsText(file); 133 | } 134 | }); 135 | 136 | function observeIssueChecklistField(element, input, add_button, fileInput) { 137 | issueChecklist = new Redmine.IssueChecklist(element, input, 138 | add_button, fileInput); 139 | } 140 | 141 | function createIssueChecklist(checkList) { 142 | issueChecklist.addChecklist(checkList); 143 | } 144 | 145 | function checklist_item_done(elem,url,id){ 146 | $.ajax({url: url, 147 | dataType: 'script', 148 | data: 'checklist_item_' + id}); 149 | var checkbox = $('#checklist_item_checkbox_'+id); 150 | if (checkbox.is(':checked')) { 151 | checkbox.removeAttr('checked'); 152 | } else { 153 | checkbox.attr('checked', true); 154 | } 155 | } 156 | -------------------------------------------------------------------------------- /assets/javascripts/issue_checklist.js: -------------------------------------------------------------------------------- 1 | window.onload = function () { 2 | Sortable.create('checklist_form_items', {tag: 'span'}); 3 | }; 4 | 5 | var Redmine = Redmine || {}; 6 | 7 | Redmine.IssueChecklist = Class.create({ 8 | initialize: function (element, input, button) { 9 | this.element = $(element); 10 | this.input = $(input); 11 | this.button = $(button); 12 | this.checklist = new Hash(); 13 | 14 | Event.observe(this.button, 'click', this.readChecklist.bindAsEventListener(this)); 15 | Event.observe(this.input, 'keypress', this.onKeyPress.bindAsEventListener(this)); 16 | }, 17 | 18 | readChecklist: function (event) { 19 | this.addChecklistItem(this.input.value); 20 | this.input.value = ''; 21 | Event.stop(event); 22 | }, 23 | 24 | onKeyPress: function (event) { 25 | if (Event.KEY_RETURN == event.keyCode) { 26 | this.readChecklist(event); 27 | Event.stop(event); 28 | } 29 | }, 30 | 31 | addChecklistItem: function (сhecklistItem, isDone) { 32 | if (сhecklistItem.blank()) return; 33 | 34 | isDone = isDone || false; 35 | 36 | var hidden = new Element('input', { 37 | 'type': 'hidden', 38 | 'name': 'check_list_items[][subject]', 39 | 'value': сhecklistItem.strip() 40 | }); 41 | var button = new Element('span', {'href': '#', 'class': 'delete icon icon-del'}); 42 | var checkbox = new Element('input', {'type': 'checkbox', 'name': 'check_list_items[][is_done]', 'value': '1'}); 43 | var label = new Element('span', {'class': 'checklist-item'}).insert(hidden).insert(checkbox).insert(сhecklistItem.strip()).insert(button); 44 | 45 | if (isDone == true) { 46 | checkbox.setAttribute('checked', 'checked'); 47 | label.addClassName('is-done-checklist-item'); 48 | } 49 | 50 | this.checklist.set(сhecklistItem, 1); 51 | this.element.insert({'bottom': label}); 52 | 53 | Event.observe(button, 'click', function () { 54 | this.checklist.unset(сhecklistItem); 55 | label.remove(); 56 | // Event.stop(event); 57 | }.bind(this)); 58 | 59 | Event.observe(checkbox, 'click', function () { 60 | if (checkbox.checked == true) { 61 | label.addClassName('is-done-checklist-item'); 62 | } 63 | else { 64 | label.removeClassName('is-done-checklist-item'); 65 | } 66 | 67 | }.bind(this)); 68 | 69 | }, 70 | 71 | addChecklist: function (checklist) { 72 | for (var i = 0; i < checklist.length; i++) { 73 | this.addChecklistItem(checklist[i]['subject'], checklist[i]['is_done']); 74 | } 75 | }, 76 | 77 | getChecklist: function () { 78 | return this.checklist; 79 | }, 80 | 81 | }); 82 | 83 | function observeIssueChecklistField(element, input, add_button) { 84 | issueChecklist = new Redmine.IssueChecklist(element, input, add_button); 85 | } 86 | 87 | function createIssueChecklist(checkList) { 88 | issueChecklist.addChecklist(checkList); 89 | } 90 | -------------------------------------------------------------------------------- /assets/javascripts/issue_checklist.prototype.js: -------------------------------------------------------------------------------- 1 | window.onload = function () { 2 | Sortable.create('checklist_form_items', {tag: 'span'}); 3 | }; 4 | 5 | var Redmine = Redmine || {}; 6 | 7 | Redmine.IssueChecklist = Class.create({ 8 | initialize: function (element, input, button) { 9 | this.element = $(element); 10 | this.input = $(input); 11 | this.button = $(button); 12 | this.checklist = new Hash(); 13 | 14 | Event.observe(this.button, 'click', this.readChecklist.bindAsEventListener(this)); 15 | Event.observe(this.input, 'keypress', this.onKeyPress.bindAsEventListener(this)); 16 | }, 17 | 18 | readChecklist: function (event) { 19 | this.addChecklistItem(this.input.value); 20 | this.input.value = ''; 21 | Event.stop(event); 22 | }, 23 | 24 | onKeyPress: function (event) { 25 | if (Event.KEY_RETURN == event.keyCode) { 26 | this.readChecklist(event); 27 | Event.stop(event); 28 | } 29 | }, 30 | 31 | addChecklistItem: function (сhecklistItem, isDone) { 32 | if (сhecklistItem.blank()) return; 33 | 34 | isDone = isDone || false; 35 | 36 | var hidden = new Element('input', { 37 | 'type': 'hidden', 38 | 'name': 'check_list_items[][subject]', 39 | 'value': сhecklistItem.strip() 40 | }); 41 | var button = new Element('span', {'href': '#', 'class': 'delete icon icon-del'}); 42 | var checkbox = new Element('input', {'type': 'checkbox', 'name': 'check_list_items[][is_done]', 'value': '1'}); 43 | var label = new Element('span', {'class': 'checklist-item'}).insert(hidden).insert(checkbox).insert(сhecklistItem.strip()).insert(button); 44 | 45 | if (isDone == true) { 46 | checkbox.setAttribute('checked', 'checked'); 47 | label.addClassName('is-done-checklist-item'); 48 | } 49 | 50 | this.checklist.set(сhecklistItem, 1); 51 | this.element.insert({'bottom': label}); 52 | 53 | Event.observe(button, 'click', function () { 54 | this.checklist.unset(сhecklistItem); 55 | label.remove(); 56 | // Event.stop(event); 57 | }.bind(this)); 58 | Event.observe(checkbox, 'click', function () { 59 | if (checkbox.checked == true) { 60 | label.addClassName('is-done-checklist-item'); 61 | } 62 | else { 63 | label.removeClassName('is-done-checklist-item'); 64 | } 65 | 66 | }.bind(this)); 67 | 68 | }, 69 | 70 | addChecklist: function (checklist) { 71 | for (var i = 0; i < checklist.length; i++) { 72 | this.addChecklistItem(checklist[i]['subject'], checklist[i]['is_done']); 73 | } 74 | }, 75 | 76 | getChecklist: function () { 77 | return this.checklist; 78 | }, 79 | 80 | }); 81 | 82 | function observeIssueChecklistField(element, input, add_button) { 83 | issueChecklist = new Redmine.IssueChecklist(element, input, add_button); 84 | } 85 | 86 | function createIssueChecklist(checkList) { 87 | issueChecklist.addChecklist(checkList); 88 | } 89 | function checklist_item_done(elem, url, id) { 90 | new Ajax.Request(url, 91 | { 92 | method: 'get', 93 | onSuccess: function (transport) { 94 | var response = transport.responseText || "no response text"; 95 | eval(response) 96 | }, 97 | onFailure: function () { 98 | alert('Something went wrong...') 99 | } 100 | }); 101 | 102 | var checkbox = $(elem) 103 | if (checkbox) 104 | if (checkbox.checked) 105 | checkbox.up().addClassName('is-done-checklist-item'); 106 | else 107 | checkbox.up().removeClassName('is-done-checklist-item'); 108 | } -------------------------------------------------------------------------------- /assets/javascripts/jquery.klass.js: -------------------------------------------------------------------------------- 1 | /*! jQuery klass v0.2a - Jean-Louis Grall - MIT license - http://code.google.com/p/jquery-klass-plugin */ 2 | 3 | ( function( $, undefined ) { 4 | 5 | 6 | // Function: $.klass( [SuperKlass,] props ) 7 | // Creates and returns a new class. 8 | // Usages: MyKlass = $.klass( { init: function() { ... } } ) 9 | // MyKlass = $.klass( SuperKlass, { } ) 10 | // Arguments: 11 | // SuperKlass (optional) The super class that the new class will extend. 12 | // props Set of methods and other class properties. 13 | // Special props names: 14 | // init The constructor. If omitted, an implicit init will be created. 15 | // Thus all classes have an init method. 16 | // _klass Set of class methods (static methods). They will be added directly to the class. 17 | // Notes: 18 | // - $.klass is the implicit super class, not Object 19 | var $klass = $.klass = function( _super, fields ) { // The class factory. It is also the invisible "super class" of all classes. Methods added to its prototype will be available to all classes. 20 | 21 | // If no _super: 22 | if ( !fields ) { 23 | fields = _super; 24 | _super = undefined; 25 | } 26 | 27 | var 28 | // init is our future class and constructor 29 | // If no init is provided, make one (Implicit constructor) 30 | klass = fields.init || ( fields.init = function() { 31 | // Automatically calls the superconstructor if there is one. 32 | _super && _super.prototype.init.apply( this, arguments ); 33 | } ), 34 | 35 | // Used to make the new klass extends its super class 36 | protoChainingProxy = function() { }, 37 | 38 | // klass.prototype 39 | proto, 40 | 41 | // index in loop 42 | name; 43 | 44 | // Prepare prototype chaining to the super class 45 | // If no super class, use $.klass as implicit super class 46 | protoChainingProxy.prototype = (_super || $klass).prototype; 47 | // Make the [[prototype]]'s chain from klass to it's super class 48 | proto = klass.prototype = new protoChainingProxy; // At the end we have: klass.prototype.[[prototype]] = protoChainingProxy.prototype = _super.prototype. Here the "new" operator creates the new object with the right prototype chain, but doesn't call the constructor because there is no "()". See also: http://brokenliving.blogspot.com/2009/09/simple-javascript-inheritance.html 49 | // Now we have: klass.prototype.[[prototype]] = protoChainingProxy.prototype = _super.prototype 50 | 51 | // Accessor for super klass ( can be undefined ) 52 | klass._super = _super; 53 | 54 | // Add each function to the prototype of the new class (they are our new class methods): 55 | for ( name in fields ) { 56 | // Add the static variables to the new class: 57 | if ( name === "_klass" ) $.extend( klass, fields[name] ); 58 | // Each new method keeps a reference to its name and its class, allowing us to find its super method dynamically at runtime: 59 | else $.isFunction( proto[ name ] = fields[name] ) && ( fields[name]._klass = { klass: klass, name: name } ); 60 | } 61 | 62 | // Sets the constructor for instanciated objects 63 | proto.constructor = klass; 64 | 65 | return klass; 66 | }, 67 | Array_slice = [].slice; 68 | 69 | 70 | /* $.klass.prototype */ 71 | // Properties assigned to it are available from any instance of a class made by $.klass 72 | 73 | // Function: this._super( [ methodName,] arguments, args... ) 74 | // Calls a super method. Finds the super method dynamically. 75 | // Usages: this._super( arguments, arg1, arg2, arg3, ... ) 76 | // this._super( "methodName", arguments, arg1, arg2, arg3, ... ) 77 | // Arguments: 78 | // methodName (optional) Name of the super method. 79 | // By default, use the name of the calling method. 80 | // arguments You must give the arguments object here. 81 | // args... List of arguments for the super method. 82 | // Note: 83 | // - Super methods are found dynamically by the function in the super class using the method's name. 84 | $klass.prototype._super = function( arg0, arg1 ) { 85 | var arg0IsArguments = arg0.callee, 86 | _klass = ( arg0IsArguments ? arg0 : arg1 ).callee._klass, 87 | name = arg0IsArguments ? _klass.name : arg0, 88 | superMethod = _klass.klass._super.prototype[ name ]; 89 | return superMethod.apply( this, Array_slice.call( arguments, 1 + ( !arg0IsArguments ) ) ); 90 | }; 91 | 92 | })( jQuery ); -------------------------------------------------------------------------------- /assets/stylesheets/issue_checklist.css: -------------------------------------------------------------------------------- 1 | 2 | div#issue_checklist ul { 3 | list-style: none; 4 | padding-left: 0px; 5 | margin-bottom: 0px; 6 | } 7 | 8 | div#issue_checklist li { 9 | padding-bottom: 10px; 10 | margin-left: 10px; 11 | } 12 | 13 | input#checklist_item { 14 | margin-right: 10px; 15 | } 16 | 17 | #issue_checklist a.delete img { 18 | vertical-align: top; 19 | margin-left: 5px; 20 | } 21 | 22 | #issue_checklist li:hover a.delete { 23 | opacity: 1; 24 | } 25 | 26 | #issue_checklist a.delete { 27 | opacity: 0.4; 28 | } 29 | 30 | span.checklist-item { 31 | display: block; 32 | margin-bottom: 5px; 33 | } 34 | 35 | span.checklist-item.is-done-checklist-item, #issue_checklist_items li.is-done-checklist-item { 36 | text-decoration: line-through; 37 | color: #999; 38 | } 39 | 40 | span.checklist-item .delete { 41 | margin-left: 2px; 42 | opacity: 0.4; 43 | } 44 | 45 | span.checklist-item:hover .delete { 46 | opacity: 1; 47 | } 48 | 49 | span.checklist-item input { 50 | margin-right: 6px; 51 | } 52 | 53 | #add_checklist_item_input { 54 | width: 40%; 55 | } 56 | -------------------------------------------------------------------------------- /config/database-mysql-travis.yml: -------------------------------------------------------------------------------- 1 | # http://about.travis-ci.org/docs/user/database-setup/#MySQL 2 | test: 3 | adapter: mysql2 4 | database: redmine 5 | username: travis 6 | encoding: utf8 7 | -------------------------------------------------------------------------------- /config/database-postgresql-travis.yml: -------------------------------------------------------------------------------- 1 | # http://about.travis-ci.org/docs/user/database-setup/#PostgreSQL 2 | test: 3 | adapter: postgresql 4 | database: redmine 5 | username: postgres 6 | -------------------------------------------------------------------------------- /config/locales/de.yml: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | # German strings go here for Rails i18n 3 | # German translation by Tobias Fischer https://github.com/paginagmbh 4 | de: 5 | label_issue_checklist_plural: Checkliste 6 | field_checklist: Checkliste 7 | label_checklist_save_log: "Speichere �nderungen in der Ticket-Historie" 8 | label_checklist_done_ratio: Aktualisiere den Ticket-Fortschritt 9 | 10 | -------------------------------------------------------------------------------- /config/locales/en.yml: -------------------------------------------------------------------------------- 1 | # English strings go here for Rails i18n 2 | en: 3 | label_issue_checklist_plural: Checklist 4 | field_checklist: Checklist 5 | label_checklist_save_log: Save changes to the issue log 6 | label_checklist_done_ratio: Automatically change the issue done ratio 7 | permission_view_checklists: View checklist items 8 | permission_done_checklists: Change done ratio based on checklist 9 | permission_edit_checklists: Edit checklist items 10 | -------------------------------------------------------------------------------- /config/locales/fr.yml: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | fr: 3 | label_issue_checklist_plural: Liste de Tâches 4 | field_checklist: Tâche 5 | -------------------------------------------------------------------------------- /config/locales/pt.yml: -------------------------------------------------------------------------------- 1 | # Portuguese strings go here for Rails i18n 2 | pt: 3 | label_issue_checklist_plural: Checklist 4 | field_checklist: Checklist 5 | label_checklist_save_log: Salvar as alterações do checklists nos logs da tarefa 6 | label_checklist_done_ratio: Automaticamente alterar o percentual de conclusão ao concluir o checklist 7 | permission_view_checklists: Visualizar itens de checklist 8 | permission_done_checklists: Alterar o percentual de conclusão baseado no checklist 9 | permission_edit_checklists: Editar itens do checklist 10 | -------------------------------------------------------------------------------- /config/locales/ru.yml: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | ru: 3 | label_issue_checklist_plural: Чеклист 4 | field_checklist: Чеклист 5 | label_checklist_save_log: Сохранять изменения в истории 6 | label_checklist_done_ratio: Рассчитывать готовность задачи 7 | permission_view_checklists: Просматривать чеклисты 8 | permission_done_checklists: Выполнять чеклисты 9 | permission_edit_checklists: Редактировать чеклисты 10 | 11 | -------------------------------------------------------------------------------- /config/locales/tr.yml: -------------------------------------------------------------------------------- 1 | # Turkish strings go here for Rails i18n 2 | tr: 3 | label_checklist_plural: Kontrol Listeleri 4 | field_checklist: Kontrol Listesi 5 | label_checklist_save_log: Değişiklikleri iş geçmişine kaydet 6 | label_checklist_done_ratio: İş tamamlanma oranını set et 7 | permission_view_checklists: Kontrol listelerini gör 8 | permission_done_checklists: Kontrol listelerini tikle 9 | permission_edit_checklists: Kontrol listelerini düzenle 10 | -------------------------------------------------------------------------------- /config/locales/zh.yml: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | # Simplified Chinese strings go here for Rails i18n 3 | # Author: Steven.W 4 | # Based on file: en.yml 5 | 6 | zh: 7 | label_issue_checklist_plural: 检查列表 8 | field_checklist: 检查列表 9 | label_checklist_save_log: 保存检查列表变更到问题日志 10 | label_checklist_done_ratio: 设置列表完成比率 11 | permission_view_checklists: 查看检查列表 12 | permission_done_checklists: 完成检查项 13 | permission_edit_checklists: 编辑检查项 14 | -------------------------------------------------------------------------------- /config/routes.rb: -------------------------------------------------------------------------------- 1 | 2 | match 'checklist/done/:checklist_item_id', to: 'issue_checklists#done', via: [:get, :post] 3 | match 'checklist/delete/:checklist_item_id', to: 'issue_checklists#delete', via: [:get, :post] 4 | -------------------------------------------------------------------------------- /db/migrate/20111010202847_create_issue_checklists.rb: -------------------------------------------------------------------------------- 1 | class CreateIssueChecklists < ActiveRecord::Migration 2 | def self.up 3 | create_table :issue_checklists do |t| 4 | t.boolean :is_done, default: false 5 | t.string :subject 6 | t.integer :position, default: 1 7 | t.references :issue, null: false 8 | end 9 | end 10 | 11 | def self.down 12 | drop_table :issue_checklists 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /doc/issue_checklist_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Restream/redmine_issue_checklist/be213c471bbbb1a548134c6a24435d1a413684a1/doc/issue_checklist_1.png -------------------------------------------------------------------------------- /doc/issue_checklist_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Restream/redmine_issue_checklist/be213c471bbbb1a548134c6a24435d1a413684a1/doc/issue_checklist_2.png -------------------------------------------------------------------------------- /doc/issue_checklist_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Restream/redmine_issue_checklist/be213c471bbbb1a548134c6a24435d1a413684a1/doc/issue_checklist_3.png -------------------------------------------------------------------------------- /doc/issue_checklist_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Restream/redmine_issue_checklist/be213c471bbbb1a548134c6a24435d1a413684a1/doc/issue_checklist_4.png -------------------------------------------------------------------------------- /doc/issue_checklist_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Restream/redmine_issue_checklist/be213c471bbbb1a548134c6a24435d1a413684a1/doc/issue_checklist_5.png -------------------------------------------------------------------------------- /init.rb: -------------------------------------------------------------------------------- 1 | require 'redmine' 2 | 3 | require 'redmine_issue_checklist/redmine_issue_checklist' 4 | 5 | Redmine::Plugin.register :redmine_issue_checklist do 6 | name 'Redmine Issue Checklist Plugin' 7 | author 'Kirill Bezrukov' 8 | description 'This plugin adds checklists to Redmine issues.' 9 | version '2.1.0' 10 | url 'http://redminecrm.com' 11 | author_url 'mailto:kirbez@redminecrm.com' 12 | 13 | requires_redmine version_or_higher: '2.0.0' 14 | 15 | settings default: { 16 | save_log: false, 17 | issue_done_ratio: false 18 | }, partial: 'settings/issue_checklist' 19 | 20 | Redmine::AccessControl.map do |map| 21 | map.project_module :issue_tracking do |map| 22 | map.permission :view_checklists, {} 23 | map.permission :done_checklists, { issue_checklist: :done } 24 | map.permission :edit_checklists, { issue_checklist: :delete, issue_checklist: :done } 25 | end 26 | end 27 | 28 | end 29 | -------------------------------------------------------------------------------- /lib/redmine_issue_checklist/hooks/model_issue_hook.rb: -------------------------------------------------------------------------------- 1 | # This file is a part of redmine_tags 2 | # redMine plugin, that adds tagging support. 3 | # 4 | # Copyright (c) 2010 Eric Davis 5 | # Copyright (c) 2010 Aleksey V Zapparov AKA ixti 6 | # 7 | # redmine_tags is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # redmine_tags is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with redmine_tags. If not, see . 19 | 20 | module RedmineIssueChecklist 21 | module Hooks 22 | class ModelIssueHook < Redmine::Hook::ViewListener 23 | 24 | def controller_issues_edit_before_save(context={}) 25 | if User.current.allowed_to?(:edit_checklists, context[:issue].project) 26 | save_checklist_to_issue(context, RedmineIssueChecklist.settings[:save_log]) 27 | end 28 | end 29 | 30 | def controller_issues_new_after_save(context={}) 31 | if User.current.allowed_to?(:edit_checklists, context[:issue].project) 32 | save_checklist_to_issue(context, false) 33 | context[:issue].save 34 | end 35 | end 36 | 37 | def save_checklist_to_issue(context, create_journal) 38 | issue = context[:issue] 39 | checklist_items = context[:params] && context[:params][:check_list_items] 40 | issue.update_checklist_items(checklist_items, create_journal) if issue && checklist_items 41 | end 42 | 43 | end 44 | end 45 | end 46 | -------------------------------------------------------------------------------- /lib/redmine_issue_checklist/hooks/views_issues_hook.rb: -------------------------------------------------------------------------------- 1 | module RedmineIssueChecklist 2 | module Hooks 3 | class ViewsIssuesHook < Redmine::Hook::ViewListener 4 | render_on :view_issues_show_description_bottom, partial: 'issues/checklist' 5 | render_on :view_issues_form_details_bottom, partial: 'issues/checklist_form' 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/redmine_issue_checklist/patches/issue_patch.rb: -------------------------------------------------------------------------------- 1 | require_dependency 'issue' 2 | 3 | module RedmineIssueChecklist 4 | module Patches 5 | 6 | module IssuePatch 7 | 8 | def self.included(base) # :nodoc: 9 | base.send(:include, InstanceMethods) 10 | base.class_eval do 11 | alias_method_chain :copy_from, :checklist 12 | has_many :checklist, class_name: 'IssueChecklist', dependent: :destroy 13 | end 14 | 15 | end 16 | 17 | module InstanceMethods 18 | def copy_from_with_checklist(arg, options={}) 19 | copy_from_without_checklist(arg, options) 20 | issue = arg.is_a?(Issue) ? arg : Issue.visible.find(arg) 21 | self.checklist = issue.checklist.map { |cl| cl.dup } 22 | self.checklist.each do |object| 23 | object.is_done = nil 24 | end 25 | self 26 | end 27 | 28 | def update_checklist_items(checklist_items, create_journal = false) 29 | checklist_items ||= [] 30 | 31 | old_checklist = checklist.collect(&:info).join(', ') 32 | 33 | checklist.destroy_all 34 | checklist << checklist_items.uniq.collect do |cli| 35 | IssueChecklist.new(is_done: cli[:is_done], subject: cli[:subject]) 36 | end 37 | 38 | new_checklist = checklist.collect(&:info).join(', ') 39 | 40 | if current_journal && create_journal && (new_checklist != old_checklist) 41 | current_journal.details << JournalDetail.new( 42 | property: 'attr', 43 | prop_key: 'checklist', 44 | old_value: old_checklist, 45 | value: new_checklist) 46 | end 47 | end 48 | 49 | end 50 | 51 | end 52 | 53 | end 54 | end 55 | 56 | 57 | unless Issue.included_modules.include?(RedmineIssueChecklist::Patches::IssuePatch) 58 | Issue.send(:include, RedmineIssueChecklist::Patches::IssuePatch) 59 | end 60 | -------------------------------------------------------------------------------- /lib/redmine_issue_checklist/patches/issues_controller_patch.rb: -------------------------------------------------------------------------------- 1 | module RedmineIssueChecklist 2 | module Patches 3 | module IssuesControllerPatch 4 | extend ActiveSupport::Concern 5 | 6 | included do 7 | alias_method_chain :build_new_issue_from_params, :checklist 8 | end 9 | 10 | def build_new_issue_from_params_with_checklist 11 | build_new_issue_from_params_without_checklist 12 | if User.current.allowed_to?(:edit_checklists, @issue.project) 13 | @issue.update_checklist_items(params[:check_list_items]) 14 | end 15 | end 16 | end 17 | end 18 | end 19 | 20 | unless IssuesController.included_modules.include? RedmineIssueChecklist::Patches::IssuesControllerPatch 21 | IssuesController.send :include, RedmineIssueChecklist::Patches::IssuesControllerPatch 22 | end 23 | -------------------------------------------------------------------------------- /lib/redmine_issue_checklist/redmine_issue_checklist.rb: -------------------------------------------------------------------------------- 1 | require 'redmine_issue_checklist/hooks/views_issues_hook' 2 | require 'redmine_issue_checklist/hooks/model_issue_hook' 3 | 4 | Rails.configuration.to_prepare do 5 | require 'redmine_issue_checklist/patches/issue_patch' 6 | require 'redmine_issue_checklist/patches/issues_controller_patch' 7 | end 8 | 9 | module RedmineIssueChecklist 10 | 11 | def self.settings() 12 | Setting[:plugin_redmine_issue_checklist].blank? ? {} : Setting[:plugin_redmine_issue_checklist] 13 | end 14 | 15 | end 16 | 17 | -------------------------------------------------------------------------------- /test/fixtures/issue_checklists.yml: -------------------------------------------------------------------------------- 1 | # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html 2 | one: 3 | id: 1 4 | is_done: false 5 | subject: First todo 6 | issue_id: 1 7 | two: 8 | id: 2 9 | is_done: false 10 | subject: Second todo 11 | issue_id: 1 12 | three: 13 | id: 3 14 | is_done: true 15 | subject: Third todo 16 | issue_id: 2 17 | -------------------------------------------------------------------------------- /test/functional/issue_checklists_controller_test.rb: -------------------------------------------------------------------------------- 1 | require File.dirname(__FILE__) + '/../test_helper' 2 | 3 | class IssueChecklistsControllerTest < ActionController::TestCase 4 | fixtures :projects, 5 | :users, 6 | :roles, 7 | :members, 8 | :member_roles, 9 | :issues, 10 | :issue_statuses, 11 | :versions, 12 | :trackers, 13 | :projects_trackers, 14 | :issue_categories, 15 | :enabled_modules, 16 | :enumerations, 17 | :attachments, 18 | :workflows, 19 | :custom_fields, 20 | :custom_values, 21 | :custom_fields_projects, 22 | :custom_fields_trackers, 23 | :time_entries, 24 | :journals, 25 | :journal_details, 26 | :queries, 27 | :issue_checklists 28 | 29 | def setup 30 | RedmineIssueChecklist::TestCase.prepare 31 | Setting.default_language = 'en' 32 | end 33 | 34 | # test "should not post new by deny user" do 35 | # @request.session[:user_id] = 5 36 | # 37 | # xhr :post, :new, issue_id: 1, new_checklist_item: "New checklist item" 38 | # assert_response 401 39 | # end 40 | 41 | 42 | test 'should post done' do 43 | # log_user('admin', 'admin') 44 | @request.session[:user_id] = 1 45 | 46 | xhr :post, :done, is_done: true, checklist_item_id: '1' 47 | assert_response :success 48 | assert_equal true, IssueChecklist.find(1).is_done 49 | end 50 | 51 | test 'should not post done by deny user' do 52 | # log_user('admin', 'admin') 53 | @request.session[:user_id] = 5 54 | 55 | xhr :post, :done, is_done: true, checklist_item_id: '1' 56 | assert_response 403 57 | end 58 | 59 | end 60 | -------------------------------------------------------------------------------- /test/functional/redmine_issue_checklist/settings_controller_test.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../test_helper', __FILE__) 2 | 3 | class RedmineIssueChecklist::SettingsControllerTest < ActionController::TestCase 4 | fixtures :users 5 | 6 | def test_plugin_settings 7 | @controller = SettingsController.new 8 | @request = ActionController::TestRequest.new 9 | @response = ActionController::TestResponse.new 10 | User.current = User.find(1) 11 | @request.session[:user_id] = 1 # admin 12 | Setting.plugin_redmine_issue_checklist = '' 13 | get :plugin, id: 'redmine_issue_checklist' 14 | assert_response :success 15 | end 16 | 17 | end 18 | -------------------------------------------------------------------------------- /test/test_helper.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../../test/test_helper', __FILE__) 2 | 3 | #Engines::Testing.set_fixture_path 4 | ActiveRecord::Fixtures.create_fixtures(File.dirname(__FILE__) + '/fixtures/', 5 | File.basename('issue_checklists', '.*')) 6 | class RedmineIssueChecklist::TestCase 7 | def self.prepare 8 | Role.find(1, 2, 3, 4).each do |r| 9 | r.permissions << :edit_checklists 10 | r.save 11 | end 12 | 13 | Role.find(3, 4).each do |r| 14 | r.permissions << :done_checklists 15 | r.save 16 | end 17 | 18 | Project.find(1, 2, 3, 4, 5).each do |project| 19 | EnabledModule.create(project: project, name: 'issue_checklist') 20 | end 21 | end 22 | 23 | end 24 | -------------------------------------------------------------------------------- /test/unit/issue_checklist_test.rb: -------------------------------------------------------------------------------- 1 | require File.dirname(__FILE__) + '/../test_helper' 2 | 3 | class IssueChecklistTest < ActiveSupport::TestCase 4 | fixtures :issue_checklists 5 | 6 | # Replace this with your real tests. 7 | def test_truth 8 | assert true 9 | end 10 | end 11 | --------------------------------------------------------------------------------