Merge branch 'develop' of github.com:martini/zammad into develop

This commit is contained in:
Felix Niklas 2015-10-07 09:49:11 +02:00
commit 20dbbfdf28
15 changed files with 280 additions and 452 deletions

View file

@ -15,5 +15,6 @@ App.Config.set( 'Admin', { prio: 9000, parent: '', name: 'Admin', translate: tru
App.Config.set( 'New', { prio: 20000, parent: '', name: 'New', translate: true, target: '#new', class: 'add' }, 'NavBarRight' )
App.Config.set( 'Misc', { prio: 90000, parent: '', name: 'Tools', translate: true, target: '#tools', child: true, class: 'tools' }, 'NavBar' )
App.Config.set( 'Misc1', { prio: 1600, parent: '#tools', name: 'Test 1', target: '#test1', role: [ 'Admin' ] }, 'NavBar' )
App.Config.set( 'Misc2', { prio: 1700, parent: '#tools', name: 'Test 2', target: '#test2', role: [ 'Admin' ] }, 'NavBar' )
# only for testing
#App.Config.set( 'Misc1', { prio: 1600, parent: '#tools', name: 'Test 1', target: '#test1', role: [ 'Admin' ] }, 'NavBar' )
#App.Config.set( 'Misc2', { prio: 1700, parent: '#tools', name: 'Test 2', target: '#test2', role: [ 'Admin' ] }, 'NavBar' )

View file

@ -6,52 +6,36 @@ class App.UiElement.date
attribute.nameRaw = attribute.name
attribute.name = "{date}#{attribute.name}"
# get time object
if attribute.value
if typeof attribute.value is 'string'
time = new Date( Date.parse( "#{attribute.value}T00:00:00Z" ) )
else
time = new Date( attribute.value )
# time items
year = time.getUTCFullYear()
month = time.getUTCMonth() + 1
day = time.getUTCDate()
# create element
item = $( App.view('generic/date')(
attribute: attribute
year: year
month: month
day: day
) )
# start bindings
item.find('.js-today').bind('click', (e) =>
e.preventDefault()
@setNewTime(item, attribute, 0, true)
@validation(item, attribute)
)
item.find('.js-plus-day').bind('click', (e) =>
e.preventDefault()
@setNewTime(item, attribute, 60 * 24, false, true)
@validation(item, attribute)
)
item.find('.js-minus-day').bind('click', (e) =>
e.preventDefault()
@setNewTime(item, attribute, -60 * 24, false, true)
@validation(item, attribute)
)
item.find('.js-plus-week').bind('click', (e) =>
e.preventDefault()
@setNewTime(item, attribute, 60 * 24 * 7, false, true)
@validation(item, attribute)
)
item.find('.js-minus-week').bind('click', (e) =>
e.preventDefault()
@setNewTime(item, attribute, -60 * 24 * 7, false, true)
@validation(item, attribute)
# apply date widgets
$.fn.datepicker.dates['custom'] =
days: [App.i18n.translateInline('Sunday'), App.i18n.translateInline('Monday'), App.i18n.translateInline('Tuesday'), App.i18n.translateInline('Wednesday'), App.i18n.translateInline('Thursday'), App.i18n.translateInline('Friday'), App.i18n.translateInline('Saturday'), App.i18n.translateInline('Sunday')],
daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
daysMin: [App.i18n.translateInline('Su'), App.i18n.translateInline('Mo'), App.i18n.translateInline('Tu'), App.i18n.translateInline('We'), App.i18n.translateInline('Th'), App.i18n.translateInline('Fr'), App.i18n.translateInline('Sa'), App.i18n.translateInline('Su')],
months: [App.i18n.translateInline('January'), App.i18n.translateInline('February'), App.i18n.translateInline('March'), App.i18n.translateInline('April'), App.i18n.translateInline('May'), App.i18n.translateInline('June'), App.i18n.translateInline('July'), App.i18n.translateInline('August'), App.i18n.translateInline('September'), App.i18n.translateInline('October'), App.i18n.translateInline('November'), App.i18n.translateInline('December')],
monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
today: App.i18n.translateInline('today'),
clear: App.i18n.translateInline('clear')
currentDate = undefined
if attribute.value
startDate = new Date(attribute.value)
item.find('.js-datepicker').datepicker(
autoclose: true
todayBtn: 'linked'
todayHighlight: true
#startDate: startDate
format: App.i18n.timeFormat().date
container: item
language: 'custom'
)
# set initial date time
@setNewTimeInitial(item, attribute)
# observer changes
item.find('input').bind('keyup blur focus change', (e) =>
@setNewTime(item, attribute, 0)
@validation(item, attribute, true)
@ -59,64 +43,42 @@ class App.UiElement.date
item.bind('validate', (e) =>
@validation(item, attribute)
)
#setShadowTimestamp()
@setNewTime(item, attribute, 0)
item
@format: (number) ->
if number isnt '' && Number(number) < 10
number = "0#{Number(number)}"
number
@setNewTime: (item, attribute, tolerant = false) ->
@setNewTime: (item, attribute, diff, reset = false, tolerant = false) ->
resetTimeToToday = =>
time = new Date()
time.setMinutes( time.getMinutes() + diff )
@setParams(item, attribute, time)
return resetTimeToToday() if reset
params = @getParams(item)
if params.year is '' && params.month is '' && params.day is ''
return if !tolerant
resetTimeToToday()
params = @getParams(item)
time = new Date( Date.parse( "#{params.year}-#{@format(params.month)}-#{@format(params.day)}T00:00:00Z" ) )
time.setMinutes( time.getMinutes() + diff )
return if !time
@setParams(item, attribute, time)
@setShadowTimestamp: (item, attribute, time) ->
timestamp = ''
if time
timestamp = time.toISOString().replace(/T\d\d:\d\d:\d\d\.\d\d\dZ$/, '')
item.find("[name=\"#{attribute.name}\"]").val(timestamp)
@setParams: (item, attribute, time) ->
App.Log.debug 'UiElement.date.setParams', time.toString()
if time.toString() is 'Invalid Date'
@setShadowTimestamp(item, attribute)
datetime = item.find('.js-datepicker').datepicker('getDate')
if !datetime || datetime.toString() is 'Invalid Date'
App.Log.debug 'UiElement.date.setNewTime', datetime
item.find("[name=\"#{attribute.name}\"]").val('')
return
day = time.getDate()
month = time.getMonth()+1
year = time.getFullYear()
item.find('[data-item=day]').val(day)
item.find('[data-item=month]').val(month)
item.find('[data-item=year]').val(year)
@setShadowTimestamp(item, attribute, time)
App.Log.debug 'UiElement.date.setNewTime', datetime
year = datetime.getFullYear()
month = datetime.getMonth() + 1
day = datetime.getDate()
date = "#{App.Utils.formatTime(year)}-#{App.Utils.formatTime(month,2)}-#{App.Utils.formatTime(day,2)}"
@getParams: (item) ->
params = {}
params.day = item.find('[data-item=day]').val().trim()
params.month = item.find('[data-item=month]').val().trim()
params.year = item.find('[data-item=year]').val().trim()
App.Log.debug 'UiElement.date.getParams', params
params
if date is ''
item.find("[name=\"#{attribute.name}\"]").val('')
return
App.Log.debug 'UiElement.date.setNewTime', date
item.find("[name=\"#{attribute.name}\"]").val(date)
@setNewTimeInitial: (item, attribute) ->
App.Log.debug 'UiElement.date.setNewTimeInitial', timestamp
timestamp = item.find("[name=\"#{attribute.name}\"]").val()
return if !timestamp
timeObject = new Date( Date.parse( timestamp ) )
hour = timeObject.getHours()
minute = timeObject.getMinutes()
App.Log.debug 'UiElement.date.setNewTimeInitial', timestamp, timeObject
item.find('.js-datepicker').datepicker('setUTCDate', timeObject)
@validation: (item, attribute, runtime) ->
@ -126,57 +88,21 @@ class App.UiElement.date
item.find('.help-inline').html('')
item.closest('.form-group').find('.help-inline').html('')
params = @getParams(item)
timestamp = item.find("[name=\"#{attribute.name}\"]").val()
# check required attributes
errors = {}
if !runtime && !attribute.null
if params.day is ''
errors.day = 'missing'
if params.month is ''
errors.month = 'missing'
if params.year is ''
errors.year = 'missing'
# ranges
if params.day
daysInMonth = 31
if params.month && params.year
daysInMonth = new Date(params.year, params.month, 0).getDate()
if isNaN( Number(params.day) )
errors.day = 'invalid'
else if Number(params.day) > daysInMonth || Number(params.day) < 1
errors.day = 'invalid'
if params.month
if isNaN( Number(params.month) )
errors.month = 'invalid'
else if Number(params.month) > 12 || Number(params.month) < 1
errors.month = 'invalid'
if params.year
if isNaN( Number(params.year) )
errors.year = 'invalid'
else if Number(params.year) > 2200 || Number(params.year) < 2001
errors.year = 'invalid'
if !timestamp
if !attribute.null
errors[attribute.name] = 'missing'
else
timeObject = new Date( Date.parse( timestamp ) )
#formGroup = item.closest('.form-group')
formGroup = item
formGroup = item.closest('.form-group')
App.Log.debug 'UiElement.date.validation', errors
if !_.isEmpty(errors)
return if _.isEmpty(errors)
# if field is required, if not do not show error
if params.year is '' && params.day is '' && params.month is ''
return if attribute.null
item.closest('.form-group').addClass('has-error')
item.closest('.form-group').find('.help-inline').text( 'is required' )
return
# show invalid options
for key, value of errors
formGroup.addClass('has-error')
formGroup.find("[data-item=#{key}]").addClass('has-error')
return
# show invalid options
for key, value of errors
formGroup.addClass('has-error')

View file

@ -6,66 +6,39 @@ class App.UiElement.datetime
attribute.nameRaw = attribute.name
attribute.name = "{datetime}#{attribute.name}"
# get time object
if attribute.value
if typeof attribute.value is 'string'
time = new Date( Date.parse( attribute.value ) )
else
time = new Date( attribute.value )
# time items
year = time.getFullYear()
month = time.getMonth() + 1
day = time.getDate()
hour = time.getHours()
minute = time.getMinutes()
# create element
item = $( App.view('generic/datetime')(
attribute: attribute
year: year
month: month
day: day
hour: hour
minute: minute
) )
# start bindings
item.find('.js-today').bind('click', (e) =>
e.preventDefault()
@setNewTime(item, attribute, 0, true)
@validation(item, attribute)
)
item.find('.js-plus-hour').bind('click', (e) =>
e.preventDefault()
@setNewTime(item, attribute, 60, false, true)
@validation(item, attribute)
)
item.find('.js-minus-hour').bind('click', (e) =>
e.preventDefault()
@setNewTime(item, attribute, -60, false, true)
@validation(item, attribute)
)
item.find('.js-plus-day').bind('click', (e) =>
e.preventDefault()
@setNewTime(item, attribute, 60 * 24, false, true)
@validation(item, attribute)
)
item.find('.js-minus-day').bind('click', (e) =>
e.preventDefault()
@setNewTime(item, attribute, -60 * 24, false, true)
@validation(item, attribute)
)
item.find('.js-plus-week').bind('click', (e) =>
e.preventDefault()
@setNewTime(item, attribute, 60 * 24 * 7, false, true)
@validation(item, attribute)
)
item.find('.js-minus-week').bind('click', (e) =>
e.preventDefault()
@setNewTime(item, attribute, -60 * 24 * 7, false, true)
@validation(item, attribute)
# apply date widgets
$.fn.datepicker.dates['custom'] =
days: [App.i18n.translateInline('Sunday'), App.i18n.translateInline('Monday'), App.i18n.translateInline('Tuesday'), App.i18n.translateInline('Wednesday'), App.i18n.translateInline('Thursday'), App.i18n.translateInline('Friday'), App.i18n.translateInline('Saturday'), App.i18n.translateInline('Sunday')],
daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
daysMin: [App.i18n.translateInline('Su'), App.i18n.translateInline('Mo'), App.i18n.translateInline('Tu'), App.i18n.translateInline('We'), App.i18n.translateInline('Th'), App.i18n.translateInline('Fr'), App.i18n.translateInline('Sa'), App.i18n.translateInline('Su')],
months: [App.i18n.translateInline('January'), App.i18n.translateInline('February'), App.i18n.translateInline('March'), App.i18n.translateInline('April'), App.i18n.translateInline('May'), App.i18n.translateInline('June'), App.i18n.translateInline('July'), App.i18n.translateInline('August'), App.i18n.translateInline('September'), App.i18n.translateInline('October'), App.i18n.translateInline('November'), App.i18n.translateInline('December')],
monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
today: App.i18n.translateInline('today'),
clear: App.i18n.translateInline('clear')
currentDate = undefined
if attribute.value
startDate = new Date(attribute.value)
item.find('.js-datepicker').datepicker(
autoclose: true
todayBtn: 'linked'
todayHighlight: true
#startDate: startDate
format: App.i18n.timeFormat().date
container: item
language: 'custom'
)
# set initial date time
@setNewTimeInitial(item, attribute)
# apply time widgets
item.find('.js-timepicker').timepicker()
# observer changes
item.find('input').bind('keyup blur focus change', (e) =>
@setNewTime(item, attribute, 0)
@validation(item, attribute, true)
@ -73,70 +46,51 @@ class App.UiElement.datetime
item.bind('validate', (e) =>
@validation(item, attribute)
)
#setShadowTimestamp()
@setNewTime(item, attribute, 0)
item
@format: (number) ->
if number isnt '' && Number(number) < 10
number = "0#{Number(number)}"
number
@setNewTime: (item, attribute, tolerant = false) ->
@setNewTime: (item, attribute, diff, reset = false, tolerant = false) ->
resetTimeToToday = =>
time = new Date()
time.setMinutes( time.getMinutes() + diff )
@setParams(item, attribute, time)
return resetTimeToToday() if reset
params = @getParams(item)
if params.year is '' && params.month is '' && params.day is '' && params.hour is '' && params.minute is ''
return if !tolerant
resetTimeToToday()
params = @getParams(item)
time = new Date( Date.parse( "#{params.year}-#{@format(params.month)}-#{@format(params.day)}T#{@format(params.hour)}:#{@format(params.minute)}:00Z" ) )
time.setMinutes( time.getMinutes() + diff + time.getTimezoneOffset() )
return if !time
@setParams(item, attribute, time)
@setShadowTimestamp: (item, attribute, time) ->
timestamp = ''
if time
timestamp = time.toISOString().replace(/\d\d\.\d\d\dZ$/, '00.000Z')
item.find("[name=\"#{attribute.name}\"]").val(timestamp)
@setParams: (item, attribute, time) ->
App.Log.debug 'UiElement.datetime.setParams', time.toString()
if time.toString() is 'Invalid Date'
@setShadowTimestamp(item, attribute)
datetime = item.find('.js-datepicker').datepicker('getDate')
if !datetime || datetime.toString() is 'Invalid Date'
App.Log.debug 'UiElement.datetime.setNewTime', datetime
item.find("[name=\"#{attribute.name}\"]").val('')
return
day = time.getDate()
month = time.getMonth()+1
year = time.getFullYear()
hour = time.getHours()
minute = time.getMinutes()
item.find('[data-item=day]').val(day)
item.find('[data-item=month]').val(month)
item.find('[data-item=year]').val(year)
item.find('[data-item=hour]').val(hour)
item.find('[data-item=minute]').val(minute)
@setShadowTimestamp(item, attribute, time)
App.Log.debug 'UiElement.datetime.setNewTime', datetime
year = datetime.getFullYear()
month = datetime.getMonth() + 1
day = datetime.getDate()
date = "#{App.Utils.formatTime(year)}-#{App.Utils.formatTime(month,2)}-#{App.Utils.formatTime(day,2)}"
time = item.find('.js-timepicker').val()
@getParams: (item) ->
params = {}
params.day = item.find('[data-item=day]').val().trim()
params.month = item.find('[data-item=month]').val().trim()
params.year = item.find('[data-item=year]').val().trim()
params.hour = item.find('[data-item=hour]').val().trim()
params.minute = item.find('[data-item=minute]').val().trim()
App.Log.debug 'UiElement.datetime.getParams', params
params
if date is '' || time is ''
item.find("[name=\"#{attribute.name}\"]").val('')
return
timestamp = "#{date}T#{time}:00.000Z"
time = new Date( Date.parse(timestamp) )
time.setMinutes( time.getMinutes() + time.getTimezoneOffset() )
App.Log.debug 'UiElement.datetime.setNewTime', time.toString()
timestamp = time.toISOString().replace(/\d\d\.\d\d\dZ$/, '00.000Z')
item.find("[name=\"#{attribute.name}\"]").val(timestamp)
@setNewTimeInitial: (item, attribute) ->
App.Log.debug 'UiElement.datetime.setNewTimeInitial', timestamp
timestamp = item.find("[name=\"#{attribute.name}\"]").val()
if !timestamp
item.find('.js-timepicker').val('08:00')
return
timeObject = new Date( Date.parse( timestamp ) )
hour = timeObject.getHours()
minute = timeObject.getMinutes()
time = "#{App.Utils.formatTime(hour,2)}:#{App.Utils.formatTime(minute,2)}"
App.Log.debug 'UiElement.datetime.setNewTimeInitial', timestamp, timeObject
item.find('.js-datepicker').datepicker('setUTCDate', timeObject)
item.find('.js-timepicker').val(time)
@validation: (item, attribute, runtime) ->
@ -146,72 +100,21 @@ class App.UiElement.datetime
item.find('.help-inline').html('')
item.closest('.form-group').find('.help-inline').html('')
params = @getParams(item)
timestamp = item.find("[name=\"#{attribute.name}\"]").val()
# check required attributes
errors = {}
if !runtime && !attribute.null
if params.day is ''
errors.day = 'missing'
if params.month is ''
errors.month = 'missing'
if params.year is ''
errors.year = 'missing'
if params.hour is ''
errors.hour = 'missing'
if params.minute is ''
errors.minute = 'missing'
if !timestamp
if !attribute.null
errors[attribute.name] = 'missing'
else
timeObject = new Date( Date.parse( timestamp ) )
# ranges
if params.day
daysInMonth = 31
if params.month && params.year
daysInMonth = new Date(params.year, params.month, 0).getDate()
if isNaN( Number(params.day) )
errors.day = 'invalid'
else if Number(params.day) > daysInMonth || Number(params.day) < 1
errors.day = 'invalid'
if params.month
if isNaN( Number(params.month) )
errors.month = 'invalid'
else if Number(params.month) > 12 || Number(params.month) < 1
errors.month = 'invalid'
if params.year
if isNaN( Number(params.year) )
errors.year = 'invalid'
else if Number(params.year) > 2200 || Number(params.year) < 2001
errors.year = 'invalid'
if params.hour
if isNaN( Number(params.hour) )
errors.hour = 'invalid'
else if parseInt(params.hour) > 23 || parseInt(params.hour) < 0
errors.hour = 'invalid'
if params.minute
if isNaN( Number(params.minute) )
errors.minute = 'invalid'
else if Number(params.minute) > 59
errors.minute = 'invalid'
#formGroup = item.closest('.form-group')
formGroup = item
formGroup = item.closest('.form-group')
App.Log.debug 'UiElement.datetime.validation', errors
if !_.isEmpty(errors)
return if _.isEmpty(errors)
# if field is required, if not do not show error
if params.year is '' && params.day is '' && params.month is '' && params.hour is '' && params.minute is ''
return if attribute.null
item.closest('.form-group').addClass('has-error')
item.closest('.form-group').find('.help-inline').text( 'is required' )
return
# show invalid options
for key, value of errors
formGroup.addClass('has-error')
formGroup.find("[data-item=#{key}]").addClass('has-error')
return
# show invalid options
for key, value of errors
formGroup.addClass('has-error')

View file

@ -15,8 +15,11 @@ class App.UiElement.ticket_perform_action
# ignore passwords and relations
if row.type isnt 'password' && row.name.substr(row.name.length-4,4) isnt '_ids'
config = _.clone(row)
elements["#{groupKey}.#{config.name}"] = config
# ignore readonly attributes
if !row.readonly
config = _.clone(row)
elements["#{groupKey}.#{config.name}"] = config
[defaults, groups, elements]

View file

@ -1509,15 +1509,16 @@ class InputsRef extends App.ControllerContent
# date picker
@$('.js-datepicker3').datepicker(
todayHighlight: true
startDate: new Date().toLocaleDateString('de-DE') # returns 25.09.2015
format: 'dd.mm.yyyy',
startDate: new Date()
format: App.i18n.timeFormat().date
container: @$('.js-datepicker3').parent()
)
# date time picker
@$('.js-datepicker4').datepicker(
todayHighlight: true
startDate: new Date().toLocaleDateString('en-US') # returns 9/25/2015
startDate: new Date()
format: App.i18n.timeFormat().date
container: @$('.js-datepicker4').parent()
)
@$('.js-timepicker4').timepicker()
@ -1674,7 +1675,7 @@ class PrimaryEmailRef extends App.ControllerContent
App.Config.set( 'layout_ref/primary_email', PrimaryEmailRef, 'Routes' )
class App.CustomerChatRef extends App.ControllerContent
class App.CustomerChatRef extends App.Controller
@extend Spine.Events
questions: [
@ -1757,6 +1758,11 @@ class App.CustomerChatRef extends App.ControllerContent
# @testChat @chatWindows[0], 100
@initQuiz()
show: (params) =>
# highlight navbar
@navupdate '#layout_ref/customer_chat'
testChat: (chat, count) ->
for i in [0..count]
text = @questions[Math.floor(Math.random() * @questions.length)].question
@ -1849,12 +1855,24 @@ class App.CustomerChatRef extends App.ControllerContent
else
@nextQuestion()
class CustomerChatRouter extends App.ControllerPermanent
constructor: (params) ->
super
# check authentication
return if !@authenticate()
App.Config.set( 'layout_ref/customer_chat', App.CustomerChatRef, 'Routes' )
App.TaskManager.execute(
key: 'CustomerChatRef'
controller: 'CustomerChatRef'
params: {}
show: true
persistent: true
)
App.Config.set( 'Chat', { prio: 300, parent: '', name: 'Customer Chat', target: '#layout_ref/customer_chat', switch: true, counter: true, role: ['Agent'], class: 'chat' }, 'NavBar' )
# App.Config.set( 'Chat', { controller: 'CustomerChatRef', authentication: true }, 'permanentTask' )
App.Config.set( 'layout_ref/customer_chat', CustomerChatRouter, 'Routes' )
App.Config.set( 'CustomerChatRef', { controller: 'CustomerChatRef', authentication: true }, 'permanentTask' )
App.Config.set( 'CustomerChatRef', { prio: 1200, parent: '', name: 'Customer Chat', target: '#layout_ref/customer_chat', switch: true, counter: true, role: ['Agent'], class: 'chat' }, 'NavBar' )
class chatWindowRef extends Spine.Controller

View file

@ -20,7 +20,7 @@ class App.TicketZoomArticleView extends App.Controller
@el.append( all )
class ArticleViewItem extends App.Controller
hasChangedAttributes: ['from', 'to', 'cc', 'subject', 'body', 'internal', 'preferences']
hasChangedAttributes: ['from', 'to', 'cc', 'subject', 'body', 'preferences']
elements:
'.textBubble-content': 'textBubbleContent'
@ -59,7 +59,7 @@ class ArticleViewItem extends App.Controller
App.TicketArticle.unsubscribe(@subscribeId)
setHighlighter: =>
return if !@el.is(':visible')
return if @el.is(':hidden')
# use delay do no ui blocking
#@highligher.loadHighlights(@ticket_article_id)
d = =>
@ -69,19 +69,19 @@ class ArticleViewItem extends App.Controller
hasChanged: (article) =>
# if no last article exists, remember it and return true
if !@article_last_updated
@article_last_updated = {}
if !@articleAttributesLastUpdate
@articleAttributesLastUpdate = {}
for item in @hasChangedAttributes
@article_last_updated[item] = article[item]
@articleAttributesLastUpdate[item] = article[item]
return true
# compare last and current article attributes
article_last_updated_check = {}
articleAttributesLastUpdateCheck = {}
for item in @hasChangedAttributes
article_last_updated_check[item] = article[item]
diff = difference(@article_last_updated, article_last_updated_check)
articleAttributesLastUpdateCheck[item] = article[item]
diff = difference(@articleAttributesLastUpdate, articleAttributesLastUpdateCheck)
return false if !diff || _.isEmpty( diff )
@article_last_updated = article_last_updated_check
@articleAttributesLastUpdate = articleAttributesLastUpdateCheck
true
render: (article) =>
@ -90,16 +90,22 @@ class ArticleViewItem extends App.Controller
@article = App.TicketArticle.fullLocal( @ticket_article_id )
# set @el attributes
@el.addClass("ticket-article-item #{@article.sender.name.toLowerCase()}")
if @article.internal is true
@el.addClass('is-internal')
else
@el.removeClass('is-internal')
@el.attr('data-id', @article.id)
@el.attr('id', "article-#{@article.id}")
if !article
@el.addClass("ticket-article-item #{@article.sender.name.toLowerCase()}")
@el.attr('data-id', @article.id)
@el.attr('id', "article-#{@article.id}")
# set internal change directly in dom, without rerender while article
if !article || ( @lastArticle && @lastArticle.internal isnt @article.internal )
if @article.internal is true
@el.addClass('is-internal')
else
@el.removeClass('is-internal')
# check if rerender is needed
return if !@hasChanged(@article)
if !@hasChanged(@article)
@lastArticle = @article.attributes()
return
# prepare html body
if @article.content_type is 'text/html'
@ -128,14 +134,16 @@ class ArticleViewItem extends App.Controller
# set see more
@shown = false
@setSeeMore()
a = =>
@setSeeMore()
@delay( a, 50 )
# set highlighter
@setHighlighter()
# set see more options
setSeeMore: =>
return if !@el.is(':visible')
return if @el.is(':hidden')
return if @shown
@shown = true

View file

@ -8,7 +8,7 @@ class App.PostmasterFilter extends App.Model
{ name: 'channel', display: 'Channel', type: 'input', readonly: 1 },
{ name: 'match', display: 'Match all of the following', tag: 'postmaster_match' },
{ name: 'perform', display: 'Perform action of the following', tag: 'postmaster_set' },
{ name: 'note', display: 'Note', tag: 'textarea', note: 'Notes are visible to agents only, never to customers.', limit: 250, null: true },
{ name: 'note', display: 'Note', tag: 'textarea', limit: 250, null: true },
{ name: 'updated_at', display: 'Updated', tag: 'datetime', readonly: 1 },
{ name: 'active', display: 'Active', tag: 'active', default: true },
{ name: 'created_by_id', display: 'Created by', relation: 'User', readonly: 1 },

View file

@ -3,22 +3,22 @@ class App.Ticket extends App.Model
@extend Spine.Model.Ajax
@url: @apiPath + '/tickets'
@configure_attributes = [
{ name: 'number', display: '#', tag: 'input', type: 'text', limit: 100, null: true, read_only: true, style: 'width: 68px' },
{ name: 'number', display: '#', tag: 'input', type: 'text', limit: 100, null: true, readonly: 1, style: 'width: 68px' },
{ name: 'title', display: 'Title', tag: 'input', type: 'text', limit: 100, null: false },
{ name: 'customer_id', display: 'Customer', tag: 'input', type: 'text', limit: 100, null: false, autocapitalize: false, relation: 'User' },
{ name: 'organization_id', display: 'Organization', tag: 'select', relation: 'Organization', tagreadonly: 1 },
{ name: 'organization_id', display: 'Organization', tag: 'select', relation: 'Organization', readonly: 1 },
{ name: 'group_id', display: 'Group', tag: 'select', multiple: false, limit: 100, null: false, relation: 'Group', style: 'width: 10%', edit: true },
{ name: 'owner_id', display: 'Owner', tag: 'select', multiple: false, limit: 100, null: true, relation: 'User', style: 'width: 12%', edit: true },
{ name: 'state_id', display: 'State', tag: 'select', multiple: false, null: false, relation: 'TicketState', default: 'new', style: 'width: 12%', edit: true, customer: true },
{ name: 'pending_time', display: 'Pending Time', tag: 'datetime', null: true, style: 'width: 130px' },
{ name: 'priority_id', display: 'Priority', tag: 'select', multiple: false, null: false, relation: 'TicketPriority', default: '2 normal', style: 'width: 12%', edit: true, customer: true },
{ name: 'article_count', display: 'Article#', style: 'width: 12%' },
{ name: 'escalation_time', display: 'Escalation', tag: 'datetime', null: true, style: 'width: 130px', class: 'escalation' },
{ name: 'last_contact', display: 'Last contact', tag: 'datetime', null: true, style: 'width: 130px' },
{ name: 'last_contact_agent', display: 'Last contact (Agent)', tag: 'datetime', null: true, style: 'width: 130px' },
{ name: 'last_contact_customer', display: 'Last contact (Customer)', tag: 'datetime', null: true, style: 'width: 130px' },
{ name: 'first_response', display: 'First response', tag: 'datetime', null: true, style: 'width: 130px' },
{ name: 'close_time', display: 'Close time', tag: 'datetime', null: true, style: 'width: 130px' },
{ name: 'article_count', display: 'Article#', readonly: 1, style: 'width: 12%' },
{ name: 'escalation_time', display: 'Escalation', tag: 'datetime', null: true, readonly: 1, style: 'width: 130px', class: 'escalation' },
{ name: 'last_contact', display: 'Last contact', tag: 'datetime', null: true, readonly: 1, style: 'width: 130px' },
{ name: 'last_contact_agent', display: 'Last contact (Agent)', tag: 'datetime', null: true, readonly: 1, style: 'width: 130px' },
{ name: 'last_contact_customer', display: 'Last contact (Customer)', tag: 'datetime', null: true, readonly: 1, style: 'width: 130px' },
{ name: 'first_response', display: 'First response', tag: 'datetime', null: true, readonly: 1, style: 'width: 130px' },
{ name: 'close_time', display: 'Close time', tag: 'datetime', null: true, readonly: 1, style: 'width: 130px' },
{ name: 'created_by_id', display: 'Created by', relation: 'User', readonly: 1 },
{ name: 'created_at', display: 'Created at', tag: 'datetime', style: 'width: 130px', readonly: 1 },
{ name: 'updated_by_id', display: 'Updated by', relation: 'User', readonly: 1 },

View file

@ -1,15 +1,4 @@
<div class="horizontal form-control" style="padding: 0 0 0 4px; line-height: 40px;" data-name="<%= @attribute.nameRaw %>">
<input type="hidden" name="<%= @attribute.name %>" value="<%= @attribute.value %>">
<input type="text" maxlength="2" data-item="day" value="<%= @day %>" placeholder="dd" style="width: 36px; padding: 6px 6px; border: 1px solid #ffffff; height: 39px;">
.
<input type="text" maxlength="2" data-item="month" value="<%= @month %>" placeholder="mm" style="width: 36px; padding: 6px 6px; border: 1px solid #ffffff; height: 39px;">
.
<input type="text" maxlength="4" data-item="year" value="<%= @year %>" placeholder="yyyy" style="width: 54px; padding: 6px 6px; border: 1px solid #ffffff; height: 39px;">
<div class="" data-name="<%= @attribute.nameRaw %>">
<input type="hidden" value="<%= @attribute.value %>" name="<%= @attribute.name %>">
<input type="text" value="" class="form-control js-datepicker" data-item="date">
</div>
<% if !@attribute.disable_feature: %>
<small>
<a href="#" class="js-today"><%- @T('today') %></a> |
<a href="#" class="js-minus-day">-1</a> <a href="#" class="js-plus-day">+1</a> <%- @T('day') %> |
<a href="#" class="js-minus-week">-7</a> <a href="#" class="js-plus-week">+7</a> <%- @T('days') %>
</small>
<% end %>

View file

@ -1,19 +1,6 @@
<div class="horizontal form-control" style="padding: 0 0 0 4px; line-height: 40px;" data-name="<%= @attribute.nameRaw %>">
<input type="hidden" name="<%= @attribute.name %>" value="<%= @attribute.value %>">
<input type="text" maxlength="2" data-item="day" value="<%= @day %>" placeholder="dd" style="width: 36px; padding: 6px 6px; border: 1px solid #ffffff; height: 39px;">
.
<input type="text" maxlength="2" data-item="month" value="<%= @month %>" placeholder="mm" style="width: 36px; padding: 6px 6px; border: 1px solid #ffffff; height: 39px;">
.
<input type="text" maxlength="4" data-item="year" value="<%= @year %>" placeholder="yyyy" style="width: 54px; padding: 6px 6px; border: 1px solid #ffffff; height: 39px;">
<input type="text" maxlength="2" data-item="hour" value="<%= @hour %>" placeholder="00" style="width: 36px; padding: 6px 6px; border: 1px solid #ffffff; height: 39px;">
:
<input type="text" maxlength="2" data-item="minute" value="<%= @minute %>" placeholder="00" style="width: 36px; padding: 6px 6px; border: 1px solid #ffffff; height: 39px;">
<div class="controls--bundle" data-name="<%= @attribute.nameRaw %>">
<input type="hidden" value="<%= @attribute.value %>" name="<%= @attribute.name %>">
<input type="text" value="" class="form-control js-datepicker" data-item="date">
<div class="controls-label"><%- @T('at') %></div>
<input type="text" value="" class="form-control time js-timepicker" data-item="time">
</div>
<% if !@attribute.disable_feature: %>
<small>
<a href="#" class="js-today"><%- @T('now') %></a> |
<a href="#" class="js-minus-hour">-1</a> <a href="#" class="js-plus-hour">+1</a> <%- @T('hour') %> |
<a href="#" class="js-minus-day">-1</a> <a href="#" class="js-plus-day">+1</a> <%- @T('day') %> |
<a href="#" class="js-minus-week">-7</a> <a href="#" class="js-plus-week">+7</a> <%- @T('days') %>
</small>
<% end %>

View file

@ -12,14 +12,14 @@
<p>A date</p>
<div class="date form-group">
<div class="controls">
<input type="text" value="10/28/2015" class="form-control js-datepicker3">
<input type="text" value="<%- @Tdate('2014-10-28') %>" class="form-control js-datepicker3">
</div>
</div>
<p>A date time</p>
<div class="date form-group formGroup--bundle">
<div class="controls">
<input type="text" value="10/28/2015" class="form-control js-datepicker4">
<div class="datetime form-group">
<div class="controls controls--bundle">
<input type="text" value="<%- @Tdate('2015-10-28') %>" class="form-control js-datepicker4">
<div class="controls-label">at</div>
<input type="text" value="08:00" class="form-control time js-timepicker4">
</div>

View file

@ -42,7 +42,7 @@
<div class="bubble-arrow"></div>
<div class="textBubble-content" id="article-content-<%= @article.id %>" data-id="<%= @article.id %>">
<%- App.Utils.signatureIdentify( @article.html ) %>
<div class="textBubble-overflowContainer">
<div class="textBubble-overflowContainer hide">
<div class="btn btn--text js-unfold"><%- @T('See more') %></div>
</div>
</div>

View file

@ -127,11 +127,10 @@ test( 'datetime validation check', function() {
//equal( el.find('[data-name="datetime1"]').closest('.form-group').find('.help-inline').text(), '', 'check datetime1 error message')
// set new values
el.find('[data-name="datetime1"] [data-item="day"]').val(1).trigger('blur')
el.find('[data-name="datetime1"] [data-item="month"]').val(1).trigger('blur')
el.find('[data-name="datetime1"] [data-item="year"]').val(2015).trigger('blur')
el.find('[data-name="datetime1"] [data-item="hour"]').val(12).trigger('blur')
el.find('[data-name="datetime1"] [data-item="minute"]').val(42).trigger('blur')
el.find('[data-name="datetime1"] [data-item="date"]').val('01/01/2015').trigger('blur')
el.find('[data-name="datetime1"] [data-item="date"]').datepicker('setDate')
el.find('[data-name="datetime1"] [data-item="time"]').val('12:42').trigger('blur')
el.find('[data-name="datetime1"] [data-item="time"]').trigger('change')
// check params
timeStamp = new Date( Date.parse('2015-01-01T12:42:00.000Z') )
@ -151,16 +150,12 @@ test( 'datetime validation check', function() {
equal( el.find('[data-name="datetime1"]').closest('.form-group').hasClass('has-error'), false, 'check datetime1 has-error')
equal( el.find('[data-name="datetime1"]').closest('.form-group').find('.help-inline').text(), '', 'check datetime1 error message')
el.find('[data-name="datetime1"] [data-item="day"]').val('47').trigger('blur')
deepEqual( el.find('[data-name="datetime1"] [data-item="day"]').hasClass('has-error'), true )
el.find('[data-name="datetime1"] [data-item="month"]').val('1').trigger('blur')
deepEqual( el.find('[data-name="datetime1"] [data-item="month"]').hasClass('has-error'), false )
el.find('[data-name="datetime1"] [data-item="year"]').val('2015').trigger('blur')
deepEqual( el.find('[data-name="datetime1"] [data-item="year"]').hasClass('has-error'), false )
el.find('[data-name="datetime1"] [data-item="hour"]').val('12').trigger('blur')
deepEqual( el.find('[data-name="datetime1"] [data-item="hour"]').hasClass('has-error'), false )
el.find('[data-name="datetime1"] [data-item="minute"]').val('42').trigger('blur')
deepEqual( el.find('[data-name="datetime1"] [data-item="minute"]').hasClass('has-error'), false )
el.find('[data-name="datetime1"] [data-item="date"]').val('').trigger('blur')
el.find('[data-name="datetime1"] [data-item="date"]').datepicker('setDate')
el.find('[data-name="datetime1"] [data-item="time"]').val('12:42').trigger('blur')
el.find('[data-name="datetime1"] [data-item="time"]').trigger('change')
equal( el.find('[data-name="datetime1"]').closest('.form-group').hasClass('has-error'), true )
params = App.ControllerForm.params( el )
errors = form.validate(params)
@ -169,10 +164,9 @@ test( 'datetime validation check', function() {
}
deepEqual( errors, test_errors, 'validation errors check' )
App.ControllerForm.validate( { errors: errors, form: el } )
equal( el.find('[data-name="datetime1"]').closest('.form-group').hasClass('has-error'), false, 'check datetime1 no has-error')
equal( el.find('[data-name="datetime1"] [data-item="day"]').hasClass('has-error'), true, 'check datetime1 no has-error')
equal( el.find('[data-name="datetime1"] [data-item="month"]').hasClass('has-error'), false, 'check datetime1 no has-error')
equal( el.find('[data-name="datetime1"]').closest('.form-group').find('.help-inline').text(), '', 'check datetime1 error message')
equal( el.find('[data-name="datetime1"]').closest('.form-group').hasClass('has-error'), true, 'check datetime1 no has-error')
equal( el.find('[data-name="datetime1"]').closest('.form-group').find('.help-inline').text(), 'is required', 'check datetime1 error message')
});
@ -186,7 +180,7 @@ test( 'date validation check', function() {
el: el,
model: {
configure_attributes: [
{ name: 'date1', display: 'Date1', tag: 'date', null: false, default: defaults['time1'] },
{ name: 'date2', display: 'Date2', tag: 'date', null: false, default: defaults['time1'] },
],
},
params: defaults,
@ -197,29 +191,29 @@ test( 'date validation check', function() {
// check params
params = App.ControllerForm.params( el )
test_params = {
date1: undefined,
date2: undefined,
}
deepEqual( params, test_params, 'params check' )
errors = form.validate(params)
test_errors = {
date1: 'is required',
date2: 'is required',
}
deepEqual( errors, test_errors, 'validation errors check' )
App.ControllerForm.validate( { errors: errors, form: el } )
equal( el.find('[data-name="date1"]').closest('.form-group').hasClass('has-error'), true, 'check date1 has-error')
equal( el.find('[data-name="date1"]').closest('.form-group').find('.help-inline').text(), 'is required', 'check date1 error message')
equal( el.find('[data-name="date2"]').closest('.form-group').hasClass('has-error'), true, 'check date2 has-error')
equal( el.find('[data-name="date2"]').closest('.form-group').find('.help-inline').text(), 'is required', 'check date2 error message')
// set new values
el.find('[data-name="date1"] [data-item="day"]').val('1').trigger('blur')
el.find('[data-name="date1"] [data-item="month"]').val('1').trigger('blur')
el.find('[data-name="date1"] [data-item="year"]').val('2015').trigger('blur')
el.find('[data-name="date2"] [data-item="date"]').val('01/01/2015').trigger('blur')
el.find('[data-name="date2"] [data-item="date"]').datepicker('setDate')
el.find('[data-name="date2"] [data-item="date"]').trigger('change')
// check params
params = App.ControllerForm.params( el )
test_params = {
date1: '2015-01-01',
date2: '2015-01-01',
}
deepEqual( params, test_params, 'params check' )
@ -228,37 +222,32 @@ test( 'date validation check', function() {
test_errors = undefined
deepEqual( errors, test_errors, 'validation errors check' )
App.ControllerForm.validate( { errors: errors, form: el } )
equal( el.find('[data-name="date1"]').closest('.form-group').hasClass('has-error'), false, 'check date1 has-error')
equal( el.find('[data-name="date1"]').closest('.form-group').find('.help-inline').text(), '', 'check date1 error message')
equal( el.find('[data-name="date2"]').closest('.form-group').hasClass('has-error'), false, 'check date1 has-error')
equal( el.find('[data-name="date2"]').closest('.form-group').find('.help-inline').text(), '', 'check date1 error message')
// set invalid values
el.find('[data-name="date1"] [data-item="day"]').val('47').trigger('blur')
deepEqual( el.find('[data-name="date1"] [data-item="day"]').hasClass('has-error'), true )
el.find('[data-name="date1"] [data-item="month"]').val('1').trigger('blur')
deepEqual( el.find('[data-name="date1"] [data-item="month"]').hasClass('has-error'), false )
el.find('[data-name="date1"] [data-item="year"]').val('2015').trigger('blur')
deepEqual( el.find('[data-name="date1"] [data-item="year"]').hasClass('has-error'), false )
el.find('[data-name="date2"] [data-item="date"]').val('').trigger('blur')
el.find('[data-name="date2"] [data-item="date"]').datepicker('setDate')
el.find('[data-name="date2"] [data-item="date"]').trigger('change')
equal( el.find('[data-name="date2"]').closest('.form-group').hasClass('has-error'), true, 'check date2 has-error')
// check params
params = App.ControllerForm.params( el )
test_params = {
date1: undefined,
date2: undefined,
}
deepEqual( params, test_params, 'params check' )
// check errors
errors = form.validate(params)
test_errors = {
date1: 'is required',
date2: 'is required',
}
deepEqual( errors, test_errors, 'validation errors check' )
App.ControllerForm.validate( { errors: errors, form: el } )
equal( el.find('[data-name="date1"]').closest('.form-group').hasClass('has-error'), false, 'check date1 no has-error')
equal( el.find('[data-name="date1"] [data-item="day"]').hasClass('has-error'), true, 'check date1 no has-error')
equal( el.find('[data-name="date1"] [data-item="month"]').hasClass('has-error'), false, 'check date1 no has-error')
equal( el.find('[data-name="date1"]').closest('.form-group').find('.help-inline').text(), '', 'check date1 error message')
equal( el.find('[data-name="date2"]').closest('.form-group').hasClass('has-error'), true, 'check date2 has-error')
equal( el.find('[data-name="date2"]').closest('.form-group').find('.help-inline').text(), 'is required', 'check date2 error message')
});
test( "datetime selector check", function() {
@ -284,12 +273,14 @@ test( "datetime selector check", function() {
}
deepEqual( params, test_params, 'params check' )
el.find('.js-today').click()
timeStamp = new Date()
el.find('.js-datepicker').datepicker('setDate', timeStamp)
el.find('.js-datepicker').trigger('blur')
// check params
timeStamp = new Date()
currentTime = timeStamp.toISOString()
currentTime = currentTime.replace(/(\d\d\.\d\d\dZ)$/, '00.000Z')
currentTime = currentTime.replace(/(\d\d.\d\d.\d\d\.\d\d\dZ)$/, '07:00:00.000Z')
params = App.ControllerForm.params( el )
test_params = {
datetime1: currentTime,
@ -308,7 +299,7 @@ test( "date selector check", function() {
el: el,
model: {
configure_attributes: [
{ name: 'date1', display: 'Datet1', tag: 'date', null: false, default: defaults['date1'] },
{ name: 'date3', display: 'Datet1', tag: 'date', null: false, default: defaults['date3'] },
],
},
params: defaults,
@ -317,11 +308,14 @@ test( "date selector check", function() {
// check params
params = App.ControllerForm.params( el )
test_params = {
date1: undefined,
date3: undefined,
}
deepEqual( params, test_params, 'params check' )
el.find('.js-today').click()
timeStamp = new Date()
el.find('.js-datepicker').datepicker('setDate', timeStamp)
el.find('.js-datepicker').trigger('blur')
// check params
format = function (number) {
@ -331,11 +325,10 @@ test( "date selector check", function() {
return number
}
timeStamp = new Date()
currentTime = timeStamp.getFullYear() + '-' + format(timeStamp.getMonth()+1) + '-' + format(timeStamp.getDate())
params = App.ControllerForm.params( el )
test_params = {
date1: currentTime,
date3: currentTime,
}
deepEqual( params, test_params, 'params check' )

View file

@ -28,24 +28,24 @@ class AgentTicketOverviewLevel1Test < TestCase
overview_create(
browser: browser1,
data: {
:name => name1,
:role => 'Agent',
:selector => {
name: name1,
role: 'Agent',
selector: {
'Priority' => '1 low',
},
:prio => 1000,
prio: 1000,
'order::direction' => 'down',
}
)
overview_create(
browser: browser1,
data: {
:name => name2,
:role => 'Agent',
:selector => {
name: name2,
role: 'Agent',
selector: {
'Priority' => '3 high',
},
:prio => 1001,
prio: 1001,
'order::direction' => 'down',
}
)

View file

@ -138,7 +138,7 @@ class TestCase < Test::Unit::TestCase
end
instance.find_elements( { css: '#login button' } )[0].click
sleep 4
sleep 5
login = instance.find_elements( { css: '.user-menu .user a' } )[0].attribute('title')
if login != params[:username]
screenshot( browser: instance, comment: 'login_failed' )