desktop project
This commit is contained in:
parent
f05638c33c
commit
b27d11a045
|
@ -1,4 +1,5 @@
|
|||
class Admin::ProjectsController < OrbitMemberController
|
||||
include Admin::PersonalProjectsHelper
|
||||
layout "member_plugin"
|
||||
|
||||
before_action :set_project, only: [:show, :edit , :update, :destroy]
|
||||
|
@ -15,28 +16,48 @@ class Admin::ProjectsController < OrbitMemberController
|
|||
def new
|
||||
@member = MemberProfile.find_by(:uid=>params['uid']) rescue nil
|
||||
@project = Project.new
|
||||
if params[:desktop]
|
||||
render :layout => false
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@member = MemberProfile.find(project_params['member_profile_id']) rescue nil
|
||||
@project = Project.new(project_params)
|
||||
@project.save
|
||||
if params[:desktop] == "true"
|
||||
render json: {"data" => get_paper_list}.to_json
|
||||
else
|
||||
redirect_to params['referer_url']
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@member = @project.member_profile rescue nil
|
||||
if params[:desktop]
|
||||
render :layout => false
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@member = @project.member_profile rescue nil
|
||||
@project.update_attributes(project_params)
|
||||
@project.save
|
||||
if params[:desktop] == "true"
|
||||
render json: {"data" => get_paper_list}.to_json
|
||||
else
|
||||
redirect_to params['referer_url']
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@project.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to(admin_projects_url) }
|
||||
# format.xml { head :ok }
|
||||
format.js
|
||||
format.json {render json: {"success" => true}}
|
||||
end
|
||||
end
|
||||
|
||||
def toggle_hide
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
class Desktop::PersonalProjectsController < DesktopAdminController
|
||||
include Admin::PersonalProjectsHelper
|
||||
|
||||
def menu
|
||||
user = OrbitHelper.current_user
|
||||
[
|
||||
{
|
||||
"title" => "List",
|
||||
"layout" => "list"
|
||||
},
|
||||
{
|
||||
"title" => "Add/Edit",
|
||||
"layout" => "form",
|
||||
"new_path" => "/admin/members/#{user.member_profile.to_param}/projects/new"
|
||||
}
|
||||
]
|
||||
end
|
||||
|
||||
def list
|
||||
get_paper_list
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,29 @@
|
|||
module Admin::PersonalProjectsHelper
|
||||
|
||||
def get_paper_list
|
||||
user = current_user.nil? ? OrbitHelper.current_user : current_user
|
||||
user_profile = user.member_profile
|
||||
projects = Project.where(:member_profile_id => user_profile.id)
|
||||
projects = projects.collect do |p|
|
||||
files = p.project_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}/projects/#{p.to_param}/edit",
|
||||
"delete_url" => "/#{I18n.locale.to_s}/admin/projects/#{p.id.to_s}",
|
||||
"paper_title" => p.project_title,
|
||||
"keywords" => p.keywords,
|
||||
"abstract" => p.abstract,
|
||||
"files" => files
|
||||
}
|
||||
end
|
||||
projects
|
||||
end
|
||||
end
|
|
@ -236,11 +236,9 @@
|
|||
<%= 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(){
|
||||
$('.main-forms').find('.add-on').tooltip().end().on('click', '.trigger, .delete_file, .remove_existing_record', function() {
|
||||
if($(this).hasClass('trigger')) {
|
||||
var new_id = $(this).prev().attr('value');
|
||||
var old_id = new RegExp("new_project_files", "g");
|
||||
var on = $('.language-nav li.active').index();
|
||||
|
@ -251,16 +249,14 @@
|
|||
$(this).children('.tab-pane').eq(on).addClass('in active').siblings().removeClass('in active');
|
||||
});
|
||||
formTip();
|
||||
});
|
||||
$(document).on('click', '.delete_file', function(){
|
||||
$('.add-on').tooltip();
|
||||
} else if($(this).hasClass('delete_file')) {
|
||||
$(this).parents('.input-prepend').remove();
|
||||
});
|
||||
$(document).on('click', '.remove_existing_record', function(){
|
||||
} else if($(this).hasClass('remove_existing_record')) {
|
||||
if(confirm("<%= I18n.t(:sure?)%>")){
|
||||
$(this).children('.should_destroy').attr('value', 1);
|
||||
$(this).parents('.start-line').hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<% end %>
|
|
@ -7,6 +7,7 @@ module PersonalProject
|
|||
personal_plugin :enable => true, :sort_number => '15', :app_name=>"Project", :intro_app_name=>"PersonalProjectIntro",:path=>"/plugin/personal_project/profile",:front_path=>"/profile",:admin_path=>"/admin/projects",:i18n=>'module_name.personal_project', :module_app_name=>"PersonalProject"
|
||||
|
||||
version "0.1"
|
||||
desktop_enabled true
|
||||
organization "Rulingcom"
|
||||
author "RD dep"
|
||||
intro "I am intro"
|
||||
|
|
Loading…
Reference in New Issue