Problem
We want to hide the create issue button until at least one attachment is added.
Solution
We will use lfExecuteJS in order to watch the attachments module from the create screen and, according to its files, to hide or show the create issue button.
All you will have to do is to add in our main live fields script a line like the one below:
livefields.sil
lfExecuteJS("lf.js");
Secondly, we will create the "lf.js" file in the silprograms directory. It's content should be:
lf.js
var attachments = AJS.$(".file-input-list "); console.log("Got attachments"); AJS.$(function() { var $div = attachments; var html = $div.html(); var checking = setInterval(function() { var newhtml = $div.html(); if (html != newhtml) { myCallback(); html = newhtml; } },100); function myCallback() { console.log("Content changed"); var size = AJS.$("[duitype='dndattachment/progressbars/ProjectUploadProgressBar']").size(); if (size == 0) { console.log("You can't create such an issue"); AJS.$("#create-issue-submit").hide(); AJS.$("#issue-create-submit").hide(); } else { console.log("You can now create the issue"); AJS.$("#create-issue-submit").show(); AJS.$("#issue-create-submit").show(); } } });
See also
- Is it possible to calculate date automatically depends on what you choose in the field?
- Forbidding creating issues until an attachment is added
- Date field must be within range
- Forbidding creating issues until an attachment is added
- Limit the number of votes per month
- Require field in subtask
- Requiring Fix Versions When Resolving an Issue
- Restrict options or number of selections in a select list
- See and Search On the Last Person to Modify an Issue