From f45435ceeb46839cc98e4eb9db55b0a79fe33a78 Mon Sep 17 00:00:00 2001 From: manson Date: Fri, 4 Jul 2014 11:48:33 +0800 Subject: [PATCH] Finished --- .../admin/patent_types_controller.rb | 41 +++ app/controllers/admin/patents_controller.rb | 89 +++++++ .../personal_patents_controller.rb | 72 ++++++ app/models/patent.rb | 39 +++ app/models/patent_file.rb | 14 + app/models/patent_intro.rb | 4 + app/models/patent_type.rb | 9 + app/views/admin/patent_types/_form.html.erb | 24 ++ app/views/admin/patent_types/_list.js.erb | 2 + app/views/admin/patent_types/edit.js.erb | 1 + app/views/admin/patent_types/new.js.erb | 1 + app/views/admin/patents/_form.html.erb | 242 ++++++++++++++++++ app/views/admin/patents/_form_file.html.erb | 55 ++++ .../admin/patents/_list_patent_type.html.erb | 8 + app/views/admin/patents/_patent.html.erb | 17 ++ app/views/admin/patents/destroy.js.erb | 1 + app/views/admin/patents/edit.html.erb | 5 + .../admin/patents/frontend_setting.html.erb | 93 +++++++ app/views/admin/patents/index.html.erb | 22 ++ app/views/admin/patents/new.html.erb | 5 + app/views/admin/patents/setting.html.erb | 52 ++++ app/views/personal_patents/index.html.erb | 1 + app/views/personal_patents/show.html.erb | 1 + .../plugin/personal_patent/_profile.html.erb | 88 +++++++ config/routes.rb | 22 ++ lib/personal_patent/engine.rb | 4 +- 26 files changed, 911 insertions(+), 1 deletion(-) create mode 100644 app/controllers/admin/patent_types_controller.rb create mode 100644 app/controllers/admin/patents_controller.rb create mode 100644 app/controllers/personal_patents_controller.rb create mode 100644 app/models/patent.rb create mode 100644 app/models/patent_file.rb create mode 100644 app/models/patent_intro.rb create mode 100644 app/models/patent_type.rb create mode 100644 app/views/admin/patent_types/_form.html.erb create mode 100644 app/views/admin/patent_types/_list.js.erb create mode 100644 app/views/admin/patent_types/edit.js.erb create mode 100644 app/views/admin/patent_types/new.js.erb create mode 100644 app/views/admin/patents/_form.html.erb create mode 100644 app/views/admin/patents/_form_file.html.erb create mode 100644 app/views/admin/patents/_list_patent_type.html.erb create mode 100644 app/views/admin/patents/_patent.html.erb create mode 100644 app/views/admin/patents/destroy.js.erb create mode 100644 app/views/admin/patents/edit.html.erb create mode 100644 app/views/admin/patents/frontend_setting.html.erb create mode 100644 app/views/admin/patents/index.html.erb create mode 100644 app/views/admin/patents/new.html.erb create mode 100644 app/views/admin/patents/setting.html.erb create mode 100644 app/views/personal_patents/index.html.erb create mode 100644 app/views/personal_patents/show.html.erb create mode 100644 app/views/plugin/personal_patent/_profile.html.erb diff --git a/app/controllers/admin/patent_types_controller.rb b/app/controllers/admin/patent_types_controller.rb new file mode 100644 index 0000000..fd5c417 --- /dev/null +++ b/app/controllers/admin/patent_types_controller.rb @@ -0,0 +1,41 @@ +class Admin::PatentTypesController < OrbitAdminController + def new + @patent_type = PatentType.new + @url = admin_patent_types_path(@patent_type) + render :layout=>false + end + + def create + @patent_type = PatentType.new(patent_type_params) + @patent_type.save + @patent_types = PatentType.all + render :partial=>'list', :layout=>false + end + + def edit + @patent_type = PatentType.find(params[:id]) + @url = admin_patent_type_path(@patent_type) + render :layout=>false + end + + def update + @patent_type = PatentType.find(params[:id]) + @patent_type.update_attributes(patent_type_params) + @patent_type.save + @patent_types = PatentType.all + render :partial=>'list', :layout=>false + end + + def destroy + patent_type = PatentType.find(params[:id]) + patent_type.destroy + @patent_types = PatentType.all + render :partial=>'list', :layout=>false + end + + private + + def patent_type_params + params.require(:patent_type).permit! rescue nil + end +end \ No newline at end of file diff --git a/app/controllers/admin/patents_controller.rb b/app/controllers/admin/patents_controller.rb new file mode 100644 index 0000000..12e6109 --- /dev/null +++ b/app/controllers/admin/patents_controller.rb @@ -0,0 +1,89 @@ +class Admin::PatentsController < OrbitMemberController + layout "member_plugin" + + before_action :set_plugin + before_action :get_settings,:only => [:new, :edit, :setting] + + def index + @patents = Patent.all + end + + def new + @member = MemberProfile.find_by(:uid=>params['uid']) rescue nil + @patent = Patent.new + end + + def create + @member = MemberProfile.find(patent_params['member_profile_id']) rescue nil + @patent = Patent.new(patent_params) + @patent.save + redirect_to '/admin/members/'+@member.to_param+'/Patent' + end + + def edit + @member = MemberProfile.find_by(:uid=>params['uid']) rescue nil + @patent = Patent.find(params[:id]) + end + + def update + @member = MemberProfile.find(patent_params['member_profile_id']) rescue nil + @patent = Patent.find(params[:id]) + @patent.update_attributes(patent_params) + @patent.save + redirect_to '/admin/members/'+@member.to_param+'/Patent' + end + + def destroy + @patent = Patent.find(params[:id]) + @patent.destroy + end + + def toggle_hide + if params[:ids] + @patents = Patent.any_in(_id: params[:ids]) + + @patents.each do |patent| + patent.is_hidden = params[:disable] + patent.save + end + end + + render json: {"success"=>true} + end + + def setting + end + + def frontend_setting + @member = MemberProfile.find_by(:uid=>params['uid']) rescue nil + @intro = PatentIntro.find_by(:member_profile_id=>@member.id) rescue nil + @intro = @intro.nil? ? PatentIntro.new({:member_profile_id=>@member.id}) : @intro + end + + def update_frontend_setting + @member = MemberProfile.find(intro_params['member_profile_id']) rescue nil + @intro = PatentIntro.find_by(:member_profile_id=>@member.id) rescue nil + @intro = @intro.nil? ? PatentIntro.new({:member_profile_id=>@member.id}) : @intro + @intro.update_attributes(intro_params) + @intro.save + redirect_to '/admin/members/'+@member.to_param+'/Patent' + end + + def get_settings + @patent_types = PatentType.all + end + + def set_plugin + @plugin = OrbitApp::Plugin::Registration.all.select{|plugin| plugin.app_name.eql? 'Patent'}.first + end + + private + + def patent_params + params.require(:patent).permit! rescue nil + end + + def intro_params + params.require(:patent_intro).permit! rescue nil + end +end \ No newline at end of file diff --git a/app/controllers/personal_patents_controller.rb b/app/controllers/personal_patents_controller.rb new file mode 100644 index 0000000..161a68b --- /dev/null +++ b/app/controllers/personal_patents_controller.rb @@ -0,0 +1,72 @@ +class PersonalPatentsController < ApplicationController + def index + patents = Patent.where(:is_hidden=>false).all + patent_list = patents.collect do |patent| + { + "publication_date" => patent.publication_date, + "patent_title" => patent.patent_title, + "patent_no" => patent.patent_no, + "patent_country" => patent.patent_country, + "authors" => patent.member_profile.name, + "link_to_show" => OrbitHelper.url_to_show(patent.to_param) + } + end + { + "patents" => patent_list, + "extras" => { + "widget-title" => t("personal_patent.personal_patent"), + "th_publication_date" => t('personal_patent.publication_date'), + "th_patent_title" => t("personal_patent.paper_patent_title"), + "th_patent_no" => t('personal_patent.patent_no'), + "th_patent_country" => t("personal_patent.paper_patent_country"), + "th_authors" => t('user.name') + } + } + end + + def show + params = OrbitHelper.params + patent = Patent.where(:is_hidden=>false).find_by(uid: params[:uid]) + + files = patent.patent_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" => { + "patent_title" => patent.patent_title, + "patent_type" => patent.patent_type.title, + "authors" => patent.authors, + "year" => patent.year, + "language" => t(patent.language), + "keywords" => patent.keywords, + "patent_no" => patent.patent_no, + "patent_country" => patent.patent_country, + "publish_date" => patent.publish_date.strftime("%Y.%m"), + "url" => patent.url, + "note" => patent.note, + + "th_patent_title" => t("personal_patent.patent_title"), + "th_authors" => t("personal_patent.authors"), + "th_year" => t("personal_patent.year"), + "th_language" => t("personal_patent.language"), + "th_keywords" => t("personal_patent.keywords"), + "th_patent_no" => t("personal_patent.patent_no"), + "th_patent_country" => t("personal_patent.patent_country"), + "th_publish_date" => t("personal_patent.publication_date"), + "th_url" => t("personal_patent.url"), + "th_note" => t("personal_patent.note"), + + "th_patent_type" => t("personal_patent.patent_category"), + "th_files" => t(:file_) + } + } + end +end \ No newline at end of file diff --git a/app/models/patent.rb b/app/models/patent.rb new file mode 100644 index 0000000..f215813 --- /dev/null +++ b/app/models/patent.rb @@ -0,0 +1,39 @@ +class Patent + include Mongoid::Document + include Mongoid::Timestamps + include OrbitModel::Status + include Slug + + belongs_to :patent_type + belongs_to :member_profile + + field :patent_title, as: :slug_title, localize: true + field :authors, localize: true + + field :year + field :language + field :keywords + field :patent_no + field :patent_country + field :publish_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 :patent_files, :autosave => true, :dependent => :destroy + accepts_nested_attributes_for :patent_files, :allow_destroy => true + + before_validation :add_http + + 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/patent_file.rb b/app/models/patent_file.rb new file mode 100644 index 0000000..30f0cc5 --- /dev/null +++ b/app/models/patent_file.rb @@ -0,0 +1,14 @@ +class PatentFile + + 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 :patent + +end diff --git a/app/models/patent_intro.rb b/app/models/patent_intro.rb new file mode 100644 index 0000000..6b55d56 --- /dev/null +++ b/app/models/patent_intro.rb @@ -0,0 +1,4 @@ +class PatentIntro < PersonalPluginIntro + + +end diff --git a/app/models/patent_type.rb b/app/models/patent_type.rb new file mode 100644 index 0000000..e5e90f4 --- /dev/null +++ b/app/models/patent_type.rb @@ -0,0 +1,9 @@ +class PatentType + include Mongoid::Document + include Mongoid::Timestamps + + field :title, localize: true + + has_many :patents + +end \ No newline at end of file diff --git a/app/views/admin/patent_types/_form.html.erb b/app/views/admin/patent_types/_form.html.erb new file mode 100644 index 0000000..97ad04b --- /dev/null +++ b/app/views/admin/patent_types/_form.html.erb @@ -0,0 +1,24 @@ +<%= form_for(@patent_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/patent_types/_list.js.erb b/app/views/admin/patent_types/_list.js.erb new file mode 100644 index 0000000..880d788 --- /dev/null +++ b/app/views/admin/patent_types/_list.js.erb @@ -0,0 +1,2 @@ +$('#patent_types tbody').html("<%= j render :partial => '/admin/patents/list_patent_type', :collection => @patent_types %>"); +$('#patent_type_modal').modal('hide'); \ No newline at end of file diff --git a/app/views/admin/patent_types/edit.js.erb b/app/views/admin/patent_types/edit.js.erb new file mode 100644 index 0000000..0606669 --- /dev/null +++ b/app/views/admin/patent_types/edit.js.erb @@ -0,0 +1 @@ +$('#patent_type_modal').html("<%= j render 'form' %>"); \ No newline at end of file diff --git a/app/views/admin/patent_types/new.js.erb b/app/views/admin/patent_types/new.js.erb new file mode 100644 index 0000000..0606669 --- /dev/null +++ b/app/views/admin/patent_types/new.js.erb @@ -0,0 +1 @@ +$('#patent_type_modal').html("<%= j render 'form' %>"); \ No newline at end of file diff --git a/app/views/admin/patents/_form.html.erb b/app/views/admin/patents/_form.html.erb new file mode 100644 index 0000000..b2bc1b2 --- /dev/null +++ b/app/views/admin/patents/_form.html.erb @@ -0,0 +1,242 @@ +<% # 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((@patent.year ? @patent.year.to_i : DateTime.now.year), {:start_year => DateTime.now.year, :end_year => 1930}, {:name => 'patent[year]', :class => "span1"} ) %> +
+
+ + +
+ +
+ <%= f.select :patent_type_id, @patent_types.collect {|t| [ t.title, t.id ]} %> +
+
+ + +
+ +
+ <%= f.datetime_picker :publish_date, :no_label => true, :format=>"yyyy/MM" %> +
+
+ + +
+ +
+ <%= f.text_field :patent_no %> +
+
+ + +
+ +
+ <%= f.text_field :patent_country %> +
+
+ + +
+ +
+ <%= f.text_field :keywords %> +
+
+ + +
+ +
+ +
+
+ + +
+ +
+ <%= f.text_field :url , :class => "span5" %> +
+
+ + +
+ +
+ <%= f.text_area :note, rows: 2, class: "input-block-level" %> +
+
+ +
+ + +
+
+ +
+ +
+
+
+ +
+ + + + + + +
+ + <% @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 %> +
+
+ + +
+ +
+ <%= f.fields_for :authors_translations do |f| %> + <%= f.text_field locale, placeholder: t("personal_patent.authors"), value: (@patent.authors_translations[locale] rescue nil) %> + <% end %> +
+
+ +
+ + <% end %> + + +
+ +
+ + + <% if @patent && !@patent.patent_files.blank? %> +
+ <% @patent.patent_files.each_with_index do |patent_file, i| %> + <%= f.fields_for :patent_files, patent_file do |f| %> + <%= render :partial => 'form_file', :object => patent_file, :locals => {:f => f, :i => i} %> + <% end %> + <% end %> +
+
+ <% end %> + + +
+
+

+ <%= hidden_field_tag 'plugin_file_field_count', @patent.patent_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/patents/_form_file.html.erb b/app/views/admin/patents/_form_file.html.erb new file mode 100644 index 0000000..8628623 --- /dev/null +++ b/app/views/admin/patents/_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/patents/_list_patent_type.html.erb b/app/views/admin/patents/_list_patent_type.html.erb new file mode 100644 index 0000000..5f738ad --- /dev/null +++ b/app/views/admin/patents/_list_patent_type.html.erb @@ -0,0 +1,8 @@ + + <%= list_patent_type.title %> + + + <%= t(:edit) %> + <%= link_to t(:delete_), admin_patent_type_path(list_patent_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/patents/_patent.html.erb b/app/views/admin/patents/_patent.html.erb new file mode 100644 index 0000000..bffef8a --- /dev/null +++ b/app/views/admin/patents/_patent.html.erb @@ -0,0 +1,17 @@ +<% @patents.each do |patent| %> + "> + <%= patent.publish_date.strftime("%Y.%m") %> + + <%= link_to patent.patent_title, OrbitHelper.url_to_plugin_show(patent.to_param,'personal_patent').to_s, target: "blank"%> +
+ +
+ + <%= patent.patent_no %> + <%= patent.patent_country %> + <%= patent.member_profile.name %> + +<% end %> \ No newline at end of file diff --git a/app/views/admin/patents/destroy.js.erb b/app/views/admin/patents/destroy.js.erb new file mode 100644 index 0000000..b1b14c0 --- /dev/null +++ b/app/views/admin/patents/destroy.js.erb @@ -0,0 +1 @@ +$('#patent_<%= @patent.id.to_s%>').remove(); \ No newline at end of file diff --git a/app/views/admin/patents/edit.html.erb b/app/views/admin/patents/edit.html.erb new file mode 100644 index 0000000..6a78eb6 --- /dev/null +++ b/app/views/admin/patents/edit.html.erb @@ -0,0 +1,5 @@ +<%= form_for @patent, url:'/admin/patents/'+@patent.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/patents/frontend_setting.html.erb b/app/views/admin/patents/frontend_setting.html.erb new file mode 100644 index 0000000..18044cc --- /dev/null +++ b/app/views/admin/patents/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(:patent_intro, :url => update_frontend_setting_admin_patents_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/patents/index.html.erb b/app/views/admin/patents/index.html.erb new file mode 100644 index 0000000..3c41822 --- /dev/null +++ b/app/views/admin/patents/index.html.erb @@ -0,0 +1,22 @@ + + + + + + + + + + + + <%= render :partial => 'patent', :collection => @patents %> + +
<%= t('personal_patent.publication_date') %><%= t('personal_patent.patent_title') %><%= t('personal_patent.patent_no') %><%= t('personal_patent.patent_country') %><%= t('personal_patent.authors') %>
+ +
+
+ <%= link_to content_tag(:i, nil, :class => 'icon-cog icon-white') + t('setting'), admin_patent_setting_path, :class => 'btn btn-primary pull-right' %> +
+ +
\ No newline at end of file diff --git a/app/views/admin/patents/new.html.erb b/app/views/admin/patents/new.html.erb new file mode 100644 index 0000000..e341030 --- /dev/null +++ b/app/views/admin/patents/new.html.erb @@ -0,0 +1,5 @@ +<%= form_for @patent, url: admin_patents_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/patents/setting.html.erb b/app/views/admin/patents/setting.html.erb new file mode 100644 index 0000000..85b77f2 --- /dev/null +++ b/app/views/admin/patents/setting.html.erb @@ -0,0 +1,52 @@ + + +
+
+
+

+ <%= t('add')%> + <%= t("personal_patent.patent_category") %> +

+
+
+
+
+
+
+
+
+
+
+ + + <%= render :partial => 'list_patent_type', :collection => @patent_types %> + +
+
+
+
+
+
+
+ +
+ +
\ No newline at end of file diff --git a/app/views/personal_patents/index.html.erb b/app/views/personal_patents/index.html.erb new file mode 100644 index 0000000..648b75c --- /dev/null +++ b/app/views/personal_patents/index.html.erb @@ -0,0 +1 @@ +<%= render_view %> \ No newline at end of file diff --git a/app/views/personal_patents/show.html.erb b/app/views/personal_patents/show.html.erb new file mode 100644 index 0000000..648b75c --- /dev/null +++ b/app/views/personal_patents/show.html.erb @@ -0,0 +1 @@ +<%= render_view %> \ No newline at end of file diff --git a/app/views/plugin/personal_patent/_profile.html.erb b/app/views/plugin/personal_patent/_profile.html.erb new file mode 100644 index 0000000..be72b63 --- /dev/null +++ b/app/views/plugin/personal_patent/_profile.html.erb @@ -0,0 +1,88 @@ +<% 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 + @patents = Patent.where(member_profile_id: @member.id).desc(:year).page(params[:page]).per(10) + else + @patents = Patent.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_patents_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_patents_path(member_profile_id: params[:id], disable: 'false') ) %> +
+
+<% end -%> + + + + + <% if is_autorized_user %> + + <% end -%> + + + + + + + + + <% @patents.each do |patent| %> + "> + <% if is_autorized_user %> + + <% end %> + + + + + + + <% end %> + +
<%= t('personal_patent.publication_date') %><%= t('personal_patent.patent_title') %><%= t('personal_patent.patent_no') %><%= t('personal_patent.patent_country') %><%= t('personal_patent.authors') %>
+ <%= check_box_tag 'to_change[]', patent.id.to_s, false, :class => "list-check" %> + <%= patent.publish_date.strftime("%Y.%m") %> + <%= link_to patent.patent_title, OrbitHelper.url_to_plugin_show(patent.to_param,'personal_patent').to_s, target: "blank"%> +
+ +
+
<%= patent.patent_no %><%= patent.patent_country %><%= patent.member_profile.name %>
+ + +
+ <% if is_autorized_user %> +
+ <%= link_to content_tag(:i, nil, :class => 'icon-edit') +' '+ t('setting'),'/admin/members/'+@member.to_param+'/patents/frontend_setting', :class => 'btn btn-primary' %> + <%= link_to content_tag(:i, nil, :class => 'icon-plus') +' '+ t('new_'), + '/admin/members/'+@member.to_param+'/patents/new', :class => 'btn btn-primary' %> +
+ <% end %> + +
+ + \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index d96d9d4..31e510c 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 'patent_setting' => "patents#setting" + + resources :patents do + collection do + get 'toggle_hide' => 'patents#toggle_hide' + end + end + + resources :members do + collection do + scope '(:name-:uid)' do + resources :patents do + collection do + get 'frontend_setting' => 'patents#frontend_setting' + post 'update_frontend_setting' => 'patents#update_frontend_setting' + end + end + end + end + end + + resources :patent_types end end end diff --git a/lib/personal_patent/engine.rb b/lib/personal_patent/engine.rb index c78dec5..c115434 100644 --- a/lib/personal_patent/engine.rb +++ b/lib/personal_patent/engine.rb @@ -4,7 +4,7 @@ module PersonalPatent OrbitApp.registration "PersonalPatent",:type=> 'ModuleApp' do module_label 'module_name.personal_patent' base_url File.expand_path File.dirname(__FILE__) - personal_plugin :enable => true, :sort_number => '35', :app_name=>"WritingPatent", :intro_app_name=>"PersonalPatentIntro",:path=>"/plugin/profile",:front_path=>"/profile",:admin_path=>"/admin/writing_patents",:i18n=>'module_name.personal_patent' + 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" organization "Rulingcom" @@ -12,6 +12,8 @@ module PersonalPatent intro "I am intro" update_info 'some update_info' + frontend_enabled + icon_class_no_sidebar "icons-user" end end end