Init version of organization zoom.

This commit is contained in:
Martin Edenhofer 2014-07-22 11:00:29 +02:00
parent d3eb5873ac
commit a937196a49
9 changed files with 167 additions and 14 deletions

View file

@ -0,0 +1,20 @@
class App.OrganizationHistory extends App.GenericHistory
constructor: ->
super
@fetch()
fetch: ->
# get data
@ajax(
id: 'organization_history',
type: 'GET',
url: @apiPath + '/organizations/history/' + @organization_id,
success: (data, status, xhr) =>
# load assets
App.Collection.loadAssets( data.assets )
# render page
@render(data.history)
)

View file

@ -0,0 +1,98 @@
class App.OrganizationZoom extends App.Controller
constructor: (params) ->
super
# check authentication
return if !@authenticate()
@navupdate '#'
start = (organization) =>
@organization = organization
@render()
App.Organization.retrieve( @organization_id, start, true )
meta: =>
meta =
url: @url()
id: @organization_id
if @organization
meta.head = @organization.displayName()
meta.title = @organization.displayName()
meta
url: =>
'#organization/zoom/' + @organization_id
activate: =>
@navupdate '#'
changed: =>
formCurrent = @formParam( @el.find('.ticket-update') )
diff = difference( @formDefault, formCurrent )
return false if !diff || _.isEmpty( diff )
return true
release: =>
# nothing
render: =>
# update taskbar with new meta data
App.Event.trigger 'task:render'
@html App.view('organization_zoom')(
organization: @organization
)
# start action controller
new ActionRow(
el: @el.find('.action')
organization: @organization
ui: @
)
new Widgets(
el: @el.find('.widgets')
organization: @organization
ui: @
)
class Widgets extends App.Controller
constructor: ->
super
@render()
render: ->
new App.WidgetOrganization(
el: @el
organization_id: @organization.id
)
class ActionRow extends App.Controller
events:
'click [data-type=history]': 'history_dialog'
constructor: ->
super
@render()
render: ->
@html App.view('user_zoom/actions')()
history_dialog: (e) ->
e.preventDefault()
new App.OrganizationHistory( organization_id: @organization.id )
class Router extends App.ControllerPermanent
constructor: (params) ->
super
# cleanup params
clean_params =
organization_id: params.organization_id
App.TaskManager.add( 'Organization-' + @organization_id, 'OrganizationZoom', clean_params )
App.Config.set( 'organization/zoom/:organization_id', Router, 'Routes' )

View file

@ -66,10 +66,8 @@ class Widgets extends App.Controller
render: ->
@html App.view('user_zoom/widgets')()
new App.WidgetUser(
el: @el.find('.user_info')
el: @el
user_id: @user.id
)

View file

@ -0,0 +1,18 @@
<div class="content-two">
<div class="sidebar">
<div class="widgets"></div>
<div class="action"></div>
</div>
<div class="main">
<div class="page-header">
<h1><%= @organization.displayName() %></h1>
</div>
<div class="ticket-answer">
<div class="article-view"></div>
<div class="edit"></div>
</div>
</div>
</div>

View file

@ -5,10 +5,8 @@
</div>
<div class="main">
<div class="page-header user-zoom clearfix">
<div class="page-header-title">
<div class="ticket-title"></div>
</div>
<div class="page-header">
<h1><%= @user.displayName() %></h1>
</div>
<div class="ticket-answer">
@ -17,5 +15,4 @@
</div>
</div>
</div>
</div>

View file

@ -168,4 +168,24 @@ Test:
return if deny_if_not_role('Agent')
model_destory_render(Organization, params)
end
end
# GET /api/v1/organizations/history/1
def history
# permissin check
if !is_role('Admin') && !is_role('Agent')
response_access_deny
return
end
# get organization data
organization = Organization.find( params[:id] )
# get history of organization
history = organization.history_get(true)
# return result
render :json => history
end
end

View file

@ -1,6 +1,7 @@
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
class History < ApplicationModel
require 'history/assets'
include History::Assets
self.table_name = 'histories'

View file

@ -4,13 +4,13 @@ class Ticket < ApplicationModel
include Ticket::Escalation
include Ticket::Subject
include Ticket::Permission
load 'ticket/assets.rb'
require 'ticket/assets'
include Ticket::Assets
load 'ticket/history_log.rb'
require 'ticket/history_log'
include Ticket::HistoryLog
load 'ticket/activity_stream_log.rb'
require 'ticket/activity_stream_log'
include Ticket::ActivityStreamLog
load 'ticket/search_index.rb'
require 'ticket/search_index'
include Ticket::SearchIndex
extend Ticket::Search

View file

@ -6,5 +6,6 @@ Zammad::Application.routes.draw do
match api_path + '/organizations/:id', :to => 'organizations#show', :via => :get
match api_path + '/organizations', :to => 'organizations#create', :via => :post
match api_path + '/organizations/:id', :to => 'organizations#update', :via => :put
match api_path + '/organizations/history/:id',:to => 'organizations#history',:via => :get
end