Browse Source

Improved loading content performance (reduced count of http requests).

Martin Edenhofer 10 years ago
parent
commit
12fc2adc3e

+ 10 - 1
app/assets/javascripts/app/controllers/ticket_zoom.js.coffee

@@ -110,6 +110,12 @@ class App.TicketZoom extends App.Controller
     # remember article ids
     @ticket_article_ids = data.ticket_article_ids
 
+    # remember link
+    @links = data.links
+
+    # remember tags
+    @tags = data.tags
+
     # get edit form attributes
     @form_meta = data.form_meta
 
@@ -263,7 +269,8 @@ class TicketInfo extends App.ControllerDrox
       new App.WidgetTag(
         el:           @el.find('.tag_info')
         object_type:  'Ticket'
-        object:        ticket
+        object:       ticket
+        tags:         @tags
       )
 
   release: =>
@@ -283,6 +290,7 @@ class Widgets extends App.Controller
     new TicketInfo(
       ticket:  ticket
       el:      @el.find('.ticket_info')
+      tags:    @ui.tags
     )
 
     # start customer info controller
@@ -299,6 +307,7 @@ class Widgets extends App.Controller
         el:           @el.find('.link_info')
         object_type:  'Ticket'
         object:       ticket
+        links:        @ui.links
       )
 
     # show frontend times

+ 6 - 1
app/assets/javascripts/app/controllers/widget/link.js.coffee

@@ -6,7 +6,12 @@ class App.WidgetLink extends App.ControllerDrox
 
   constructor: ->
     super
-    @fetch()
+
+    # if links are given, do not init fetch
+    if @links
+      @render()
+    else
+      @fetch()
 
   fetch: =>
     # fetch item on demand

+ 5 - 0
app/assets/javascripts/app/controllers/widget/tag.js.coffee

@@ -3,6 +3,11 @@ class App.WidgetTag extends App.Controller
     super
 
     @attribute_id = 'tags_' + @object.id + '_' + @object_type
+
+    if @tags
+      @render(@tags)
+      return
+
     tags = App.Store.get( "tags::#{@attribute_id}" )
     if tags
       @render( tags )

+ 5 - 1
app/assets/javascripts/app/models/_application_model.js.coffee

@@ -162,6 +162,7 @@ class App.Model extends Spine.Model
               attribute[item] = value
             attributesNew[ attribute.name ] = attribute
 
+    # if no screen is given or no attribute has this screen - use default attributes
     if !screen || _.isEmpty( attributesNew )
       console.log(attributesNew)
       for attribute in attributes
@@ -327,8 +328,11 @@ class App.Model extends Spine.Model
     # fetch init collection
     if param.initFetch is true
       @one 'refresh', (collection) =>
+        @initFetchActive = false
         callback(collection)
-      @fetch( {}, { clear: true } )
+      if !@initFetchActive
+        @initFetchActive = true
+        @fetch( {}, { clear: true } )
 
     # return key
     key

+ 22 - 0
app/controllers/tickets_controller.rb

@@ -279,12 +279,34 @@ class TicketsController < ApplicationController
       assets = article.assets(assets)
     }
 
+    # get links
+    links = Link.list(
+      :link_object       => 'Ticket',
+      :link_object_value => ticket.id,
+    )
+    link_list = []
+    links.each { |item|
+      link_list.push item
+      if item['link_object'] == 'Ticket'
+        ticket = Ticket.lookup( :id => item['link_object_value'] )
+        assets = ticket.assets(assets)
+      end
+    }
+
+    # get tags
+    tags = Tag.tag_list(
+      :object => 'Ticket',
+      :o_id   => ticket.id,
+    )
+
     # return result
     render :json => {
       :ticket_id          => ticket.id,
       :ticket_article_ids => article_ids,
       :signature          => signature,
       :assets             => assets,
+      :links              => link_list,
+      :tags               => tags,
       :form_meta          => attributes_to_change,
       :edit_form          => attributes_to_change,
     }