Просмотр исходного кода

Improved rendering of profile pages. Added touch to customer and organization if ticket has changed.

Martin Edenhofer 10 лет назад
Родитель
Сommit
412f868d42

+ 39 - 19
app/assets/javascripts/app/controllers/organization_profile.js.coffee

@@ -1,7 +1,4 @@
 class App.OrganizationProfile extends App.Controller
-  events:
-    'focusout [contenteditable]': 'update'
-
   constructor: (params) ->
     super
 
@@ -12,11 +9,8 @@ class App.OrganizationProfile extends App.Controller
 
     @navupdate '#'
 
-    # subscribe and reload data / fetch new data if triggered
-    @subscribeId = App.Organization.full( @organization_id, @render, false, true )
-
-  release: =>
-    App.Organization.unsubscribe(@subscribeId)
+    # fetch new data if needed
+    App.Organization.full( @organization_id, @render )
 
   meta: =>
     meta =
@@ -48,6 +42,39 @@ class App.OrganizationProfile extends App.Controller
       @doNotLog = 1
       @recentView( 'Organization', @organization_id )
 
+    @html App.view('organization_profile/index')(
+      organization: organization
+    )
+
+    new Object(
+      el:           @$('.js-object-container')
+      organization: organization
+    )
+
+    new App.TicketStats(
+      el:           @$('.js-ticket-stats')
+      organization: organization
+    )
+
+    new App.UpdateTastbar(
+      genericObject: organization
+    )
+
+class Object extends App.Controller
+  events:
+    'focusout [contenteditable]': 'update'
+
+  constructor: (params) ->
+    super
+
+    # subscribe and reload data / fetch new data if triggered
+    @subscribeId = App.Organization.full( @organization.id, @render, false, true )
+
+  release: =>
+    App.Organization.unsubscribe(@subscribeId)
+
+  render: (organization) =>
+
     # get display data
     organizationData = []
     for attributeName, attributeConfig of App.Organization.attributesGet('view')
@@ -65,7 +92,7 @@ class App.OrganizationProfile extends App.Controller
         if name isnt 'name'
           organizationData.push attributeConfig
 
-    @html App.view('organization_profile')(
+    @html App.view('organization_profile/object')(
       organization:     organization
       organizationData: organizationData
     )
@@ -76,15 +103,6 @@ class App.OrganizationProfile extends App.Controller
       maxlength: 250
     })
 
-    new App.TicketStats(
-      el:           @$('.js-ticket-stats')
-      organization: organization
-    )
-
-    new App.UpdateTastbar(
-      genericObject: organization
-    )
-
     # start action controller
     showHistory = =>
       new App.OrganizationHistory( organization_id: organization.id )
@@ -97,6 +115,7 @@ class App.OrganizationProfile extends App.Controller
           title: 'Organizations'
           object: 'Organization'
           objects: 'Organizations'
+        container: @el.closest('.content')
       )
 
     actions = [
@@ -120,13 +139,14 @@ class App.OrganizationProfile extends App.Controller
   update: (e) =>
     name  = $(e.target).attr('data-name')
     value = $(e.target).html()
-    org   = App.Organization.find( @organization_id )
+    org   = App.Organization.find( @organization.id )
     if org[name] isnt value
       data = {}
       data[name] = value
       org.updateAttributes( data )
       @log 'notice', 'update', name, value, org
 
+
 class Router extends App.ControllerPermanent
   constructor: (params) ->
     super

+ 39 - 16
app/assets/javascripts/app/controllers/user_profile.js.coffee

@@ -1,7 +1,4 @@
 class App.UserProfile extends App.Controller
-  events:
-    'focusout [contenteditable]': 'update'
-
   constructor: (params) ->
     super
 
@@ -12,8 +9,8 @@ class App.UserProfile extends App.Controller
 
     @navupdate '#'
 
-    # subscribe and reload data / fetch new data if triggered
-    @subscribeId = App.User.full( @user_id, @render, false, true )
+    # fetch new data if needed
+    @subscribeId = App.User.full( @user_id, @render )
 
   release: =>
     App.User.unsubscribe(@subscribeId)
@@ -47,6 +44,40 @@ class App.UserProfile extends App.Controller
       @doNotLog = 1
       @recentView( 'User', @user_id )
 
+    @html App.view('user_profile/index')(
+      user: user
+    )
+
+    new Object(
+      el:   @$('.js-object-container')
+      user: user
+    )
+
+    new App.TicketStats(
+      el:   @$('.js-ticket-stats')
+      user: user
+    )
+
+    new App.UpdateTastbar(
+      genericObject: user
+    )
+
+
+class Object extends App.Controller
+  events:
+    'focusout [contenteditable]': 'update'
+
+  constructor: (params) ->
+    super
+
+    # subscribe and reload data / fetch new data if triggered
+    @subscribeId = App.User.full( @user.id, @render, false, true )
+
+  release: =>
+    App.User.unsubscribe(@subscribeId)
+
+  render: (user) =>
+
     # get display data
     userData = []
     for attributeName, attributeConfig of App.User.attributesGet('view')
@@ -64,7 +95,7 @@ class App.UserProfile extends App.Controller
         if name isnt 'firstname' && name isnt 'lastname' && name isnt 'organization'
           userData.push attributeConfig
 
-    @html App.view('user_profile')(
+    @html App.view('user_profile/object')(
       user:     user
       userData: userData
     )
@@ -75,15 +106,6 @@ class App.UserProfile extends App.Controller
       maxlength: 250
     })
 
-    new App.TicketStats(
-      el:   @$('.js-ticket-stats')
-      user: user
-    )
-
-    new App.UpdateTastbar(
-      genericObject: user
-    )
-
     # start action controller
     showHistory = =>
       new App.UserHistory( user_id: user.id )
@@ -97,6 +119,7 @@ class App.UserProfile extends App.Controller
           title: 'Users'
           object: 'User'
           objects: 'Users'
+        container: @el.closest('.content')
       )
 
     actions = [
@@ -120,7 +143,7 @@ class App.UserProfile extends App.Controller
   update: (e) =>
     name  = $(e.target).attr('data-name')
     value = $(e.target).html()
-    user  = App.User.find( @user_id )
+    user  = App.User.find( @user.id )
     if user[name] isnt value
       data = {}
       data[name] = value

+ 0 - 50
app/assets/javascripts/app/views/organization_profile.jst.eco

@@ -1,50 +0,0 @@
-<div class="flex profile">
-
-  <div class="profile-window">
-    <div class="profile-section vertical centered">
-      <div class="align-right profile-action js-action"></div>
-      <div class="profile-organizationIcon">
-        <div class="organization icon"></div>
-      </div>
-      <h1><%= @organization.displayName() %></h1>
-    </div>
-    <div class="profile-section">
-      <div class="profile-details horizontal wrap">
-        <% for row in @organizationData: %>
-          <% if @organization[row.name]: %>
-            <% if row.tag is 'richtext': %>
-              <div class="profile-detailsEntry" style="width: 100%;">
-                <label><%- @Ti( row.display ) %></label>
-                <div contenteditable="true" data-name="<%= row.name %>" data-type="update" data-placeholder="<%- @T('Add a Note') %>"><%- @organization[row.name] %></div>
-              </div>
-            <% else: %>
-              <div class="profile-detailsEntry">
-                <label><%- @Ti( row.display ) %></label>
-                <%- @L( @P( @organization[row.name] ) ) %>
-              </div>
-            <% end %>
-          <% end %>
-        <% end %>
-      </div>
-    </div>
-
-    <% if @organization.members: %>
-    <div class="profile-section profile-memberSection">
-      <label><%- @T('Members') %></label>
-      <div class="profile-details horizontal wrap">
-
-        <% for user in @organization.members: %>
-          <div class="profile-organizationMember">
-            <%- user.avatar("40") %>
-            <a href="<%- user.uiUrl() %>" class="user-popover" data-id="<%- user.id %>"><%= user.displayName() %></a>
-          </div>
-        <% end %>
-
-      </div>
-    </div>
-    <% end %>
-
-    <div class="profile-section js-ticket-stats"></div>
-
-  </div>
-</div>

+ 6 - 0
app/assets/javascripts/app/views/organization_profile/index.jst.eco

@@ -0,0 +1,6 @@
+<div class="flex profile">
+  <div class="profile-window">
+    <div class="js-object-container"></div>
+    <div class="profile-section js-ticket-stats"></div>
+  </div>
+</div>

+ 39 - 0
app/assets/javascripts/app/views/organization_profile/object.jst.eco

@@ -0,0 +1,39 @@
+<div class="profile-section vertical centered">
+  <div class="align-right profile-action js-action"></div>
+  <div class="profile-organizationIcon">
+    <div class="organization icon"></div>
+  </div>
+  <h1><%= @organization.displayName() %></h1>
+</div>
+<div class="profile-section">
+  <div class="profile-details horizontal wrap">
+    <% for row in @organizationData: %>
+      <% if row.tag is 'richtext': %>
+        <div class="profile-detailsEntry" style="width: 100%;">
+          <label><%- @Ti( row.display ) %></label>
+          <div contenteditable="true" data-name="<%= row.name %>" data-type="update" data-placeholder="<%- @T('Add a Note') %>"><%- @organization[row.name] %></div>
+        </div>
+      <% else: %>
+        <% if @organization[row.name]: %>
+          <div class="profile-detailsEntry">
+            <label><%- @Ti( row.display ) %></label>
+            <%- @L( @P( @organization[row.name] ) ) %>
+          </div>
+        <% end %>
+      <% end %>
+    <% end %>
+  </div>
+</div>
+<% if @organization.members: %>
+<div class="profile-section profile-memberSection">
+  <label><%- @T('Members') %></label>
+  <div class="profile-details horizontal wrap">
+    <% for user in @organization.members: %>
+      <div class="profile-organizationMember">
+        <%- user.avatar("40") %>
+        <a href="<%- user.uiUrl() %>" class="user-popover" data-id="<%- user.id %>"><%= user.displayName() %></a>
+      </div>
+    <% end %>
+  </div>
+</div>
+<% end %>

+ 0 - 37
app/assets/javascripts/app/views/user_profile.jst.eco

@@ -1,37 +0,0 @@
-<div class="flex profile">
-
-  <div class="profile-window">
-    <div class="profile-section vertical centered">
-      <div class="align-right profile-action js-action"></div>
-      <%- @user.avatar("80") %>
-      <h1><%= @user.displayName() %></h1>
-      <% if @user.organization: %>
-        <div class="profile-organization"><a href="<%- @user.organization.uiUrl() %>"><%= @user.organization.displayName() %></a></div>
-      <% end %>
-    </div>
-
-    <div class="profile-section">
-      <div class="profile-details horizontal wrap">
-        <% for row in @userData: %>
-          <% if @user[row.name]: %>
-            <% if row.tag is 'richtext': %>
-              <div class="profile-detailsEntry" style="width: 100%;">
-                <label><%- @Ti( row.display ) %></label>
-                <div contenteditable="true" data-name="<%= row.name %>" data-type="update" data-placeholder="<%- @T('Add a Note') %>"><%- @user[row.name] %></div>
-              </div>
-            <% else: %>
-              <div class="profile-detailsEntry">
-                <label><%- @Ti( row.display ) %></label>
-                <%- @L( @P( @user[row.name] ) ) %>
-              </div>
-            <% end %>
-          <% end %>
-        <% end %>
-      </div>
-    </div>
-
-    <div class="profile-section js-ticket-stats"></div>
-
-  </div>
-
-</div>

+ 6 - 0
app/assets/javascripts/app/views/user_profile/index.jst.eco

@@ -0,0 +1,6 @@
+<div class="flex profile">
+  <div class="profile-window">
+    <div class="js-object-container"></div>
+    <div class="profile-section js-ticket-stats"></div>
+  </div>
+</div>

+ 27 - 0
app/assets/javascripts/app/views/user_profile/object.jst.eco

@@ -0,0 +1,27 @@
+<div class="profile-section vertical centered">
+  <div class="align-right profile-action js-action"></div>
+  <%- @user.avatar("80") %>
+  <h1><%= @user.displayName() %></h1>
+  <% if @user.organization: %>
+    <div class="profile-organization"><a href="<%- @user.organization.uiUrl() %>"><%= @user.organization.displayName() %></a></div>
+  <% end %>
+</div>
+<div class="profile-section">
+  <div class="profile-details horizontal wrap">
+    <% for row in @userData: %>
+      <% if @user[row.name]: %>
+        <% if row.tag is 'richtext': %>
+          <div class="profile-detailsEntry" style="width: 100%;">
+            <label><%- @Ti( row.display ) %></label>
+            <div contenteditable="true" data-name="<%= row.name %>" data-type="update" data-placeholder="<%- @T('Add a Note') %>"><%- @user[row.name] %></div>
+          </div>
+        <% else: %>
+          <div class="profile-detailsEntry">
+            <label><%- @Ti( row.display ) %></label>
+            <%- @L( @P( @user[row.name] ) ) %>
+          </div>
+        <% end %>
+      <% end %>
+    <% end %>
+  </div>
+</div>

+ 30 - 0
app/models/observer/ticket/ref_object_touch.rb

@@ -0,0 +1,30 @@
+# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
+
+class Observer::Ticket::RefObjectTouch < ActiveRecord::Observer
+  observe 'ticket'
+
+  def after_create(record)
+    ref_object_touch(record)
+  end
+  def after_update(record)
+    ref_object_touch(record)
+  end
+  def after_touch(record)
+    ref_object_touch(record)
+  end
+  def after_destroy(record)
+    ref_object_touch(record)
+  end
+
+  def ref_object_touch(record)
+
+    # return if we run import mode
+    return if Setting.get('import_mode')
+    if record.customer
+      record.customer.touch
+    end
+    if record.organization
+      record.organization.touch
+    end
+  end
+end

+ 1 - 0
config/application.rb

@@ -40,6 +40,7 @@ module Zammad
       'observer::_ticket::_notification',
       'observer::_ticket::_reset_new_state',
       'observer::_ticket::_escalation_calculation',
+      'observer::_ticket::_ref_object_touch',
       'observer::_tag::_ticket_history',
       'observer::_user::_geo'
 

Некоторые файлы не были показаны из-за большого количества измененных файлов