Fixed ticket templates.
This commit is contained in:
parent
62987c82e8
commit
b040a2d2a7
|
@ -265,12 +265,6 @@ class App.TicketCreate extends App.Controller
|
|||
params: params
|
||||
)
|
||||
|
||||
# show template UI
|
||||
# new App.WidgetTemplate(
|
||||
# el: @el.find('.ticket_template')
|
||||
# template_id: template['id']
|
||||
# )
|
||||
|
||||
# set type selector
|
||||
@setFormTypeInUi( params['formSenderType'] )
|
||||
|
||||
|
@ -473,12 +467,19 @@ class Sidebar extends App.Controller
|
|||
callback: showCustomer
|
||||
}
|
||||
|
||||
showTemplates = (el) =>
|
||||
|
||||
# show template UI
|
||||
new App.WidgetTemplate(
|
||||
el: el
|
||||
#template_id: template['id']
|
||||
)
|
||||
|
||||
items.push {
|
||||
head: 'Templates'
|
||||
name: 'template'
|
||||
icon: 'templates'
|
||||
#callback: showCustomer
|
||||
callback: showTemplates
|
||||
}
|
||||
|
||||
new App.Sidebar(
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
class App.WidgetTemplate extends App.ControllerDrox
|
||||
class App.WidgetTemplate extends App.Controller
|
||||
events:
|
||||
'click [data-type=template_save]': 'create',
|
||||
'click [data-type=template_select]': 'select',
|
||||
'click [data-type=template_delete]': 'delete',
|
||||
'click .templates-welcome .create': 'showManage',
|
||||
|
||||
constructor: ->
|
||||
super
|
||||
|
@ -17,22 +18,37 @@ class App.WidgetTemplate extends App.ControllerDrox
|
|||
]
|
||||
|
||||
template = {}
|
||||
if @template_id
|
||||
if @template_id && App.Template.exists( @template_id )
|
||||
template = App.Template.find( @template_id )
|
||||
|
||||
# insert data
|
||||
@html @template(
|
||||
file: 'widget/template'
|
||||
header: 'Select Template:'
|
||||
params:
|
||||
@html App.view('widget/template')(
|
||||
template: template
|
||||
)
|
||||
new App.ControllerForm(
|
||||
el: @el.find('#form-template')
|
||||
model: { configure_attributes: @configure_attributes, className: '' }
|
||||
model:
|
||||
configure_attributes: @configure_attributes
|
||||
autofocus: false
|
||||
)
|
||||
|
||||
if App.Template.all().length is 0
|
||||
@showWelcome()
|
||||
else
|
||||
@showManage()
|
||||
|
||||
showManage: (e) ->
|
||||
if e
|
||||
e.preventDefault()
|
||||
@el.find('.templates-manage').show()
|
||||
@el.find('.templates-welcome').hide()
|
||||
|
||||
showWelcome: (e) ->
|
||||
if e
|
||||
e.preventDefault()
|
||||
@el.find('.templates-manage').hide()
|
||||
@el.find('.templates-welcome').show()
|
||||
|
||||
delete: (e) =>
|
||||
e.preventDefault()
|
||||
|
||||
|
@ -40,9 +56,8 @@ class App.WidgetTemplate extends App.ControllerDrox
|
|||
params = @formParam(e.target)
|
||||
template = App.Template.find( params['template_id'] )
|
||||
if confirm('Sure?')
|
||||
@template_id = false
|
||||
template.destroy()
|
||||
@template_id = undefined
|
||||
@render()
|
||||
|
||||
select: (e) =>
|
||||
e.preventDefault()
|
||||
|
@ -50,6 +65,7 @@ class App.WidgetTemplate extends App.ControllerDrox
|
|||
# get params
|
||||
params = @formParam(e.target)
|
||||
|
||||
@template_id = params['template_id']
|
||||
template = App.Template.find( params['template_id'] )
|
||||
App.Event.trigger 'ticket_create_rerender', template.attributes()
|
||||
|
||||
|
@ -60,6 +76,7 @@ class App.WidgetTemplate extends App.ControllerDrox
|
|||
form = @formParam( $('.ticket-create') )
|
||||
params = @formParam(e.target)
|
||||
name = params['template_name']
|
||||
return if !name
|
||||
# delete params['template_name']
|
||||
|
||||
template = App.Template.findByAttribute( 'name', name )
|
||||
|
@ -82,7 +99,6 @@ class App.WidgetTemplate extends App.ControllerDrox
|
|||
template.save(
|
||||
done: ->
|
||||
ui.template_id = @.id
|
||||
ui.render()
|
||||
|
||||
fail: =>
|
||||
@log 'error', 'save failed!'
|
||||
|
|
|
@ -1,17 +1,23 @@
|
|||
<!--<form>
|
||||
<div class="templates-manage">
|
||||
<form>
|
||||
<label class="" for="template_name"><%- @T( 'Select Template' ) %></label>
|
||||
<div id="form-template"></div>
|
||||
<button type="submit" class="btn btn-default" data-type="template_delete"><%- @T( 'Delete' ) %></button>
|
||||
<button type="submit" class="btn btn-default" data-type="template_select"><%- @T( 'Apply' ) %></button>
|
||||
</form>
|
||||
<br>
|
||||
<form>
|
||||
</form>
|
||||
<hr>
|
||||
<form>
|
||||
<fieldset>
|
||||
<label class="" for="template_name"><%- @T( 'Save as Template' ) %></label>
|
||||
<input type="text" name="template_name" id="template_name" class="form-control" value="<%= @template.name %>"/>
|
||||
</fieldset>
|
||||
<button type="submit" class="btn btn-default" data-type="template_save"><%- @T( 'Save' ) %></button>
|
||||
</form>-->
|
||||
<p>No template created yet.</p>
|
||||
<p>With templates you can pre-fill ticket attributes.</p>
|
||||
<p>Choose attributes and then save them as a new template.</p>
|
||||
<p><a class="create u-clickable">Save new template</a></p>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="templates-welcome">
|
||||
<p>No template created yet.</p>
|
||||
<p>With templates you can pre-fill ticket attributes.</p>
|
||||
<p>Choose attributes and then save them as a new template.</p>
|
||||
<p><a class="create u-clickable">Save new template</a></p>
|
||||
</div>
|
Loading…
Reference in a new issue