Happy new year everyone! It’s a new year and I have some new problems with which I could use some help.
I have some javascript in my addon which doesn’t work in the navigator but does work when I’m directly viewing the issue. Or atleast some parts of the javascript won’t work. The AJS.$(document).on('change keyup keydown paste cut', 'textarea', function ()
works after I add something to the textarea but outside of the navigator it changes size automatically. The rest of my code simply doesn’t run.
I’ve tried changing and adding tags in my web-resource but it doesn’t seem to do the trick for me.
Can someone help me figure out what I’m doing wrong? Or atleast point me in the right direction?
My javascript file:
AJS.toInit(function($) {
AJS.$(document).on('change keyup keydown paste cut', 'textarea', function () {
$(this).height(0).height(this.scrollHeight);
}).find('textarea').change();
AJS.$('.customer-note__expand-note').click(function(){
AJS.$header = AJS.$(this);
AJS.$content = AJS.$header.next();
AJS.$content.slideToggle(0);
AJS.$(this).toggleClass('customer-note_head-collapse');
AJS.$(this).toggleClass('customer-note_head-expand');
});
AJS.$('.customer-note__button').click(function(){
var id = AJS.$(this).attr('id').replace("saveButtonTIG", "");
console.log(id);
console.log("noteInputTIG"+id);
data = {};
data.content = document.getElementById("noteInputTIG"+id).value;
data.domain = document.getElementById("domainInputTIG"+id).value;
console.log(document.getElementById("reporterInputTIG"+id).value);
console.log(document.getElementById("noteInputTIG"+id).value);
console.log(document.getElementById("domainInputTIG"+id).value);
console.log(JSON.stringify(data));
AJS.$.ajax({
url: AJS.params.baseURL + "/rest/noteresource/1.0/note/" + document.getElementById("reporterInputTIG"+id).value,
type: "POST",
data:JSON.stringify(data),
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function(msg){
console.log("Success !");
}
});
});
});
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><![CDATA[
<p>Add notes to the issue-view and manage who can view them!</p>
<p>For further instructions and troubleshooting please refer to <a href="https://tig.nl/jira" target="_blank" rel="noopener noreferrer">https://tig.nl/jira</a>.</p>
]]></description>
<version>${project.version}</version>
<vendor name="${project.organization.name}" url="${project.organization.url}"/>
<param name="plugin-icon">images/note_logo_72x72.png</param>
<param name="plugin-logo">images/note_logo.png</param>
<param name="vendor-icon">images/tig_jira_v2.png</param>
<param name="vendor-logo">images/tig_logo_72x72.png</param>
</plugin-info>
<!-- add our i18n resource -->
<resource type="i18n" name="i18n" location="tigNoteExtension"/>
<!-- add our web resources -->
<web-resource key="tigNoteExtension-resources" name="tigNoteExtension Web Resources">
<dependency>com.atlassian.auiplugin:ajs</dependency>
<context>atl.general</context>
<context>jira.navigator.advanced</context>
<context>jira.navigator.simple</context>
<resource type="download" name="tigNoteExtension.css" location="css/tigNoteExtension.css"/>
<resource type="download" name="tigNoteExtension.js" location="js/tigNoteExtension.js"/>
<resource type="download" name="images/" location="/images"/>
</web-resource>
<web-panel name="IssuePageInput" i18n-name-key="issue-page-input.name" key="issue-page-input" location="atl.jira.view.issue.right.context" weight="1">
<description key="issue-page-input.description">User notes for Jira</description>
<context-provider class="tig.jira.extension.tigNoteExtension.NoteContextProvider"/>
<resource name="view" type="velocity" location="/vm/note-input.vm"/>
<label key="issue-page-input.title"/>
</web-panel>
<ao key="ao-module">
<description>The configuration of the Active Objects service</description>
<entity>tig.jira.extension.tigNoteExtension.entity.Note</entity>
</ao>
<rest name="Note Resource" i18n-name-key="note-resource.name" key="note-resource" path="/noteresource" version="1.0">
<description key="note-resource.description">The Note Resource Plugin</description>
<package>tig.jira.extension.tigNoteExtension.rest</package>
</rest>
</atlassian-plugin>
velocity file
$webResourceManager.requireResourcesForContext("tigNoteExtensionResource")
<div id="tigNoteExtensionContent" class="dont-default-focus ajs-dirty-warning-exempt">
<img alt="" src="images/note_logo.png"
style="height: 50px; width: 50px" id="imgVIP"/>
<img src="$req.contextPath/download/resources/tig.jira.extension.tigNoteExtension:tigNoteExtension-resources/images/note_logo_72x72.png" id="imgVIPTrue"/>
<p>$i18n.getText("tigNoteExtension.toptext") $reporterName $domain</p><br/>
<div class="customer-note__head-background">
<h2 class="customer-note__expand-note customer-note__head customer-note_head-expand">$reporterId</h2>
<div class="customer-note__content-div">
<p>Notities van $reporterId</p><br/>
<textarea id="noteInputTIG" class="customer-note__content customer-note__content--editable ajs-dirty-warning-exempt" name="noteInputTIG" placeholder="$i18n.getText("tigNoteExtension.placeholder")">$content</textarea>
<input class="hidden" id="reporterInputTIG" name="reporterInputTIG" value="$reporterId"></input>
<input class="hidden" id="domainInputTIG" name="domainInputTIG" value="$domain"></input>
<button id="saveButtonTIG" class="customer-note__button aui-button" name="saveButtonTIG">$i18n.getText("tigNoteExtension.save")</button>
</div></div><br/>
#foreach ($item in $noteArray)
#if ($item.getCurrentReporter() == false)
<div class="customer-note__head-background">
<h2 class="customer-note__expand-note customer-note__head customer-note_head-expand">$item.getUserId()</h2>
<div class="customer-note__content-div">
<p>Notities van $item.getUserId()</p><br/>
<textarea id="noteInputTIG$item.getId()" class="customer-note__content customer-note__content--editable ajs-dirty-warning-exempt" name="noteInputTIG" placeholder="$i18n.getText("tigNoteExtension.placeholder")">$item.getContent()</textarea>
<input class="hidden" id="reporterInputTIG$item.getId()" name="reporterInputTIG" value="$item.getUserId()"></input>
<input class="hidden" id="domainInputTIG$item.getId()" name="domainInputTIG" value="$domain"></input>
<button id="saveButtonTIG$item.getId()" class="customer-note__button aui-button" name="saveButtonTIG">$i18n.getText("tigNoteExtension.save")</button>
</div></div><br/>
#end
#end
</div>