From 713ac7f7931d44177a8c80305fc31c68d7f72aba Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Tue, 26 Dec 2017 21:07:35 +0800 Subject: [PATCH] job form category and industry type forms added --- .../admin/recruitments_controller.rb | 73 +++++++++++++++++++ app/controllers/recruitments_controller.rb | 5 +- app/models/employer_profile.rb | 1 + app/models/recruitment_category.rb | 6 ++ app/models/recruitment_industry.rb | 6 ++ app/models/recruitment_job.rb | 2 +- .../admin/recruitments/addcategory.html.erb | 14 ++++ .../admin/recruitments/addindustry.html.erb | 14 ++++ .../admin/recruitments/categories.html.erb | 61 ++++++++++++++++ .../admin/recruitments/editcategory.html.erb | 14 ++++ .../admin/recruitments/editindustry.html.erb | 14 ++++ .../admin/recruitments/industries.html.erb | 61 ++++++++++++++++ .../recruitments/_employer_form.html.erb | 10 ++- app/views/recruitments/_job_form.html.erb | 13 +++- config/locales/en.yml | 7 +- config/locales/zh_tw.yml | 7 +- config/routes.rb | 18 +++++ lib/recruitment/engine.rb | 15 +++- 18 files changed, 332 insertions(+), 9 deletions(-) create mode 100644 app/models/recruitment_category.rb create mode 100644 app/models/recruitment_industry.rb create mode 100644 app/views/admin/recruitments/addcategory.html.erb create mode 100644 app/views/admin/recruitments/addindustry.html.erb create mode 100644 app/views/admin/recruitments/categories.html.erb create mode 100644 app/views/admin/recruitments/editcategory.html.erb create mode 100644 app/views/admin/recruitments/editindustry.html.erb create mode 100644 app/views/admin/recruitments/industries.html.erb diff --git a/app/controllers/admin/recruitments_controller.rb b/app/controllers/admin/recruitments_controller.rb index 6fda688..1a8216a 100644 --- a/app/controllers/admin/recruitments_controller.rb +++ b/app/controllers/admin/recruitments_controller.rb @@ -1,4 +1,77 @@ class Admin::RecruitmentsController < OrbitAdminController def index end + + def industries + @industries = RecruitmentIndustry.all + end + + def addindustry + @industry = RecruitmentIndustry.new + render :layout => false + end + + def createindustry + industry = RecruitmentIndustry.create(industry_params) + redirect_to industries_admin_recruitments_path + end + + def editindustry + @industry = RecruitmentIndustry.find(params[:id]) + render :layout => false + end + + def updateindustry + industry = RecruitmentIndustry.find(params[:id]) + industry.update_attributes(industry_params) + redirect_to industries_admin_recruitments_path + end + + def deleteindustry + industry = RecruitmentIndustry.find(params[:id]) + industry.destroy + redirect_to industries_admin_recruitments_path + end + + + def categories + @categories = RecruitmentCategory.all + end + + def addcategory + @category = RecruitmentCategory.new + render :layout => false + end + + def createcategory + category = RecruitmentCategory.create(category_params) + redirect_to categories_admin_recruitments_path + end + + def editcategory + @category = RecruitmentCategory.find(params[:id]) + render :layout => false + end + + def updatecategory + category = RecruitmentCategory.find(params[:id]) + category.update_attributes(category_params) + redirect_to categories_admin_recruitments_path + end + + def deletecategory + category = RecruitmentCategory.find(params[:id]) + category.destroy + redirect_to categories_admin_recruitments_path + end + + private + + def industry_params + params.require(:recruitment_industry).permit! + end + + def category_params + params.require(:recruitment_category).permit! + end end \ No newline at end of file diff --git a/app/controllers/recruitments_controller.rb b/app/controllers/recruitments_controller.rb index 84b86ee..d9c0419 100644 --- a/app/controllers/recruitments_controller.rb +++ b/app/controllers/recruitments_controller.rb @@ -104,7 +104,10 @@ class RecruitmentsController < PseudoSessionController end def recruitment_job_params - params.require(:recruitment_job).permit! + par = params.require(:recruitment_job).permit! + par[:skills] = par[:skills].split(",") if par[:skills].present? + par[:skills].collect!{|sk| sk.strip} + par end end \ No newline at end of file diff --git a/app/models/employer_profile.rb b/app/models/employer_profile.rb index d54b443..f346b61 100644 --- a/app/models/employer_profile.rb +++ b/app/models/employer_profile.rb @@ -14,6 +14,7 @@ class EmployerProfile field :country_code field :phone_number field :mobile_number + field :industry mount_uploader :avatar, ImageUploader diff --git a/app/models/recruitment_category.rb b/app/models/recruitment_category.rb new file mode 100644 index 0000000..ee90af5 --- /dev/null +++ b/app/models/recruitment_category.rb @@ -0,0 +1,6 @@ +class RecruitmentCategory + include Mongoid::Document + include Mongoid::Timestamps + + field :job_category, localize: true +end \ No newline at end of file diff --git a/app/models/recruitment_industry.rb b/app/models/recruitment_industry.rb new file mode 100644 index 0000000..e7cebf4 --- /dev/null +++ b/app/models/recruitment_industry.rb @@ -0,0 +1,6 @@ +class RecruitmentIndustry + include Mongoid::Document + include Mongoid::Timestamps + + field :industry_title, localize: true +end \ No newline at end of file diff --git a/app/models/recruitment_job.rb b/app/models/recruitment_job.rb index 52bdfdf..bd72ccc 100644 --- a/app/models/recruitment_job.rb +++ b/app/models/recruitment_job.rb @@ -19,7 +19,7 @@ class RecruitmentJob field :work_experience_months, type: Integer field :academic_requirement field :language_requirement - field :tools_requirement + field :skills, type: Array, :default => [] field :category field :location_of_work field :industrial_area diff --git a/app/views/admin/recruitments/addcategory.html.erb b/app/views/admin/recruitments/addcategory.html.erb new file mode 100644 index 0000000..cf2865c --- /dev/null +++ b/app/views/admin/recruitments/addcategory.html.erb @@ -0,0 +1,14 @@ +<%= form_for @category, :url => {:action => "createcategory"}, html: {:class => "form-horizontal", :id => "category_form"} do |f| %> +
+ <% @site_in_use_locales.each do |locale| %> + <%= f.fields_for :job_category_translations do |fe| %> +
+ <%= fe.label locale, t("recruitment.job_category") + " (" + t("#{locale}") + ")", :class => "control-label" %> +
+ <%= fe.text_field locale %> +
+
+ <% end %> + <% end %> +
+<% end %> \ No newline at end of file diff --git a/app/views/admin/recruitments/addindustry.html.erb b/app/views/admin/recruitments/addindustry.html.erb new file mode 100644 index 0000000..6c8bc8f --- /dev/null +++ b/app/views/admin/recruitments/addindustry.html.erb @@ -0,0 +1,14 @@ +<%= form_for @industry, :url => {:action => "createindustry"}, html: {:class => "form-horizontal", :id => "industry_form"} do |f| %> +
+ <% @site_in_use_locales.each do |locale| %> + <%= f.fields_for :industry_title_translations do |fe| %> +
+ <%= fe.label locale, t("recruitment.industry_title") + " (" + t("#{locale}") + ")", :class => "control-label" %> +
+ <%= fe.text_field locale %> +
+
+ <% end %> + <% end %> +
+<% end %> \ No newline at end of file diff --git a/app/views/admin/recruitments/categories.html.erb b/app/views/admin/recruitments/categories.html.erb new file mode 100644 index 0000000..0e5e75d --- /dev/null +++ b/app/views/admin/recruitments/categories.html.erb @@ -0,0 +1,61 @@ + + + + + + + + + <% @categories.each do |category| %> + + + + <% end %> + +
Title
+ <%= category.job_category_translations["en"] %> / <%= category.job_category_translations["zh_tw"] %> + +
+
+
+ +
+ + + + + \ No newline at end of file diff --git a/app/views/admin/recruitments/editcategory.html.erb b/app/views/admin/recruitments/editcategory.html.erb new file mode 100644 index 0000000..674033e --- /dev/null +++ b/app/views/admin/recruitments/editcategory.html.erb @@ -0,0 +1,14 @@ +<%= form_for @category, :url => updatecategory_admin_recruitment_path(@category), html: {:class => "form-horizontal", :id => "category_form"} do |f| %> +
+ <% @site_in_use_locales.each do |locale| %> + <%= f.fields_for :job_category_translations do |fe| %> +
+ <%= fe.label locale, t("recruitment.job_category") + " (" + t("#{locale}") + ")", :class => "control-label" %> +
+ <%= fe.text_field locale, :value => @category.job_category_translations[locale.to_s] %> +
+
+ <% end %> + <% end %> +
+<% end %> \ No newline at end of file diff --git a/app/views/admin/recruitments/editindustry.html.erb b/app/views/admin/recruitments/editindustry.html.erb new file mode 100644 index 0000000..037cc7d --- /dev/null +++ b/app/views/admin/recruitments/editindustry.html.erb @@ -0,0 +1,14 @@ +<%= form_for @industry, :url => updateindustry_admin_recruitment_path(@industry), html: {:class => "form-horizontal", :id => "industry_form"} do |f| %> +
+ <% @site_in_use_locales.each do |locale| %> + <%= f.fields_for :industry_title_translations do |fe| %> +
+ <%= fe.label locale, t("recruitment.industry_title") + " (" + t("#{locale}") + ")", :class => "control-label" %> +
+ <%= fe.text_field locale, :value => @industry.industry_title_translations[locale.to_s] %> +
+
+ <% end %> + <% end %> +
+<% end %> \ No newline at end of file diff --git a/app/views/admin/recruitments/industries.html.erb b/app/views/admin/recruitments/industries.html.erb new file mode 100644 index 0000000..4856a0b --- /dev/null +++ b/app/views/admin/recruitments/industries.html.erb @@ -0,0 +1,61 @@ + + + + + + + + + <% @industries.each do |industry| %> + + + + <% end %> + +
Title
+ <%= industry.industry_title_translations["en"] %> / <%= industry.industry_title_translations["zh_tw"] %> + +
+
+
+ +
+ + + + + \ No newline at end of file diff --git a/app/views/recruitments/_employer_form.html.erb b/app/views/recruitments/_employer_form.html.erb index 2d8ad87..b8552fe 100644 --- a/app/views/recruitments/_employer_form.html.erb +++ b/app/views/recruitments/_employer_form.html.erb @@ -63,11 +63,19 @@ <%= f.fields_for :employer_profile do |fe| %> + +
+ <%= fe.label :industry, "Industry", :class => "col-sm-2 control-label" %> +
+ <%= fe.select :industry, RecruitmentIndustry.all.collect{|ri| [ri.industry_title, ri.id.to_s]}, {:include_blank => "Select Industry"}, {:class => "form-control"} %> +
+
+
<%= fe.label :country, "Country", :class => "col-sm-2 control-label" %>
- <%= fe.select :country, MiscList.countries_for_select, :class => "form-control" %> + <%= fe.select :country, MiscList.countries_for_select, {:include_blank => "Select Country"}, {:class => "form-control"} %>
diff --git a/app/views/recruitments/_job_form.html.erb b/app/views/recruitments/_job_form.html.erb index b261750..33db05a 100644 --- a/app/views/recruitments/_job_form.html.erb +++ b/app/views/recruitments/_job_form.html.erb @@ -60,6 +60,14 @@ <% end %>
+ + +
+ <%= f.label :category, "Category", :class => "col-sm-2 control-label" %> +
+ <%= f.select :category, RecruitmentCategory.all.collect{|rc| [rc.job_category,rc.id.to_s]}, {:include_blank => "Select Category"},{:class => "form-control"} %> +
+
@@ -212,9 +220,9 @@
- <%= f.label :tools_requirement, "Tools Requirement", :class => "col-sm-2 control-label" %> + <%= f.label :tools_requirement, "Skills", :class => "col-sm-2 control-label" %>
- <%= f.text_field :tools_requirement, :class => "form-control", :placeholder => "Seperate with (,) ex; Word, Excel" %> + <%= f.text_field :skills, :class => "form-control", :placeholder => "Seperate with (,) ex; Word, Excel", :value => @job.skills.join(", ") %>
@@ -222,6 +230,7 @@
<%= f.hidden_field :employer_profile_id, :value => @profile.profile.id %> <%= f.submit "Submit", :class =>"btn btn-primary" %> + Cancel
diff --git a/config/locales/en.yml b/config/locales/en.yml index dc47ac5..65cc22f 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -5,4 +5,9 @@ en: recruitment: Recruitment select_a_profile: Please select a profile employee: Employee - employer: Employer \ No newline at end of file + employer: Employer + members: Members + industries: Industry Type + categories: Job Categories + industry_title: Industry Title + job_category: Job Category \ No newline at end of file diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index 32a6741..3a0e772 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -5,4 +5,9 @@ zh_tw: recruitment: Recruitment select_a_profile: Please select a profile employee: Employee - employer: Employer \ No newline at end of file + employer: Employer + members: Members + industries: Industry Type + categories: Job Categories + industry_title: Industry Title + job_category: Job Category \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index de05faa..82a3b1e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,6 +4,24 @@ Rails.application.routes.draw do scope "(:locale)", locale: Regexp.new(locales.join("|")) do namespace :admin do resources :recruitments do + collection do + get "industries" + get "categories" + get "addindustry" + post "createindustry" + + get "addcategory" + post "createcategory" + end + member do + delete "deleteindustry" + get "editindustry" + patch "updateindustry" + + delete "deletecategory" + get "editcategory" + patch "updatecategory" + end end end scope "recruit" do diff --git a/lib/recruitment/engine.rb b/lib/recruitment/engine.rb index 3f6689e..7ad646b 100644 --- a/lib/recruitment/engine.rb +++ b/lib/recruitment/engine.rb @@ -9,7 +9,7 @@ module Recruitment set_keyword_contstraints ["/recruit/"] side_bar do head_label_i18n 'recruitment.recruitment', icon_class: "icons-briefcase" - available_for "admin" + available_for "managers" active_for_controllers (['admin/recruitments']) head_link_path "admin_recruitments_path" @@ -17,7 +17,18 @@ module Recruitment :link_path=>"admin_recruitments_path" , :priority=>1, :active_for_action=>{'admin/recruitments'=>"index"}, - :available_for => 'admin' + :available_for => 'managers' + + context_link 'recruitment.industries', + :link_path=>"industries_admin_recruitments_path" , + :priority=>1, + :active_for_action=>{'admin/recruitments'=>"industries"}, + :available_for => 'managers' + context_link 'recruitment.categories', + :link_path=>"categories_admin_recruitments_path" , + :priority=>1, + :active_for_action=>{'admin/recruitments'=>"categories"}, + :available_for => 'managers' end end