From a68cba924b0624fa48e0cfa04968c5dfb3f44ba7 Mon Sep 17 00:00:00 2001 From: manson Date: Fri, 4 Jul 2014 14:14:37 +0800 Subject: [PATCH] Finished --- .../admin/project_types_controller.rb | 41 +++ app/controllers/admin/projects_controller.rb | 89 ++++++ .../personal_projects_controller.rb | 74 +++++ app/models/project.rb | 46 +++ app/models/project_file.rb | 14 + app/models/project_intro.rb | 4 + app/models/project_type.rb | 9 + app/views/admin/project_types/_form.html.erb | 24 ++ app/views/admin/project_types/_list.js.erb | 2 + app/views/admin/project_types/edit.js.erb | 1 + app/views/admin/project_types/new.js.erb | 1 + app/views/admin/projects/_form.html.erb | 262 ++++++++++++++++++ app/views/admin/projects/_form_file.html.erb | 55 ++++ .../projects/_list_project_type.html.erb | 8 + app/views/admin/projects/_project.html.erb | 18 ++ app/views/admin/projects/destroy.js.erb | 1 + app/views/admin/projects/edit.html.erb | 5 + .../admin/projects/frontend_setting.html.erb | 93 +++++++ app/views/admin/projects/index.html.erb | 23 ++ app/views/admin/projects/new.html.erb | 5 + app/views/admin/projects/setting.html.erb | 52 ++++ app/views/personal_projects/index.html.erb | 1 + app/views/personal_projects/show.html.erb | 1 + .../plugin/personal_project/_profile.html.erb | 84 ++++++ config/routes.rb | 22 ++ lib/personal_project/engine.rb | 4 +- 26 files changed, 938 insertions(+), 1 deletion(-) create mode 100644 app/controllers/admin/project_types_controller.rb create mode 100644 app/controllers/admin/projects_controller.rb create mode 100644 app/controllers/personal_projects_controller.rb create mode 100644 app/models/project.rb create mode 100644 app/models/project_file.rb create mode 100644 app/models/project_intro.rb create mode 100644 app/models/project_type.rb create mode 100644 app/views/admin/project_types/_form.html.erb create mode 100644 app/views/admin/project_types/_list.js.erb create mode 100644 app/views/admin/project_types/edit.js.erb create mode 100644 app/views/admin/project_types/new.js.erb create mode 100644 app/views/admin/projects/_form.html.erb create mode 100644 app/views/admin/projects/_form_file.html.erb create mode 100644 app/views/admin/projects/_list_project_type.html.erb create mode 100644 app/views/admin/projects/_project.html.erb create mode 100644 app/views/admin/projects/destroy.js.erb create mode 100644 app/views/admin/projects/edit.html.erb create mode 100644 app/views/admin/projects/frontend_setting.html.erb create mode 100644 app/views/admin/projects/index.html.erb create mode 100644 app/views/admin/projects/new.html.erb create mode 100644 app/views/admin/projects/setting.html.erb create mode 100644 app/views/personal_projects/index.html.erb create mode 100644 app/views/personal_projects/show.html.erb create mode 100644 app/views/plugin/personal_project/_profile.html.erb diff --git a/app/controllers/admin/project_types_controller.rb b/app/controllers/admin/project_types_controller.rb new file mode 100644 index 0000000..8fbde4b --- /dev/null +++ b/app/controllers/admin/project_types_controller.rb @@ -0,0 +1,41 @@ +class Admin::ProjectTypesController < OrbitAdminController + def new + @project_type = ProjectType.new + @url = admin_project_types_path(@project_type) + render :layout=>false + end + + def create + @project_type = ProjectType.new(project_type_params) + @project_type.save + @project_types = ProjectType.all + render :partial=>'list', :layout=>false + end + + def edit + @project_type = ProjectType.find(params[:id]) + @url = admin_project_type_path(@project_type) + render :layout=>false + end + + def update + @project_type = ProjectType.find(params[:id]) + @project_type.update_attributes(project_type_params) + @project_type.save + @project_types = ProjectType.all + render :partial=>'list', :layout=>false + end + + def destroy + project_type = ProjectType.find(params[:id]) + project_type.destroy + @project_types = ProjectType.all + render :partial=>'list', :layout=>false + end + + private + + def project_type_params + params.require(:project_type).permit! rescue nil + end +end \ No newline at end of file diff --git a/app/controllers/admin/projects_controller.rb b/app/controllers/admin/projects_controller.rb new file mode 100644 index 0000000..6f4d1b0 --- /dev/null +++ b/app/controllers/admin/projects_controller.rb @@ -0,0 +1,89 @@ +class Admin::ProjectsController < OrbitMemberController + layout "member_plugin" + + before_action :set_plugin + before_action :get_settings,:only => [:new, :edit, :setting] + + def index + @projects = Project.all + end + + def new + @member = MemberProfile.find_by(:uid=>params['uid']) rescue nil + @project = Project.new + end + + def create + @member = MemberProfile.find(project_params['member_profile_id']) rescue nil + @project = Project.new(project_params) + @project.save + redirect_to '/admin/members/'+@member.to_param+'/Project' + end + + def edit + @member = MemberProfile.find_by(:uid=>params['uid']) rescue nil + @project = Project.find(params[:id]) + end + + def update + @member = MemberProfile.find(project_params['member_profile_id']) rescue nil + @project = Project.find(params[:id]) + @project.update_attributes(project_params) + @project.save + redirect_to '/admin/members/'+@member.to_param+'/Project' + end + + def destroy + @project = Project.find(params[:id]) + @project.destroy + end + + def toggle_hide + if params[:ids] + @projects = Project.any_in(_id: params[:ids]) + + @projects.each do |project| + project.is_hidden = params[:disable] + project.save + end + end + + render json: {"success"=>true} + end + + def setting + end + + def frontend_setting + @member = MemberProfile.find_by(:uid=>params['uid']) rescue nil + @intro = ProjectIntro.find_by(:member_profile_id=>@member.id) rescue nil + @intro = @intro.nil? ? ProjectIntro.new({:member_profile_id=>@member.id}) : @intro + end + + def update_frontend_setting + @member = MemberProfile.find(intro_params['member_profile_id']) rescue nil + @intro = ProjectIntro.find_by(:member_profile_id=>@member.id) rescue nil + @intro = @intro.nil? ? ProjectIntro.new({:member_profile_id=>@member.id}) : @intro + @intro.update_attributes(intro_params) + @intro.save + redirect_to '/admin/members/'+@member.to_param+'/Project' + end + + def get_settings + @project_types = ProjectType.all + end + + def set_plugin + @plugin = OrbitApp::Plugin::Registration.all.select{|plugin| plugin.app_name.eql? 'Project'}.first + end + + private + + def project_params + params.require(:project).permit! rescue nil + end + + def intro_params + params.require(:project_intro).permit! rescue nil + end +end \ No newline at end of file diff --git a/app/controllers/personal_projects_controller.rb b/app/controllers/personal_projects_controller.rb new file mode 100644 index 0000000..6d7b8c6 --- /dev/null +++ b/app/controllers/personal_projects_controller.rb @@ -0,0 +1,74 @@ +class PersonalProjectsController < ApplicationController + def index + projects = Project.where(:is_hidden=>false).all + project_list = projects.collect do |project| + { + "duration" => project.duration, + "project_title" => project.project_title, + "job_title" => project.job_title, + "participator" => project.participator, + "authors" => project.member_profile.name, + "link_to_show" => OrbitHelper.url_to_show(project.to_param) + } + end + { + "projects" => project_list, + "extras" => { + "widget-title" => t("module_name.personal_project"), + "th_duration" => t('personal_project.period'), + "th_project_title" => t("personal_project.project_title"), + "th_job_title" => t('personal_project.job_title'), + "th_participator" => t("personal_project.participator"), + "th_authors" => t('users.name') + } + } + end + + def show + params = OrbitHelper.params + project = Project.where(:is_hidden=>false).find_by(uid: params[:uid]) + + files = project.project_files.map do |file| + { + "file_url" => file.file.url, + "file_title" => (file.title.blank? ? File.basename(file.file.path) : file.title), + "file_ext" => File.extname(file.file.path).sub('.',''), + "file_description" => file.description + } + end + + { + "files" => files, + + "data" => { + "project_title" => project.project_title, + "project_type" => project.project_type.title, + "job_title" => project.job_title, + "participator" => project.participator, + "unit" => project.unit, + "year" => project.year, + "language" => project.language, + "keywords" => project.keywords, + "abstract" => project.abstract, + "duration" => project.duration, + "url" => project.url, + "note" => project.note, + + "th_project_title" => t("personal_project.project_title"), + "th_job_title" => t("personal_project.job_title"), + "th_participator" => t("personal_project.participator"), + "th_unit" => t("personal_project.unit"), + "th_year" => t("personal_project.year"), + "th_language" => t("personal_project.language"), + "th_keywords" => t("personal_project.keywords"), + "th_abstract" => t("personal_project.abstract"), + "th_duration" => t("personal_project.period"), + "th_url" => t("personal_project.url"), + "th_note" => t("personal_project.note"), + + "th_project_type" => t("personal_project.project_category"), + "th_files" => t(:file_) + } + } + end +end \ No newline at end of file diff --git a/app/models/project.rb b/app/models/project.rb new file mode 100644 index 0000000..4290efd --- /dev/null +++ b/app/models/project.rb @@ -0,0 +1,46 @@ +class Project + include Mongoid::Document + include Mongoid::Timestamps + include OrbitModel::Status + include Slug + + belongs_to :project_type + belongs_to :member_profile + + field :project_title, as: :slug_title, localize: true + field :job_title, localize: true + field :participator, localize: true + field :unit, localize: true + + field :year + field :language + field :keywords + field :abstract + field :period_start_date, :type => Date + field :period_end_date, :type => Date + field :url + field :note + field :create_user_id, :type => BSON::ObjectId + field :update_user_id, :type => BSON::ObjectId + + paginates_per 10 + + has_many :project_files, :autosave => true, :dependent => :destroy + + accepts_nested_attributes_for :project_files, :allow_destroy => true + + before_validation :add_http + + def duration + "#{self.period_start_date.strftime("%Y.%m")} ~ #{self.period_end_date.strftime("%Y.%m")}" + end + + protected + + def add_http + unless self.url.blank? || self.url[/^http:\/\//] || self.url[/^https:\/\//] + self.url = 'http://' + self.url + end + end + +end \ No newline at end of file diff --git a/app/models/project_file.rb b/app/models/project_file.rb new file mode 100644 index 0000000..d4706f0 --- /dev/null +++ b/app/models/project_file.rb @@ -0,0 +1,14 @@ +class ProjectFile + + include Mongoid::Document + include Mongoid::Timestamps + + mount_uploader :file, AssetUploader + + field :description, localize: true + field :should_destroy, :type => Boolean + field :title, localize: true + + belongs_to :project + +end diff --git a/app/models/project_intro.rb b/app/models/project_intro.rb new file mode 100644 index 0000000..d155014 --- /dev/null +++ b/app/models/project_intro.rb @@ -0,0 +1,4 @@ +class ProjectIntro < PersonalPluginIntro + + +end diff --git a/app/models/project_type.rb b/app/models/project_type.rb new file mode 100644 index 0000000..d2811fb --- /dev/null +++ b/app/models/project_type.rb @@ -0,0 +1,9 @@ +class ProjectType + include Mongoid::Document + include Mongoid::Timestamps + + field :title, localize: true + + has_many :projects + +end \ No newline at end of file diff --git a/app/views/admin/project_types/_form.html.erb b/app/views/admin/project_types/_form.html.erb new file mode 100644 index 0000000..d9b14dd --- /dev/null +++ b/app/views/admin/project_types/_form.html.erb @@ -0,0 +1,24 @@ +<%= form_for(@project_type, :html =>{:class=>"form-horizontal", :style=>"margin: 0;"}, :remote => true, :url => @url ) do |f| %> + + + + + +<% end %> \ No newline at end of file diff --git a/app/views/admin/project_types/_list.js.erb b/app/views/admin/project_types/_list.js.erb new file mode 100644 index 0000000..53f8e8b --- /dev/null +++ b/app/views/admin/project_types/_list.js.erb @@ -0,0 +1,2 @@ +$('#project_types tbody').html("<%= j render :partial => '/admin/projects/list_project_type', :collection => @project_types %>"); +$('#project_type_modal').modal('hide'); \ No newline at end of file diff --git a/app/views/admin/project_types/edit.js.erb b/app/views/admin/project_types/edit.js.erb new file mode 100644 index 0000000..5e34a1d --- /dev/null +++ b/app/views/admin/project_types/edit.js.erb @@ -0,0 +1 @@ +$('#project_type_modal').html("<%= j render 'form' %>"); \ No newline at end of file diff --git a/app/views/admin/project_types/new.js.erb b/app/views/admin/project_types/new.js.erb new file mode 100644 index 0000000..5e34a1d --- /dev/null +++ b/app/views/admin/project_types/new.js.erb @@ -0,0 +1 @@ +$('#project_type_modal').html("<%= j render 'form' %>"); \ No newline at end of file diff --git a/app/views/admin/projects/_form.html.erb b/app/views/admin/projects/_form.html.erb new file mode 100644 index 0000000..ce0069f --- /dev/null +++ b/app/views/admin/projects/_form.html.erb @@ -0,0 +1,262 @@ +<% # encoding: utf-8 %> +<% content_for :page_specific_css do %> + <%= stylesheet_link_tag "lib/main-forms" %> + <%= stylesheet_link_tag "lib/fileupload" %> + <%= stylesheet_link_tag "lib/main-list" %> +<% end %> +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "lib/bootstrap-datetimepicker" %> + <%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %> + <%= javascript_include_tag "lib/bootstrap-fileupload" %> + <%= javascript_include_tag "lib/file-type" %> + <%= javascript_include_tag "lib/module-area" %> +<% end %> + + +
+ + + + + + +
+ + +
+ +
+ +
+ <%= @member.name rescue ''%> + <%= f.hidden_field :member_profile_id, :value => @member.id %> +
+
+ + +
+ +
+ <%= select_year((@project.year ? @project.year.to_i : DateTime.now.year), {:start_year => DateTime.now.year, :end_year => 1930}, {:name => 'project[year]',:class => 'span1'} ) %> +
+
+ + +
+ +
+ <%= f.select :project_type_id, @project_types.collect {|t| [ t.title, t.id ]} %> +
+
+ + +
+ +
+ <%= f.datetime_picker :period_start_date, :no_label => true, :format=>"yyyy/MM" %> +
+
+ + +
+ +
+ <%= f.datetime_picker :period_end_date, :no_label => true, :format=>"yyyy/MM" %> +
+
+ + +
+ +
+ <%= f.text_field :url , :class => "span5" %> +
+
+ + +
+ +
+ <%= f.text_field :keywords %> +
+
+ + +
+ +
+ +
+
+ + +
+ +
+ <%= f.text_area :abstract, rows: 2, class: "input-block-level" %> +
+
+ + +
+ +
+ <%= f.text_area :note, rows: 2, class: "input-block-level" %> +
+
+ +
+ + +
+
+ +
+ +
+
+
+ +
+ + + + + + +
+ + <% @site_in_use_locales.each_with_index do |locale, i| %> + +
"> + + +
+ +
+ <%= f.fields_for :project_title_translations do |f| %> + <%= f.text_field locale, class: "input-block-level", placeholder: t("personal_project.project_title"), value: (@project.project_title_translations[locale] rescue nil) %> + <% end %> +
+
+ + +
+ +
+ <%= f.fields_for :job_title_translations do |f| %> + <%= f.text_field locale, class: "input-block-level", placeholder: t("personal_project.job_title"), value: (@project.job_title_translations[locale] rescue nil) %> + <% end %> +
+
+ + +
+ +
+ <%= f.fields_for :participator_translations do |f| %> + <%= f.text_field locale, class: "input-block-level", placeholder: t("personal_project.participator"), value: (@project.participator_translations[locale] rescue nil) %> + <% end %> +
+
+ + +
+ +
+ <%= f.fields_for :unit_translations do |f| %> + <%= f.text_field locale, class: "input-block-level", placeholder: t("personal_project.unit"), value: (@project.unit_translations[locale] rescue nil) %> + <% end %> +
+
+ +
+ + <% end %> + + +
+ +
+ + + <% if @project && !@project.project_files.blank? %> +
+ <% @project.project_files.each_with_index do |project_file, i| %> + <%= f.fields_for :project_files, project_file do |f| %> + <%= render :partial => 'form_file', :object => project_file, :locals => {:f => f, :i => i} %> + <% end %> + <% end %> +
+
+ <% end %> + + +
+
+

+ <%= hidden_field_tag 'plugin_file_field_count', @project.project_files.count %> + <%= t(:add) %> +

+ +
+
+ +
+
+ + +
+ <%= f.hidden_field :user_id, :value => params[:user_id] if !params[:user_id].blank? %> + <%= f.submit t('submit'), class: 'btn btn-primary' %> + <%= link_to t('cancel'), get_go_back, :class=>"btn" %> +
+ +<% content_for :page_specific_javascript do %> + +<% end %> \ No newline at end of file diff --git a/app/views/admin/projects/_form_file.html.erb b/app/views/admin/projects/_form_file.html.erb new file mode 100644 index 0000000..8628623 --- /dev/null +++ b/app/views/admin/projects/_form_file.html.erb @@ -0,0 +1,55 @@ +<% if form_file.new_record? %> +
+<% else %> +
+ <% if form_file.file.blank? %> + <%= t(:no_file) %> + <% else %> + <%= link_to content_tag(:i) + form_file.file_identifier, form_file.file.url, {:class => 'file-link file-type', :target => '_blank', :title => form_file.file_identifier} %> + <% end %> +<% end %> +
+ + + + <% @site_in_use_locales.each_with_index do |locale, i| %> + <%= locale %>"> + <%= f.fields_for :title_translations do |f| %> + <%= f.text_field locale, :class => "input-medium", placeholder: t(:alternative), :value => (form_file.title_translations[locale] rescue nil) %> + <% end %> + + <% end %> + + + + <% @site_in_use_locales.each_with_index do |locale, i| %> + <%= locale %>"> + <%= f.fields_for :description_translations do |f| %> + <%= f.text_field locale, :class => "input-medium", placeholder: t(:description), :value => (form_file.description_translations[locale] rescue nil) %> + <% end %> + + <% end %> + + + <% if form_file.new_record? %> + + + + <% else %> + + <%= f.hidden_field :id %> + + <%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %> + + <% end %> +
+
\ No newline at end of file diff --git a/app/views/admin/projects/_list_project_type.html.erb b/app/views/admin/projects/_list_project_type.html.erb new file mode 100644 index 0000000..3a916cd --- /dev/null +++ b/app/views/admin/projects/_list_project_type.html.erb @@ -0,0 +1,8 @@ + + <%= list_project_type.title %> + + + <%= t(:edit) %> + <%= link_to t(:delete_), admin_project_type_path(list_project_type), "data-confirm" => t('sure?'), :method => :delete, :remote => true,:class=>"archive_toggle action" %> + + \ No newline at end of file diff --git a/app/views/admin/projects/_project.html.erb b/app/views/admin/projects/_project.html.erb new file mode 100644 index 0000000..5b23138 --- /dev/null +++ b/app/views/admin/projects/_project.html.erb @@ -0,0 +1,18 @@ +<% @projects.each do |project| %> + "> + <%= project.duration %> + + <%= link_to project.project_title, OrbitHelper.url_to_plugin_show(project.to_param,'personal_project').to_s, target: "blank"%> +
+ +
+ + <%= project.job_title %> + <%= project.participator %> + <%= project.unit %> + <%= project.member_profile.name %> + +<% end %> \ No newline at end of file diff --git a/app/views/admin/projects/destroy.js.erb b/app/views/admin/projects/destroy.js.erb new file mode 100644 index 0000000..350f05d --- /dev/null +++ b/app/views/admin/projects/destroy.js.erb @@ -0,0 +1 @@ +$('#project_<%= @project.id.to_s%>').remove(); \ No newline at end of file diff --git a/app/views/admin/projects/edit.html.erb b/app/views/admin/projects/edit.html.erb new file mode 100644 index 0000000..6d5be9f --- /dev/null +++ b/app/views/admin/projects/edit.html.erb @@ -0,0 +1,5 @@ +<%= form_for @project, url:'/admin/projects/'+@project.id.to_s, html: {class: "form-horizontal main-forms previewable"} do |f| %> +
+ <%= render partial: 'form', locals: {f: f} %> +
+<% end %> \ No newline at end of file diff --git a/app/views/admin/projects/frontend_setting.html.erb b/app/views/admin/projects/frontend_setting.html.erb new file mode 100644 index 0000000..527e11b --- /dev/null +++ b/app/views/admin/projects/frontend_setting.html.erb @@ -0,0 +1,93 @@ +<% content_for :page_specific_css do %> + <%= stylesheet_link_tag "lib/main-forms" %> + <%= stylesheet_link_tag "lib/main-list" %> +<% end %> + +<%= form_for(:project_intro, :url => update_frontend_setting_admin_projects_path, :method => "post", html: {class: "form-horizontal main-forms previewable"} ) do |f| %> +
+ +
+ + + + + + +
+ +
+ <% if !@member.blank? %> +
+ +
+ <%= @member.name rescue ''%> + <%= f.hidden_field :member_profile_id, :value => @member.id %> +
+
+ <% end %> + +
+ +
+ <%= f.check_box :brief_intro, :checked => @intro.brief_intro %> <%= t("personal_plugins.brief_intro") %> + <%= f.check_box :complete_list, :checked => @intro.complete_list %> <%= t("personal_plugins.complete_list") %> +
+
+
+
+ + + + + + +
+ + <% @site_in_use_locales.each_with_index do |locale, i| %> + +
"> + + +
+ +
+
+ <%= f.fields_for :text_translations do |f| %> + <%= f.cktext_area locale, rows: 5, class: "input-block-level", :value => (@intro.text_translations[locale] rescue nil) %> + <% end %> +
+
+
+ + +
+ + <% end %> + + + +
+ + + +
+ + +
+ <%= f.hidden_field :user_id, :value => params[:user_id] if !params[:user_id].blank? %> + <%= f.submit t('submit'), class: 'btn btn-primary' %> + <%= link_to t('cancel'), get_go_back, :class=>"btn" %> +
+
+<% end %> \ No newline at end of file diff --git a/app/views/admin/projects/index.html.erb b/app/views/admin/projects/index.html.erb new file mode 100644 index 0000000..9c54e5f --- /dev/null +++ b/app/views/admin/projects/index.html.erb @@ -0,0 +1,23 @@ + + + + + + + + + + + + + <%= render :partial => 'project', :collection => @projects %> + +
<%= t('personal_project.period') %><%= t('personal_project.project_title') %><%= t('personal_project.job_title') %><%= t('personal_project.participator') %><%= t('personal_project.unit') %><%= t('users.name') %>
+ +
+
+ <%= link_to content_tag(:i, nil, :class => 'icon-cog icon-white') + t('setting'), admin_project_setting_path, :class => 'btn btn-primary pull-right' %> +
+ +
\ No newline at end of file diff --git a/app/views/admin/projects/new.html.erb b/app/views/admin/projects/new.html.erb new file mode 100644 index 0000000..4bc2cca --- /dev/null +++ b/app/views/admin/projects/new.html.erb @@ -0,0 +1,5 @@ +<%= form_for @project, url: admin_projects_path, html: {class: "form-horizontal main-forms previewable"} do |f| %> +
+ <%= render partial: 'form', locals: {f: f} %> +
+<% end %> \ No newline at end of file diff --git a/app/views/admin/projects/setting.html.erb b/app/views/admin/projects/setting.html.erb new file mode 100644 index 0000000..f7252ef --- /dev/null +++ b/app/views/admin/projects/setting.html.erb @@ -0,0 +1,52 @@ + + +
+
+
+

+ <%= t('add')%> + <%= t("personal_project.project_category") %> +

+
+
+
+
+
+
+
+
+
+
+ + + <%= render :partial => 'list_project_type', :collection => @project_types %> + +
+
+
+
+
+
+
+ +
+ +
\ No newline at end of file diff --git a/app/views/personal_projects/index.html.erb b/app/views/personal_projects/index.html.erb new file mode 100644 index 0000000..648b75c --- /dev/null +++ b/app/views/personal_projects/index.html.erb @@ -0,0 +1 @@ +<%= render_view %> \ No newline at end of file diff --git a/app/views/personal_projects/show.html.erb b/app/views/personal_projects/show.html.erb new file mode 100644 index 0000000..648b75c --- /dev/null +++ b/app/views/personal_projects/show.html.erb @@ -0,0 +1 @@ +<%= render_view %> \ No newline at end of file diff --git a/app/views/plugin/personal_project/_profile.html.erb b/app/views/plugin/personal_project/_profile.html.erb new file mode 100644 index 0000000..6dd2ff5 --- /dev/null +++ b/app/views/plugin/personal_project/_profile.html.erb @@ -0,0 +1,84 @@ +<% content_for :page_specific_css do %> + <%= stylesheet_link_tag "lib/list-check" %> +<% end %> +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "lib/list-check" %> +<% end %> + +<% + is_autorized_user = (current_user==@member.user || current_user.is_admin?) + if is_autorized_user + @projects = Project.where(member_profile_id: @member.id).desc(:year).page(params[:page]).per(10) + else + @projects = Project.where(is_hidden: false, member_profile_id: @member.id).desc(:year).page(params[:page]).per(10) + end +%> + +<% if is_autorized_user %> +
+
+ <%= link_to('Hide', '#', :class => "btn btn-mini list-active-btn disabled", "data-check-action" => "list-be-hide", :rel => toggle_hide_admin_projects_path(member_profile_id: params[:id], disable: 'true') ) %> + <%= link_to('Show', '#', :class => "btn btn-mini list-active-btn disabled", "data-check-action" => "list-be-show", :rel => toggle_hide_admin_projects_path(member_profile_id: params[:id], disable: 'false') ) %> +
+
+<% end -%> + + + + + <% if is_autorized_user %> + + <% end -%> + + + + + + + <% @projects.each do |project| %> + "> + <% if is_autorized_user %> + + <% end %> + + + + + <% end %> + +
<%= t('personal_project.year') %><%= t('personal_project.project_title') %><%= t('personal_project.job_title') %>
+ <%= check_box_tag 'to_change[]', project.id.to_s, false, :class => "list-check" %> + <%= project.year %> + <%= link_to project.project_title, OrbitHelper.url_to_plugin_show(project.to_param,'personal_project').to_s, target: "blank"%> +
+ +
+
<%= project.job_title %>
+ + +
+ <% if is_autorized_user %> +
+ <%= link_to content_tag(:i, nil, :class => 'icon-edit') +' '+ t('setting'),'/admin/members/'+@member.to_param+'/projects/frontend_setting', :class => 'btn btn-primary' %> + <%= link_to content_tag(:i, nil, :class => 'icon-plus') +' '+ t('new_'), + '/admin/members/'+@member.to_param+'/projects/new', :class => 'btn btn-primary' %> +
+ <% end %> + +
+ + \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index d96d9d4..2fe619e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2,6 +2,28 @@ Rails.application.routes.draw do locales = Site.find_by(site_active: true).in_use_locales rescue I18n.available_locales scope "(:locale)", locale: Regexp.new(locales.join("|")) do namespace :admin do + get 'project_setting' => "projects#setting" + + resources :projects do + collection do + get 'toggle_hide' => 'projects#toggle_hide' + end + end + + resources :members do + collection do + scope '(:name-:uid)' do + resources :projects do + collection do + get 'frontend_setting' => 'projects#frontend_setting' + post 'update_frontend_setting' => 'projects#update_frontend_setting' + end + end + end + end + end + + resources :project_types end end end diff --git a/lib/personal_project/engine.rb b/lib/personal_project/engine.rb index 6881b0b..015bc20 100644 --- a/lib/personal_project/engine.rb +++ b/lib/personal_project/engine.rb @@ -4,7 +4,7 @@ module PersonalProject OrbitApp.registration "PersonalProject",:type=> 'ModuleApp' do module_label 'module_name.personal_project' base_url File.expand_path File.dirname(__FILE__) - personal_plugin :enable => true, :sort_number => '15', :app_name=>"Project", :intro_app_name=>"PersonalProjectIntro",:path=>"/plugin/profile",:front_path=>"/profile",:admin_path=>"/admin/projects",:i18n=>'module_name.personal_project' + personal_plugin :enable => true, :sort_number => '15', :app_name=>"Project", :intro_app_name=>"PersonalProjectIntro",:path=>"/plugin/personal_project/profile",:front_path=>"/profile",:admin_path=>"/admin/projects",:i18n=>'module_name.personal_project', :module_app_name=>"PersonalProject" version "0.1" organization "Rulingcom" @@ -12,6 +12,8 @@ module PersonalProject intro "I am intro" update_info 'some update_info' + frontend_enabled + icon_class_no_sidebar "icons-user" end end end