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
@_selectedOptions( attribute )
# filter attributes
@_filterOption( attribute )
if attribute.tag is 'boolean'
# build options list
@ -459,7 +462,7 @@ class App.ControllerForm extends App.Controller
App.Log.log 'ControllerForm', 'debug', '_getRelationOptionList:filter-function'
all = App[attribute.relation].all()
list = attribute.filter( all )
list = attribute.filter( all, 'collection' )
# data based filter
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
_selectedOptions: (attribute) ->

View file

@ -196,5 +196,6 @@ class Index extends App.Controller
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.timestamp( args )
class _Singleton
class _Singleton extends Spine.Module
@include App.Log
constructor: ->
@locale = 'de'
@ -134,6 +135,8 @@ class _Singleton
# escape
translated = @escape(translated)
@log 'i18n', 'debug', 'translate', string, args, translated
# return translated string
return translated

View file

@ -1,6 +1,6 @@
<form class="form-horizontal">
<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>
</div>
<div class="modal-body" id="object_edit"></div>

View file

@ -1,6 +1,6 @@
<form class="form-horizontal">
<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>
</div>
<div class="modal-body" id="object_new"></div>

View file

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

View file

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

View file

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

View file

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

View file

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