Improved link feature.

This commit is contained in:
Martin Edenhofer 2012-08-24 21:40:22 +02:00
parent 112ec68e7d
commit 959faa6a94
4 changed files with 14 additions and 11 deletions

View file

@ -59,7 +59,7 @@ class App.LinkInfo extends App.Controller
edit: (e) => edit: (e) =>
e.preventDefault() e.preventDefault()
if $(e.target).parent().parent().find('[data-type=remove]').is('.hide') if $(e.target).parent().parent().find('[data-type=remove]').hasClass('hide')
$(e.target).parent().parent().find('[data-type=remove]').removeClass('hide') $(e.target).parent().parent().find('[data-type=remove]').removeClass('hide')
else else
$(e.target).parent().parent().find('[data-type=remove]').addClass('hide') $(e.target).parent().parent().find('[data-type=remove]').addClass('hide')
@ -123,10 +123,10 @@ class App.LinkAdd extends App.ControllerModal
url: '/links/add', url: '/links/add',
data: { data: {
link_type: params['link_type'], link_type: params['link_type'],
link_object_source: 'Ticket',
link_object_source_value: @object.id,
link_object_target: 'Ticket', link_object_target: 'Ticket',
link_object_target_number: params['ticket_number'], link_object_target_value: @object.id,
link_object_source: 'Ticket',
link_object_source_number: params['ticket_number'],
} }
processData: true, processData: true,
success: (data, status, xhr) => success: (data, status, xhr) =>

View file

@ -4,7 +4,8 @@
<h3><%- T('Link') %></h3> <h3><%- T('Link') %></h3>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<%- T('Link Ticket#') %> <%- T('Link') %>
<%- T(@link_object) %>
<input type="text" name="ticket_number" value="" class="span2" required/> <input type="text" name="ticket_number" value="" class="span2" required/>
<%- T('as') %> <%- T('as') %>
<select name="link_type" class="span2" required> <select name="link_type" class="span2" required>
@ -13,8 +14,8 @@
<option value="child"><%- T('child') %></option> <option value="child"><%- T('child') %></option>
<option value="parent"><%- T('parent') %></option> <option value="parent"><%- T('parent') %></option>
</select> </select>
<%- T('with') %> <%- T('of') %>
<%- T(@link_object) %> Ticket#
<%= @object.number %>. <%= @object.number %>.
<!-- <!--
<ul> <ul>

View file

@ -11,7 +11,9 @@
<% end %> <% end %>
<div> <div>
<% if !_.isEmpty(@links): %>
<a href="" data-type="edit" class="icon-edit" title="<%- T('edit') %>"></a> <a href="" data-type="edit" class="icon-edit" title="<%- T('edit') %>"></a>
<% end %>
<a href="" data-type="add" class="icon-plus" title="<%- T('add') %>"></a> <a href="" data-type="add" class="icon-plus" title="<%- T('add') %>"></a>
</div> </div>

View file

@ -41,13 +41,13 @@ class LinksController < ApplicationController
def add def add
# lookup object id # lookup object id
object_id = Ticket.where( :number => params[:link_object_target_number] ).first.id object_id = Ticket.where( :number => params[:link_object_source_number] ).first.id
link = Link.add( link = Link.add(
:link_type => params[:link_type], :link_type => params[:link_type],
:link_object_source => params[:link_object_source],
:link_object_source_value => params[:link_object_source_value],
:link_object_target => params[:link_object_target], :link_object_target => params[:link_object_target],
:link_object_target_value => object_id :link_object_target_value => params[:link_object_target_value],
:link_object_source => params[:link_object_source],
:link_object_source_value => object_id
) )
if link if link