Added title update feature.

This commit is contained in:
Martin Edenhofer 2012-10-18 14:32:33 +02:00
parent 035c4c06e8
commit 8bdd4a315a
3 changed files with 26 additions and 2 deletions

View file

@ -9,6 +9,7 @@ class Index extends App.Controller
'click [data-type=internal]': 'public_internal',
'change [name="ticket_article_type_id"]': 'form_update',
'click .show_toogle': 'show_toogle',
'blur .title_update': 'title_update',
constructor: (params) ->
super
@ -330,6 +331,17 @@ class Index extends App.Controller
# update textarea size
@el.find('[name="body"]').trigger('change')
title_update: (e) =>
$this = $(e.target)
title = $this.html()
title = ('' + title)
.replace(/<.+?>/g, '')
if title is '-'
title = ''
@ticket.title = title
@ticket.load( title: title )
@ticket.save()
update: (e) =>
e.preventDefault()
params = @formParam(e.target)
@ -345,12 +357,22 @@ class Index extends App.Controller
if !ticket_update['owner_id']
ticket_update['owner_id'] = 1
# check if title exists
if !ticket_update['title'] && !@ticket.title
alert( App.i18n.translateContent('Title needed') )
return
@ticket.load( ticket_update )
@log 'update ticket', ticket_update, @ticket
# disable form
@formDisable(e)
errors = @ticket.validate()
@log 'errors', errors
if errors
@formEnable(e)
@ticket.save(
success: (r) =>

View file

@ -40,6 +40,8 @@ class App extends Spine.Controller
# define print name helper
params.P = ( item, row = {} ) ->
return '-' if item is undefined
return '-' if item is ''
return item if !item
# if date is a object, get name of the object

View file

@ -1,7 +1,7 @@
<div class="page-header">
<div class="row">
<div class="span10">
<h1><%= @ticket.title %> <small><%= @ticket.number %></small></h1>
<h1><span contenteditable="true" class="title_update"><%= @P( @ticket.title ) %></span> <small><%= @ticket.number %></small></h1>
</div>
<div class="span2">
<% if window.Config['LastOverview'] && @nav: %>