如何向Jira添加国家/地区选择字段?
答案 0 :(得分:1)
我已经发布了答案,希望能帮助他人,并听取你的想法。
添加测试字段并获取其ID,例如,假设它是“customfield_11111”。然后添加以下描述:
<script src="https://jira.com/getCountrySelect.js">
</script>
您可以在说明中编写代码目录,但我发现以这种方式备份和更新脚本更容易。然后,在app-data文件夹中创建文件getCountrySelect.js
(用您的文件ID替换fieldID
):
var fieldId = "customfield_11111";
AJS.$(document).ready(function() {
var country = AJS.$("#" + fieldId).val();
AJS.$("#" + fieldId).parent().append("<select class='select' id='" + fieldId + "' name='" + fieldId + "'></select>");
var select = AJS.$("select#" + fieldId);
select.append("<option>Afghanistan</option>");
select.append("<option>Albania</option>");
select.append("<option>Algeria</option>");
select.append("<option>Andorra</option>");
select.append("<option>Angola</option>");
select.append("<option>Antigua & Deps</option>");
select.append("<option>Argentina</option>");
select.append("<option>Armenia</option>");
select.append("<option>Australia</option>");
select.append("<option>Austria</option>");
select.append("<option>Azerbaijan</option>");
select.append("<option>Bahamas</option>");
select.append("<option>Bahrain</option>");
select.append("<option>Bangladesh</option>");
select.append("<option>Barbados</option>");
select.append("<option>Belarus</option>");
select.append("<option>Belgium</option>");
select.append("<option>Belize</option>");
select.append("<option>Benin</option>");
select.append("<option>Bhutan</option>");
select.append("<option>Bolivia</option>");
select.append("<option>Bosnia Herzegovina</option>");
select.append("<option>Botswana</option>");
select.append("<option>Brazil</option>");
select.append("<option>Brunei</option>");
select.append("<option>Bulgaria</option>");
select.append("<option>Burkina</option>");
select.append("<option>Burundi</option>");
select.append("<option>Cambodia</option>");
select.append("<option>Cameroon</option>");
select.append("<option>Canada</option>");
select.append("<option>Cape Verde</option>");
select.append("<option>Central African Rep</option>");
select.append("<option>Chad</option>");
select.append("<option>Chile</option>");
select.append("<option>China</option>");
select.append("<option>Colombia</option>");
select.append("<option>Comoros</option>");
select.append("<option>Congo</option>");
select.append("<option>Congo {Democratic Rep}</option>");
select.append("<option>Costa Rica</option>");
select.append("<option>Croatia</option>");
select.append("<option>Cuba</option>");
select.append("<option>Cyprus</option>");
select.append("<option>Czech Republic</option>");
select.append("<option>Denmark</option>");
select.append("<option>Djibouti</option>");
select.append("<option>Dominica</option>");
select.append("<option>Dominican Republic</option>");
select.append("<option>East Timor</option>");
select.append("<option>Ecuador</option>");
select.append("<option>Egypt</option>");
select.append("<option>El Salvador</option>");
select.append("<option>Equatorial Guinea</option>");
select.append("<option>Eritrea</option>");
select.append("<option>Estonia</option>");
select.append("<option>Ethiopia</option>");
select.append("<option>Fiji</option>");
select.append("<option>Finland</option>");
select.append("<option>France</option>");
select.append("<option>Gabon</option>");
select.append("<option>Gambia</option>");
select.append("<option>Georgia</option>");
select.append("<option>Germany</option>");
select.append("<option>Ghana</option>");
select.append("<option>Greece</option>");
select.append("<option>Grenada</option>");
select.append("<option>Guatemala</option>");
select.append("<option>Guinea</option>");
select.append("<option>Guinea-Bissau</option>");
select.append("<option>Guyana</option>");
select.append("<option>Haiti</option>");
select.append("<option>Honduras</option>");
select.append("<option>Hungary</option>");
select.append("<option>Iceland</option>");
select.append("<option>India</option>");
select.append("<option>Indonesia</option>");
select.append("<option>Iran</option>");
select.append("<option>Iraq</option>");
select.append("<option>Ireland {Republic}</option>");
select.append("<option>Israel</option>");
select.append("<option>Italy</option>");
select.append("<option>Ivory Coast</option>");
select.append("<option>Jamaica</option>");
select.append("<option>Japan</option>");
select.append("<option>Jordan</option>");
select.append("<option>Kazakhstan</option>");
select.append("<option>Kenya</option>");
select.append("<option>Kiribati</option>");
select.append("<option>Korea North</option>");
select.append("<option>Korea South</option>");
select.append("<option>Kosovo</option>");
select.append("<option>Kuwait</option>");
select.append("<option>Kyrgyzstan</option>");
select.append("<option>Laos</option>");
select.append("<option>Latvia</option>");
select.append("<option>Lebanon</option>");
select.append("<option>Lesotho</option>");
select.append("<option>Liberia</option>");
select.append("<option>Libya</option>");
select.append("<option>Liechtenstein</option>");
select.append("<option>Lithuania</option>");
select.append("<option>Luxembourg</option>");
select.append("<option>Macedonia</option>");
select.append("<option>Madagascar</option>");
select.append("<option>Malawi</option>");
select.append("<option>Malaysia</option>");
select.append("<option>Maldives</option>");
select.append("<option>Mali</option>");
select.append("<option>Malta</option>");
select.append("<option>Marshall Islands</option>");
select.append("<option>Mauritania</option>");
select.append("<option>Mauritius</option>");
select.append("<option>Mexico</option>");
select.append("<option>Micronesia</option>");
select.append("<option>Moldova</option>");
select.append("<option>Monaco</option>");
select.append("<option>Mongolia</option>");
select.append("<option>Montenegro</option>");
select.append("<option>Morocco</option>");
select.append("<option>Mozambique</option>");
select.append("<option>Myanmar, {Burma}</option>");
select.append("<option>Namibia</option>");
select.append("<option>Nauru</option>");
select.append("<option>Nepal</option>");
select.append("<option>Netherlands</option>");
select.append("<option>New Zealand</option>");
select.append("<option>Nicaragua</option>");
select.append("<option>Niger</option>");
select.append("<option>Nigeria</option>");
select.append("<option>Norway</option>");
select.append("<option>Oman</option>");
select.append("<option>Pakistan</option>");
select.append("<option>Palau</option>");
select.append("<option>Panama</option>");
select.append("<option>Papua New Guinea</option>");
select.append("<option>Paraguay</option>");
select.append("<option>Peru</option>");
select.append("<option>Philippines</option>");
select.append("<option>Poland</option>");
select.append("<option>Portugal</option>");
select.append("<option>Qatar</option>");
select.append("<option>Romania</option>");
select.append("<option>Russian Federation</option>");
select.append("<option>Rwanda</option>");
select.append("<option>St Kitts & Nevis</option>");
select.append("<option>St Lucia</option>");
select.append("<option>Saint Vincent & the Grenadines</option>");
select.append("<option>Samoa</option>");
select.append("<option>San Marino</option>");
select.append("<option>Sao Tome & Principe</option>");
select.append("<option>Saudi Arabia</option>");
select.append("<option>Senegal</option>");
select.append("<option>Serbia</option>");
select.append("<option>Seychelles</option>");
select.append("<option>Sierra Leone</option>");
select.append("<option>Singapore</option>");
select.append("<option>Slovakia</option>");
select.append("<option>Slovenia</option>");
select.append("<option>Solomon Islands</option>");
select.append("<option>Somalia</option>");
select.append("<option>South Africa</option>");
select.append("<option>Spain</option>");
select.append("<option>Sri Lanka</option>");
select.append("<option>Sudan</option>");
select.append("<option>Suriname</option>");
select.append("<option>Swaziland</option>");
select.append("<option>Sweden</option>");
select.append("<option>Switzerland</option>");
select.append("<option>Syria</option>");
select.append("<option>Taiwan</option>");
select.append("<option>Tajikistan</option>");
select.append("<option>Tanzania</option>");
select.append("<option>Thailand</option>");
select.append("<option>Togo</option>");
select.append("<option>Tonga</option>");
select.append("<option>Trinidad & Tobago</option>");
select.append("<option>Tunisia</option>");
select.append("<option>Turkey</option>");
select.append("<option>Turkmenistan</option>");
select.append("<option>Tuvalu</option>");
select.append("<option>Uganda</option>");
select.append("<option>Ukraine</option>");
select.append("<option>United Arab Emirates</option>");
select.append("<option>United Kingdom</option>");
select.append("<option>United States</option>");
select.append("<option>Uruguay</option>");
select.append("<option>Uzbekistan</option>");
select.append("<option>Vanuatu</option>");
select.append("<option>Vatican City</option>");
select.append("<option>Venezuela</option>");
select.append("<option>Vietnam</option>");
select.append("<option>Yemen</option>");
select.append("<option>Zambia</option>");
select.append("<option>Zimbabwe</option>");
AJS.$("input#" + fieldId).remove();
AJS.$('#' + fieldId + ' option:contains('+country+')').attr('selected', 'selected');
});
希望它也能帮到你:)。