Merge branch 'private-issue427' into develop
This commit is contained in:
commit
2111145fb1
12 changed files with 209 additions and 19 deletions
|
@ -435,7 +435,7 @@ class App.ControllerForm extends App.Controller
|
||||||
else
|
else
|
||||||
value = parseInt(value)
|
value = parseInt(value)
|
||||||
if param[item.name] isnt undefined
|
if param[item.name] isnt undefined
|
||||||
if typeof param[item.name] is 'string'
|
if typeof param[item.name] is 'string' || typeof param[item.name] is 'boolean' || typeof param[item.name] is 'number'
|
||||||
param[item.name] = [param[item.name], value]
|
param[item.name] = [param[item.name], value]
|
||||||
else
|
else
|
||||||
param[item.name].push value
|
param[item.name].push value
|
||||||
|
|
|
@ -35,10 +35,11 @@ class App.SettingsArea extends App.Controller
|
||||||
|
|
||||||
elements = []
|
elements = []
|
||||||
for setting in settings
|
for setting in settings
|
||||||
if setting.preferences.controller && App[setting.preferences.controller]
|
if setting.preferences.hidden isnt true
|
||||||
item = new App[setting.preferences.controller](setting: setting)
|
if setting.preferences.controller && App[setting.preferences.controller]
|
||||||
else
|
item = new App[setting.preferences.controller](setting: setting)
|
||||||
item = new App.SettingsAreaItem(setting: setting)
|
else
|
||||||
elements.push item.el
|
item = new App.SettingsAreaItem(setting: setting)
|
||||||
|
elements.push item.el
|
||||||
|
|
||||||
@html elements
|
@html elements
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
class App.SettingsAreaItem extends App.Controller
|
class App.SettingsAreaItem extends App.Controller
|
||||||
|
template: 'settings/item'
|
||||||
events:
|
events:
|
||||||
'submit form': 'update'
|
'submit form': 'update'
|
||||||
|
|
||||||
|
@ -21,8 +22,12 @@ class App.SettingsAreaItem extends App.Controller
|
||||||
# form
|
# form
|
||||||
@configure_attributes = @setting.options['form']
|
@configure_attributes = @setting.options['form']
|
||||||
|
|
||||||
|
for attribute in @configure_attributes
|
||||||
|
if attribute.tag is 'boolean'
|
||||||
|
attribute.translate = true
|
||||||
|
|
||||||
# item
|
# item
|
||||||
@html App.view('settings/item')(
|
@html App.view(@template)(
|
||||||
setting: @setting
|
setting: @setting
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
class App.SettingsAreaTicketHookPosition extends App.SettingsAreaItem
|
||||||
|
template: 'settings/ticket_hook_position'
|
|
@ -0,0 +1,132 @@
|
||||||
|
class App.SettingsAreaTicketNumber extends App.Controller
|
||||||
|
events:
|
||||||
|
'submit form': 'update'
|
||||||
|
|
||||||
|
constructor: ->
|
||||||
|
super
|
||||||
|
@render()
|
||||||
|
|
||||||
|
render: =>
|
||||||
|
|
||||||
|
# defaults
|
||||||
|
directValue = 0
|
||||||
|
for item in @setting.options['form']
|
||||||
|
directValue += 1
|
||||||
|
if directValue > 1
|
||||||
|
for item in @setting.options['form']
|
||||||
|
item['default'] = @setting.state_current.value[item.name]
|
||||||
|
else
|
||||||
|
item['default'] = @setting.state_current.value
|
||||||
|
|
||||||
|
@map =
|
||||||
|
'Ticket::Number::Increment': 'ticket_number_increment'
|
||||||
|
'Ticket::Number::Date': 'ticket_number_date'
|
||||||
|
|
||||||
|
# form
|
||||||
|
@configure_attributes = @setting.options['form']
|
||||||
|
|
||||||
|
# item
|
||||||
|
@html App.view('settings/ticket_number')(
|
||||||
|
setting: @setting
|
||||||
|
)
|
||||||
|
|
||||||
|
togglePreferences = (params, attribute, @attributes, classname, form) =>
|
||||||
|
return if attribute.name isnt 'ticket_number'
|
||||||
|
@showPreferences(params.ticket_number)
|
||||||
|
|
||||||
|
updatePreview = (params, attribute) =>
|
||||||
|
paramsParent = @formParam(@$('.js-form'))
|
||||||
|
number = "#{App.Config.get('ticket_hook')}???"
|
||||||
|
if paramsParent.ticket_number is 'Ticket::Number::Increment'
|
||||||
|
paramsItem = @paramsPreferences('Ticket::Number::Increment')
|
||||||
|
number = "#{App.Config.get('ticket_hook')}#{App.Config.get('system_id')}"
|
||||||
|
counter = '1'
|
||||||
|
if paramsItem.min_size
|
||||||
|
minSize = parseInt(paramsItem.min_size)
|
||||||
|
if paramsItem.checksum
|
||||||
|
minSize -= 1
|
||||||
|
if minSize > 1
|
||||||
|
for itemCounter in [2 .. minSize]
|
||||||
|
counter = "0#{counter}"
|
||||||
|
number += counter
|
||||||
|
if paramsItem.checksum
|
||||||
|
number += '9'
|
||||||
|
else if paramsParent.ticket_number is 'Ticket::Number::Date'
|
||||||
|
paramsItem = @paramsPreferences('Ticket::Number::Date')
|
||||||
|
current = new Date()
|
||||||
|
currentDay = current.getDate()
|
||||||
|
currentMonth = current.getMonth() + 1
|
||||||
|
currentYear = current.getFullYear()
|
||||||
|
|
||||||
|
number = "#{App.Config.get('ticket_hook')}#{currentYear}#{currentMonth}#{currentDay}#{App.Config.get('system_id')}001"
|
||||||
|
if paramsItem.checksum
|
||||||
|
number += '9'
|
||||||
|
|
||||||
|
@$('.js-preview').text(number)
|
||||||
|
|
||||||
|
new App.ControllerForm(
|
||||||
|
el: @el.find('.js-form'),
|
||||||
|
model: { configure_attributes: @configure_attributes, className: '' }
|
||||||
|
autofocus: false
|
||||||
|
handlers: [togglePreferences, updatePreview]
|
||||||
|
)
|
||||||
|
|
||||||
|
# preferences
|
||||||
|
preferences_settings = @setting.preferences.settings_included || ['ticket_number_increment', 'ticket_number_date']
|
||||||
|
for preferences_setting in preferences_settings
|
||||||
|
setting = App.Setting.findByAttribute('name', preferences_setting)
|
||||||
|
value = App.Setting.get(preferences_setting)
|
||||||
|
el = $(App.view("settings/#{preferences_setting}")(
|
||||||
|
setting: setting
|
||||||
|
))
|
||||||
|
new App.ControllerForm(
|
||||||
|
el: el.find('.js-formItem'),
|
||||||
|
model: { configure_attributes: setting.options['form'], className: '' }
|
||||||
|
autofocus: false
|
||||||
|
params: value
|
||||||
|
handlers: [updatePreview]
|
||||||
|
)
|
||||||
|
@$('.js-formPreferences').append(el)
|
||||||
|
|
||||||
|
# show current preferences
|
||||||
|
@showPreferences(item['default'])
|
||||||
|
|
||||||
|
showPreferences: (name) =>
|
||||||
|
@$('.js-formPreferencesItem').addClass('hidden')
|
||||||
|
@$(".js-formPreferencesItem[data-backend=\"#{name}\"]").removeClass('hidden')
|
||||||
|
|
||||||
|
paramsPreferences: (name) =>
|
||||||
|
@formParam(@$(".js-formPreferencesItem[data-backend=\"#{name}\"] form"))
|
||||||
|
|
||||||
|
update: (e) =>
|
||||||
|
e.preventDefault()
|
||||||
|
@formDisable(@$('.js-form'))
|
||||||
|
params = @formParam(@$('.js-form'))
|
||||||
|
if params.ticket_number
|
||||||
|
paramsItem = @paramsPreferences(params.ticket_number)
|
||||||
|
setting_name = @map[params.ticket_number]
|
||||||
|
if setting_name && paramsItem
|
||||||
|
App.Setting.set(setting_name, paramsItem)
|
||||||
|
|
||||||
|
@setting['state_current'] = {value: params.ticket_number}
|
||||||
|
ui = @
|
||||||
|
@setting.save(
|
||||||
|
done: =>
|
||||||
|
ui.formEnable(e)
|
||||||
|
App.Event.trigger 'notify', {
|
||||||
|
type: 'success'
|
||||||
|
msg: App.i18n.translateContent('Update successful!')
|
||||||
|
timeout: 2000
|
||||||
|
}
|
||||||
|
|
||||||
|
# rerender ui || get new collections and session data
|
||||||
|
App.Setting.preferencesPost(@setting)
|
||||||
|
|
||||||
|
fail: (settings, details) ->
|
||||||
|
ui.formEnable(e)
|
||||||
|
App.Event.trigger 'notify', {
|
||||||
|
type: 'error'
|
||||||
|
msg: App.i18n.translateContent(details.error_human || details.error || 'Unable to update object!')
|
||||||
|
timeout: 2000
|
||||||
|
}
|
||||||
|
)
|
|
@ -1,6 +1,6 @@
|
||||||
<form class="settings-entry" id="<%= @setting.name %>">
|
<form class="settings-entry" id="<%= @setting.name %>">
|
||||||
<h2><%- @T(@setting.title) %></h2>
|
<h2><%- @T(@setting.title) %></h2>
|
||||||
<p class="help-text"><%- @RichText(@setting.description) %></p>
|
<p class="help-text"><%- @T(@setting.description) %></p>
|
||||||
<div class="horizontal end">
|
<div class="horizontal end">
|
||||||
<div class="form-item flex"></div>
|
<div class="form-item flex"></div>
|
||||||
<button type="submit" class="btn btn--primary"><%- @T('Submit') %></button>
|
<button type="submit" class="btn btn--primary"><%- @T('Submit') %></button>
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
<form class="settings-entry" id="<%= @setting.name %>">
|
||||||
|
<h2><%- @T(@setting.title) %></h2>
|
||||||
|
<p class="help-text">
|
||||||
|
<%- @T('The format of the subject.') %>
|
||||||
|
<ul>
|
||||||
|
<li><%- @T('|Right| means |Some Subject [Ticket#12345]|') %>
|
||||||
|
<li><%- @T('|Left| means |[Ticket#12345] Some Subject|') %>
|
||||||
|
<li><%- @T('|None| means |Some Subject| (without ticket number). In the last case you should enable "postmaster___follow___up___search___in" to recognize followups based on email headers and/or body.') %>
|
||||||
|
</ul>
|
||||||
|
<div class="horizontal end">
|
||||||
|
<div class="js-form form-item flex"></div>
|
||||||
|
<button type="submit" class="btn btn--primary"><%- @T('Submit') %></button>
|
||||||
|
</div>
|
||||||
|
</form>
|
|
@ -0,0 +1,19 @@
|
||||||
|
<div class="settings-entry" id="<%= @setting.name %>">
|
||||||
|
<h2><%- @T(@setting.title) %></h2>
|
||||||
|
<p class="help-text">
|
||||||
|
<%- @T('Selects the ticket number generator module.') %>
|
||||||
|
<ul>
|
||||||
|
<li><%- @T('|Increment| increments the ticket number, the SystemID and the counter are used with "SystemID.Counter" format (e.g. 1010138, 1010139).') %>
|
||||||
|
<li><%- @T('With |Date| the ticket numbers will be generated by the current date, the SystemID and the counter. The format looks like "Year.Month.Day.SystemID.Counter" (e.g. 201206231010138, 201206231010139).') %>
|
||||||
|
</ul>
|
||||||
|
<form class="js-form"></form>
|
||||||
|
<br>
|
||||||
|
<div class="js-formPreferences"></div>
|
||||||
|
<br>
|
||||||
|
<label class="formGroup-label"><%- @T('Preview') %></label>
|
||||||
|
<div class="js-preview"></div>
|
||||||
|
<br>
|
||||||
|
<form class="horizontal end">
|
||||||
|
<button type="submit" class="btn btn--primary"><%- @T('Submit') %></button>
|
||||||
|
</form>
|
||||||
|
</div>
|
|
@ -0,0 +1,6 @@
|
||||||
|
<div class="js-date js-formPreferencesItem hidden" data-backend="Ticket::Number::Date">
|
||||||
|
<label class="formGroup-label"><%- @T('Options') %></label>
|
||||||
|
<div><%- @T('With Checksum the counter will be appended with a checksum at the end. The format looks like "%s" (e. g. %s).', 'Year.Month.Day.SystemID.Counter.CheckSum', '2012070110101520, 2012070110101535') %></div>
|
||||||
|
<br>
|
||||||
|
<form class="js-formItem"></form>
|
||||||
|
</div>
|
|
@ -0,0 +1,6 @@
|
||||||
|
<div class="js-increment js-formPreferencesItem hidden" data-backend="Ticket::Number::Increment">
|
||||||
|
<label class="formGroup-label"><%- @T('Options') %></label>
|
||||||
|
<div><%- @T('With Checksum the counter will be appended with a checksum at the end. The format looks like "%s" (e. g. %s).', 'SystemID.Counter.CheckSum', '10101384, 10101392') %></div>
|
||||||
|
<br>
|
||||||
|
<form class="js-formItem"></form>
|
||||||
|
</div>
|
|
@ -20,7 +20,7 @@ returns
|
||||||
# generate number
|
# generate number
|
||||||
49_999.times {
|
49_999.times {
|
||||||
number = adapter.generate
|
number = adapter.generate
|
||||||
ticket = Ticket.find_by( number: number )
|
ticket = Ticket.find_by(number: number)
|
||||||
return number if !ticket
|
return number if !ticket
|
||||||
}
|
}
|
||||||
raise "Can't generate new ticket number!"
|
raise "Can't generate new ticket number!"
|
||||||
|
|
25
db/seeds.rb
25
db/seeds.rb
|
@ -1137,10 +1137,10 @@ Setting.create_if_not_exists(
|
||||||
title: 'Ticket Hook Position',
|
title: 'Ticket Hook Position',
|
||||||
name: 'ticket_hook_position',
|
name: 'ticket_hook_position',
|
||||||
area: 'Ticket::Base',
|
area: 'Ticket::Base',
|
||||||
description: "@T('The format of the subject.')
|
description: "The format of the subject.
|
||||||
* @T('**Right** means **Some Subject [Ticket#12345]**')
|
* **Right** means **Some Subject [Ticket#12345]**
|
||||||
* @T('**Left** means **[Ticket#12345] Some Subject**')
|
* **Left** means **[Ticket#12345] Some Subject**
|
||||||
* @T('**None** means **Some Subject** (without ticket number). In the last case you should enable *postmaster_follow_up_search_in* to recognize followups based on email headers and/or body.')",
|
* **None** means **Some Subject** (without ticket number). In the last case you should enable *postmaster_follow_up_search_in* to recognize followups based on email headers and/or body.",
|
||||||
options: {
|
options: {
|
||||||
form: [
|
form: [
|
||||||
{
|
{
|
||||||
|
@ -1148,6 +1148,7 @@ Setting.create_if_not_exists(
|
||||||
null: true,
|
null: true,
|
||||||
name: 'ticket_hook_position',
|
name: 'ticket_hook_position',
|
||||||
tag: 'select',
|
tag: 'select',
|
||||||
|
translate: true,
|
||||||
options: {
|
options: {
|
||||||
'left' => 'left',
|
'left' => 'left',
|
||||||
'right' => 'right',
|
'right' => 'right',
|
||||||
|
@ -1158,6 +1159,7 @@ Setting.create_if_not_exists(
|
||||||
},
|
},
|
||||||
state: 'right',
|
state: 'right',
|
||||||
preferences: {
|
preferences: {
|
||||||
|
controller: 'SettingsAreaTicketHookPosition',
|
||||||
permission: ['admin.ticket'],
|
permission: ['admin.ticket'],
|
||||||
},
|
},
|
||||||
frontend: false
|
frontend: false
|
||||||
|
@ -1166,11 +1168,9 @@ Setting.create_if_not_exists(
|
||||||
title: 'Ticket Number Format',
|
title: 'Ticket Number Format',
|
||||||
name: 'ticket_number',
|
name: 'ticket_number',
|
||||||
area: 'Ticket::Number',
|
area: 'Ticket::Number',
|
||||||
description: "@T('Selects the ticket number generator module.')
|
description: "Selects the ticket number generator module.
|
||||||
* @T('**Increment** increments the ticket number, the SystemID and the counter are used with SystemID.Counter format (e.g. 1010138, 1010139).')
|
* **Increment** increments the ticket number, the SystemID and the counter are used with SystemID.Counter format (e.g. 1010138, 1010139).
|
||||||
* @T('With **Date** the ticket numbers will be generated by the current date, the SystemID and the counter. The format looks like Year.Month.Day.SystemID.counter (e.g. 201206231010138, 201206231010139).')
|
* With **Date** the ticket numbers will be generated by the current date, the SystemID and the counter. The format looks like Year.Month.Day.SystemID.counter (e.g. 201206231010138, 201206231010139).",
|
||||||
|
|
||||||
@T('With param 'Checksum => true' the counter will be appended as checksum to the string. The format looks like SystemID.Counter.CheckSum (e. g. 10101384, 10101392) or Year.Month.Day.SystemID.Counter.CheckSum (e.g. 2012070110101520, 2012070110101535).')",
|
|
||||||
options: {
|
options: {
|
||||||
form: [
|
form: [
|
||||||
{
|
{
|
||||||
|
@ -1178,6 +1178,7 @@ Setting.create_if_not_exists(
|
||||||
null: true,
|
null: true,
|
||||||
name: 'ticket_number',
|
name: 'ticket_number',
|
||||||
tag: 'select',
|
tag: 'select',
|
||||||
|
translate: true,
|
||||||
options: {
|
options: {
|
||||||
'Ticket::Number::Increment' => 'Increment (SystemID.Counter)',
|
'Ticket::Number::Increment' => 'Increment (SystemID.Counter)',
|
||||||
'Ticket::Number::Date' => 'Date (Year.Month.Day.SystemID.Counter)',
|
'Ticket::Number::Date' => 'Date (Year.Month.Day.SystemID.Counter)',
|
||||||
|
@ -1187,6 +1188,8 @@ Setting.create_if_not_exists(
|
||||||
},
|
},
|
||||||
state: 'Ticket::Number::Increment',
|
state: 'Ticket::Number::Increment',
|
||||||
preferences: {
|
preferences: {
|
||||||
|
settings_included: %w(ticket_number_increment ticket_number_date),
|
||||||
|
controller: 'SettingsAreaTicketNumber',
|
||||||
permission: ['admin.ticket'],
|
permission: ['admin.ticket'],
|
||||||
},
|
},
|
||||||
frontend: false
|
frontend: false
|
||||||
|
@ -1244,6 +1247,7 @@ Setting.create_if_not_exists(
|
||||||
},
|
},
|
||||||
preferences: {
|
preferences: {
|
||||||
permission: ['admin.ticket'],
|
permission: ['admin.ticket'],
|
||||||
|
hidden: true,
|
||||||
},
|
},
|
||||||
frontend: false
|
frontend: false
|
||||||
)
|
)
|
||||||
|
@ -1267,10 +1271,11 @@ Setting.create_if_not_exists(
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
state: {
|
state: {
|
||||||
checksum: false,
|
checksum: false
|
||||||
},
|
},
|
||||||
preferences: {
|
preferences: {
|
||||||
permission: ['admin.ticket'],
|
permission: ['admin.ticket'],
|
||||||
|
hidden: true,
|
||||||
},
|
},
|
||||||
frontend: false
|
frontend: false
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue