Fixed not shown ticket templates.
This commit is contained in:
parent
6c3dc608ab
commit
e1140ebce6
1 changed files with 13 additions and 12 deletions
|
@ -1,25 +1,26 @@
|
||||||
class App.WidgetTemplate extends App.Controller
|
class App.WidgetTemplate extends App.Controller
|
||||||
events:
|
events:
|
||||||
'click [data-type=template_save]': 'create',
|
'click [data-type=template_save]': 'create'
|
||||||
'click [data-type=template_select]': 'select',
|
'click [data-type=template_select]': 'select'
|
||||||
'click [data-type=template_delete]': 'delete',
|
'click [data-type=template_delete]': 'delete'
|
||||||
'click .templates-welcome .create': 'showManage',
|
'click .templates-welcome .create': 'showManage'
|
||||||
|
|
||||||
constructor: ->
|
constructor: ->
|
||||||
super
|
super
|
||||||
@subscribeId = App.Template.subscribe(@render, initFetch: true )
|
@subscribeId = App.Template.subscribe(@render, initFetch: true)
|
||||||
|
@render()
|
||||||
|
|
||||||
release: =>
|
release: =>
|
||||||
App.Template.unsubscribe(@subscribeId)
|
App.Template.unsubscribe(@subscribeId)
|
||||||
|
|
||||||
render: =>
|
render: =>
|
||||||
@configure_attributes = [
|
@configure_attributes = [
|
||||||
{ name: 'template_id', display: '', tag: 'select', multiple: false, null: true, nulloption: true, relation: 'Template', class: 'span2', default: @template_id },
|
{ name: 'template_id', display: '', tag: 'select', multiple: false, null: true, nulloption: true, relation: 'Template', default: @template_id },
|
||||||
]
|
]
|
||||||
|
|
||||||
template = {}
|
template = {}
|
||||||
if @template_id && App.Template.exists( @template_id )
|
if @template_id && App.Template.exists(@template_id)
|
||||||
template = App.Template.find( @template_id )
|
template = App.Template.find(@template_id)
|
||||||
|
|
||||||
# insert data
|
# insert data
|
||||||
@html App.view('widget/template')(
|
@html App.view('widget/template')(
|
||||||
|
@ -58,7 +59,7 @@ class App.WidgetTemplate extends App.Controller
|
||||||
# check if template is selected
|
# check if template is selected
|
||||||
return if !params['template_id']
|
return if !params['template_id']
|
||||||
|
|
||||||
template = App.Template.find( params['template_id'] )
|
template = App.Template.find(params['template_id'])
|
||||||
if confirm('Sure?')
|
if confirm('Sure?')
|
||||||
@template_id = false
|
@template_id = false
|
||||||
template.destroy()
|
template.destroy()
|
||||||
|
@ -75,20 +76,20 @@ class App.WidgetTemplate extends App.Controller
|
||||||
# remember template (to select it after rerender)
|
# remember template (to select it after rerender)
|
||||||
@template_id = params['template_id']
|
@template_id = params['template_id']
|
||||||
|
|
||||||
template = App.Template.find( params['template_id'] )
|
template = App.Template.find(params['template_id'])
|
||||||
App.Event.trigger 'ticket_create_rerender', template.attributes()
|
App.Event.trigger 'ticket_create_rerender', template.attributes()
|
||||||
|
|
||||||
create: (e) =>
|
create: (e) =>
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|
||||||
# get params
|
# get params
|
||||||
form = @formParam( $('.ticket-create') )
|
form = @formParam($('.ticket-create'))
|
||||||
params = @formParam(e.target)
|
params = @formParam(e.target)
|
||||||
name = params['template_name']
|
name = params['template_name']
|
||||||
return if !name
|
return if !name
|
||||||
# delete params['template_name']
|
# delete params['template_name']
|
||||||
|
|
||||||
template = App.Template.findByAttribute( 'name', name )
|
template = App.Template.findByAttribute('name', name)
|
||||||
if !template
|
if !template
|
||||||
template = new App.Template
|
template = new App.Template
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue