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
|
for valueItem in value
|
||||||
if @_selectedOptionsIsSelectedItem(valueItem, record)
|
if @_selectedOptionsIsSelectedItem(valueItem, record)
|
||||||
return true
|
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)
|
if @_selectedOptionsIsSelectedItem(value, record)
|
||||||
return true
|
return true
|
||||||
false
|
false
|
||||||
|
|
||||||
@_selectedOptionsIsSelectedItem: (value, record) ->
|
@_selectedOptionsIsSelectedItem: (valueOrigin, record) ->
|
||||||
# if name or value is matching
|
# 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 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()
|
if record.value.toString() is value.toString() || record.name.toString() is value.toString()
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -359,7 +359,8 @@ class App.TicketZoom extends App.Controller
|
||||||
@sidebar = new App.TicketZoomSidebar(
|
@sidebar = new App.TicketZoomSidebar(
|
||||||
el: el.find('.tabsSidebar')
|
el: el.find('.tabsSidebar')
|
||||||
sidebarState: @sidebarState
|
sidebarState: @sidebarState
|
||||||
ticket: @ticket
|
object_id: @ticket.id
|
||||||
|
model: 'Ticket'
|
||||||
taskGet: @taskGet
|
taskGet: @taskGet
|
||||||
task_key: @task_key
|
task_key: @task_key
|
||||||
tags: @tags
|
tags: @tags
|
||||||
|
@ -404,7 +405,7 @@ class App.TicketZoom extends App.Controller
|
||||||
|
|
||||||
autosaveStop: =>
|
autosaveStop: =>
|
||||||
@autosaveLast = {}
|
@autosaveLast = {}
|
||||||
@clearInterval('autosave')
|
@el.off('change.local blur.local keyup.local paste.local input.local')
|
||||||
|
|
||||||
autosaveStart: =>
|
autosaveStart: =>
|
||||||
if !@autosaveLast
|
if !@autosaveLast
|
||||||
|
@ -424,7 +425,9 @@ class App.TicketZoom extends App.Controller
|
||||||
@markFormDiff(modelDiff)
|
@markFormDiff(modelDiff)
|
||||||
@taskUpdateAll(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: =>
|
currentStore: =>
|
||||||
return if !@ticket
|
return if !@ticket
|
||||||
|
@ -459,6 +462,16 @@ class App.TicketZoom extends App.Controller
|
||||||
|
|
||||||
formDiff: (currentParams, currentStore) ->
|
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
|
# get diff of model
|
||||||
modelDiff =
|
modelDiff =
|
||||||
ticket: App.Utils.formDiff(currentParams.ticket, currentStore.ticket)
|
ticket: App.Utils.formDiff(currentParams.ticket, currentStore.ticket)
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
class App.TicketZoomSidebar extends App.Controller
|
class App.TicketZoomSidebar extends App.ObserverController
|
||||||
constructor: ->
|
model: 'Ticket'
|
||||||
super
|
observeNot:
|
||||||
ticket = App.Ticket.fullLocal(@ticket.id)
|
created_at: true
|
||||||
@subscribeId = ticket.subscribe(@render)
|
updated_at: true
|
||||||
@render(ticket)
|
|
||||||
|
|
||||||
release: =>
|
|
||||||
App.Ticket.unsubscribe(@subscribeId)
|
|
||||||
|
|
||||||
render: (ticket) =>
|
render: (ticket) =>
|
||||||
|
|
||||||
|
@ -19,11 +15,11 @@ class App.TicketZoomSidebar extends App.Controller
|
||||||
|
|
||||||
defaults = ticket.attributes()
|
defaults = ticket.attributes()
|
||||||
delete defaults.article # ignore article infos
|
delete defaults.article # ignore article infos
|
||||||
task_state = @taskGet('ticket')
|
taskState = @taskGet('ticket')
|
||||||
modelDiff = App.Utils.formDiff(task_state, defaults)
|
modelDiff = App.Utils.formDiff(taskState, defaults)
|
||||||
|
|
||||||
if !_.isEmpty(task_state)
|
if !_.isEmpty(taskState)
|
||||||
defaults = _.extend(defaults, task_state)
|
defaults = _.extend(defaults, taskState)
|
||||||
|
|
||||||
new App.ControllerForm(
|
new App.ControllerForm(
|
||||||
el: el.find('.edit')
|
el: el.find('.edit')
|
||||||
|
@ -36,7 +32,7 @@ class App.TicketZoomSidebar extends App.Controller
|
||||||
params: defaults
|
params: defaults
|
||||||
#bookmarkable: true
|
#bookmarkable: true
|
||||||
)
|
)
|
||||||
#console.log('Ichanges', modelDiff, task_state, ticket.attributes())
|
#console.log('Ichanges', modelDiff, taskState, ticket.attributes(), defaults)
|
||||||
#@markFormDiff( modelDiff )
|
#@markFormDiff( modelDiff )
|
||||||
|
|
||||||
show(ticket)
|
show(ticket)
|
||||||
|
|
Loading…
Reference in a new issue