From bc4e559c08616de312906903a1c89eb74d09ffd7 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sat, 22 Dec 2012 12:32:36 +0100 Subject: GUI improvement for new acd agents. --- app/controllers/acd_agents_controller.rb | 4 ++++ app/models/acd_agent.rb | 8 +++++++- app/views/acd_agents/_form_core.html.haml | 10 ++++++---- app/views/acd_agents/show.html.haml | 20 +++++++++++--------- config/initializers/gemeinschaft_parameters.rb | 4 ++-- 5 files changed, 30 insertions(+), 16 deletions(-) diff --git a/app/controllers/acd_agents_controller.rb b/app/controllers/acd_agents_controller.rb index 1d119b3..4c08f68 100644 --- a/app/controllers/acd_agents_controller.rb +++ b/app/controllers/acd_agents_controller.rb @@ -28,6 +28,8 @@ class AcdAgentsController < ApplicationController @acd_agent.name = "#{t('acd_agents.name')} #{i}" @acd_agent.status = 'active' @acd_agent.calls_answered = 0 + + @available_sip_accounts = SipAccount.all - @automatic_call_distributor.acd_agents.where(:destination_type => 'SipAccount').map{|acd_agent| acd_agent.destination} end def create @@ -41,6 +43,8 @@ class AcdAgentsController < ApplicationController def edit @acd_agent = AcdAgent.find(params[:id]) + + @available_sip_accounts = SipAccount.all end def update diff --git a/app/models/acd_agent.rb b/app/models/acd_agent.rb index a00ac4b..4be4700 100644 --- a/app/models/acd_agent.rb +++ b/app/models/acd_agent.rb @@ -3,13 +3,19 @@ class AcdAgent < ActiveRecord::Base STATUSES = ['active', 'inactive'] attr_accessible :uuid, :name, :status, :automatic_call_distributor_id, :last_call, :calls_answered, :destination_type, :destination_id - + belongs_to :automatic_call_distributor belongs_to :destination, :polymorphic => true after_save :set_presence + # Validations: + # + validates_presence_of :name + validates_presence_of :destination + validates_presence_of :destination_id + def to_s self.name || I18n.t('acd_agents.name') + ' ID ' + self.id.to_s end diff --git a/app/views/acd_agents/_form_core.html.haml b/app/views/acd_agents/_form_core.html.haml index ab4657c..a56fc9a 100644 --- a/app/views/acd_agents/_form_core.html.haml +++ b/app/views/acd_agents/_form_core.html.haml @@ -1,7 +1,9 @@ .inputs = f.input :name, :label => t('acd_agents.form.name.label'), :hint => conditional_hint('acd_agents.form.name.hint') = f.input :status, :label => t('acd_agents.form.status.label'), :hint => conditional_hint('acd_agents.form.status.hint'), :include_blank => false, :collection => AcdAgent::STATUSES - = f.input :last_call, :label => t('acd_agents.form.last_call.label'), :hint => conditional_hint('acd_agents.form.last_call.hint') - = f.input :calls_answered, :label => t('acd_agents.form.calls_answered.label'), :hint => conditional_hint('acd_agents.form.calls_answered.hint') - = f.input :destination_type, :label => t('acd_agents.form.destination_type.label'), :hint => conditional_hint('acd_agents.form.destination_type.hint'), :include_blank => false, :collection => AcdAgent::DESTINATION_TYPES - = f.input :destination_id, :label => t('acd_agents.form.destination_id.label'), :hint => conditional_hint('acd_agents.form.destination_id.hint') + - if AcdAgent::DESTINATION_TYPES.count == 1 && AcdAgent::DESTINATION_TYPES.first == 'SipAccount' && @available_sip_accounts && @available_sip_accounts.count < 30 + = f.hidden_field :destination_type, :value => AcdAgent::DESTINATION_TYPES.first + = f.input :destination_id, :collection => @available_sip_accounts.map { |r| [r.to_s, r.id] }, :include_blank => false + - else + = f.input :destination_type, :label => t('acd_agents.form.destination_type.label'), :hint => conditional_hint('acd_agents.form.destination_type.hint'), :include_blank => false, :collection => AcdAgent::DESTINATION_TYPES + = f.input :destination_id, :label => t('acd_agents.form.destination_id.label'), :hint => conditional_hint('acd_agents.form.destination_id.hint') diff --git a/app/views/acd_agents/show.html.haml b/app/views/acd_agents/show.html.haml index 97881f6..0c90f4b 100644 --- a/app/views/acd_agents/show.html.haml +++ b/app/views/acd_agents/show.html.haml @@ -1,8 +1,5 @@ - title t("acd_agents.show.page_title") -%p - %strong= t('acd_agents.show.uuid') + ":" - = @acd_agent.uuid %p %strong= t('acd_agents.show.name') + ":" = @acd_agent.name @@ -18,11 +15,16 @@ %p %strong= t('acd_agents.show.calls_answered') + ":" = @acd_agent.calls_answered -%p - %strong= t('acd_agents.show.destination_type') + ":" - = @acd_agent.destination_type -%p - %strong= t('acd_agents.show.destination_id') + ":" - = @acd_agent.destination_id +- if @acd_agent.destination_type == 'SipAccount' + %p + %strong= t('acd_agents.index.destination') + ":" + = SipAccount.where(:id => @acd_agent.destination_id).first.try(:to_s) +- else + %p + %strong= t('acd_agents.show.destination_type') + ":" + = @acd_agent.destination_type + %p + %strong= t('acd_agents.show.destination_id') + ":" + = @acd_agent.destination_id = render :partial => 'shared/show_edit_destroy_part', :locals => {:parent => @automatic_call_distributor, :child => @acd_agent } \ No newline at end of file diff --git a/config/initializers/gemeinschaft_parameters.rb b/config/initializers/gemeinschaft_parameters.rb index 6e89abd..fbe9c56 100644 --- a/config/initializers/gemeinschaft_parameters.rb +++ b/config/initializers/gemeinschaft_parameters.rb @@ -22,8 +22,8 @@ CALL_WAITING = false DEFAULT_CLIR_SETTING = false DEFAULT_CLIP_SETTING = true -TO_S_MAX_CALLER_NAME_LENGTH = 20 -TO_S_MAX_LENGTH_OF_AUTH_NAME = 8 +TO_S_MAX_CALLER_NAME_LENGTH = 25 +TO_S_MAX_LENGTH_OF_AUTH_NAME = 6 # Pagination defaults DEFAULT_PAGINATION_ENTRIES_PER_PAGE = 50 -- cgit v1.2.3