How do I enable inline editing on fields in custom web-panels?

Nick Seegmiller November 27, 2012

I've created some custom panels to go along with the People and Date panels on the right side of the view issue screen. No matter what I do, I can't seem to get JIRA to "detect" the fields in such a way that it will enable inline editing for the custom fields that appear in those panels. My VM file looks like this:

<ul class="item-details">
	<li>
		#foreach($field in $customFields.fields)
			#if (${field.showField})
				<dl>
					<dt title="$field.name" class="item">$field.name:</dt>
					<dd>
						<span id="${field.id}-val" class="value ${field.styleClass}" data-name="$field.name" data-fieldtype="${field.fieldType}" data-fieldtypecompletekey="${field.fieldTypeCompleteKey}">$field.fieldHtml</span>
					</dd>
				</dl>
			#end
		#end
	</li>
</ul>

I've modeled that after the peopleblock.vm from the JIRA source. All the fields show up as you'd expect, but none of them are editable. Additionally, these custom fields are on the edit screen and they show up in the Details block in the main/left section of the view issue screen and they are inline editable there. All the data is filling in correctly in my <span>, but it's like there is some Javascript or something that alters the elements to be editable that isn't triggering. Any ideas as to what I'm missing?

4 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Nick Seegmiller December 2, 2012

As is often the case, it ended up being something rather stupid/obvious.

Like I mentioned above, I was showing the custom fields on the screen twice. Once in the Details block and once in my custom panels. The generated HTML for the two pieces is shown below:

&lt;div id="customfield_10521-val" class="value type-select editable-field inactive" title="Click to edit"&gt;Low&lt;span class="overlay-icon icon icon-edit-sml"&gt;&lt;/span&gt;&lt;/div&gt;

&lt;span id="customfield_10521-val" class="value type-select" data-name="Risk" data-fieldtype="select" data-fieldtypecompletekey="com.atlassian.jira.plugin.system.customfieldtypes:select"&gt;Low&lt;/span&gt;

The first is from the Details block and was decorated to enable inline editing while the second is from my custom panel and did not receive the decoration. Notice that the two have the exact same id value. This was the key. Apparently, the Javascript that does the decoration keys off of the id value and only decorates a specific custom field a single time. It was finding the one in the Details block and decorating it and then failing to find it the second one in the custom panel. When I edited the record and went back to the view issue screen, it was calling the decorate all code a second time and now finding the non-decorated elements and thus inline editing would get enabled in my panels after an update.

To fix this, I merely removed the fields from showing up twice (took them out of the Details block specifically) and everything worked like magic.

2 votes
Florin Manaila
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 28, 2012

Hi Nick,

This might help: https://developer.atlassian.com/display/JIRADEV/Inline+Edit+for+JIRA+Plugins

It's not just about respecting a certain HTML template anymore (like it is with other UI components).

Nick Seegmiller November 29, 2012

That's what I'd need if I got inline editing working and wanted to interact with/intercept the events. I can't even get it to work in the first place.

0 votes
Nick Seegmiller November 29, 2012

Also: if I edit the issue and make any tweak of anykind and save when it returns to the view issue screen, the fields become inline editable. Basically, they are not editable when the screen first loads and then are somehow magically granted that ability after modifying the issue.

0 votes
Nick Seegmiller November 29, 2012

Please note that I'm talking about custom fields using more or less standard field types. Numbers, select boxes, simple strings, etc rather than new custom field types I created..

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events