'jira multiselect customfield AUI selest2 defined in plugin does not pick any options
I'm completly stuck trying to implement AUI.select2 style multiselect customfield in jira plugin.
in main class I just declare the constructor and do not override getVelocityParams, so it looks like
import javax.inject.Inject;
import javax.inject.Named;
import java.util.logging.Level;
/*
jira.core dependency should be uncommented for this plugin to work
*/
@Named // using @Named instead of @Scanned by Matveev's suggestion
public class MultiSelect2 extends MultiSelectCFType {
/*
use of atlassian logger described it this tutorial
https://developer.atlassian.com/server/jira/platform/writing-jira-event-listeners-with-the-atlassian-event-library/
*/
// private static final Logger log = LoggerFactory.getLogger(MultiSelect2.class);
private final LoggerUtils loggerUtils;
private final java.util.logging.Logger logger;
/*
atlassian tutorial step 4.4 suggests to use @JiraImport annotation for
constructor arguments to import them from host application with atlassian
spring scanner
https://developer.atlassian.com/server/jira/platform/creating-a-custom-field-in-jira/
*/
@Autowired // appears to be unnecessary
@Inject
public MultiSelect2(@ComponentImport CustomFieldValuePersister customFieldValuePersister
, @ComponentImport GenericConfigManager genericConfigManager
, @ComponentImport JiraBaseUrls jiraBaseUrls
, @ComponentImport SearchService searchService
, @ComponentImport FeatureManager featureManager
, @ComponentImport JiraAuthenticationContext jiraAuthenticationContext) {
/*
Options manager is acquired trough ComponentAccessor and the rest of
managers trough @ComponentImport annotation of Atlassian Spring Scanner
I do not know what this matters for yet
*/
super(ComponentAccessor.getOptionsManager() // this interface is used to manipulate options. not sure if I need it here
, customFieldValuePersister // This interface is used to save an issue's custom field value to the database
, genericConfigManager
, jiraBaseUrls
, searchService
, featureManager
, jiraAuthenticationContext); // This interface is used to store Generic configuration values for issue's custom field
loggerUtils = new LoggerUtils("CfAuiSelect2Logger"
, "C:\\Users\\digit\\Documents\\JAVA\\Plugin\\CfAuiSelect2\\log.log");
logger = LoggerUtils.getLogger();
logger.log(Level.INFO, "MultiSelect2 instance construction");
logger.info("closing logger's " + logger.getName() + " handlers");
loggerUtils.closeLogFiles();
}
}
I've added neccessary dependensies to atlassian-plugin.xml
<web-resource key="CfAuiSelect2-resources" name="CfAuiSelect2 Web Resources">
<!-- context changed due tutorial
https://developer.atlassian.com/server/jira/platform/custom-fields-that-use-css-or-javascript-web-resources-in-jira-5-0/
-->
<context>atl.general</context>
<dependency>com.atlassian.auiplugin:ajs</dependency>
<!-- dependency below are taken from example at
https://community.atlassian.com/t5/Jira-discussions/Jira-Custom-Field-Select2-problems/td-p/1833237 -->
<dependency>com.atlassian.auiplugin:jquery</dependency>
<dependency>com.atlassian.auiplugin:jquery-ui-other</dependency>
<dependency>com.atlassian.auiplugin:aui-select2</dependency>
<resource type="download" name="CfAuiSelect2.css" location="/css/CfAuiSelect2.css"/>
<resource type="download" name="CfAuiSelect2.js" location="/js/CfAuiSelect2.js"/>
<resource type="download" name="images/" location="/images"/>
<!-- <context>CfAuiSelect2</context> -->
</web-resource>
<customfield-type name="Multi Select 2" i18n-name-key="multi-select-2.name" key="multi-select-2"
class="HCBplugins.jira.customfields.MultiSelect2">
<description key="multi-select-2.description">The Multi Select 2 Plugin</description>
<resource name="view" type="velocity" location="/templates/customfields/multi-select-2/view.vm"/>
<resource name="edit" type="velocity" location="/templates/customfields/multi-select-2/edit.vm"/>
</customfield-type>
populated edit.vm
with this code
#disable_html_escaping()
#controlHeader ($action $customField.id $customField.name $fieldLayoutItem.required $displayParameters.noHeader)
<form class="aui" style="width: available">
<script type="text/javascript">
AJS.toInit(function () {
AJS.$("#$customField.id").auiSelect2();
});
</script>
<select class="js-example-placeholder-single js-states form-control" name="$customField.id" id="$customField.id" style="width: inherit">
<option></option>
#foreach ($option in $options)
<option value="$option">$option</option>
#end
</select>
</form>
#controlFooter ($action $fieldLayoutItem.fieldDescription $displayParameters.noHeader)
new customfield is now availible at JIRA, I've added couple of options to it and added it to screens.
the problem is - when I'm trying to edit it there are no options from options list picked up
probably I'm missing something obvious. could it be CfAuiSelect2.js
content? I've just left it empty cus edit.vm alredy has neccessary js code in it. Commenting out CfAuiSelect2.js
in atlassian-plugin.xml
havn't helped either
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|