JIRA: Show @Mentions Feed

During the regular process of working on tickets people will use @mention to alert me when there is a question or something I need to know.  I get emails with this in it but was looking for a way to use JIRA to find them.  I found the following two articles that when combined together gave me the basics of what I need.

First JIRA Advanced Search capabilities are very strong.  I used this article to set up a new filter for the mentions.

Then in this article I got the following query that works fairly good to get a list of the mentions.  It shows me all tickets updated in the last 7 days that I have ever been mentioned in.

(text ~ currentUser()) AND updatedDate >= -7d ORDER BY updated DESC

So I tweaked it to only show tickets with new comments added in the last 7 days instead. This article got me this query.

text ~ currentUser() AND issueFunction in commented("after -7d") ORDER BY updated DESC

It still isn’t exactly what I want but is closer to what I need. It will do for now.

 

 

#TinyMCE: Disable/Enable Brute Force Solution

tinymceI spent a good chunk of yesterday trying to figure out how to change the state of the TinyMCE textbox from readonly to edit mode.  Or to set the values to enable and disable the box properly.  After much trial, error, and research I found this post which links to this post that explains that it is just not possible to do it cleanly.  These posts are a few years old but in the rest of my research I couldn’t find anything that contradicted them.  I tried many different workarounds suggested by other people and each one had something that just didn’t work quite right.  Here is the brute force solution that I came up with:

I created two TinyMCE editors one that is readonly and one that is not.  Then I show and hide them via a button click.

Another problem that I came across is properly showing and hiding the editors.  When I tried to use the built in options they would not show properly when toggling. I had problems with the textareas being set to visible.   To solve this problem I wrapped the original textarea inside a div and I show and hide the divs instead of the actual text area.

I like so many things about the TinyMCE editor but these problems were very frustrating and took up far too much of my time.

C# Tips N Tricks: Saving Character Literals as String Characters

We have a requirement that when saving a specific type of string to the database it needs to save newline characters as a string (“\n”) not the character literal (‘\n’). It should have been straight forward but I found myself spinning in circles and decided to make a note on what the final code looked like.

CSHTML View:

	@Html.TextArea("Message", Model.Message, new { maxlength = 5000 })

Saving to DB:

      item.Message = model.Message.Replace("\r\n","\\n");

Pulling from DB:

      if (item != null)
      {
        Message = item.Message.ToStringOrEmpty().Replace("\\n", "\r\n");
      }
      if (Message.IsNullOrEmpty())
        Message = "Message goes here.\r\n\r\nSincerely,";

TinyMCE validation with MVC

Today I am trying to figure out how to do validation with TinyMCE editors while using MVC’ s unobtrusive validation.  I did a google search and came up with a large number of results that all said the same thing.  I couldn’t get any of them to work.  While testing I found the following solution.  It isn’t perfect but is pretty close to what I need.

Here is the solution I came up with. I didn’t need to add any other additional code to the page.

      $('form button[type=submit]').not('.cancel').click(function () {
        var form = $('#FormName');
        var isValid = form.valid();
        var istinymceValid = $('#ContentField').valid();
        if (!isValid || !istinymceValid) {
          return false;
        }
        return true;
      });

Bootstrap3 Dialog

Bootstrap3dialog

One of the great things about programming in the world today is that so much of the basic functionality I need can be found somewhere on the Web, as long as you know the correct search string.

I spent a good chunk of time looking for a quick and easy way to use Bootstrap modals without having a ton of ugly code on each page that isn’t really necessary.  Especially for modals that are repeated throughout the software.

This time I was looking for a Bootstrap modal that could be easily used for Alert and Confirmation boxes.  I couldn’t find one out there, even though I knew it should exist, so I built my own.  Then I plugged in a different search string and found exactly what I needed.

Bootstrap3 Dialog (Git Hub)is a nice clean simple solution that meets all our needs.  The code is well laid out and I was able to make some minor modifications that met our custom needs.