Domanda

I want to add a combo box with some elements in my JIRA work log dialog / screen. The combo box will add a String (like "[DEV] - ") in front of the work description.

It seens to be simple, but I cannot find a tutorial in the Jira documentation...

I have seen this plugin called Tempo. But I want to do this on my own. Not using others plugins.

I am think about editing the jira's JSP pages, but I realized that when I update the jira version, I will have to edit the JSP again. So, I think that the best way is to develop a plugin. But I don't know how .

È stato utile?

Soluzione 2

In order to help other people that are trying the same as me. I will describe what I've done to add a custom field in Jira's log work...

First of all, you will need to find de JSP file that is setting the worklog page. You can add your custom field by HTML e do the work by JavaScript.

Jira uses a deprecated framework called WebWork, so the best way to customize screens is using simple HTML.

Anyway, this is an option for who do not want to use the Tempo Plugin.

Altri suggerimenti

My solution to this problem was to add my new fields to the logwork.jsp. This is code for a text field, and a drop-down.

        <page:applyDecorator name="auifieldgroup">
            <aui:textfield id="'numberOfDefects'" label="text('Number Of Defects')" mandatory="'false'" name="'numberOfDefects'" size="'short'" theme="'aui'" /><br>
        </page:applyDecorator>
        <page:applyDecorator name="auifieldgroup">
                <label for="select-example">Development Phase</label>
                <select class="select" id="developmentPhase" name="developmentPhase">
                    <option>testing</option>
                    <option>configuration</option>
                    <option>development</option>
                </select>
        </page:applyDecorator>

Then I used the Servlet-Filter plugin module provided by Atlassian, and the filter was configured to apply to urls matching the pattern /secure/CreateWorklog.jspa. This is in atlassian-plugin.xml.

  <servlet-filter name="Create Worklog Servlet Filter" i18n-name-key="create-worklog-servlet-filter.name" key="create-worklog-servlet-filter" class="com.pelletier.jira.servlet.filter.CreateWorklogServletFilter" location="before-dispatch" weight="200">
     <description key="create-worklog-servlet-filter.description">The Create Worklog Servlet Filter Plugin</description>
     <url-pattern>/secure/CreateWorklog.jspa</url-pattern>
     <dispatcher>REQUEST</dispatcher>
  </servlet-filter>

In my Servlet-Filter class, I was then able to get the new parameters from the request, and write them to my database. (Not the Jira one, unfortunately, I hear that is frowned upon)

public class CreateWorklogServletFilter implements Filter {


private JdbcTemplate jdbcTemplate = null;

//OSGi injects the JdbcTemplate
public CreateWorklogServletFilter(JdbcTemplate jdbcTemplate) {
    this.jdbcTemplate = jdbcTemplate;
}

@Override
public void init(FilterConfig filterConfig) throws ServletException {
}

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
    chain.doFilter(request, response);

    //do stuff with new params from modified jsp
}

@Override
public void destroy() {
}

I am familiar with spring, so I put a spring.xml file in the META-INF/spring/ directory of my plugin, and jars needed for my DataSource, and database driver in the META-INF/lib directory. The JdbcTemplate configured in spring.xml gets put in the OSGi bundle (I think) which then injects it into the constructor of my ServletFilter implementation.

We chose to use Tempo to do this at ServiceRocket, and we recommend that add-on (plugin) for our customers. In general using a single field (work description) for two pieces of information (the work type and work description) is not a good idea in the long term.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top