Changeset 715
- Timestamp:
- 11/02/07 17:49:45 (1 year ago)
- Files:
-
- trunk/app/controllers/application.rb (modified) (3 diffs)
- trunk/app/controllers/task_controller.rb (modified) (3 diffs)
- trunk/app/views/layouts/mainlevel.rhtml (modified) (1 diff)
- trunk/config/menu.rb (modified) (1 diff)
- trunk/db/migrate/010_customer_interface_data.rb (modified) (2 diffs)
- trunk/public/stylesheets/typography.css (modified) (8 diffs)
- trunk/test/functional/task_controller_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/app/controllers/application.rb
r710 r715 20 20 21 21 layout 'mainlevel' 22 before_filter :set_current_user, :set_selected_asset, :prepare_tree_view, :protect_page_groups, :handle_cancel_submit, :set_host 22 before_filter :set_current_user, :set_selected_asset, :prepare_tree_view, :protect_page_groups, :handle_cancel_submit, :set_host, :check_new_service_requests 23 23 after_filter :reset_timedout_session, :process_model_events 24 24 … … 206 206 login = session[:user].login if session[:user] 207 207 ActiveRecord::Base.logged_information(login, request.remote_ip) 208 if UserAccount.current_user.i s_a?(User)209 @message_count = session[:user].received_messages.count(:conditions => "unread = '1'")210 @message_id = session[:user].received_messages.find(:first, :conditions => "unread = '1'").id if @message_count == 1208 if UserAccount.current_user.instance_of?(User) 209 @message_count = session[:user].received_messages.count(:conditions => ['unread = ?', true]) 210 @message_id = session[:user].received_messages.find(:first, :conditions => ['unread = ?', true]).id if @message_count == 1 211 211 end 212 212 GetText.locale = session[:user].lang … … 681 681 end 682 682 683 # Function: check_new_service_requests 684 # ==================================== 685 # Checks for new service requests by counting them. 686 # 687 def check_new_service_requests 688 conditions = ['task_type_id = ? AND state = ?', TaskType.get_service_request_type.id, Task.NEW] 689 @service_request_count = Task.count_authorized_to(:read, conditions) 690 @service_request_id = Task.find_authorized_to_read(:first, :conditions => conditions).id if @service_request_count == 1 691 end 683 692 end trunk/app/controllers/task_controller.rb
r710 r715 389 389 # Method: list_service_requests 390 390 # ============================= 391 # Shows a list of service request s task391 # Shows a list of service request tasks 392 392 # 393 393 def list_service_requests 394 define_priority_options 395 @fields = [ 396 [_('ID'), :self, 'id'], 397 [_('State'), {:name => :state}.merge(@state_to_text), 'state'], 398 [_('Description'), :short_description, 'short_description'], 399 [_('Created at'), :created_at, 'created_at'], 400 [_('Asset'), :asset, 'asset_id'] 401 ] 402 403 asset_options = Asset.find_authorized_to(:create_task, [:all]).collect { |a| [a.full_code, a.id] } 404 @actions = [] 405 @check_title = _('Select') 406 @list_actions = [ 407 { :name => _('Remove'), :url => {:action => 'remove'} }, 408 { :name => _('Move'), :url => {:action => 'move'}, 409 :fields => [ [_('Asset'), :our_select_tag, 'asset_id', asset_options] ] } 410 ] 394 setup_service_request_list 411 395 412 396 if session[:select_branches] … … 422 406 423 407 @items = items_for_page(Task, :finder_method => :find_authorized_to_read, :conditions => conditions, :readonly => true) 408 common_list 409 end 410 411 # Method: list_new_service_requests 412 # ================================== 413 # Shows a list of new service request tasks in all assets. 414 # 415 def list_new_service_requests 416 setup_service_request_list 417 @title = _('New service requests') 418 @hide_subaction_links = true 419 420 @items = items_for_page(Task, :finder_method => :find_authorized_to_read, 421 :conditions => ['task_type_id = ? AND state = ?', TaskType.get_service_request_type.id, Task.NEW], 422 :readonly => true) 424 423 common_list 425 424 end … … 452 451 @state_to_text = {0 => _('New'), 1 => _('Assigned'), 2 => _('Accepted'), 3 => _('Closed')} 453 452 end 453 454 def setup_service_request_list 455 define_priority_options 456 @fields = [ 457 [_('ID'), :self, 'id'], 458 [_('State'), {:name => :state}.merge(@state_to_text), 'state'], 459 [_('Description'), :short_description, 'short_description'], 460 [_('Created at'), :created_at, 'created_at'], 461 [_('Asset'), :asset, 'asset_id'] 462 ] 463 464 asset_options = Asset.find_authorized_to(:create_task, [:all]).collect { |a| [a.full_code, a.id] } 465 @actions = [] 466 @check_title = _('Select') 467 @list_actions = [ 468 { :name => _('Remove'), :url => {:action => 'remove'} }, 469 { :name => _('Move'), :url => {:action => 'move'}, 470 :fields => [ [_('Asset'), :our_select_tag, 'asset_id', asset_options] ] } 471 ] 472 end 454 473 end trunk/app/views/layouts/mainlevel.rhtml
r704 r715 267 267 <% end -%> 268 268 269 <% if @service_request_count == 1 and not (controller.controller_name == 'task' and controller.action_name == 'view' and params.has_key?(:id) and params[:id].to_i == @service_request_id) -%> 270 <p id="service_request_count"> 271 <%= link_to(_('There is a new service request'), :controller => 'task', :action => 'view', :id => @service_request_id) %> 272 </p> 273 <% elsif @service_request_count > 1 and controller.action_name != 'list_new_service_requests' -%> 274 <p id="service_request_count"> 275 <%= link_to(_('There are %i new service requests', @service_request_count), :controller => 'task', :action => 'list_new_service_requests') %> 276 </p> 277 <% end -%> 278 269 279 <%= @content_for_layout %> 270 280 </div> trunk/config/menu.rb
r710 r715 48 48 Page.new('task', 'edit'), 49 49 Page.new('task', 'view'), 50 Page.new('task', 'select_asset') 50 Page.new('task', 'select_asset'), 51 Page.new('task', 'list_new_service_requests') 51 52 ), 52 53 MenuButton.new(_('Timeline'), '22x22/menu_clock.gif', trunk/db/migrate/010_customer_interface_data.rb
r712 r715 21 21 # The new 'task/list_service_requests' key is added to all keyrings 22 22 # which have the 'task/list' key. 23 new_list_key = TempActionKey.create!(:name => 'task/list_service_requests') 23 new_list_keys = [ 24 'task/list_service_requests', 25 'task/list_new_service_requests' 26 ].map { |name| TempActionKey.create!(:name => name) } 24 27 old_list_key = TempActionKey.find_by_name('task/list') 25 28 if old_list_key … … 27 30 unless keyring_ids.empty? 28 31 TempKeyring.find(keyring_ids).each { |keyring| 29 puts "Adding the 'task/list_service_requests' action keyfor '%s'" % keyring.name30 keyring.grant(new_list_key)32 puts "Adding the service request listing keys for '%s'" % keyring.name 33 new_list_keys.each { |key| keyring.grant(key) } 31 34 } 32 35 end trunk/public/stylesheets/typography.css
r602 r715 8 8 9 9 h1, h2, h3, h4, h5, h6 { 10 font-family: Arial, Verdana, sans-serif;11 color: #467;10 font-family: Arial, Verdana, sans-serif; 11 color: #467; 12 12 } 13 13 14 14 h2 { 15 font-size: 1.8em;16 font-weight: bold;17 margin-bottom: 1.6em;18 padding-bottom: 4px;19 border-bottom: 1px solid #CCC;15 font-size: 1.8em; 16 font-weight: bold; 17 margin-bottom: 1.6em; 18 padding-bottom: 4px; 19 border-bottom: 1px solid #CCC; 20 20 } 21 21 22 22 h3 { 23 font-size: 1.4em;24 font-weight: bold;25 margin-bottom: .8em;26 padding-bottom: 4px;27 border-bottom: 1px solid #CCC;23 font-size: 1.4em; 24 font-weight: bold; 25 margin-bottom: .8em; 26 padding-bottom: 4px; 27 border-bottom: 1px solid #CCC; 28 28 } 29 29 30 30 h4 { 31 font-size: 1.1em;32 font-weight: bold;33 margin-bottom: .8em;31 font-size: 1.1em; 32 font-weight: bold; 33 margin-bottom: .8em; 34 34 } 35 35 … … 37 37 38 38 p { 39 font-family: Verdana, Arial, sans-serif;40 color: #000;41 margin-bottom: 1.5em;42 }39 font-family: Verdana, Arial, sans-serif; 40 color: #000; 41 margin-bottom: 1.5em; 42 } 43 43 44 44 /* BASE LINK STYLES */ … … 48 48 a:active, 49 49 a:visited { 50 color: #45F;51 text-decoration: none;50 color: #45F; 51 text-decoration: none; 52 52 } 53 53 54 54 a:hover { 55 text-decoration: underline;55 text-decoration: underline; 56 56 } 57 57 … … 64 64 65 65 ul, ol, dl { 66 margin-bottom: 1.5em;67 padding: 0;66 margin-bottom: 1.5em; 67 padding: 0; 68 68 } 69 69 70 70 ul, ol { 71 margin-left: 2em;72 list-style-position: outside;71 margin-left: 2em; 72 list-style-position: outside; 73 73 } 74 74 … … 77 77 78 78 ul li, ol li { 79 line-height: 1.6em;79 line-height: 1.6em; 80 80 } 81 81 82 82 dt { 83 font-weight: bold;83 font-weight: bold; 84 84 } 85 85 86 86 dt.sub { 87 font-weight: normal;88 text-decoration: underline;87 font-weight: normal; 88 text-decoration: underline; 89 89 } 90 90 91 91 dd { 92 margin-left: 2em;92 margin-left: 2em; 93 93 } 94 94 95 95 /* BASE TABLE STYLES */ 96 /* This needs a complete rework and cleanup, custom tables should be moved under 96 /* This needs a complete rework and cleanup, custom tables should be moved under 97 97 their section sheets and a base table design needs to be written */ 98 98 99 99 table { 100 margin-bottom: 1em;101 border-spacing: 0;102 width: 100%;100 margin-bottom: 1em; 101 border-spacing: 0; 102 width: 100%; 103 103 } 104 104 105 105 th { 106 font-weight: bold;107 padding: 0.3em 1.5em 0.3em 0.4em;108 text-align: left;106 font-weight: bold; 107 padding: 0.3em 1.5em 0.3em 0.4em; 108 text-align: left; 109 109 } 110 110 111 111 td { 112 padding: 0.3em 1.5em 0.3em 0.4em;112 padding: 0.3em 1.5em 0.3em 0.4em; 113 113 } 114 114 115 115 table.form td, table.form th { 116 border-bottom: 1px solid #EEE;117 padding: 7px 0;116 border-bottom: 1px solid #EEE; 117 padding: 7px 0; 118 118 } 119 119 120 120 table.form th { 121 padding-left: .8em;121 padding-left: .8em; 122 122 } 123 123 124 124 table.form th.light { 125 font-weight: normal;125 font-weight: normal; 126 126 } 127 127 128 128 table.form td { 129 padding-left: .8em;130 padding-right: .8em;129 padding-left: .8em; 130 padding-right: .8em; 131 131 } 132 132 133 133 table.buttons { 134 border: 1px solid #CCC;135 background: #FFF url(/images/bg_table_form_buttons.gif) top left repeat-x;136 margin-bottom: 2em;134 border: 1px solid #CCC; 135 background: #FFF url(/images/bg_table_form_buttons.gif) top left repeat-x; 136 margin-bottom: 2em; 137 137 } 138 138 139 139 table.buttons td, table.buttons th { 140 padding: 5px 10px;140 padding: 5px 10px; 141 141 } 142 142 … … 273 273 /* FORM STYLES */ 274 274 275 form { 276 margin-bottom: 1em;275 form { 276 margin-bottom: 1em; 277 277 } 278 278 279 279 form#cancel { 280 float: left;280 float: left; 281 281 } 282 282 … … 302 302 303 303 #notice { 304 background: #def1ce url(../images/info.png) 5px 5px no-repeat;305 padding: 1em 1em 1em 4em;306 line-height: 1em;307 margin-bottom: 2em;304 background: #def1ce url(../images/info.png) 5px 5px no-repeat; 305 padding: 1em 1em 1em 4em; 306 line-height: 1em; 307 margin-bottom: 2em; 308 308 } 309 309 310 310 #error { 311 background: #f1cece url(../images/error.png) 5px 5px no-repeat;312 padding: 1em 1em 1em 4em;313 line-height: 1em;314 margin-bottom: 2em;311 background: #f1cece url(../images/error.png) 5px 5px no-repeat; 312 padding: 1em 1em 1em 4em; 313 line-height: 1em; 314 margin-bottom: 2em; 315 315 } 316 316 317 317 #message_count { 318 background: #dddddd url(../images/22x22/message.png) 5px 5px no-repeat; 319 padding: 1em 1em 1em 4em; 320 line-height: 1em; 321 margin-bottom: 2em; 318 background: #dddddd url(../images/22x22/message.png) 5px 5px no-repeat; 319 padding: 1em 1em 1em 4em; 320 line-height: 1em; 321 margin-bottom: 2em; 322 } 323 324 #service_request_count { 325 background: #ffa url(../images/22x22/task.png) 5px 5px no-repeat; 326 padding: 1em 1em 1em 4em; 327 line-height: 1em; 328 margin-bottom: 2em; 322 329 } 323 330 324 331 div.errorExplanation p, div.errorExplanation ul { /* Validation errors */ 325 margin: 0em;332 margin: 0em; 326 333 } 327 334 328 335 div.errorExplanation { 329 /* border: 1px solid black;*/330 background: #f1cece url(../images/error.png) 5px 5px no-repeat;331 padding: 1em 1em 1em 4em;332 line-height: 1em;333 margin-bottom: 2em;336 /* border: 1px solid black;*/ 337 background: #f1cece url(../images/error.png) 5px 5px no-repeat; 338 padding: 1em 1em 1em 4em; 339 line-height: 1em; 340 margin-bottom: 2em; 334 341 } 335 342 … … 342 349 343 350 div.fieldWithErrors input { 344 background-color: #f1cece;351 background-color: #f1cece; 345 352 } 346 353 347 354 input.error { 348 background-color: #f1cece;355 background-color: #f1cece; 349 356 } 350 357 351 358 #table-form-buttons { 352 text-align: right;353 border: 1px solid #CCC;354 padding: 5px 10px;355 margin-bottom: 2em;356 background: #FFF url(/images/bg_table_form_buttons.gif) top left repeat-x;359 text-align: right; 360 border: 1px solid #CCC; 361 padding: 5px 10px; 362 margin-bottom: 2em; 363 background: #FFF url(/images/bg_table_form_buttons.gif) top left repeat-x; 357 364 } 358 365 359 366 /* SEARCH BOX (hidden) */ 360 367 div#search_box { 361 display: none;368 display: none; 362 369 visibility: hidden; /* FIXME: Find a better location */ 363 370 } trunk/test/functional/task_controller_test.rb
r710 r715 344 344 end 345 345 346 def test_list_new_service_request_GET_empty 347 @keyring.action_keys << create_action_key('task/list_new_service_requests') 348 login('test') 349 350 customer = create_customer('customer') 351 UserAccount.current_user = @user 352 assert @root.update_attribute(:customer, customer) 353 354 UserAccount.current_user = customer 355 create_task_in_state(Task.ACCEPTED) 356 create_task_in_state(Task.ASSIGNED) 357 create_task_in_state(Task.CLOSED) 358 359 get 'list_new_service_requests' 360 assert_response :success 361 assert_template 'shared/_list_items' 362 assert_equal true, assigns(:items).empty? 363 end 364 365 def test_list_new_service_request_GET_not_empty 366 @keyring.action_keys << create_action_key('task/list_new_service_requests') 367 368 customer = create_customer('customer') 369 UserAccount.current_user = @user 370 assert @root.update_attribute(:customer, customer) 371 372 UserAccount.current_user = customer 373 for i in 1..100 374 create_task(@root, true, 'Service request %d' % i) 375 end 376 377 login('test') 378 379 get 'list_new_service_requests' 380 assert_response :success 381 assert_template 'shared/_list_items' 382 assert_equal false, assigns(:items).empty? 383 end 384 346 385 private 347 386