Greasy Fork is available in English.

JiraRoboScript

Jira helper to preselect some fields when creating dialog is shown

11.04.2020 itibariyledir. En son verisyonu görün.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         JiraRoboScript
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Jira helper to preselect some fields when creating dialog is shown
// @author       Robo
// @match        https://pmjira.cz.tmo/*
// @grant        none
// ==/UserScript==

(function () {
	'use strict';

	let bodyMutationObserver = new MutationObserver(function (mutations) {
		for (let i = 0; i < mutations.length; i++) { //faster than forEach
			let mutation = mutations[i];
			//console.log(mutation);
			if (mutation.addedNodes.length > 0
					&& (mutation.addedNodes[0].id === "create-issue-dialog" || mutation.addedNodes[0].id === "create-subtask-dialog")) {
				//add inner dialog mutationObserver
				initializeDialogMutationObserver(mutation.addedNodes[0]);
			}
		}
	});

	// Starts listening for changes in the target HTML element of the page.
	let target = document.getElementById('jira');
	bodyMutationObserver.observe(target, {
		childList: true
	});

	function initializeDialogMutationObserver(dialog) {
		 let dialogMutationObserver = new MutationObserver(function (mutations) {
			for (let i = 0; i < mutations.length; i++) { //faster than forEach
				let mutation = mutations[i];
				//console.log(mutation);
				if (mutation.target.className.includes("jira-dialog-content-ready")) {
					//dialog is ready
					//don't disconnect observer, because changing project type cause reload of inner content and dialog panel class change is triggered
					makeMiracle(mutation.target);
					//createMiracleButton(mutation.target);
				}
			}
		});

		dialogMutationObserver.observe(dialog, {
			attributes: true,
			attributeFilter: ["class"]
		});
	}

	jQuery(document).ready(function () {
		//header buttons
		jQuery("header#header div.aui-header-primary ul.aui-nav").append(
			"<li>" +
			"<a class='aui-button aui-button-primary aui-style' title='Create a new TUS' href='http://www.google.com'>Create TUS</a>" +
			"</li>" +
			"<li>" +
			"<a class='aui-button aui-button-primary aui-style' title='Create a new BUS' href='http://www.google.com'>Create BUS</a>" +
			"</li>");
	});

	/*function createMiracleButton(dialog) {
		let dialogHeader = jQuery(dialog).find(".jira-dialog-heading h2");
		if (dialogHeader.find(".miracleButton").length === 0) {
			let miracleButton = jQuery("<a class='aui-button aui-button-primary aui-style miracleButton' title='Prefil form' href='#' style='margin-left:20px;'>Make miracle</a>");
			dialogHeader.append(miracleButton).one("click", makeMiracle);
		}
	}*/

	function makeMiracle(dialog) {
		let dialogContent = jQuery(dialog).find(".jira-dialog-content");
		//        var dialogContent = jQuery("#create-issue-dialog, #create-subtask-dialog").find(".jira-dialog-content");

		//Project type preselect
		let projectTypeAgile = dialogContent.find("label:contains('Agile')").prev();
		if (projectTypeAgile.prop('checked')) {
			return;
		}
		projectTypeAgile.prop('checked', true);

		//Epic preselect
		dialogContent.find("div.aui-field-labelpicker input[role='combobox']").val("OASK - Generic Epic");

		let teamSelect = dialogContent.find("label:contains('Team')").next();

		//Team deleting
		//         teamSelect.find("option").filter(function () {
		//             var optionText = jQuery.trim(jQuery(this).text());
		//             return optionText != "ST_SK - OneApp" && optionText != "ST_SK - One Shop";
		//         }).remove();

		//Team preselect
		teamSelect.val("16135"); //select only ST_SK - One App

		//Team scroll to selected
		setTimeout(function () {
			let optionTop = teamSelect.find("option:selected").offset().top;
			let selectTop = teamSelect.offset().top;
			teamSelect.scrollTop(teamSelect.scrollTop() + (optionTop - selectTop));
		}, 100);
	}

})();