From 8a76d83a3ef73b3f32a8627fecc5daf55dcb1d13 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 16 Oct 2012 11:46:22 +0200 Subject: [PATCH] Moved to reworked template processing. Added organization to user model. --- .../_application_controller.js.coffee | 52 +++++++++++-------- .../_application_controller_form.js.coffee | 2 +- .../_application_controller_generic.js.coffee | 36 ++++++++----- .../app/controllers/_channel/email.js.coffee | 8 +-- .../controllers/agent_ticket_create.js.coffee | 23 ++++---- .../controllers/agent_ticket_merge.js.coffee | 4 +- .../controllers/agent_ticket_zoom.js.coffee | 2 +- .../app/controllers/login.js.coffee | 4 +- .../app/controllers/user_info.js.coffee | 20 +++++-- app/assets/javascripts/app/index.js.coffee | 30 ++++++++++- .../javascripts/app/lib/collection.js.coffee | 24 ++++----- app/assets/javascripts/app/lib/i18n.js.coffee | 50 +++++++++++------- .../app/lib/interface_handle.js.coffee | 2 +- .../app/models/application_model.js.coffee | 9 +++- .../javascripts/app/models/user.js.coffee | 5 +- .../app/views/agent_ticket_create.jst.eco | 4 +- .../app/views/agent_ticket_customer.jst.eco | 4 +- .../app/views/agent_ticket_history.jst.eco | 12 ++--- .../app/views/agent_ticket_merge.jst.eco | 6 +-- .../app/views/agent_ticket_view.jst.eco | 2 +- .../views/agent_ticket_view/detail.jst.eco | 2 +- .../app/views/agent_ticket_zoom.jst.eco | 24 ++++----- .../app/views/agent_user_create.jst.eco | 6 +-- .../app/views/channel/email_outbound.jst.eco | 2 +- .../javascripts/app/views/dashboard.jst.eco | 2 +- .../views/dashboard/activity_stream.jst.eco | 6 +-- .../app/views/dashboard/recent_viewed.jst.eco | 2 +- .../app/views/dashboard/rss.jst.eco | 2 +- .../app/views/dashboard/ticket.jst.eco | 2 +- .../views/dashboard/ticket_settings.jst.eco | 6 +-- .../javascripts/app/views/error.jst.eco | 6 +-- .../app/views/generic/admin/edit.jst.eco | 6 +-- .../app/views/generic/admin/index.jst.eco | 8 +-- .../app/views/generic/admin/new.jst.eco | 6 +-- .../views/generic/admin_level2/index.jst.eco | 4 +- .../app/views/generic/attribute.jst.eco | 6 +-- .../app/views/generic/hero_message.jst.eco | 2 +- .../app/views/generic/table.jst.eco | 18 ++----- .../app/views/generic/tabs.jst.eco | 2 +- .../app/views/getting_started.jst.eco | 27 +++++----- .../javascripts/app/views/link/add.jst.eco | 18 +++---- .../javascripts/app/views/link/info.jst.eco | 8 +-- .../javascripts/app/views/login.jst.eco | 41 +++++++-------- .../javascripts/app/views/navigation.jst.eco | 20 +++---- .../javascripts/app/views/profile.jst.eco | 8 +-- .../app/views/reset_password.jst.eco | 6 +-- .../app/views/reset_password_change.jst.eco | 4 +- .../app/views/settings/item.jst.eco | 6 +-- .../javascripts/app/views/signup.jst.eco | 6 +-- .../javascripts/app/views/template.jst.eco | 12 ++--- .../app/views/ticket_action.jst.eco | 8 +-- .../javascripts/app/views/user_info.jst.eco | 26 +++++----- .../app/views/user_info_small.jst.eco | 24 ++++----- app/controllers/users_controller.rb | 7 +-- db/migrate/20120101000001_create_base.rb | 2 + 55 files changed, 353 insertions(+), 281 deletions(-) diff --git a/app/assets/javascripts/app/controllers/_application_controller.js.coffee b/app/assets/javascripts/app/controllers/_application_controller.js.coffee index 9e73b3370..10ef6675e 100644 --- a/app/assets/javascripts/app/controllers/_application_controller.js.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller.js.coffee @@ -2,8 +2,8 @@ class App.Controller extends Spine.Controller # add @title methode to set title title: (name) -> -# $('html head title').html( Config.product_name + ' - ' + Ti(name) ) - document.title = Config.product_name + ' - ' + Ti(name) +# $('html head title').html( Config.product_name + ' - ' + App.i18n.translateInline(name) ) + document.title = Config.product_name + ' - ' + App.i18n.translateInline(name) # add @notify methode to create notification notify: (data) -> @@ -217,32 +217,32 @@ class App.Controller extends Spine.Controller if diff >= 86400 unit = Math.round( ( diff / 86400 ) ) # if unit > 1 -# return unit + ' ' + T('days') +# return unit + ' ' + App.i18n.translateContent('days') # else -# return unit + ' ' + T('day') - string = unit + ' ' + T('d') +# return unit + ' ' + App.i18n.translateContent('day') + string = unit + ' ' + App.i18n.translateInline('d') if diff >= 3600 unit = Math.round( ( diff / 3600 ) % 24 ) # if unit > 1 -# return unit + ' ' + T('hours') +# return unit + ' ' + App.i18n.translateContent('hours') # else -# return unit + ' ' + T('hour') +# return unit + ' ' + App.i18n.translateContent('hour') if string isnt '' - string = string + ' ' + unit + ' ' + T('h') + string = string + ' ' + unit + ' ' + App.i18n.translateInline('h') return string else - string = unit + ' ' + T('h') + string = unit + ' ' + App.i18n.translateInline('h') if diff <= 86400 unit = Math.round( ( diff / 60 ) % 60 ) # if unit > 1 -# return unit + ' ' + T('minutes') +# return unit + ' ' + App.i18n.translateContent('minutes') # else -# return unit + ' ' + T('minute') +# return unit + ' ' + App.i18n.translateContent('minute') if string isnt '' - string = string + ' ' + unit + ' ' + T('m') + string = string + ' ' + unit + ' ' + App.i18n.translateInline('m') return string else - string = unit + ' ' + T('m') + string = unit + ' ' + App.i18n.translateInline('m') return string userInfo: (data) => @@ -254,7 +254,7 @@ class App.Controller extends Spine.Controller authenticate: -> console.log 'authenticate', window.Session - + # return rtue if session exists return true if window.Session['id'] @@ -275,7 +275,7 @@ class App.Controller extends Spine.Controller # console.log('rewrite frontendTimeUpdate', this) timestamp = $(this).data('time') time = ui.humanTime( timestamp ) - $(this).attr( 'title', Ts(timestamp) ) + $(this).attr( 'title', App.i18n.translateTimestamp(timestamp) ) $(this).text( time ) ) @interval( update, 30000, 'frontendTimeUpdate' ) @@ -318,19 +318,29 @@ class App.Controller extends Spine.Controller title: -> user_id = $(@).data('id') user = App.Collection.find( 'User', user_id ) - user.realname + user.displayName() content: -> user_id = $(@).data('id') user = App.Collection.find( 'User', user_id ) # get display data data = [] - for item in App.User.configure_attributes + for item2 in App.User.configure_attributes + item = _.clone( item2 ) + + # check if value for _id exists + itemNameValue = item.name + itemNameValueNew = itemNameValue.substr( 0, itemNameValue.length - 3 ) + if itemNameValueNew of user + item.name = itemNameValueNew + + # add to show if value exists if user[item.name] - if item.name isnt 'firstname' - if item.name isnt 'lastname' - if item.info #&& ( @user[item.name] || item.name isnt 'note' ) - data.push item + + # do not show firstname and lastname / already show via diplayName() + if item.name isnt 'firstname' && item.name isnt 'lastname' + if item.info #&& ( @user[item.name] || item.name isnt 'note' ) + data.push item # insert data App.view('user_info_small')( diff --git a/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee b/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee index 92d4ec952..fe9bec22e 100644 --- a/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee @@ -472,7 +472,7 @@ class App.ControllerForm extends App.Controller if item.displayName name_new = item.displayName() if attribute.translate - name_new = Ti(name_new) + name_new = App.i18n.translateInline(name_new) attribute.options.push { name: name_new, value: item.id, diff --git a/app/assets/javascripts/app/controllers/_application_controller_generic.js.coffee b/app/assets/javascripts/app/controllers/_application_controller_generic.js.coffee index 834f1769a..9704a8522 100644 --- a/app/assets/javascripts/app/controllers/_application_controller_generic.js.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller_generic.js.coffee @@ -42,14 +42,20 @@ class App.ControllerGenericNew extends App.ControllerModal @formDisable(e) # save object + ui = @ object.save( - success: => - if @callback - @callback(@item) - @modalHide() + success: -> + + # force to reload object + callbackReload = (user) -> + if ui.callback + ui.callback( user ) + ui.modalHide() + App.Collection.find( ui.pageData.object, @id, callbackReload , true ) + error: => - @log 'errors' - @modalHide() + ui.log 'errors' + ui.modalHide() ) class App.ControllerGenericEdit extends App.ControllerModal @@ -98,14 +104,20 @@ class App.ControllerGenericEdit extends App.ControllerModal @formDisable(e) # save object + ui = @ @item.save( - success: => - if @callback - @callback(@item) - @modalHide() + success: -> + + # force to reload object + callbackReload = (user) -> + if ui.callback + ui.callback( user ) + ui.modalHide() + App.Collection.find( ui.pageData.object, @id, callbackReload , true ) + error: => - @log 'errors' - @modalHide() + ui.log 'errors' + ui.modalHide() ) class App.ControllerGenericIndex extends App.Controller diff --git a/app/assets/javascripts/app/controllers/_channel/email.js.coffee b/app/assets/javascripts/app/controllers/_channel/email.js.coffee index c8c3cedb1..bc6f99a03 100644 --- a/app/assets/javascripts/app/controllers/_channel/email.js.coffee +++ b/app/assets/javascripts/app/controllers/_channel/email.js.coffee @@ -67,7 +67,7 @@ class App.ChannelEmailFilter extends App.Controller ) html.append( table ) - html.append( '' + T('New') + '' ) + html.append( '' + App.i18n.translateContent('New') + '' ) @html html new: (e) => @@ -160,7 +160,7 @@ class App.ChannelEmailAddress extends App.Controller ) html.append( table ) - html.append( '' + T('New') + '' ) + html.append( '' + App.i18n.translateContent('New') + '' ) @html html new: (e) => @@ -251,7 +251,7 @@ class App.ChannelEmailSignature extends App.Controller ) html.append( table ) - html.append( '' + T('New') + '' ) + html.append( '' + App.i18n.translateContent('New') + '' ) @html html new: (e) => @@ -351,7 +351,7 @@ class App.ChannelEmailInbound extends App.Controller ) html.append( table ) - html.append( '' + T('New') + '' ) + html.append( '' + App.i18n.translateContent('New') + '' ) @html html new: (e) => diff --git a/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee b/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee index ed3c4af2b..aa1ffded2 100644 --- a/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee +++ b/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee @@ -202,8 +202,8 @@ class Index extends App.Controller # notify UI ui.notify type: 'success', - msg: T('Ticket %s created!', @.number), - link: "#ticket/zoom/#{@.id}" + msg: App.i18n.translateContent( 'Ticket %s created!', @number ), + link: "#ticket/zoom/#{@id}" timeout: 12000, # create new create screen @@ -263,13 +263,18 @@ class UserNew extends App.ControllerModal ui = @ user.save( success: -> - realname = @displayName() - $('#create_customer_id').val( @id ) - $('#create_customer_id_autocompletion').val( realname ) - - # start customer info controller - ui.userInfo( user_id: @id ) - ui.modalHide() + + # force to reload object + callbackReload = (user) -> + realname = user.displayName() + $('#create_customer_id').val( user.id ) + $('#create_customer_id_autocompletion').val( realname ) + + # start customer info controller + ui.userInfo( user_id: user.id ) + ui.modalHide() + App.Collection.find( 'User', @id, callbackReload , true ) + error: -> ui.modalHide() ) diff --git a/app/assets/javascripts/app/controllers/agent_ticket_merge.js.coffee b/app/assets/javascripts/app/controllers/agent_ticket_merge.js.coffee index bb469524a..e9560b257 100644 --- a/app/assets/javascripts/app/controllers/agent_ticket_merge.js.coffee +++ b/app/assets/javascripts/app/controllers/agent_ticket_merge.js.coffee @@ -39,7 +39,7 @@ class App.TicketMerge extends App.ControllerModal # notify UI @notify type: 'success', - msg: T( 'Ticket %s merged!', data.slave_ticket['number'] ), + msg: App.i18n.translateContent( 'Ticket %s merged!', data.slave_ticket['number'] ), timeout: 6000, else @@ -47,7 +47,7 @@ class App.TicketMerge extends App.ControllerModal # notify UI @notify type: 'error', - msg: T( data['message'] ), + msg: App.i18n.translateContent( data['message'] ), timeout: 6000, # error: => ) diff --git a/app/assets/javascripts/app/controllers/agent_ticket_zoom.js.coffee b/app/assets/javascripts/app/controllers/agent_ticket_zoom.js.coffee index 85a19bc48..93225f28e 100644 --- a/app/assets/javascripts/app/controllers/agent_ticket_zoom.js.coffee +++ b/app/assets/javascripts/app/controllers/agent_ticket_zoom.js.coffee @@ -423,7 +423,7 @@ class Article extends App.Controller article_lines.splice( preview + 1, 0, '----SEEMORE----' ) @article['html'] = article_lines.join("\n") @article['html'] = window.linkify( @article['html'] ) - notify = '' + T('See more') + '' + notify = '' + App.i18n.translateContent('See more') + '' # preview mode if preview_mode diff --git a/app/assets/javascripts/app/controllers/login.js.coffee b/app/assets/javascripts/app/controllers/login.js.coffee index 2a20aa0e4..4344e4be7 100644 --- a/app/assets/javascripts/app/controllers/login.js.coffee +++ b/app/assets/javascripts/app/controllers/login.js.coffee @@ -98,7 +98,7 @@ class Index extends App.Controller Spine.trigger 'notify:removeall' Spine.trigger 'notify', { type: 'success', - msg: T('Login successfully! Have a nice day!'), + msg: App.i18n.translateContent('Login successfully! Have a nice day!'), } # redirect to # @@ -117,7 +117,7 @@ class Index extends App.Controller Spine.trigger 'notify:removeall' Spine.trigger 'notify', { type: 'error', - msg: T('Wrong Username and Password combination.'), + msg: App.i18n.translateContent('Wrong Username and Password combination.'), } # rerender login page diff --git a/app/assets/javascripts/app/controllers/user_info.js.coffee b/app/assets/javascripts/app/controllers/user_info.js.coffee index 14b4fc047..6504223af 100644 --- a/app/assets/javascripts/app/controllers/user_info.js.coffee +++ b/app/assets/javascripts/app/controllers/user_info.js.coffee @@ -13,10 +13,22 @@ class App.UserInfo extends App.Controller # get display data data = [] - for item in App.User.configure_attributes - if item.name isnt 'firstname' && item.name isnt 'lastname' - if item.info - data.push item + for item2 in App.User.configure_attributes + item = _.clone( item2 ) + + # check if value for _id exists + itemNameValue = item.name + itemNameValueNew = itemNameValue.substr( 0, itemNameValue.length - 3 ) + if itemNameValueNew of user + item.name = itemNameValueNew + + # add to show if value exists + if user[item.name] + + # do not show firstname and lastname / already show via diplayName() + if item.name isnt 'firstname' && item.name isnt 'lastname' + if item.info + data.push item # insert data @html App.view('user_info')( diff --git a/app/assets/javascripts/app/index.js.coffee b/app/assets/javascripts/app/index.js.coffee index 552669b61..52e10e1d9 100644 --- a/app/assets/javascripts/app/index.js.coffee +++ b/app/assets/javascripts/app/index.js.coffee @@ -36,6 +36,34 @@ class App extends Spine.Controller @view: (name) -> - JST["app/views/#{name}"] + template = ( params = {} ) => + + # define print name helper + params.P = ( item ) -> + if typeof item is 'object' + if item.displayNameLong + item.displayNameLong() + else if item.displayName + item.displayName() + else + item.name + else + item + + # define translation helper + params.T = ( item ) -> + App.i18n.translateContent( item ) + + # define translation inline helper + params.Ti = ( item ) -> + App.i18n.translateInline( item ) + + # define linkify helper + params.L = ( item ) -> + window.linkify( item ) + + # define template + JST["app/views/#{name}"](params) + template window.App = App \ No newline at end of file diff --git a/app/assets/javascripts/app/lib/collection.js.coffee b/app/assets/javascripts/app/lib/collection.js.coffee index d2979b17a..517aada1c 100644 --- a/app/assets/javascripts/app/lib/collection.js.coffee +++ b/app/assets/javascripts/app/lib/collection.js.coffee @@ -9,10 +9,10 @@ class App.Collection _instance ?= new _Singleton _instance.load( args ) - @find: ( type, id, callback ) -> + @find: ( type, id, callback, force ) -> if _instance == undefined _instance ?= new _Singleton - _instance.find( type, id, callback ) + _instance.find( type, id, callback, force ) @get: ( args ) -> if _instance == undefined @@ -99,17 +99,20 @@ class _Singleton if !localStorage App.Store.write( 'collection::' + params.type + '::' + object.id, { type: params.type, localStorage: true, data: [ object ] } ) - find: ( type, id, callback ) -> + find: ( type, id, callback, force ) -> -# console.log( 'find', type, id ) +# console.log( 'find', type, id, force ) # if App[type].exists( id ) && !callback - if App[type].exists( id ) + if !force && App[type].exists( id ) # console.log( 'find exists', type, id ) data = App[type].find( id ) if callback callback( data ) else - console.log( 'find not loaded!', type, id ) + if force + console.log( 'find forced to load!', type, id ) + else + console.log( 'find not loaded!', type, id ) if callback App[type].bind 'refresh', -> console.log 'loaded..' + type + '..', id @@ -136,15 +139,6 @@ class _Singleton if data && !data['image'] data['image'] = 'http://placehold.it/48x48' - # set realname - data['realname'] = '' - if data['firstname'] - data['realname'] = data['firstname'] - if data['lastname'] - if data['realname'] isnt '' - data['realname'] = data['realname'] + ' ' - data['realname'] = data['realname'] + data['lastname'] - return data # tickets diff --git a/app/assets/javascripts/app/lib/i18n.js.coffee b/app/assets/javascripts/app/lib/i18n.js.coffee index 24c013f4e..218d0c774 100644 --- a/app/assets/javascripts/app/lib/i18n.js.coffee +++ b/app/assets/javascripts/app/lib/i18n.js.coffee @@ -1,18 +1,32 @@ $ = jQuery.sub() -# create dumy function till i18n is loaded -window.T = (text) -> - return text - class App.i18n + _instance = undefined + + @init: -> + _instance ?= new _Singleton + + @translateContent: ( string, args... ) -> + if _instance == undefined + _instance ?= new _Singleton + _instance.translate_content( string, args ) + + @translateInline: ( string, args... ) -> + if _instance == undefined + _instance ?= new _Singleton + _instance.translate_inline( string, args ) + + @translateTimestamp: ( args ) -> + if _instance == undefined + _instance ?= new _Singleton + _instance.timestamp( args ) + +class _Singleton constructor: -> @locale = 'de' @timestampFormat = 'yyyy-mm-dd HH:MM' @set( @locale ) - window.T = @translate_content - window.Ti = @translate_inline - window.Ts = @timestamp # $('.translation [contenteditable]') $('body') @@ -60,7 +74,7 @@ class App.i18n return $this - set: (locale) -> + set: ( locale ) -> @map = {} App.Com.ajax( id: 'i18n-set-' + locale, @@ -86,11 +100,11 @@ class App.i18n console.log 'error', error, statusText, xhr.statusCode ) - translate_inline: (string, args...) => - @translate(string, args...) + translate_inline: ( string, args... ) => + @translate( string, args... ) - translate_content: (string, args...) => - translated = @translate(string, args...) + translate_content: ( string, args... ) => + translated = @translate( string, args... ) # replace = '' + translated + '' if window.Config['Translation'] replace = '' + translated + '' @@ -100,7 +114,7 @@ class App.i18n else translated - translate: (string, args...) => + translate: ( string, args... ) => # return '' on undefined return '' if string is undefined @@ -112,7 +126,7 @@ class App.i18n else @_translated = false translated = string - + # search %s for arg in args translated = translated.replace(/%s/, arg) @@ -123,15 +137,15 @@ class App.i18n # return translated string return translated - escape: (string) -> - string = ('' + string) + escape: ( string ) -> + string = ( '' + string ) .replace(/&/g, '&') .replace(//g, '>') .replace(/\x22/g, '"') - timestamp: (time) => - s = (num, digits) -> + timestamp: ( time ) => + s = ( num, digits ) -> while num.toString().length < digits num = "0" + num return num diff --git a/app/assets/javascripts/app/lib/interface_handle.js.coffee b/app/assets/javascripts/app/lib/interface_handle.js.coffee index db60d3e7b..2da1bf42f 100644 --- a/app/assets/javascripts/app/lib/interface_handle.js.coffee +++ b/app/assets/javascripts/app/lib/interface_handle.js.coffee @@ -12,7 +12,7 @@ class App.Run extends App.Controller App.WebSocket.connect() # init of i18n - new App.i18n + App.i18n.init() # start navigation controller new App.Navigation( el: @el.find('#navigation') ) diff --git a/app/assets/javascripts/app/models/application_model.js.coffee b/app/assets/javascripts/app/models/application_model.js.coffee index 94aa6b0a5..0f0e3e15e 100644 --- a/app/assets/javascripts/app/models/application_model.js.coffee +++ b/app/assets/javascripts/app/models/application_model.js.coffee @@ -21,8 +21,13 @@ class App.Model extends Spine.Model if name name = name + ' ' name = name + @lastname - if @note - name = "#{name} (#{@note})" + if @organization + if typeof @organization is 'object' + name = "#{name} (#{@organization.name})" + else + name = "#{name} (#{@organization})" + else if @department + name = "#{name} (#{@department})" return name return '???' diff --git a/app/assets/javascripts/app/models/user.js.coffee b/app/assets/javascripts/app/models/user.js.coffee index 5d6f9c0a5..d11c67066 100644 --- a/app/assets/javascripts/app/models/user.js.coffee +++ b/app/assets/javascripts/app/models/user.js.coffee @@ -1,5 +1,5 @@ class App.User extends App.Model - @configure 'User', 'login', 'firstname', 'lastname', 'email', 'web', 'password', 'phone', 'fax', 'mobile', 'street', 'zip', 'city', 'country', 'organization_id', 'note', 'role_ids', 'group_ids', 'active', 'invite' + @configure 'User', 'login', 'firstname', 'lastname', 'email', 'web', 'password', 'phone', 'fax', 'mobile', 'street', 'zip', 'city', 'country', 'organization_id', 'department', 'note', 'role_ids', 'group_ids', 'active', 'invite' @extend Spine.Model.Ajax @url: '/api/users' @@ -13,11 +13,12 @@ class App.User extends App.Model { name: 'phone', display: 'Phone', tag: 'input', type: 'phone', limit: 100, null: true, class: 'span4', signup: false, quick: true, info: true }, { name: 'mobile', display: 'Mobile', tag: 'input', type: 'phone', limit: 100, null: true, class: 'span4', signup: false, quick: true, info: true }, { name: 'fax', display: 'Fax', tag: 'input', type: 'phone', limit: 100, null: true, class: 'span4', signup: false, quick: true, info: true }, + { name: 'organization_id', display: 'Organization', tag: 'select', multiple: false, nulloption: true, null: true, relation: 'Organization', class: 'span4', signup: false, quick: true, info: true }, + { name: 'department', display: 'Department', tag: 'input', type: 'text', limit: 200, null: true, class: 'span4', signup: false, quick: true, info: true }, { name: 'street', display: 'Street', tag: 'input', type: 'text', limit: 100, null: true, class: 'span4', signup: false, quick: true, info: true }, { name: 'zip', display: 'Zip', tag: 'input', type: 'text', limit: 100, null: true, class: 'span4', signup: false, quick: true, info: true }, { name: 'city', display: 'City', tag: 'input', type: 'text', limit: 100, null: true, class: 'span4', signup: false, quick: true, info: true }, { name: 'password', display: 'Password', tag: 'input', type: 'password', limit: 50, null: true, autocomplete: 'off', class: 'span4', signup: true, quick: false, }, - { name: 'organization_id', display: 'Organization', tag: 'select', multiple: false, nulloption: true, null: true, relation: 'Organization', class: 'span4' }, { name: 'note', display: 'Note', tag: 'textarea', note: 'Notes are visible to agents only, never to customers.', limit: 250, null: true, class: 'span4', quick: true, info: true }, { name: 'role_ids', display: 'Roles', tag: 'checkbox', multiple: true, null: false, relation: 'Role', class: 'span4' }, { name: 'group_ids', display: 'Groups', tag: 'checkbox', multiple: true, null: true, relation: 'Group', class: 'span4', invite_agent: true }, diff --git a/app/assets/javascripts/app/views/agent_ticket_create.jst.eco b/app/assets/javascripts/app/views/agent_ticket_create.jst.eco index b24b63ec1..9a836d7a4 100644 --- a/app/assets/javascripts/app/views/agent_ticket_create.jst.eco +++ b/app/assets/javascripts/app/views/agent_ticket_create.jst.eco @@ -1,5 +1,5 @@
@@ -14,6 +14,6 @@
-   +  
diff --git a/app/assets/javascripts/app/views/agent_ticket_customer.jst.eco b/app/assets/javascripts/app/views/agent_ticket_customer.jst.eco index 644925cea..31982cd29 100644 --- a/app/assets/javascripts/app/views/agent_ticket_customer.jst.eco +++ b/app/assets/javascripts/app/views/agent_ticket_customer.jst.eco @@ -1,10 +1,10 @@
\ No newline at end of file diff --git a/app/assets/javascripts/app/views/agent_ticket_history.jst.eco b/app/assets/javascripts/app/views/agent_ticket_history.jst.eco index d857b1fb1..5e9568587 100644 --- a/app/assets/javascripts/app/views/agent_ticket_history.jst.eco +++ b/app/assets/javascripts/app/views/agent_ticket_history.jst.eco @@ -1,6 +1,6 @@ diff --git a/app/assets/javascripts/app/views/generic/admin/edit.jst.eco b/app/assets/javascripts/app/views/generic/admin/edit.jst.eco index 377477aaf..184a3d3eb 100644 --- a/app/assets/javascripts/app/views/generic/admin/edit.jst.eco +++ b/app/assets/javascripts/app/views/generic/admin/edit.jst.eco @@ -1,11 +1,11 @@ diff --git a/app/assets/javascripts/app/views/generic/admin/index.jst.eco b/app/assets/javascripts/app/views/generic/admin/index.jst.eco index 7aef63789..2f0d8979e 100644 --- a/app/assets/javascripts/app/views/generic/admin/index.jst.eco +++ b/app/assets/javascripts/app/views/generic/admin/index.jst.eco @@ -1,5 +1,5 @@
@@ -23,15 +23,15 @@ <% for note in @notes: %> -

<%- T(note) %>

+

<%- @T( note ) %>

<% end %> <% if @buttons: %> <% for button in @buttons: %> -

<%- T(button.name) %>

+

<%- @T( button.name ) %>

<% end %> <% end %> - +
diff --git a/app/assets/javascripts/app/views/generic/admin/new.jst.eco b/app/assets/javascripts/app/views/generic/admin/new.jst.eco index 0a6d75025..a4acf0f18 100644 --- a/app/assets/javascripts/app/views/generic/admin/new.jst.eco +++ b/app/assets/javascripts/app/views/generic/admin/new.jst.eco @@ -1,11 +1,11 @@
diff --git a/app/assets/javascripts/app/views/generic/admin_level2/index.jst.eco b/app/assets/javascripts/app/views/generic/admin_level2/index.jst.eco index 23a57dd7a..27d89c39d 100644 --- a/app/assets/javascripts/app/views/generic/admin_level2/index.jst.eco +++ b/app/assets/javascripts/app/views/generic/admin_level2/index.jst.eco @@ -1,5 +1,5 @@
@@ -7,7 +7,7 @@ diff --git a/app/assets/javascripts/app/views/generic/attribute.jst.eco b/app/assets/javascripts/app/views/generic/attribute.jst.eco index daacf50a0..8374db770 100644 --- a/app/assets/javascripts/app/views/generic/attribute.jst.eco +++ b/app/assets/javascripts/app/views/generic/attribute.jst.eco @@ -1,9 +1,9 @@
-
diff --git a/app/assets/javascripts/app/views/generic/hero_message.jst.eco b/app/assets/javascripts/app/views/generic/hero_message.jst.eco index 439c27da2..fce7de609 100644 --- a/app/assets/javascripts/app/views/generic/hero_message.jst.eco +++ b/app/assets/javascripts/app/views/generic/hero_message.jst.eco @@ -1,5 +1,5 @@
-

<%- T(@head) %> <%- T(@head_small) %>

+

<%- @T( @head ) %> <%- @T( @head_small ) %>

<%- @message %> diff --git a/app/assets/javascripts/app/views/generic/table.jst.eco b/app/assets/javascripts/app/views/generic/table.jst.eco index 833aef43a..11aa59bfb 100644 --- a/app/assets/javascripts/app/views/generic/table.jst.eco +++ b/app/assets/javascripts/app/views/generic/table.jst.eco @@ -5,7 +5,7 @@ <% end %> <% for row in @header: %> - style="<%= row.style %>"<% end %>><%- T(row.display) %> + style="<%= row.style %>"<% end %>><%- @T( row.display ) %> <% end %>

\ No newline at end of file diff --git a/app/assets/javascripts/app/views/link/info.jst.eco b/app/assets/javascripts/app/views/link/info.jst.eco index 1d06dc097..93ee9d228 100644 --- a/app/assets/javascripts/app/views/link/info.jst.eco +++ b/app/assets/javascripts/app/views/link/info.jst.eco @@ -1,14 +1,14 @@
-

<%- T('Links') %>

+

<%- @T( 'Links' ) %>

<% for type of @links: %> - <%- T( type ) %> + <%- @T( type ) %> <% end %>
- +
diff --git a/app/assets/javascripts/app/views/login.jst.eco b/app/assets/javascripts/app/views/login.jst.eco index 9aa618e69..15b032a1e 100644 --- a/app/assets/javascripts/app/views/login.jst.eco +++ b/app/assets/javascripts/app/views/login.jst.eco @@ -1,39 +1,38 @@
-

Welcome stranger!

+

<%- @T( 'Welcome stranger!' ) %>

-

<%- T('Sign in with') %>

+

<%- @T( 'Sign in with' ) %>

- - - <% if !_.isEmpty(@auth_providers): %> + + <% if !_.isEmpty( @auth_providers ): %>
-

--- <%- T('or') %> ---

+

--- <%- @T( 'or' ) %> ---

- +
-

<%- T('Sign in using') %>

+

<%- @T( 'Sign in using' ) %>

@@ -42,19 +41,19 @@
-

--- <%- T('or') %> ---

+

--- <%- @T( 'or' ) %> ---

- +
-

<%- T('New to') %> <%= Config.product_name %>, <%- T('join today!') %>

-

<%- T('Sign up') %> +

<%- @T( 'New to' ) %> <%= Config.product_name %>, <%- @T( 'join today!' ) %>

+

<%- @T( 'Sign up' ) %>

- +
- +
- +
diff --git a/app/assets/javascripts/app/views/navigation.jst.eco b/app/assets/javascripts/app/views/navigation.jst.eco index 0f984bf53..d489fab47 100644 --- a/app/assets/javascripts/app/views/navigation.jst.eco +++ b/app/assets/javascripts/app/views/navigation.jst.eco @@ -6,26 +6,26 @@ <% for item in @navbar_left: %> <% if item.child: %> <% else: %> -
  • <%- T(item.name) %>
  • +
  • <%- @T( item.name ) %>
  • <% end %> <% end %>
    <% if @user: %> @@ -33,27 +33,27 @@ <% for item in @navbar_right: %> <% if item.child: %> <% else: %> -
  • <%- T(item.name) %>
  • +
  • <%- @T( item.name ) %>
  • <% end %> <% end %> <% else: %> <% end %>
    diff --git a/app/assets/javascripts/app/views/profile.jst.eco b/app/assets/javascripts/app/views/profile.jst.eco index 41282ca4d..8d4197455 100644 --- a/app/assets/javascripts/app/views/profile.jst.eco +++ b/app/assets/javascripts/app/views/profile.jst.eco @@ -1,11 +1,11 @@
      -
    • <%- T('Password') %>
    • -
    • <%- T('Link Accounts') %>
    • -
    • <%- T('Notifications') %>
    • +
    • <%- @T( 'Password' ) %>
    • +
    • <%- @T( 'Link Accounts' ) %>
    • +
    • <%- @T( 'Notifications' ) %>
    diff --git a/app/assets/javascripts/app/views/reset_password.jst.eco b/app/assets/javascripts/app/views/reset_password.jst.eco index d7a3f8069..050dedeb8 100644 --- a/app/assets/javascripts/app/views/reset_password.jst.eco +++ b/app/assets/javascripts/app/views/reset_password.jst.eco @@ -1,10 +1,10 @@
    -

    <%- T('Forgot your password?') %>

    +

    <%- @T( 'Forgot your password?' ) %>

    - <%- T('Cancel') %> - + <%- @T( 'Cancel' ) %> +
    \ No newline at end of file diff --git a/app/assets/javascripts/app/views/reset_password_change.jst.eco b/app/assets/javascripts/app/views/reset_password_change.jst.eco index d5f2fe5a6..b3e27cf0d 100644 --- a/app/assets/javascripts/app/views/reset_password_change.jst.eco +++ b/app/assets/javascripts/app/views/reset_password_change.jst.eco @@ -1,9 +1,9 @@
    -

    <%- T('Choose your new password.') %>

    +

    <%- @T( 'Choose your new password.' ) %>

    - +
    diff --git a/app/assets/javascripts/app/views/settings/item.jst.eco b/app/assets/javascripts/app/views/settings/item.jst.eco index ca5b0d1e6..1168b4880 100644 --- a/app/assets/javascripts/app/views/settings/item.jst.eco +++ b/app/assets/javascripts/app/views/settings/item.jst.eco @@ -1,7 +1,7 @@
    -

    <%- T(@setting.title) %>

    -

    <%- T(@setting.description) %>

    +

    <%- @T( @setting.title ) %>

    +

    <%- @T( @setting.description ) %>

    - +

    \ No newline at end of file diff --git a/app/assets/javascripts/app/views/signup.jst.eco b/app/assets/javascripts/app/views/signup.jst.eco index 738b46652..8d891a33b 100644 --- a/app/assets/javascripts/app/views/signup.jst.eco +++ b/app/assets/javascripts/app/views/signup.jst.eco @@ -1,10 +1,10 @@
    -

    <%- T('Join') %> <%= Config.product_name %>

    +

    <%- @T( 'Join' ) %> <%= Config.product_name %>

    - <%- T('Cancel') %> - + <%- @T( 'Cancel' ) %> +
    \ No newline at end of file diff --git a/app/assets/javascripts/app/views/template.jst.eco b/app/assets/javascripts/app/views/template.jst.eco index a8aa4890e..9b0eab000 100644 --- a/app/assets/javascripts/app/views/template.jst.eco +++ b/app/assets/javascripts/app/views/template.jst.eco @@ -1,11 +1,11 @@
    -

    <%- T('Templates') %>

    +

    <%- @T( 'Templates' ) %>

    - - - + + +
    - + - +
    \ No newline at end of file diff --git a/app/assets/javascripts/app/views/ticket_action.jst.eco b/app/assets/javascripts/app/views/ticket_action.jst.eco index 8e7dce34c..c99a1c5c1 100644 --- a/app/assets/javascripts/app/views/ticket_action.jst.eco +++ b/app/assets/javascripts/app/views/ticket_action.jst.eco @@ -1,8 +1,8 @@ \ No newline at end of file diff --git a/app/assets/javascripts/app/views/user_info.jst.eco b/app/assets/javascripts/app/views/user_info.jst.eco index c3ee1865c..60970efe0 100644 --- a/app/assets/javascripts/app/views/user_info.jst.eco +++ b/app/assets/javascripts/app/views/user_info.jst.eco @@ -1,19 +1,19 @@
    -

    <%- T('Customer') %>

    +

    <%- @T( 'Customer' ) %>

    <% if @user.image: %> <% end %>
    -
    <%= @user.displayName() %>
    +
    <%= @user.displayName() %>
    <% for row in @data: %> <% if @user[row.name] || row.name is 'note': %>
    <% if row.tag isnt 'textarea': %> -
    <%- window.linkify( @user[row.name] ) %>
    +
    <%- @L( @P( @user[row.name] ) ) %>
    <% else: %> -
    - <%- T(row.display) %>
    +
    + <%- @T( row.display ) %>
    <% end %> @@ -23,7 +23,7 @@ <% if !_.isEmpty(@user['accounts']): %>
    - <%- T('Linked Accounts') %>
    + <%- @T( 'Linked Accounts' ) %>
    <% for account of @user['accounts']: %> <%= account %> <% end %> @@ -34,19 +34,19 @@ <% for link in @user['links']: %> diff --git a/app/assets/javascripts/app/views/user_info_small.jst.eco b/app/assets/javascripts/app/views/user_info_small.jst.eco index 0c5c5de83..f590e6d5a 100644 --- a/app/assets/javascripts/app/views/user_info_small.jst.eco +++ b/app/assets/javascripts/app/views/user_info_small.jst.eco @@ -1,37 +1,37 @@ <% for row in @data: %> <% if @user[row.name]: %>
    -
    <%- window.linkify( @user[row.name] ) %>
    +
    <%- @L( @P( @user[row.name] ) ) %>
    <% end %> <% end %> <% if !_.isEmpty(@user['accounts']): %>
    - <%- T('Linked Accounts') %>
    - <% for account of @user['accounts']: %> - <%= account %> - <% end %> + <%- @T( 'Linked Accounts' ) %>
    + <% for account of @user['accounts']: %> + <%= account %> + <% end %>
    <% end %> -<% if !_.isEmpty(@user['links']): %> +<% if !_.isEmpty( @user['links'] ): %> <% for link in @user['links']: %> diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 36a85e67e..1631dbc66 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -161,7 +161,8 @@ curl http://localhost/api/users.json -v -u #{login}:#{password} -H "Content-Type # logger.debug('IIIIIIIIIIIIIIIIIIIIIIIIIIIIII') # exit '123' end - render :json => user, :status => :created + user_new = User.user_data_full( user.id ) + render :json => user_new, :status => :created rescue Exception => e render :json => { :error => e.message }, :status => :unprocessable_entity end @@ -206,8 +207,8 @@ curl http://localhost/api/users/2.json -v -u #{login}:#{password} -H "Content-Ty if params[:organization_ids] user.organization_ids = params[:organization_ids] end - user = User.user_data_full( params[:id] ) - render :json => user, :status => :ok + user_new = User.user_data_full( params[:id] ) + render :json => user_new, :status => :ok rescue Exception => e render :json => { :error => e.message }, :status => :unprocessable_entity end diff --git a/db/migrate/20120101000001_create_base.rb b/db/migrate/20120101000001_create_base.rb index dbd4f1e9d..535d02dd6 100644 --- a/db/migrate/20120101000001_create_base.rb +++ b/db/migrate/20120101000001_create_base.rb @@ -21,6 +21,7 @@ class CreateBase < ActiveRecord::Migration t.column :phone, :string, :limit => 100, :null => true t.column :fax, :string, :limit => 100, :null => true t.column :mobile, :string, :limit => 100, :null => true + t.column :department, :string, :limit => 200, :null => true t.column :street, :string, :limit => 120, :null => true t.column :zip, :string, :limit => 100, :null => true t.column :city, :string, :limit => 100, :null => true @@ -37,6 +38,7 @@ class CreateBase < ActiveRecord::Migration add_index :users, [:login], :unique => true add_index :users, [:email] # add_index :users, [:email], :unique => true + add_index :users, [:department] add_index :users, [:phone] add_index :users, [:fax] add_index :users, [:mobile]