diff --git a/app/assets/images/desktop/personal_project.svg b/app/assets/images/desktop/personal_project.svg new file mode 100644 index 0000000..e69de29 diff --git a/app/controllers/admin/projects_controller.rb b/app/controllers/admin/projects_controller.rb index d4acd30..0a35223 100644 --- a/app/controllers/admin/projects_controller.rb +++ b/app/controllers/admin/projects_controller.rb @@ -1,4 +1,5 @@ class Admin::ProjectsController < OrbitMemberController + include Admin::PersonalProjectsHelper layout "member_plugin" before_action :set_project, only: [:show, :edit , :update, :destroy] @@ -15,28 +16,48 @@ class Admin::ProjectsController < OrbitMemberController def new @member = MemberProfile.find_by(:uid=>params['uid']) rescue nil @project = Project.new + if params[:desktop] + render :layout => false + end end def create @member = MemberProfile.find(project_params['member_profile_id']) rescue nil @project = Project.new(project_params) @project.save - redirect_to params['referer_url'] + if params[:desktop] == "true" + render json: {"data" => get_paper_list}.to_json + else + redirect_to params['referer_url'] + end end def edit @member = @project.member_profile rescue nil + if params[:desktop] + render :layout => false + end end def update @member = @project.member_profile rescue nil @project.update_attributes(project_params) @project.save - redirect_to params['referer_url'] + if params[:desktop] == "true" + render json: {"data" => get_paper_list}.to_json + else + redirect_to params['referer_url'] + end end def destroy @project.destroy + respond_to do |format| + format.html { redirect_to(admin_projects_url) } + # format.xml { head :ok } + format.js + format.json {render json: {"success" => true}} + end end def toggle_hide diff --git a/app/controllers/desktop/personal_projects_controller.rb b/app/controllers/desktop/personal_projects_controller.rb new file mode 100644 index 0000000..1e2a99a --- /dev/null +++ b/app/controllers/desktop/personal_projects_controller.rb @@ -0,0 +1,23 @@ +class Desktop::PersonalProjectsController < DesktopAdminController + include Admin::PersonalProjectsHelper + + def menu + user = OrbitHelper.current_user + [ + { + "title" => "List", + "layout" => "list" + }, + { + "title" => "Add/Edit", + "layout" => "form", + "new_path" => "/admin/members/#{user.member_profile.to_param}/projects/new" + } + ] + end + + def list + get_paper_list + end + +end \ No newline at end of file diff --git a/app/helpers/admin/personal_projects_helper.rb b/app/helpers/admin/personal_projects_helper.rb new file mode 100644 index 0000000..9b0453c --- /dev/null +++ b/app/helpers/admin/personal_projects_helper.rb @@ -0,0 +1,29 @@ +module Admin::PersonalProjectsHelper + + def get_paper_list + user = current_user.nil? ? OrbitHelper.current_user : current_user + user_profile = user.member_profile + projects = Project.where(:member_profile_id => user_profile.id) + projects = projects.collect do |p| + files = p.project_files.collect do |pf| + { + "title" => pf.title, + "description" => pf.description, + "link" => pf.file.url, + "extension" => (pf.file.url.split(".").last rescue "") + } + end + + { + "id" => p.id.to_s, + "edit_url" => "/#{I18n.locale.to_s}/admin/members/#{user_profile.to_param}/projects/#{p.to_param}/edit", + "delete_url" => "/#{I18n.locale.to_s}/admin/projects/#{p.id.to_s}", + "paper_title" => p.project_title, + "keywords" => p.keywords, + "abstract" => p.abstract, + "files" => files + } + end + projects + end +end \ No newline at end of file diff --git a/app/views/admin/projects/_form.html.erb b/app/views/admin/projects/_form.html.erb index b9901ae..7a79ff0 100644 --- a/app/views/admin/projects/_form.html.erb +++ b/app/views/admin/projects/_form.html.erb @@ -7,7 +7,7 @@ <% 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/bootstrap-fileupload" %> <%= javascript_include_tag "lib/file-type" %> <%= javascript_include_tag "lib/module-area" %> <% end %> @@ -15,7 +15,7 @@
- +
@@ -63,7 +63,7 @@
<%= f.datetime_picker :period_start_date, :no_label => true, :format=>"yyyy/MM" %>
-
+
@@ -71,7 +71,7 @@
<%= f.datetime_picker :period_end_date, :no_label => true, :format=>"yyyy/MM" %>
-
+
@@ -79,7 +79,7 @@
<%= f.text_field :url , :class => "span5" %>
-
+
@@ -87,7 +87,7 @@
<%= f.text_field :keywords %>
-
+
@@ -99,7 +99,7 @@ <% end %>
- +
@@ -107,7 +107,7 @@
<%= f.text_area :abstract, rows: 2, class: "input-block-level" %>
-
+ @@ -140,13 +140,13 @@
<% @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 %> @@ -156,7 +156,7 @@
-
+
<%= 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 %> @@ -166,7 +166,7 @@
-
+
<%= 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 %> @@ -176,7 +176,7 @@
-
+
<%= 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 %> @@ -191,7 +191,7 @@ <%= f.text_area locale, rows: 2, class: "input-block-level", value: (@project.note_translations[locale] rescue nil) %> <% end %>
-
+
@@ -209,7 +209,7 @@ <%= f.fields_for :project_files, project_file do |f| %> <%= render :partial => 'form_file', :object => project_file, :locals => {:f => f, :i => i} %> <% end %> - <% end %> + <% end %>
<% end %> @@ -233,34 +233,30 @@ <%= 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" %> + <%= link_to t('cancel'), get_go_back, :class=>"btn" %>
-<% content_for :page_specific_javascript do %> - -<% end %> \ No newline at end of file + formTip(); + $('.add-on').tooltip(); + } else if($(this).hasClass('delete_file')) { + $(this).parents('.input-prepend').remove(); + } else if($(this).hasClass('remove_existing_record')) { + if(confirm("<%= I18n.t(:sure?)%>")){ + $(this).children('.should_destroy').attr('value', 1); + $(this).parents('.start-line').hide(); + } + } + }); + \ No newline at end of file diff --git a/lib/personal_project/engine.rb b/lib/personal_project/engine.rb index a584bb6..cb40854 100644 --- a/lib/personal_project/engine.rb +++ b/lib/personal_project/engine.rb @@ -7,6 +7,7 @@ module PersonalProject 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" + desktop_enabled true organization "Rulingcom" author "RD dep" intro "I am intro"