Moved to event based store of task state. Reduced rerendering of ticket sidebar.
This commit is contained in:
parent
ba611c377e
commit
3f5a3da61a
3 changed files with 32 additions and 20 deletions
|
@ -203,13 +203,16 @@ class App.UiElement.ApplicationUiElement
|
|||
for valueItem in value
|
||||
if @_selectedOptionsIsSelectedItem(valueItem, record)
|
||||
return true
|
||||
if typeof value is 'string' || typeof value is 'number' || typeof value is 'boolean'
|
||||
if value is null || value is undefined || typeof value is 'string' || typeof value is 'number' || typeof value is 'boolean'
|
||||
if @_selectedOptionsIsSelectedItem(value, record)
|
||||
return true
|
||||
false
|
||||
|
||||
@_selectedOptionsIsSelectedItem: (value, record) ->
|
||||
@_selectedOptionsIsSelectedItem: (valueOrigin, record) ->
|
||||
# if name or value is matching
|
||||
value = valueOrigin
|
||||
if value is null || value is undefined
|
||||
value = ''
|
||||
if typeof value is 'string' || typeof value is 'number' || typeof value is 'boolean'
|
||||
if record.value.toString() is value.toString() || record.name.toString() is value.toString()
|
||||
return true
|
||||
|
|
|
@ -359,7 +359,8 @@ class App.TicketZoom extends App.Controller
|
|||
@sidebar = new App.TicketZoomSidebar(
|
||||
el: el.find('.tabsSidebar')
|
||||
sidebarState: @sidebarState
|
||||
ticket: @ticket
|
||||
object_id: @ticket.id
|
||||
model: 'Ticket'
|
||||
taskGet: @taskGet
|
||||
task_key: @task_key
|
||||
tags: @tags
|
||||
|
@ -404,7 +405,7 @@ class App.TicketZoom extends App.Controller
|
|||
|
||||
autosaveStop: =>
|
||||
@autosaveLast = {}
|
||||
@clearInterval('autosave')
|
||||
@el.off('change.local blur.local keyup.local paste.local input.local')
|
||||
|
||||
autosaveStart: =>
|
||||
if !@autosaveLast
|
||||
|
@ -424,7 +425,9 @@ class App.TicketZoom extends App.Controller
|
|||
@markFormDiff(modelDiff)
|
||||
@taskUpdateAll(modelDiff)
|
||||
|
||||
@interval(update, 2800, 'autosave')
|
||||
@el.on('change.local blur.local keyup.local paste.local input.local', 'form, .js-textarea', (e) =>
|
||||
@delay(update, 250, 'ticket-zoom-form-update')
|
||||
)
|
||||
|
||||
currentStore: =>
|
||||
return if !@ticket
|
||||
|
@ -459,6 +462,16 @@ class App.TicketZoom extends App.Controller
|
|||
|
||||
formDiff: (currentParams, currentStore) ->
|
||||
|
||||
# do not compare null or undefined value
|
||||
if currentStore.ticket
|
||||
for key, value of currentStore.ticket
|
||||
if value is null || value is undefined
|
||||
currentStore.ticket[key] = ''
|
||||
if currentParams.ticket
|
||||
for key, value of currentParams.ticket
|
||||
if value is null || value is undefined
|
||||
currentParams.ticket[key] = ''
|
||||
|
||||
# get diff of model
|
||||
modelDiff =
|
||||
ticket: App.Utils.formDiff(currentParams.ticket, currentStore.ticket)
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
class App.TicketZoomSidebar extends App.Controller
|
||||
constructor: ->
|
||||
super
|
||||
ticket = App.Ticket.fullLocal(@ticket.id)
|
||||
@subscribeId = ticket.subscribe(@render)
|
||||
@render(ticket)
|
||||
|
||||
release: =>
|
||||
App.Ticket.unsubscribe(@subscribeId)
|
||||
class App.TicketZoomSidebar extends App.ObserverController
|
||||
model: 'Ticket'
|
||||
observeNot:
|
||||
created_at: true
|
||||
updated_at: true
|
||||
|
||||
render: (ticket) =>
|
||||
|
||||
|
@ -17,13 +13,13 @@ class App.TicketZoomSidebar extends App.Controller
|
|||
show = (ticket) =>
|
||||
el.find('.edit').html('')
|
||||
|
||||
defaults = ticket.attributes()
|
||||
defaults = ticket.attributes()
|
||||
delete defaults.article # ignore article infos
|
||||
task_state = @taskGet('ticket')
|
||||
modelDiff = App.Utils.formDiff(task_state, defaults)
|
||||
taskState = @taskGet('ticket')
|
||||
modelDiff = App.Utils.formDiff(taskState, defaults)
|
||||
|
||||
if !_.isEmpty(task_state)
|
||||
defaults = _.extend(defaults, task_state)
|
||||
if !_.isEmpty(taskState)
|
||||
defaults = _.extend(defaults, taskState)
|
||||
|
||||
new App.ControllerForm(
|
||||
el: el.find('.edit')
|
||||
|
@ -36,7 +32,7 @@ class App.TicketZoomSidebar extends App.Controller
|
|||
params: defaults
|
||||
#bookmarkable: true
|
||||
)
|
||||
#console.log('Ichanges', modelDiff, task_state, ticket.attributes())
|
||||
#console.log('Ichanges', modelDiff, taskState, ticket.attributes(), defaults)
|
||||
#@markFormDiff( modelDiff )
|
||||
|
||||
show(ticket)
|
||||
|
|
Loading…
Reference in a new issue