From bad459a9a11bc93e25766800d41de55304b5b0ca Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Fri, 18 May 2012 17:32:06 +0200 Subject: [PATCH] Small improvements. --- .../app/controllers/_application_controller.js.coffee | 9 +++++++++ app/controllers/sessions_controller.rb | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/app/controllers/_application_controller.js.coffee b/app/assets/javascripts/app/controllers/_application_controller.js.coffee index 48c19cd44..19d33c1f1 100644 --- a/app/assets/javascripts/app/controllers/_application_controller.js.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller.js.coffee @@ -398,6 +398,15 @@ class App.Controller extends Spine.Controller # execute callback on content if row.callback object[row.name]['name'] = row.callback(object[row.name]['name']) + + # lookup relation + if !object[row.name]['name'] + rowWithoutId = row.name + '_id' + for attribute in attributes + if rowWithoutId is attribute.name + if attribute.relation && App[attribute.relation] + record = App[attribute.relation].find( object[rowWithoutId] ) + object[row.name]['name'] = record.name # @log 'table', 'header', header, 'overview', data_types, 'objects', objects table = App.view('generic/table')( diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 19d921641..5e2d78039 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -134,11 +134,11 @@ class SessionsController < ApplicationController default_collection['Group'] = Group.all default_collection['Organization'] = Organization.all - # load routes from external files + # load collections to deliver from external files dir = File.expand_path('../', __FILE__) files = Dir.glob( "#{dir}/sessions/collection_*.rb" ) for file in files - require file + load file ExtraCollection.add(default_collection) end