How to modify a system field to be a required item when updating the issue like "spent time"
Added by shuang guo over 6 years ago
our team need to collect working time from every member.So we can know the effect
But our member always forget to write the time,so we want [spent time] on the web could be a required item
Now I just modifid this file:\redmine\htdocs\app\views\issues\_edit.html.erb
though it has a * showing on the web,it still can pass without anything
I don't know how to do now
spent_time.jpg (88.7 KB) spent_time.jpg |
Replies (6)
RE: How to modify a system field to be a required item when updating the issue like "spent time" - Added by Martin Denizet (redmine.org team member) over 6 years ago
Hello,
I think the easiest solution is to install this plugin: http://www.redmine.org/plugins/redmine_custom_js
And then use the plugin to inject the following JavaScript:
jQuery( document ).ready(function() {
jQuery('#issue-form #time_entry_hours').prop('required',true);
});
Disclamer: I wrote that plugin.
Done, that easy :)
Cheers,
RE: How to modify a system field to be a required item when updating the issue like "spent time" - Added by shuang guo over 6 years ago
Martin Denizet (redmine.org team member) wrote:
Hello,
I think the easiest solution is to install this plugin: http://www.redmine.org/plugins/redmine_custom_js
And then use the plugin to inject the following JavaScript:
[...]
Disclamer: I wrote that plugin.
Done, that easy :)
Cheers,
Thankyou verymuch! But I cannot install this plugin. Always said not found the plugin
And my redmine is 3.4.3,I'm not sure whether it not suits
plugin-install.jpg (163 KB) plugin-install.jpg |
RE: How to modify a system field to be a required item when updating the issue like "spent time" - Added by Martin Denizet (redmine.org team member) over 6 years ago
Hello, I just published a new version today.
Is it possible that you didn't name correctly the plugin folder?
It should be: /path/to/redmine/plugins/redmine_custom_js
If you renamed the folder to anything else, you will get trouble.
Do you have a log entry related to that?
Cheers,
RE: How to modify a system field to be a required item when updating the issue like "spent time" - Added by shuang guo over 6 years ago
thank you very much!
I can install now.Because when I use the name of[redmine_custom_js-master],it always said cannot found. And then I changed into[redmine_custom_js],it works!
But a new problem,I found it cannot come out an error message like other null situation when I submit.Only tells me this textfield need to be filled.
Could this be improved?
RE: How to modify a system field to be a required item when updating the issue like "spent time" - Added by Martin Denizet (redmine.org team member) over 6 years ago
How about this?
jQuery( document ).ready(function() {
jQuery('#issue-form #time_entry_hours').prop('required',true);
jQuery('#issue-form #time_entry_hours').on("invalid", function(event) {
this.setCustomValidity('You need to input your spent time')
});
jQuery('#issue-form #time_entry_hours').on("change", function(event) {
this.setCustomValidity('')
});
});
If you need more complexity, you will probably need to write your own Ruby plugin.
Let me know how it goes.
Cheers,
RE: How to modify a system field to be a required item when updating the issue like "spent time" - Added by shuang guo over 6 years ago
thankyou very much!
I really appreciate your help.
And it works!