问题
I am upgrading my Jira from 4.3.2 to 5.1.8. I have my reporter field as read-only field for couple of transitions.
I wanted to make this reporter field as read-only in Jira 5.1.8 also. But when I install compatible version for Jira 5.1.8 i.e. Behaviour Plugin 0.5.3. then reporter field or any other user picker is not made as read-only.
This is a Bug for Behaviour Plugin. Can anyone please tell me the workaround for this?
Any help will be appreciable...
Thanks in Advance.
Renu
回答1:
UPDATE
How are you applying this? when running on the browser console, this should do the job:
AJS.$("#reporter-field").attr("disabled", true);
but when entering it to a field description use
<script type="text/javascript">
AJS.$(document).ready(function() {
AJS.$("#reporter-field").attr("disabled", true);
});
</script>
You can apply this script in the following ways:
- go to
View Field Configuration
and edit thereporter
field and add this code as description. - add it to a custom field description. this custom field should be present on every screen that the
reporter
field is at. - add it to the
Announcement Banner
description
That will make the reporter
field to be read only in all the screens. To disable the quick edit option, add this to the Announcement Banner
description:
<script type="text/javascript">
AJS.$(document).ready(function() {
AJS.$("#reporter-val").removeClass("editable-field inactive");
AJS.$("#reporter-val .icon-edit-sml").remove();
});
</script>
EDIT
To limit this only for specific transitions you can either:
- add a custom field only to the specific transition screen and add it the script to it's description.
- execute the script only on specific transition screen:
for example, to apply it only to Resolve Issue
:
if (AJS.$("#workflow-transition-5-dialog .aui-popup-heading").text().indexOf("Resolve Issue") >= 0) {
AJS.$("#reporter-field").attr("disabled", true);;
}
original post
You can achieve this easily by using jQuery. In the custome filed page, click Edit
on the desired field, than under description
enter the jQuery code, something like:
To disable the field:
<script type="text/javascript">
AJS.$(document).ready(function() {
AJS.$("#customfield_10001").attr("disabled", true);
});
</script>
To make it read only:
<script type="text/javascript">
AJS.$(document).ready(function() {
AJS.$("#customfield_10001").attr("readonly", true);
});
</script>
EDIT
I've just noticed that you meant to disable reporter
, which is not a custom field, and there can't add description
to it.
As a workaround, you can create a custom field, doesn't matter which (if you allready have one in your page it will do the trick), and just swap #customfield_10001
for reporter
:
<script type="text/javascript">
AJS.$(document).ready(function() {
AJS.$("#reporter-field").attr("disabled", true);
});
</script>
回答2:
You are trying to set the reporter field as readonly in behaviours plugin . I guess this is a bug in the plugin . What i would suggest you is write a groovy script which will add a helptext to the reporter field using setHelpText(String helptext). the help text will be the below javascript . You will need to escape it as a string :)
<script type="text/javascript">
AJS.$(document).ready(function() {
AJS.$("#reporter-field").attr("disabled", true);
});
</script>
Hope this helps
来源:https://stackoverflow.com/questions/14316021/in-behaviors-plugin-0-5-3-for-jira-5-1-8-i-am-unable-to-make-reporter-field-as