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