Small improvements.

This commit is contained in:
Martin Edenhofer 2012-11-12 10:34:22 +01:00
parent 076b2e344a
commit 8ad7c46b8a
10 changed files with 78 additions and 35 deletions

View file

@ -155,6 +155,9 @@ class App.ControllerForm extends App.Controller
# finde selected/checked item of list # finde selected/checked item of list
@_selectedOptions( attribute ) @_selectedOptions( attribute )
# filter attributes
@_filterOption( attribute )
if attribute.tag is 'boolean' if attribute.tag is 'boolean'
# build options list # build options list
@ -459,7 +462,7 @@ class App.ControllerForm extends App.Controller
App.Log.log 'ControllerForm', 'debug', '_getRelationOptionList:filter-function' App.Log.log 'ControllerForm', 'debug', '_getRelationOptionList:filter-function'
all = App[attribute.relation].all() all = App[attribute.relation].all()
list = attribute.filter( all ) list = attribute.filter( all, 'collection' )
# data based filter # data based filter
else if attribute.filter[ attribute.name ] else if attribute.filter[ attribute.name ]
@ -511,6 +514,15 @@ class App.ControllerForm extends App.Controller
} }
) )
# execute filter
_filterOption: (attribute) ->
return if !attribute.filter
return if !attribute.options
return if typeof attribute.filter isnt 'function'
App.Log.log 'ControllerForm', 'debug', '_filterOption:filter-function'
attribute.options = attribute.filter( attribute.options, attribute )
# set selected attributes # set selected attributes
_selectedOptions: (attribute) -> _selectedOptions: (attribute) ->

View file

@ -196,5 +196,6 @@ class Index extends App.Controller
App.Config.set( 'customer_ticket_new', Index, 'Routes' ) App.Config.set( 'customer_ticket_new', Index, 'Routes' )
App.Config.set( 'CustomerTicketNew', { prio: 1600, parent: '', name: 'New Ticket', target: '#customer_ticket_new', role: ['Customer'] }, 'NavBar' ) #App.Config.set( 'CustomerTicketNew', { prio: 1600, parent: '', name: 'New Ticket', target: '#customer_ticket_new', role: ['Customer'] }, 'NavBar' )
App.Config.set( 'CustomerTicketNew', { prio: 8000, parent: '', name: 'New', target: '#customer_ticket_new', role: ['Customer'] }, 'NavBarRight' )

View file

@ -21,7 +21,8 @@ class App.i18n
_instance ?= new _Singleton _instance ?= new _Singleton
_instance.timestamp( args ) _instance.timestamp( args )
class _Singleton class _Singleton extends Spine.Module
@include App.Log
constructor: -> constructor: ->
@locale = 'de' @locale = 'de'
@ -134,6 +135,8 @@ class _Singleton
# escape # escape
translated = @escape(translated) translated = @escape(translated)
@log 'i18n', 'debug', 'translate', string, args, translated
# return translated string # return translated string
return translated return translated

View file

@ -1,6 +1,6 @@
<form class="form-horizontal"> <form class="form-horizontal">
<div class="modal-header"> <div class="modal-header">
<a href="#" class="close" title="<%- @T( 'close' ) -%>">&times;</a> <a href="#" class="close" title="<%- @Ti( 'close' ) %>">&times;</a>
<h2><%- @T( 'Edit' ) %>: <%- @T( @head ) %></h2> <h2><%- @T( 'Edit' ) %>: <%- @T( @head ) %></h2>
</div> </div>
<div class="modal-body" id="object_edit"></div> <div class="modal-body" id="object_edit"></div>

View file

@ -1,6 +1,6 @@
<form class="form-horizontal"> <form class="form-horizontal">
<div class="modal-header"> <div class="modal-header">
<a href="#" class="close">&times;</a> <a href="#" class="close" title="<%- @Ti( 'close' ) %>">&times;</a>
<h2><%- @T( 'Neu' ) %>: <%- @T( @head ) %></h2> <h2><%- @T( 'Neu' ) %>: <%- @T( @head ) %></h2>
</div> </div>
<div class="modal-body" id="object_new"></div> <div class="modal-body" id="object_new"></div>

View file

@ -1,14 +1,14 @@
<div class="page-header"> <div class="page-header">
<h1><%- @T( 'Profile' ) %><small></small></h1> <h1><%- @T( 'Profile' ) %><small></small></h1>
</div> </div>
<!--
<ul> <ul>
<li><%- @T( 'Password' ) %></li> <li><%- @T( 'Password' ) %></li>
<li><%- @T( 'Link Accounts' ) %></li> <li><%- @T( 'Link Accounts' ) %></li>
<li><%- @T( 'Notifications' ) %></li> <li><%- @T( 'Notifications' ) %></li>
<li></li> <li></li>
</ul> </ul>
-->
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="span12"> <div class="span12">

View file

@ -163,6 +163,11 @@ class ApplicationController < ActionController::Base
def ticket_permission(ticket) def ticket_permission(ticket)
return true if ticket.permission( :current_user => current_user ) return true if ticket.permission( :current_user => current_user )
response_access_deny
return false
end
def response_access_deny
render( render(
:json => {}, :json => {},
:status => :unauthorized :status => :unauthorized
@ -197,12 +202,15 @@ class ApplicationController < ActionController::Base
# save object # save object
generic_object.save generic_object.save
render :json => generic_object, :status => :created model_create_render_item(generic_object)
rescue Exception => e rescue Exception => e
logger.error e.message logger.error e.message
render :json => { :error => e.message }, :status => :unprocessable_entity render :json => { :error => e.message }, :status => :unprocessable_entity
end end
end end
def model_create_render_item (generic_object)
render :json => generic_object, :status => :created
end
def model_update_render (object, params) def model_update_render (object, params)
begin begin
@ -215,42 +223,54 @@ class ApplicationController < ActionController::Base
# save object # save object
generic_object.update_attributes( object.param_cleanup(params) ) generic_object.update_attributes( object.param_cleanup(params) )
render :json => generic_object, :status => :ok model_update_render_item(generic_object)
rescue Exception => e rescue Exception => e
logger.error e.message logger.error e.message
render :json => { :error => e.message }, :status => :unprocessable_entity render :json => { :error => e.message }, :status => :unprocessable_entity
end end
end end
def model_update_render_item (generic_object)
render :json => generic_object, :status => :ok
end
def model_destory_render (object, params) def model_destory_render (object, params)
begin begin
generic_object = object.find( params[:id] ) generic_object = object.find( params[:id] )
generic_object.destroy generic_object.destroy
render :json => {}, :status => :ok model_destory_render_item()
rescue Exception => e rescue Exception => e
logger.error e.message logger.error e.message
render :json => { :error => e.message }, :status => :unprocessable_entity render :json => { :error => e.message }, :status => :unprocessable_entity
end end
end end
def model_destory_render_item ()
render :json => {}, :status => :ok
end
def model_show_render (object, params) def model_show_render (object, params)
begin begin
generic_object = object.find( params[:id] ) generic_object = object.find( params[:id] )
render :json => generic_object, :status => :ok model_show_render_item(generic_object)
rescue Exception => e rescue Exception => e
logger.error e.message logger.error e.message
render :json => { :error => e.message }, :status => :unprocessable_entity render :json => { :error => e.message }, :status => :unprocessable_entity
end end
end end
def model_show_render_item (generic_object)
render :json => generic_object, :status => :ok
end
def model_index_render (object, params) def model_index_render (object, params)
begin begin
generic_object = object.all generic_object = object.all
render :json => generic_object, :status => :ok model_index_render_result( generic_object )
rescue Exception => e rescue Exception => e
logger.error e.message logger.error e.message
render :json => { :error => e.message }, :status => :unprocessable_entity render :json => { :error => e.message }, :status => :unprocessable_entity
end end
end end
def model_index_render_result (generic_objects)
render :json => generic_objects, :status => :ok
end
end end

View file

@ -4,16 +4,20 @@ module ExtraCollection
# all base stuff # all base stuff
collections['Role'] = Role.all collections['Role'] = Role.all
collections['Group'] = Group.all collections['Group'] = Group.all
collections['Organization'] = Organization.all
if !user.is_role('Customer')
collections['Organization'] = Organization.all
end
end end
def push( collections, user ) def push( collections, user )
# all base stuff # all base stuff
collections['Role'] = Role.all collections['Role'] = Role.all
collections['Group'] = Group.all collections['Group'] = Group.all
collections['Organization'] = Organization.all
if !user.is_role('Customer')
collections['Organization'] = Organization.all
end
end end
module_function :session, :push module_function :session, :push
end end

View file

@ -8,12 +8,14 @@ module ExtraCollection
collections['TicketArticleType'] = Ticket::Article::Type.all collections['TicketArticleType'] = Ticket::Article::Type.all
collections['TicketArticleSender'] = Ticket::Article::Sender.all collections['TicketArticleSender'] = Ticket::Article::Sender.all
# all signatures if !user.is_role('Customer')
collections['Signature'] = Signature.all
# all signatures
# all email addresses collections['Signature'] = Signature.all
collections['EmailAddress'] = EmailAddress.all
# all email addresses
collections['EmailAddress'] = EmailAddress.all
end
end end
def push( collections, user ) def push( collections, user )
@ -24,18 +26,20 @@ module ExtraCollection
collections['TicketArticleType'] = Ticket::Article::Type.all collections['TicketArticleType'] = Ticket::Article::Type.all
collections['TicketArticleSender'] = Ticket::Article::Sender.all collections['TicketArticleSender'] = Ticket::Article::Sender.all
# all signatures if !user.is_role('Customer')
collections['Signature'] = Signature.all
# all email addresses
collections['EmailAddress'] = EmailAddress.all
# all templates
collections['Template'] = Template.all
# all text modules
collections['TextModule'] = TextModule.all
# all signatures
collections['Signature'] = Signature.all
# all email addresses
collections['EmailAddress'] = EmailAddress.all
# all templates
collections['Template'] = Template.all
# all text modules
collections['TextModule'] = TextModule.all
end
end end
module_function :session, :push module_function :session, :push

View file

@ -18,12 +18,11 @@ class SessionsController < ApplicationController
# remember last login date # remember last login date
user.update_last_login() user.update_last_login()
user = User.find_fulldata(user.id)
# auto population of default collections # auto population of default collections
default_collection = SessionHelper::default_collections(user) default_collection = SessionHelper::default_collections(user)
# set session user_id # set session user_id
user = User.find_fulldata(user.id)
session[:user_id] = user['id'] session[:user_id] = user['id']
# check logon session # check logon session
@ -82,7 +81,7 @@ class SessionsController < ApplicationController
user = User.user_data_full( user_id ) user = User.user_data_full( user_id )
# auto population of default collections # auto population of default collections
default_collection = SessionHelper::default_collections(user) default_collection = SessionHelper::default_collections( User.find(user_id) )
# return current session # return current session
render :json => { render :json => {