Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

behaviour doesn't work for customized multi checkbox plugin

Shenbaga Delip September 17, 2020

I have built a customised multi checkbox custom field plugin.
I thought of restricting this custom field to some users.
when i tried to add behaviour(makeing it read only) for this custom field, it's not working.

Plugin .vm file
#disable_html_escaping()
$!{auiparams.put("fieldsetClass", "group")}
$!{auiparams.put("controlHeaderType", "checkbox")}
$!{auiparams.put("noLabel", "true")}
#AUIformFieldsetHeader ($customField.name $fieldLayoutItem.required $displayParameters $auiparams)
#foreach($checkbox in $checkBoxOptions.entrySet())
#set($checked = false)
#if($selectedSignOffCheckBoxes && $selectedSignOffCheckBoxes.keySet().contains($!checkbox.value))
#set($checked = true)
#end
#customControlHeader ($action $customField.id $customField.name $fieldLayoutItem.required $displayParameters $auiparams)
<input
class="checkbox"
#if($checked)
checked="checked"
#end
id="${customField.id}-${velocityCount}"
name="$customField.id"
type="checkbox"
value="$!checkbox.key"
>
<label for="${customField.id}-${velocityCount}">$!checkbox.value</label>
#if($checked)
<div class="signoffs-information-section">
<span class="aui-lozenge signoff-information-labels signoff-information-user">
<span
class="aui-icon aui-icon-small aui-iconfont-user signoffIcon"
>
</span>
$selectedSignOffCheckBoxes.get($!checkbox.value).get(0)
</span>
<span
class="signoff-information-labels signoff-information-date aui-lozenge aui-lozenge-subtle"
>
$selectedSignOffCheckBoxes.get($!checkbox.value).get(1)
</span>
</div>
#end
#customControlFooter ($action '${customField.id}_${velocityCount}' '' $displayParameters $auiparams)
#end
#AUIformFieldsetFooter ($action $customField.id $fieldLayoutItem.fieldDescription $displayParameters $auiparams)
$!{auiparams.clear()}


Plugin atlassian plugin.xml

<?xml version="1.0" encoding="UTF-8"?>

<atlassian-plugin key="${atlassian.plugin.key}" name="${project.name}" plugins-version="2">
<plugin-info>
<description>${project.description}</description>
<version>${project.version}</version>
<vendor name="${project.organization.name}" url="${project.organization.url}"/>
<param name="plugin-icon">images/pluginIcon.png</param>
<param name="plugin-logo">images/pluginLogo.png</param>
</plugin-info>
<!-- add our i18n resource -->
<resource type="i18n" name="i18n" location="checkboxsignoff"/>
<!-- add our web resources -->
<web-resource key="checkboxsignoff-resources" name="checkboxsignoff Web Resources">
<dependency>com.atlassian.auiplugin:ajs</dependency>
<resource type="download" name="checkboxsignoff.css" location="/css/checkboxsignoff.css"/>
<resource type="download" name="checkboxsignoff.js" location="/js/checkboxsignoff.js"/>
<resource type="download" name="images/" location="/images"/>
<context>jira.general</context>
<context>jira.admin</context>
</web-resource>
<customfield-type name="Sign Off Checkbox Field" i18n-name-key="sign-off-checkbox-field.name" key="sign-off-checkbox-field" class="com.athena.plugins.signoffcheckboxfield.jira.customfields.SignOffCheckboxField">
<description key="sign-off-checkbox-field.description">The Sign Off Checkbox Field Plugin</description>
<resource name="view" type="velocity" location="/templates/customfields/sign-off-checkbox-field/view.vm"/>
<resource name="edit" type="velocity" location="/templates/customfields/sign-off-checkbox-field/edit.vm"/>
<valid-searcher package="com.atlassian.jira.plugin.system.customfieldtypes" key="multiselectsearcher"/>
</customfield-type>
</atlassian-plugin>

Am i missing anything?

I have also built a similar custom field, multi project picker. for that custom field behaviour is working fine. but it's not working for this?

Attached screenshots

 

Screenshot 2020-09-17 at 7.55.56 PM.pngScreenshot 2020-09-17 at 7.57.23 PM.png

1 answer

1 accepted

1 vote
Answer accepted
Martin Bayer [MoroSystems, s.r.o.]
Community Champion
September 17, 2020

hi @Shenbaga Delip I experienced this too. It was the case that "id" of HTML element must match ID of the custom field. I also found in Bitbucket history:

<div id="${customField.id}-edit" data-cf-type="co-cf" data-cf-mode="edit"> (not working)
<div id="${customField.id}" data-cf-type="co-cf" data-cf-mode="edit"> (working)

I think you have the same issue.

Shenbaga Delip September 17, 2020

hi @Martin Bayer [MoroSystems, s.r.o.] 

Where do i need to exactly add this div html?Kindly help me

Martin Bayer [MoroSystems, s.r.o.]
Community Champion
September 18, 2020

I have it just under the #customHeader macro so it should be

#customControlHeader ($action $customField.id $customField.name $fieldLayoutItem.required $displayParameters $auiparams)
<div id="${customField.id}">

and closing tag is above #customControlFooter, so it should be

</div>
#customControlFooter ($action '${customField.id}_${velocityCount}' '' $displayParameters $auiparams)
Shenbaga Delip September 18, 2020

Thank you so much Martin. It worked @Martin Bayer [MoroSystems, s.r.o.] 

Suggest an answer

Log in or Sign up to answer