This commit is contained in:
manson 2014-07-04 11:48:33 +08:00
parent 47e825b663
commit f45435ceeb
26 changed files with 911 additions and 1 deletions

View File

@ -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

View File

@ -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

View File

@ -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

39
app/models/patent.rb Normal file
View File

@ -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

14
app/models/patent_file.rb Normal file
View File

@ -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

View File

@ -0,0 +1,4 @@
class PatentIntro < PersonalPluginIntro
end

View File

@ -0,0 +1,9 @@
class PatentType
include Mongoid::Document
include Mongoid::Timestamps
field :title, localize: true
has_many :patents
end

View File

@ -0,0 +1,24 @@
<%= form_for(@patent_type, :html =>{:class=>"form-horizontal", :style=>"margin: 0;"}, :remote => true, :url => @url ) do |f| %>
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel"><%= t("personal_patent.patent_category") %></h3>
</div>
<div class="modal-body">
<%= f.fields_for :title_translations do |f| %>
<% @site_in_use_locales.each do |locale| %>
<div class="control-group">
<%= label_tag t(locale), t(locale), :class => 'control-label' %>
<div class="controls">
<%= f.text_field locale, :value => (@patent_type.title_translations[locale] rescue nil) %>
</div>
</div>
<% end %>
<% end %>
</div>
<div class="modal-footer">
<%= f.submit t('submit'), :class=>'btn btn-primary' %>
<a class="btn" data-dismiss="modal"><%= t('cancel')%></a>
</div>
<% end %>

View File

@ -0,0 +1,2 @@
$('#patent_types tbody').html("<%= j render :partial => '/admin/patents/list_patent_type', :collection => @patent_types %>");
$('#patent_type_modal').modal('hide');

View File

@ -0,0 +1 @@
$('#patent_type_modal').html("<%= j render 'form' %>");

View File

@ -0,0 +1 @@
$('#patent_type_modal').html("<%= j render 'form' %>");

View File

@ -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 %>
<!-- Input Area -->
<div class="input-area">
<!-- Module Tabs -->
<div class="nav-name"><strong><%= t(:module) %></strong></div>
<ul class="nav nav-pills module-nav">
<li></li>
<li class="active">
<a href="#basic" data-toggle="tab"><%= t(:basic) %></a>
</li>
<li>
<a href="#status" data-toggle="tab"><%= t(:status) %></a>
</li>
</ul>
<!-- Module -->
<div class="tab-content module-area">
<!-- Basic Module -->
<div class="tab-pane fade in active" id="basic">
<div class="control-group">
<label class="control-label muted"><%= t("personal_plugins.author") %></label>
<div class="controls">
<%= @member.name rescue ''%>
<%= f.hidden_field :member_profile_id, :value => @member.id %>
</div>
</div>
<!-- year -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_patent.year") %></label>
<div class="controls">
<%= select_year((@patent.year ? @patent.year.to_i : DateTime.now.year), {:start_year => DateTime.now.year, :end_year => 1930}, {:name => 'patent[year]', :class => "span1"} ) %>
</div>
</div>
<!-- patent_category -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_patent.patent_category") %></label>
<div class="controls">
<%= f.select :patent_type_id, @patent_types.collect {|t| [ t.title, t.id ]} %>
</div>
</div>
<!-- publish_date -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_patent.publication_date") %></label>
<div class="controls">
<%= f.datetime_picker :publish_date, :no_label => true, :format=>"yyyy/MM" %>
</div>
</div>
<!-- patent_no -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_patent.patent_no") %></label>
<div class="controls">
<%= f.text_field :patent_no %>
</div>
</div>
<!-- patent_country -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_patent.patent_country") %></label>
<div class="controls">
<%= f.text_field :patent_country %>
</div>
</div>
<!-- keywords -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_patent.keywords") %></label>
<div class="controls">
<%= f.text_field :keywords %>
</div>
</div>
<!-- language -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_patent.language") %></label>
<div class="controls">
<select id="patent_language" name="patent[language]">
<% @site_in_use_locales.each do |locale| %>
<option value="<%= locale %>" <%= @patent.language.eql?(locale.to_s) ? "selected" : ""%>><%= t(locale) %></option>
<% end %>
</select>
</div>
</div>
<!-- url -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_patent.url") %></label>
<div class="controls">
<%= f.text_field :url , :class => "span5" %>
</div>
</div>
<!-- note -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_patent.note") %></label>
<div class="controls">
<%= f.text_area :note, rows: 2, class: "input-block-level" %>
</div>
</div>
</div>
<!-- Status Module -->
<div class="tab-pane fade" id="status">
<div class="control-group">
<label class="control-label muted"><%= t(:status) %></label>
<div class="controls" data-toggle="buttons-checkbox">
<label class="checkbox inline btn <%= 'active' if @patent.is_hidden? %>">
<%= f.check_box :is_hidden %> <%= t(:hide) %>
</label>
</div>
</div>
</div>
</div>
<!-- Language Tabs -->
<div class="nav-name"><strong><%= t(:language) %></strong></div>
<ul class="nav nav-pills language-nav">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<li class="<%= 'active' if i == 0 %>">
<a data-toggle="tab" href=".<%= locale %>"><%= t(locale) %></a>
</li>
<% end %>
</ul>
<!-- Language -->
<div class="tab-content language-area">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<div class="<%= locale %> tab-pane fade <%= ( i == 0 ) ? "in active" : '' %>">
<!-- patent_title-->
<div class="control-group input-title">
<label class="control-label muted"><%= t("personal_patent.patent_title") %></label>
<div class="controls">
<%= 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 %>
</div>
</div>
<!-- authors-->
<div class="control-group input-title">
<label class="control-label muted"><%= t("personal_patent.authors") %></label>
<div class="controls">
<%= f.fields_for :authors_translations do |f| %>
<%= f.text_field locale, placeholder: t("personal_patent.authors"), value: (@patent.authors_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
</div>
<% end %>
<!-- File -->
<div class="control-group">
<label class="control-label muted"><%= t(:file_) %></label>
<div class="controls">
<!-- Exist -->
<% if @patent && !@patent.patent_files.blank? %>
<div class="exist">
<% @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 %>
<hr>
</div>
<% end %>
<!-- Add -->
<div class="add-target">
</div>
<p class="add-btn">
<%= hidden_field_tag 'plugin_file_field_count', @patent.patent_files.count %>
<a id="add_file" class="trigger btn btn-small btn-primary"><i class="icons-plus"></i> <%= t(:add) %></a>
</p>
</div>
</div>
</div>
</div>
<!-- Form Actions -->
<div class="form-actions">
<%= 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" %>
</div>
<% content_for :page_specific_javascript do %>
<script>
$(document).ready(function() {
$('.main-forms .add-on').tooltip();
$(document).on('click', '#add_file', function(){
var new_id = $(this).prev().attr('value');
var old_id = new RegExp("new_patent_files", "g");
var on = $('.language-nav li.active').index();
var le = $(this).parent('.add-btn').prev('.add-target').children('.start-line').length;
$(this).prev().attr('value', parseInt(new_id) + 1);
$(this).parent().siblings('.add-target').append(("<%= escape_javascript(add_attribute 'form_file', f, :patent_files) %>").replace(old_id, new_id));
$(this).parent('.add-btn').prev('.add-target').children('.start-line').eq(le).children('.input-append').find('.tab-content').each(function() {
$(this).children('.tab-pane').eq(on).addClass('in active').siblings().removeClass('in active');
});
formTip();
});
$(document).on('click', '.delete_file', function(){
$(this).parents('.input-prepend').remove();
});
$(document).on('click', '.remove_existing_record', function(){
if(confirm("<%= I18n.t(:sure?)%>")){
$(this).children('.should_destroy').attr('value', 1);
$(this).parents('.start-line').hide();
}
});
});
</script>
<% end %>

View File

@ -0,0 +1,55 @@
<% if form_file.new_record? %>
<div class="fileupload fileupload-new start-line" data-provides="fileupload">
<% else %>
<div class="fileupload fileupload-exist start-line" data-provides="fileupload">
<% 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 %>
<div class="input-prepend input-append">
<label>
<span class="add-on btn btn-file" title='<%= t(:file_) %>'>
<i class="icons-paperclip"></i>
<%= f.file_field :file %>
</span>
<div class="uneditable-input input-medium">
<i class="icon-file fileupload-exists"></i>
<span class="fileupload-preview"><%= (form_file.new_record? || form_file.file.blank?) ? t(:select_file) : t(:change_file) %></span>
</div>
</label>
<span class="add-on icons-pencil" title='<%= t(:alternative) %>'></span>
<span class="tab-content">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<span class="tab-pane fade <%= ( i == 0 ) ? "in active" : '' %> <%= 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 %>
</span>
<% end %>
</span>
<span class="add-on icons-pencil" title='<%= t(:description) %>'></span>
<span class="tab-content">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<span class="tab-pane fade <%= ( i == 0 ) ? "in active" : '' %> <%= 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 %>
</span>
<% end %>
</span>
</span>
<% if form_file.new_record? %>
<span class="delete_file add-on btn" title="<%= t(:delete_) %>">
<a class="icon-trash"></a>
</span>
<% else %>
<span class="remove_existing_record add-on btn" title="<%= t(:remove) %>">
<%= f.hidden_field :id %>
<a class="icon-remove"></a>
<%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %>
</span>
<% end %>
</div>
</div>

View File

@ -0,0 +1,8 @@
<tr id="<%= dom_id list_patent_type %>">
<td><%= list_patent_type.title %></td>
<td class="span2">
<a href="<%= edit_admin_patent_type_path(list_patent_type) %>#patent_type_modal" data-toggle="modal" data-remote="true" class="action"><%= t(:edit) %></a>
<%= link_to t(:delete_), admin_patent_type_path(list_patent_type), "data-confirm" => t('sure?'), :method => :delete, :remote => true,:class=>"archive_toggle action" %>
</td>
</tr>

View File

@ -0,0 +1,17 @@
<% @patents.each do |patent| %>
<tr id="<%= dom_id patent %>" class="<%= patent.is_hidden ? "checkHide" : "" %>">
<td><%= patent.publish_date.strftime("%Y.%m") %></td>
<td>
<%= link_to patent.patent_title, OrbitHelper.url_to_plugin_show(patent.to_param,'personal_patent').to_s, target: "blank"%>
<div class="quick-edit">
<ul class="nav nav-pills hide">
<li><%= link_to t('edit'), '/admin/members/'+patent.member_profile.to_param+'/patents/'+patent.id+'/edit' %></li>
<li><%= link_to t(:delete_), admin_patent_path(id: patent.id, member_profile_id: patent.member_profile.id), method: :delete, remote: true, data: { confirm: t('sure?') } %></li>
</ul>
</div>
</td>
<td><%= patent.patent_no %></td>
<td><%= patent.patent_country %></td>
<td><%= patent.member_profile.name %></td>
</tr>
<% end %>

View File

@ -0,0 +1 @@
$('#patent_<%= @patent.id.to_s%>').remove();

View File

@ -0,0 +1,5 @@
<%= form_for @patent, url:'/admin/patents/'+@patent.id.to_s, html: {class: "form-horizontal main-forms previewable"} do |f| %>
<fieldset>
<%= render partial: 'form', locals: {f: f} %>
</fieldset>
<% end %>

View File

@ -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| %>
<fieldset>
<!-- Input Area -->
<div class="input-area">
<!-- Module Tabs -->
<div class="nav-name"><strong><%= t("module_name.personal_patent") %></strong></div>
<ul class="nav nav-pills module-nav">
<li></li>
<li class="active">
<a href="#basic" data-toggle="tab"><%= t(:basic) %></a>
</li>
</ul>
<!-- Module -->
<div class="tab-content module-area">
<!-- Basic Module -->
<div class="tab-pane fade in active" id="basic">
<% if !@member.blank? %>
<div class="control-group">
<label class="control-label muted"><%= t("personal_plugins.author") %></label>
<div class="controls">
<%= @member.name rescue ''%>
<%= f.hidden_field :member_profile_id, :value => @member.id %>
</div>
</div>
<% end %>
<!-- frontend_page -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_plugins.frontend_page") %></label>
<div class="controls">
<%= 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") %>
</div>
</div>
</div>
</div>
<!-- Language Tabs -->
<div class="nav-name"><strong><%= t(:language) %></strong></div>
<ul class="nav nav-pills language-nav">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<li class="<%= 'active' if i == 0 %>">
<a data-toggle="tab" href=".<%= locale %>"><%= t(locale) %></a>
</li>
<% end %>
</ul>
<!-- Language -->
<div class="tab-content language-area">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<div class="<%= locale %> tab-pane fade <%= ( i == 0 ) ? "in active" : '' %>">
<!-- Content -->
<div class="control-group input-content">
<label class="control-label muted"><%= t(:content) %></label>
<div class="controls">
<div class="textarea">
<%= 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 %>
</div>
</div>
</div>
</div>
<% end %>
</div>
</div>
<!-- Form Actions -->
<div class="form-actions">
<%= 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" %>
</div>
</fieldset>
<% end %>

View File

@ -0,0 +1,22 @@
<table class="table main-list">
<thead>
<tr>
<th class="span1"><%= t('personal_patent.publication_date') %></th>
<th class="span2"><%= t('personal_patent.patent_title') %></th>
<th class="span2"><%= t('personal_patent.patent_no') %></th>
<th class="span2"><%= t('personal_patent.patent_country') %></th>
<th class="span2"><%= t('personal_patent.authors') %></th>
</tr>
</thead>
<tbody id="tbody_patents" class="sort-holder">
<%= render :partial => 'patent', :collection => @patents %>
</tbody>
</table>
<div class="bottomnav clearfix">
<div class="action pull-right">
<%= link_to content_tag(:i, nil, :class => 'icon-cog icon-white') + t('setting'), admin_patent_setting_path, :class => 'btn btn-primary pull-right' %>
</div>
<div class="pagination pagination-centered">
</div>
</div>

View File

@ -0,0 +1,5 @@
<%= form_for @patent, url: admin_patents_path, html: {class: "form-horizontal main-forms previewable"} do |f| %>
<fieldset>
<%= render partial: 'form', locals: {f: f} %>
</fieldset>
<% end %>

View File

@ -0,0 +1,52 @@
<style type="text/css">
.element{
background: #FFF;
margin-bottom: 10px;
border-radius: 5px;
border: 1px solid #DDD;
}
.detail{
padding: 10px;
min-height: 250px;
}
.totle{
margin-bottom: 25px;
}
.totle span{
font-size: 18px;
}
</style>
<div class="row">
<div class="element span4">
<div class="detail w-a h-a">
<p class="totle">
<a class="btn btn-small btn-primary pull-right" href="<%= new_admin_patent_type_path %>#patent_type_modal" data-toggle="modal" data-remote="true"><i class="icon-plus"></i> <%= t('add')%></a>
<span><%= t("personal_patent.patent_category") %></span>
</p>
<div class="detal-list my_scroll">
<div class="scrollbar">
<div class="track">
<div class="thumb">
<div class="end"></div>
</div>
</div>
</div>
<div class="viewport">
<div class="overview">
<table id="patent_types" class="table table-striped">
<tbody>
<%= render :partial => 'list_patent_type', :collection => @patent_types %>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="patent_type_qe">
<div style="display:none;" class="modal" id="patent_type_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
</div>
</div>

View File

@ -0,0 +1 @@
<%= render_view %>

View File

@ -0,0 +1 @@
<%= render_view %>

View File

@ -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 %>
<div class="list-active">
<div class="btn-group">
<%= 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') ) %>
</div>
</div>
<% end -%>
<table class="table table-condensed table-striped main-list">
<thead>
<tr>
<% if is_autorized_user %>
<th><input type="checkbox" /></th>
<% end -%>
<th class="span3"><%= t('personal_patent.publication_date') %></th>
<th class="span3"><%= t('personal_patent.patent_title') %></th>
<th class="span2"><%= t('personal_patent.patent_no') %></th>
<th class="span2"><%= t('personal_patent.patent_country') %></th>
<th class="span2"><%= t('personal_patent.authors') %></th>
</tr>
</thead>
<tbody>
<% @patents.each do |patent| %>
<tr id="<%= dom_id patent %>" class="<%= patent.is_hidden ? "checkHide" : "" %>">
<% if is_autorized_user %>
<td>
<%= check_box_tag 'to_change[]', patent.id.to_s, false, :class => "list-check" %>
</td>
<% end %>
<td><%= patent.publish_date.strftime("%Y.%m") %></td>
<td>
<%= link_to patent.patent_title, OrbitHelper.url_to_plugin_show(patent.to_param,'personal_patent').to_s, target: "blank"%>
<div class="quick-edit">
<ul class="nav nav-pills hide">
<li><%= link_to t('edit'), '/admin/members/'+@member.to_param+'/patents/'+patent.id+'/edit' %></li>
<li><%= link_to t(:delete_), admin_patent_path(id: patent.id, member_profile_id: @member.id), method: :delete, remote: true, data: { confirm: t('sure?') } %></li>
</ul>
</div>
</td>
<td><%= patent.patent_no %></td>
<td><%= patent.patent_country %></td>
<td><%= patent.member_profile.name %></td>
</tr>
<% end %>
</tbody>
</table>
<div class="bottomnav clearfix">
<% if is_autorized_user %>
<div class="action pull-right">
<%= 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' %>
</div>
<% end %>
<div class="pagination pagination-centered">
<%= paginate @patents, :params => {:direction => params[:direction], :sort => params[:sort] } %>
</div>
</div>
<div id="dialog" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="Delete item" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3><%= t(:sure?) %></h3>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true"><%= t(:close) %></button>
<button class="delete-item btn btn-danger"><%= t(:submit) %></button>
</div>
</div>

View File

@ -2,6 +2,28 @@ Rails.application.routes.draw do
locales = Site.find_by(site_active: true).in_use_locales rescue I18n.available_locales locales = Site.find_by(site_active: true).in_use_locales rescue I18n.available_locales
scope "(:locale)", locale: Regexp.new(locales.join("|")) do scope "(:locale)", locale: Regexp.new(locales.join("|")) do
namespace :admin 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 end
end end

View File

@ -4,7 +4,7 @@ module PersonalPatent
OrbitApp.registration "PersonalPatent",:type=> 'ModuleApp' do OrbitApp.registration "PersonalPatent",:type=> 'ModuleApp' do
module_label 'module_name.personal_patent' module_label 'module_name.personal_patent'
base_url File.expand_path File.dirname(__FILE__) 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" version "0.1"
organization "Rulingcom" organization "Rulingcom"
@ -12,6 +12,8 @@ module PersonalPatent
intro "I am intro" intro "I am intro"
update_info 'some update_info' update_info 'some update_info'
frontend_enabled
icon_class_no_sidebar "icons-user"
end end
end end
end end