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) =>
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')
else
$(e.target).parent().parent().find('[data-type=remove]').addClass('hide')
@ -123,10 +123,10 @@ class App.LinkAdd extends App.ControllerModal
url: '/links/add',
data: {
link_type: params['link_type'],
link_object_source: 'Ticket',
link_object_source_value: @object.id,
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,
success: (data, status, xhr) =>

View file

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

View file

@ -11,7 +11,9 @@
<% end %>
<div>
<% if !_.isEmpty(@links): %>
<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>
</div>

View file

@ -41,13 +41,13 @@ class LinksController < ApplicationController
def add
# 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_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_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