diff --git a/app/assets/images/desktop/personal_patent.svg b/app/assets/images/desktop/personal_patent.svg new file mode 100644 index 0000000..e69de29 diff --git a/app/controllers/admin/patents_controller.rb b/app/controllers/admin/patents_controller.rb index 0c9525a..44f0123 100644 --- a/app/controllers/admin/patents_controller.rb +++ b/app/controllers/admin/patents_controller.rb @@ -1,5 +1,6 @@ class Admin::PatentsController < OrbitMemberController layout "member_plugin" + include Admin::PersonalPatentsHelper before_action :set_patent, only: [:show, :edit , :update, :destroy] before_action :set_plugin @@ -15,28 +16,49 @@ class Admin::PatentsController < OrbitMemberController def new @member = MemberProfile.find_by(:uid=>params['uid']) rescue nil @patent = Patent.new + + if params[:desktop] + render :layout => false + end end def create @member = MemberProfile.find(patent_params['member_profile_id']) rescue nil @patent = Patent.new(patent_params) @patent.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 = @patent.member_profile rescue nil + if params[:desktop] + render :layout => false + end end def update @member = @patent.member_profile rescue nil @patent.update_attributes(patent_params) @patent.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 @patent.destroy + respond_to do |format| + format.html { redirect_to(admin_writing_conferences_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_patents_controller.rb b/app/controllers/desktop/personal_patents_controller.rb new file mode 100644 index 0000000..0c30ee4 --- /dev/null +++ b/app/controllers/desktop/personal_patents_controller.rb @@ -0,0 +1,23 @@ +class Desktop::PersonalPatentsController < DesktopAdminController + include Admin::PersonalPatentsHelper + + def menu + user = OrbitHelper.current_user + [ + { + "title" => "List", + "layout" => "list" + }, + { + "title" => "Add/Edit", + "layout" => "form", + "new_path" => "/admin/members/#{user.member_profile.to_param}/patents/new" + } + ] + end + + def list + get_paper_list + end + +end \ No newline at end of file diff --git a/app/helpers/admin/personal_patents_helper.rb b/app/helpers/admin/personal_patents_helper.rb new file mode 100644 index 0000000..6c165f6 --- /dev/null +++ b/app/helpers/admin/personal_patents_helper.rb @@ -0,0 +1,28 @@ +module Admin::PersonalPatentsHelper + + def get_paper_list + user = current_user.nil? ? OrbitHelper.current_user : current_user + user_profile = user.member_profile + patents = Patent.where(:member_profile_id => user_profile.id) + patents = patents.collect do |p| + files = p.patent_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}/patents/#{p.to_param}/edit", + "delete_url" => "/#{I18n.locale.to_s}/admin/patents/#{p.id.to_s}", + "paper_title" => p.patent_title, + "keywords" => p.keywords, + "abstract" => [], + "files" => files + } + end + patents + end +end \ No newline at end of file diff --git a/app/views/admin/patents/_form.html.erb b/app/views/admin/patents/_form.html.erb index 3a3c576..4633a51 100644 --- a/app/views/admin/patents/_form.html.erb +++ b/app/views/admin/patents/_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 @@
- +
@@ -65,7 +65,7 @@
<%= f.datetime_picker :publish_date, :no_label => true, :format=>"yyyy/MM" %>
-
+
@@ -73,7 +73,7 @@
<%= f.text_field :patent_no %>
-
+
@@ -81,7 +81,7 @@
<%= f.text_field :keywords %>
-
+
@@ -89,7 +89,7 @@
<%= f.text_field :language ,class: "span5"%>
-
+
@@ -97,7 +97,7 @@
<%= f.text_field :url , :class => "span5" %>
-
+
@@ -105,7 +105,7 @@
<%= f.text_area :note, rows: 2, class: "input-block-level" %>
-
+ @@ -137,13 +137,13 @@
<% @site_in_use_locales.each_with_index do |locale, i| %> - +
">
-
+
<%= f.fields_for :patent_title_translations do |f| %> <%= f.text_field locale, placeholder: t("personal_patent.patent_title"), value: (@patent.patent_title_translations[locale] rescue nil) %> <% end %> @@ -158,12 +158,12 @@ <%= f.text_field locale, placeholder: t("personal_patent.patent_country"), value: (@patent.patent_country_translations[locale] rescue nil) %> <% end %>
-
+
-
+
<%= f.fields_for :authors_translations do |f| %> <%= f.text_field locale, placeholder: t("personal_patent.authors"), value: (@patent.authors_translations[locale] rescue nil) %> <% end %> @@ -186,7 +186,7 @@ <%= f.fields_for :patent_files, patent_file do |f| %> <%= render :partial => 'form_file', :object => patent_file, :locals => {:f => f, :i => i} %> <% end %> - <% end %> + <% end %>
<% end %> @@ -210,14 +210,12 @@ <%= 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 + \ No newline at end of file diff --git a/lib/personal_patent/engine.rb b/lib/personal_patent/engine.rb index 12d2e5a..0192133 100644 --- a/lib/personal_patent/engine.rb +++ b/lib/personal_patent/engine.rb @@ -7,6 +7,7 @@ module PersonalPatent personal_plugin :enable => true, :sort_number => '35', :app_name=>"Patent", :intro_app_name=>"PersonalPatentIntro",:path=>"/plugin/personal_patent/profile",:front_path=>"/profile",:admin_path=>"/admin/patents",:i18n=>'module_name.personal_patent', :module_app_name=>"PersonalPatent" version "0.1" + desktop_enabled true organization "Rulingcom" author "RD dep" intro "I am intro"