diff --git a/app/assets/images/desktop/personal_research.svg b/app/assets/images/desktop/personal_research.svg new file mode 100644 index 0000000..e69de29 diff --git a/app/controllers/admin/researchs_controller.rb b/app/controllers/admin/researchs_controller.rb index acb6856..206105c 100644 --- a/app/controllers/admin/researchs_controller.rb +++ b/app/controllers/admin/researchs_controller.rb @@ -1,4 +1,5 @@ class Admin::ResearchsController < OrbitMemberController + include Admin::PersonalResearchesHelper layout "member_plugin" before_action :set_research, only: [:show, :edit , :update, :destroy] @@ -15,28 +16,48 @@ class Admin::ResearchsController < OrbitMemberController def new @member = MemberProfile.find_by(:uid=>params['uid']) rescue nil @research = Research.new + if params[:desktop] + render :layout => false + end end def create @member = MemberProfile.find(research_params['member_profile_id']) rescue nil @research = Research.new(research_params) @research.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 = @research.member_profile rescue nil + if params[:desktop] + render :layout => false + end end def update @member = @research.member_profile rescue nil @research.update_attributes(research_params) @research.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 @research.destroy + respond_to do |format| + format.html { redirect_to(admin_researchs_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_researches_controller.rb b/app/controllers/desktop/personal_researches_controller.rb new file mode 100644 index 0000000..67d660a --- /dev/null +++ b/app/controllers/desktop/personal_researches_controller.rb @@ -0,0 +1,23 @@ +class Desktop::PersonalResearchesController < DesktopAdminController + include Admin::PersonalResearchesHelper + + def menu + user = OrbitHelper.current_user + [ + { + "title" => "List", + "layout" => "list" + }, + { + "title" => "Add/Edit", + "layout" => "form", + "new_path" => "/admin/members/#{user.member_profile.to_param}/researchs/new" + } + ] + end + + def list + get_paper_list + end + +end \ No newline at end of file diff --git a/app/helpers/admin/personal_researches_helper.rb b/app/helpers/admin/personal_researches_helper.rb new file mode 100644 index 0000000..d98f92b --- /dev/null +++ b/app/helpers/admin/personal_researches_helper.rb @@ -0,0 +1,28 @@ +module Admin::PersonalResearchesHelper + + def get_paper_list + user = current_user.nil? ? OrbitHelper.current_user : current_user + user_profile = user.member_profile + researchs = Research.where(:member_profile_id => user_profile.id) + researchs = researchs.collect do |r| + files = r.research_files.collect do |rf| + { + "title" => rf.title, + "description" => rf.description, + "link" => rf.file.url, + "extension" => (rf.file.url.split(".").last rescue "") + } + end + + { + "id" => r.id.to_s, + "edit_url" => "/#{I18n.locale.to_s}/admin/members/#{user_profile.to_param}/researchs/#{r.to_param}/edit", + "delete_url" => "/#{I18n.locale.to_s}/admin/researchs/#{r.id.to_s}", + "paper_title" => r.research_title, + "keywords" => r.keywords, + "files" => files + } + end + researchs + end +end \ No newline at end of file diff --git a/app/views/admin/researchs/_form.html.erb b/app/views/admin/researchs/_form.html.erb index 3f2699e..353877b 100644 --- a/app/views/admin/researchs/_form.html.erb +++ b/app/views/admin/researchs/_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 @@
- +
@@ -55,7 +55,7 @@
<%= f.datetime_picker :publish_date, :no_label => true, :format=>"yyyy/MM" %>
-
+
@@ -63,7 +63,7 @@
<%= f.text_field :keywords %>
-
+
@@ -75,7 +75,7 @@ <% end %>
- +
@@ -83,7 +83,7 @@
<%= f.text_field :url , :class => "span6" %>
-
+
@@ -91,7 +91,7 @@
<%= f.text_area :note, rows: 2, class: "input-block-level" %>
-
+ @@ -123,13 +123,13 @@
<% @site_in_use_locales.each_with_index do |locale, i| %> - +
">
-
+
<%= f.fields_for :research_title_translations do |f| %> <%= f.text_field locale, class: "input-block-level", placeholder: t("personal_research.research_title"), value: (@research.research_title_translations[locale] rescue nil) %> <% end %> @@ -139,7 +139,7 @@
-
+
<%= f.fields_for :extracted_chapters_translations do |f| %> <%= f.text_field locale, class: "input-block-level", placeholder: t("personal_research.extracted_chapters"), value: (@research.extracted_chapters_translations[locale] rescue nil) %> <% end %> @@ -149,7 +149,7 @@
-
+
<%= f.fields_for :authors_translations do |f| %> <%= f.text_field locale, class: "input-block-level", placeholder: t("personal_research.authors"), value: (@research.authors_translations[locale] rescue nil) %> <% end %> @@ -172,7 +172,7 @@ <%= f.fields_for :research_files, research_file do |f| %> <%= render :partial => 'form_file', :object => research_file, :locals => {:f => f, :i => i} %> <% end %> - <% end %> + <% end %>
<% end %> @@ -196,34 +196,29 @@ <%= 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 + $('.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_research/engine.rb b/lib/personal_research/engine.rb index 5c9df52..be237b7 100644 --- a/lib/personal_research/engine.rb +++ b/lib/personal_research/engine.rb @@ -6,6 +6,7 @@ module PersonalResearch base_url File.expand_path File.dirname(__FILE__) personal_plugin :enable => true, :sort_number => '20', :app_name=>"Research", :intro_app_name=>"PersonalResearchIntro",:path=>"/plugin/personal_research/profile",:front_path=>"/profile",:admin_path=>"/admin/researchs",:i18n=>'module_name.personal_research', :module_app_name=>"PersonalResearch" version "0.1" + desktop_enabled true organization "Rulingcom" author "RD dep" intro "I am intro"