forked from saurabh/personal-patent
desktop patent
This commit is contained in:
parent
f8f3212b7a
commit
fb7371f5f8
|
@ -1,5 +1,6 @@
|
||||||
class Admin::PatentsController < OrbitMemberController
|
class Admin::PatentsController < OrbitMemberController
|
||||||
layout "member_plugin"
|
layout "member_plugin"
|
||||||
|
include Admin::PersonalPatentsHelper
|
||||||
|
|
||||||
before_action :set_patent, only: [:show, :edit , :update, :destroy]
|
before_action :set_patent, only: [:show, :edit , :update, :destroy]
|
||||||
before_action :set_plugin
|
before_action :set_plugin
|
||||||
|
@ -15,28 +16,49 @@ class Admin::PatentsController < OrbitMemberController
|
||||||
def new
|
def new
|
||||||
@member = MemberProfile.find_by(:uid=>params['uid']) rescue nil
|
@member = MemberProfile.find_by(:uid=>params['uid']) rescue nil
|
||||||
@patent = Patent.new
|
@patent = Patent.new
|
||||||
|
|
||||||
|
if params[:desktop]
|
||||||
|
render :layout => false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@member = MemberProfile.find(patent_params['member_profile_id']) rescue nil
|
@member = MemberProfile.find(patent_params['member_profile_id']) rescue nil
|
||||||
@patent = Patent.new(patent_params)
|
@patent = Patent.new(patent_params)
|
||||||
@patent.save
|
@patent.save
|
||||||
|
if params[:desktop] == "true"
|
||||||
|
render json: {"data" => get_paper_list}.to_json
|
||||||
|
else
|
||||||
redirect_to params['referer_url']
|
redirect_to params['referer_url']
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@member = @patent.member_profile rescue nil
|
@member = @patent.member_profile rescue nil
|
||||||
|
if params[:desktop]
|
||||||
|
render :layout => false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@member = @patent.member_profile rescue nil
|
@member = @patent.member_profile rescue nil
|
||||||
@patent.update_attributes(patent_params)
|
@patent.update_attributes(patent_params)
|
||||||
@patent.save
|
@patent.save
|
||||||
|
if params[:desktop] == "true"
|
||||||
|
render json: {"data" => get_paper_list}.to_json
|
||||||
|
else
|
||||||
redirect_to params['referer_url']
|
redirect_to params['referer_url']
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@patent.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
|
end
|
||||||
|
|
||||||
def toggle_hide
|
def toggle_hide
|
||||||
|
|
|
@ -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
|
|
@ -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
|
|
@ -213,11 +213,9 @@
|
||||||
<%= link_to t('cancel'), get_go_back, :class=>"btn" %>
|
<%= link_to t('cancel'), get_go_back, :class=>"btn" %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% content_for :page_specific_javascript do %>
|
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function() {
|
$('.main-forms').find('.add-on').tooltip().end().on('click', '.trigger, .delete_file, .remove_existing_record', function() {
|
||||||
$('.main-forms .add-on').tooltip();
|
if($(this).hasClass('trigger')) {
|
||||||
$(document).on('click', '#add_file', function(){
|
|
||||||
var new_id = $(this).prev().attr('value');
|
var new_id = $(this).prev().attr('value');
|
||||||
var old_id = new RegExp("new_patent_files", "g");
|
var old_id = new RegExp("new_patent_files", "g");
|
||||||
var on = $('.language-nav li.active').index();
|
var on = $('.language-nav li.active').index();
|
||||||
|
@ -227,17 +225,14 @@
|
||||||
$(this).parent('.add-btn').prev('.add-target').children('.start-line').eq(le).children('.input-append').find('.tab-content').each(function() {
|
$(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');
|
$(this).children('.tab-pane').eq(on).addClass('in active').siblings().removeClass('in active');
|
||||||
});
|
});
|
||||||
formTip();
|
$('.add-on').tooltip();
|
||||||
});
|
} else if($(this).hasClass('delete_file')) {
|
||||||
$(document).on('click', '.delete_file', function(){
|
|
||||||
$(this).parents('.input-prepend').remove();
|
$(this).parents('.input-prepend').remove();
|
||||||
});
|
} else if($(this).hasClass('remove_existing_record')) {
|
||||||
$(document).on('click', '.remove_existing_record', function(){
|
|
||||||
if(confirm("<%= I18n.t(:sure?)%>")){
|
if(confirm("<%= I18n.t(:sure?)%>")){
|
||||||
$(this).children('.should_destroy').attr('value', 1);
|
$(this).children('.should_destroy').attr('value', 1);
|
||||||
$(this).parents('.start-line').hide();
|
$(this).parents('.start-line').hide();
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<% end %>
|
|
|
@ -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"
|
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"
|
||||||
|
desktop_enabled true
|
||||||
organization "Rulingcom"
|
organization "Rulingcom"
|
||||||
author "RD dep"
|
author "RD dep"
|
||||||
intro "I am intro"
|
intro "I am intro"
|
||||||
|
|
Loading…
Reference in New Issue