Skip to content

Commit

Permalink
Search page entire functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
thamizh committed Jul 13, 2013
1 parent 66cfc60 commit ae3da92
Show file tree
Hide file tree
Showing 25 changed files with 405 additions and 182 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ group :assets do
gem 'angularjs-rails'
end
gem 'jquery-tokeninput-rails'
gem 'angular-ui-bootstrap-rails'

group :development do
gem "better_errors"
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ GEM
activesupport (3.2.12)
i18n (~> 0.6)
multi_json (~> 1.0)
angular-ui-bootstrap-rails (0.3.0.1)
angularjs-rails (1.0.7)
arel (3.0.2)
bcrypt-ruby (3.1.0)
Expand Down Expand Up @@ -150,6 +151,7 @@ PLATFORMS
ruby

DEPENDENCIES
angular-ui-bootstrap-rails
angularjs-rails
better_errors
coffee-rails (~> 3.2.1)
Expand Down
3 changes: 3 additions & 0 deletions app/assets/javascripts/call_lists.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
1 change: 1 addition & 0 deletions app/assets/javascripts/search/application.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//= require jquery
//= require angular
//= require angular-resource
//= require angular-ui-bootstrap
//= require jquery_ujs
//= require jquery.tokeninput
15 changes: 5 additions & 10 deletions app/assets/javascripts/search/search.js.coffee
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
$(document).ready ->
checked = true
$("#selectAll").click () ->
if(checked)
$("#search_result input[type=checkbox]").attr("checked","checked")
else
$("#search_result input[type=checkbox]:checked").removeAttr("checked")
checked= !checked
false

$(document).ready ->
$("#keywords").tokenInput(window.tags,theme:"facebook", preventDuplicates:true)
$("#keywords").change () ->
$("#keywords").trigger('input');

3 changes: 3 additions & 0 deletions app/assets/javascripts/shortlists.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/call_lists.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the call_lists controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
20 changes: 12 additions & 8 deletions app/assets/stylesheets/search/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ line-height: 18px;
.key-search{
margin-top: 100px;
margin-bottom: 10px;
padd
}
.display_result{
background: #ddd;
Expand All @@ -67,10 +66,9 @@ font-size: 14px;
height: 500px;
outline: #eee solid 1px;
margin-left: 5px;
width: 315px;
height: 500px;
overflow-y: scroll;
overflow-x: hidden;
overflow-y: auto;
overflow-x:hidden;
}
.candidate-list-box span,.candidate-list span,.NameDiv span{
display: block;
Expand Down Expand Up @@ -122,12 +120,12 @@ font-size: 14px;
outline: #eee solid 1px;
}
.QV-content,.edit-content{
margin: 10px 0px 25px 0px;
padding: 20px 15px 25px 15px;
position: relative;
}
.innerDiv{
padding:5px 0px 0px 0px;
display: block;
padding: 0px 0px 0px 15px;

}
.bold{
font-weight: bold;
Expand Down Expand Up @@ -159,4 +157,10 @@ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#8cc1d3', end
width: auto !important; }
.new-note-form{
display: none;
}
}

.notes_date{color: #0088cc;
margin-bottom: 0px;}

.notes_note{text-indent: 20px;
margin-bottom: 15px;}
3 changes: 3 additions & 0 deletions app/assets/stylesheets/shortlists.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the shortlists controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
4 changes: 4 additions & 0 deletions app/controllers/call_lists_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class CallListsController < ApplicationController
def index
end
end
2 changes: 1 addition & 1 deletion app/controllers/candidates_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def show

def search
@result = []
@candidates = current_team.candidates
@candidates = current_team.candidates.order("first_name")
if params[:query]
tag_ids = params[:query].split(",").map{ |t| t.to_i }.uniq
@tags = Tag.includes(:candidates).where(:id=> tag_ids)
Expand Down
27 changes: 27 additions & 0 deletions app/controllers/shortlists_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
class ShortlistsController < ApplicationController
def create
@call_list = params[:call_list_id] ? CallList.find(params[:call_list_id]) : current_user.call_lists.create(:name=>params[:name])
candidate_ids = params[:candidate_ids].split(",").map{|id| id.to_i}
candidate_ids.each do |id|
@call_list.shortlists.create(:candidate_id=>id)
end
respond_to do |f|
f.html
f.json { render :json=> @call_list.to_json}
end
end

def bulk_update
@call_list = CallList.find(params[:call_list_id])
candidate_ids = params[:candidate_ids].split(",").map{|id| id.to_i}
call_list_ids = @call_list.shortlists.map(&:id)
remaining_ids = candidate_ids - call_list_ids
remaining_ids.each do |id|
@call_list.shortlists.create(:candidate_id=>id)
end
respond_to do |f|
f.html
f.json { render :json=> {"count"=>remaining_ids.count}.to_json}
end
end
end
2 changes: 2 additions & 0 deletions app/helpers/call_lists_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module CallListsHelper
end
3 changes: 3 additions & 0 deletions app/helpers/candidates_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ def get_tags
tags = Tag.all.map{|tag| { "id"=>tag.id,"name"=>tag.name} }
raw tags.to_json
end
def get_call_list
raw current_user.call_lists.to_json
end
end
2 changes: 2 additions & 0 deletions app/helpers/shortlists_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module ShortlistsHelper
end
6 changes: 5 additions & 1 deletion app/models/candidate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class Candidate < ActiveRecord::Base
has_many :notes
belongs_to :user
belongs_to :team
has_many :shortlists
delegate :name, :to=>:user, :prefix=>true
has_and_belongs_to_many :tags
attr_reader :get_tags, :profile_pic_url,:get_notes
def as_json options={}
Expand All @@ -36,7 +38,9 @@ def as_json options={}
linked_in: self.linked_in,
facebook: self.facebook,
twitter: self.twitter,
notes: self.get_notes
notes: self.get_notes,
resume: self.resume,
added_by: self.user_name
}
# options ||= {}
# options[:methods] = ((options[:methods] || []) + [:get_tags,:profile_pic_url])
Expand Down
8 changes: 8 additions & 0 deletions app/models/note.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,12 @@ class Note < ActiveRecord::Base
attr_accessible :creater_id, :candidate_note, :candidate_id
belongs_to :candidate
belongs_to :creater, :class_name=>"User", :foreign_key=>"creater_id"
def as_json(options={})
{
id: self.id,
date: self.created_at.strftime("%m/%d/%Y"),
candidate_note: self.candidate_note,
candidate_id: self.candidate_id
}
end
end
1 change: 1 addition & 0 deletions app/models/shortlist.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class Shortlist < ActiveRecord::Base
attr_accessible :candidate_id, :status, :call_list_id
belongs_to :call_list
belongs_to :candidate
end
7 changes: 5 additions & 2 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ class User < ActiveRecord::Base

# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me, :first_name, :last_name, :company,
:user_type, :status, :team_id, :plan_id, :register_type
attr_accessor :plan_id, :register_type
:user_type, :status, :team_id, :plan_id, :register_type,:name
attr_accessor :plan_id, :register_type, :name
def name
"#{first_name.to_s} #{last_name.to_s}"
end
after_create :create_team
# attr_accessible :title, :body
belongs_to :team
Expand Down
Loading

0 comments on commit ae3da92

Please sign in to comment.