Setting assignee to reporter when resolving an issue in JIRA

by Geert 10. May 2012 17:25

While using JIRA, you normally want to resolve an issue to the person that created the issue. This way, that reporter can check whether the issue is resolved correctly and close the issue.

While this is described here, I decided to sum up the whole procedure to save other people some time.

Creating a custom field

The first step is to create a custom field. I gave it the name “Set assignee to reporter” and the following description (yes, this javascript):

<script type="text/javascript">
 
/* CUSTOMIZE THESE VALUES */
var jiraUrl = "<YOUR_JIRA_URL_HERE>";
var customFieldId = "<YOUR_CUSTOM_FIELD_ID>";
/* DO NOT MODIFY SCRIPT BELOW */
function getAssigneeControl() { 
	var setAssigneeToReporterField = document.getElementById("customfield_" + customFieldId);	
	
	var parentContainer = jQuery(setAssigneeToReporterField).parents("#issue-workflow-transition");
	
	return parentContainer.find("#assignee");
}
function getAssignee() {
	return getAssigneeControl().val();
}
function setAssignee(newAssignee) {
	var assigneeControl = getAssigneeControl();
	
	//console.log("setting assignee from '" + assigneeControl.val() + "' to '" + newAssignee + "'");
	
	assigneeControl.val("" + newAssignee);
	
	//console.log("assignee should now be " + newAssignee);
}
jQuery(document).ready(function() {
	var setAssigneeToReporterField = document.getElementById("customfield_" + customFieldId);	
	setAssigneeToReporterField.parentNode.style.display = 'none';	
	//console.log("Searching for issue id");
	// Parse issue key from title
	var issueText = jQuery(".dialog-title").html();
	var startIndex = issueText.indexOf('[');
	var endIndex = issueText.indexOf(']');
	var issueId = issueText.substring(startIndex + 1, endIndex);
	//console.log("Found issue " + issueId);
	
	// Get reporter via REST
	var restUrl = jiraUrl + "/rest/api/latest/issue/" + issueId;
	
	//console.log("Getting data from url " + restUrl);
	
	// Do a synchronous request (otherwise it will not work, don't blame me!)
	if (window.XMLHttpRequest) xmlhttp=new XMLHttpRequest(); 
	else if (window.ActiveXObject) xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	xmlhttp.open("GET", restUrl, false);
	xmlhttp.send(null);
	var data = jQuery.parseJSON(xmlhttp.responseText);
	//console.log("Retrieved data from url " + restUrl);	
			
	var currentAssignee = getAssignee();
	var reporter = data.fields.reporter.name;
	if (currentAssignee == reporter)
	{
		alert("Important, you are both the reporter and assignee. Make sure to double check the assignee.");
	}
	
	setAssignee(reporter);
});
</script>

This way, as soon as the document is loaded, it will search for the fields and set the values correctly. As soon as the values are set, it will hide the custom field.

Add the custom field to the resolve issue screen

It is important to add the custom field to the “Resolve issue screen”:

  • Set assignee to reporter custom field

That’s all! Now when you resolve an issue, the assignee is automatically set to the reporter. You can of course also set the main tester in the javascript, it works the same and saves you a lot of manual steps Smile

Tags:

Why there won’t be a WinRT version of Catel…

by Geert 6. May 2012 14:00

So, lots of people came to me asking whether there will be a WinRT version of Catel. First, I said we were seriously considering it. But lately the idea of not supporting it became more and more the idea I wanted to follow.

A little history

Instead of going with the flow, let’s first take a look at the history of Catel and why it has been created anyway. Mid 2010, I needed a (WPF) MVVM framework that would contain the following features:

  • Support IDataErrorInfo for the view model so it could contain validation
  • Nested user controls (because I couldn’t create big trees of hierarchy view models)
  • Ease of development

With the latest I mean I didn’t want to go with the hype where everything needed to be “light”, simply because I always found myself writing extension methods and improving code. After I seriously considered Cinch, the moment I decided to write my own was when there was a “view model generator tool”.

When I started with MVVM and Xaml, all I did was WPF, which is simply the best implementation of Xaml for me. But, then people started asking: can you support Silverlight as well? Then the hell of missing features began. Lots of interfaces that Catel uses to allow property undo-ing such as INotifyPropertyChanging were not supported. It took me about 3 weeks to make sure everything in Catel also worked in Silverlight. Most of the time, I simply wrote the WPF features that were missing from Silverlight to allow the same functionality of Catel in Silverlight.

When WP7 came out, I was already prepared for the upcoming hell, but it wasn’t as bad as the transition from WPF => Silverlight. However, it again took me at least 2 weeks to create all the project and item templates and the Windows Phone specific implementations of the navigation services and tombstoning.

When the windows 8 beta came out, I quickly installed it to check out what has changed so I could convert Catel. But… it seems there are more, much more changes than I expected. For example, the whole reflection system has been changed.

Also, Catel supports a WeakEventListener and WeakActions for the MessageMediator, but this is simply not possible in WinRT because important reflection (although public) is not available.

What’s WinRT exactly?

After fighting with WinRT for about 4 weeks, I decided to take a look at the the current state and how much work there was in front of me. Then I realized I already left out the most important features (because I knew they wouldn’t compile anyway out of the box), but I couldn’t even get the Core libraries to compile (such as the WeakEventListener).

Then I thought: is Catel the way to go for WinRT anyway? And the answer is no. I see WinRT applications as a windows phone application without any specific LoB requirements. For example, checking the weather, checking facebook, etc. If you need a real LoB application, I still recommend to go for WPF or Silverlight which is the way to go.

Taking a look at the history of Catel, it was originally founded as a LoB framework, not as a framework to fit all purposes such as very light applications. I have decided to stick with the initial goal (targeting LoB applications) and the pain is just not worth the gain.

Is it definitely a no go?

For now: yes. If I am honest, apps written in WinRT are so light that a full-featured framework such as Catel is an overkill. You can better choose a light framework such as MVVM light which basically only supports property change notifications, a messenger and event to command.

I did write lots of code to allow reflection on both WinRT and not WinRT platforms in Catel , but it is not finished. Maybe, if Microsoft makes some changes so we can actually get, for example, the MethodInfo of a handler, we will re-evaluate the decision.

Tags: , ,

Catel | MVVM | WinRT

Catel 3.1 released

by Geert 6. May 2012 13:49

We just released Catel 3.1. You can grab the latest version:

In this blog post, we already described the most important changes, but you can find a full list of changes here.

As always, if you have any questions or feature requests, don’t hesitate to contact us or create an issue!

Tags: ,

C# | Catel | MVVM | Silverlight | Windows Phone 7 | WPF

Catel 3.1 - beta version released

by Geert 27. April 2012 18:25

So, it’s been another month since we released Catel 3.0. This means that soon, we will release a new version, and it will be 3.1. You can grab the latest version:

Below is a list of the most important changes.

OnDataContextChanged and OnPropertyChanged methods

Since lots of people need to write handlers (but forget to unsubscribe thus cause memory leaks), we made these available as default to all controls that Catel provides.

AsynchronousCommand

Asynchronous development becomes more and more important. In the latest version, we proudly introduce the AsynchronousCommand, which is a command that runs in the background and doesn’t block and UI. It is able to provide thread-safe callbacks to the UI as well.

You can read all about it in the official docs.

Memento pattern

The memento pattern is something hardly any custom made application implements due to its complexity. Catel now includes a memento service which allows to undo/redo changes on properties, collections and custom actions.

If you ever need to build in undo/redo support, this is what you are looking for! You can read all about it in the official docs.

Note that this feature is also available for non-xaml solutions

Improved handling of datacontext changes for nested user control scenarios

If you are using Catel, you are probably aware that you sometimes get false reports of binding errors. Catel now uses an improved way of determining the right datacontext in nested user control scenarios so these false errors no long appear in your output window.

What to expect next?

We are currently investigating what it takes to port Catel to WinRT. However, since reflection in WinRT is very basic (for example, we cannot get the name of a method), it is really hard to implement the WeakEventListener and MessageMediator in WinRT. However, we will keep trying…

You can also checkout the road map.

Tags: ,

C# | Catel | MVVM | WPF | Silverlight | NuGet | Windows Phone 7

Catel.Resharper - a plugin for resharper

by Geert 24. April 2012 19:05

We as developers of Catel are a huge fan of Resharper. And, of course we are also a big fan of Catel. One of the developers, Alex, came up with a great idea (and implementation) of a plugin for Resharper which makes it much easier to write Catel specific features.

Before we start, you can find the installer here.

Checking arguments of a method

If you are not using the Argument class, you are definitely missing something! It allows you to check for a method input and make sure it is valid. So, instead of writing this:

public void DoSomething(string myInput)
{
    if (string.IsNullOrWhitespace(myInput)
    {
        Log.Error("Argument 'myInput' cannot be null or whitespace");
        throw new ArgumentException("Argument 'myInput' cannot be null or whitespace", "myInput");
    }
    // custom logic
}

You can write this:

public void DoSomething(string myInput)
{
    Argument.IsNotNullOrWhitespace("myInput", myInput);
    // custom logic
}

However, when you are writing lots of code, then even this piece of code can be too much. Thanks to the Catel.Resharper plugin, it is possible to select the argument (in this case myInput), hit ALT + Enter and generate the code, just like the video below:

 

Converting regular properties into Catel properties

Catel is extremely powerful, but sometimes the property definitions are lots of work to write down. The code snippets already make your life much easier, but with the Catel.Resharper plugin it might be even easier. You can simply write this code:

public class Person : DataObjectBase<Person>
{
    public string FirstName { get; set; }
    public string MiddleName { get; set; }
    public string LastName { get; set; }
}

Then hit ALT + Enter and turn properties into Catel properties, which will result in this class:

public class Person : DataObjectBase<Person>
{
    /// <summary>
    /// Gets or sets the first name.
    /// </summary>
    public string FirstName
    {
        get { return GetValue<string>(FirstNameProperty); }
        set { SetValue(FirstNameProperty, value); }
    }
    /// <summary>
    /// Register the FirstName property so it is known in the class.
    /// </summary>
    public static readonly PropertyData FirstNameProperty = RegisterProperty("FirstName", typeof(string));

    /// <summary>
    /// Gets or sets the middle name.
    /// </summary>
    public string MiddleName
    {
        get { return GetValue<string>(MiddleNameProperty); }
        set { SetValue(MiddleNameProperty, value); }
    }
    /// <summary>
    /// Register the MiddleName property so it is known in the class.
    /// </summary>
    public static readonly PropertyData MiddleNameProperty = RegisterProperty("MiddleName", typeof(string));
    /// <summary>
    /// Gets or sets the last name.
    /// </summary>
    public string LastName
    {
        get { return GetValue<string>(LastNameProperty); }
        set { SetValue(LastNameProperty, value); }
    }
    /// <summary>
    /// Register the LastName property so it is known in the class.
    /// </summary>
    public static readonly PropertyData LastNameProperty = RegisterProperty("LastName", typeof(string));
}

Tags: , ,

Catel | MVVM


About the Author

Geert van Horrik is an independent freelance software developer since January 1st, 2007. Since then he was been working on several projects from C++ to C# (WPF, Silverlight, ASP.NET, etc). Currently he loves to write his software using WPF (or Silverlight if WPF isn't an option).

Lately, Geert is spending a lot of time on Catel, a free open-source MVVM Framework for WPF and Silverlight. Actually, it's more than "just" an MVVM Framework, it's a complete application library!