desktop project
This commit is contained in:
parent
f05638c33c
commit
b27d11a045
|
@ -1,4 +1,5 @@
|
||||||
class Admin::ProjectsController < OrbitMemberController
|
class Admin::ProjectsController < OrbitMemberController
|
||||||
|
include Admin::PersonalProjectsHelper
|
||||||
layout "member_plugin"
|
layout "member_plugin"
|
||||||
|
|
||||||
before_action :set_project, only: [:show, :edit , :update, :destroy]
|
before_action :set_project, only: [:show, :edit , :update, :destroy]
|
||||||
|
@ -15,28 +16,48 @@ class Admin::ProjectsController < OrbitMemberController
|
||||||
def new
|
def new
|
||||||
@member = MemberProfile.find_by(:uid=>params['uid']) rescue nil
|
@member = MemberProfile.find_by(:uid=>params['uid']) rescue nil
|
||||||
@project = Project.new
|
@project = Project.new
|
||||||
|
if params[:desktop]
|
||||||
|
render :layout => false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@member = MemberProfile.find(project_params['member_profile_id']) rescue nil
|
@member = MemberProfile.find(project_params['member_profile_id']) rescue nil
|
||||||
@project = Project.new(project_params)
|
@project = Project.new(project_params)
|
||||||
@project.save
|
@project.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
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@member = @project.member_profile rescue nil
|
@member = @project.member_profile rescue nil
|
||||||
|
if params[:desktop]
|
||||||
|
render :layout => false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@member = @project.member_profile rescue nil
|
@member = @project.member_profile rescue nil
|
||||||
@project.update_attributes(project_params)
|
@project.update_attributes(project_params)
|
||||||
@project.save
|
@project.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
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@project.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
|
end
|
||||||
|
|
||||||
def toggle_hide
|
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
|
|
@ -7,7 +7,7 @@
|
||||||
<% content_for :page_specific_javascript do %>
|
<% content_for :page_specific_javascript do %>
|
||||||
<%= javascript_include_tag "lib/bootstrap-datetimepicker" %>
|
<%= javascript_include_tag "lib/bootstrap-datetimepicker" %>
|
||||||
<%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %>
|
<%= 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/file-type" %>
|
||||||
<%= javascript_include_tag "lib/module-area" %>
|
<%= javascript_include_tag "lib/module-area" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
@ -15,7 +15,7 @@
|
||||||
<!-- Input Area -->
|
<!-- Input Area -->
|
||||||
<div class="input-area">
|
<div class="input-area">
|
||||||
|
|
||||||
<!-- Module Tabs -->
|
<!-- Module Tabs -->
|
||||||
<div class="nav-name"><strong><%= t(:module) %></strong></div>
|
<div class="nav-name"><strong><%= t(:module) %></strong></div>
|
||||||
<ul class="nav nav-pills module-nav">
|
<ul class="nav nav-pills module-nav">
|
||||||
<li></li>
|
<li></li>
|
||||||
|
@ -32,14 +32,14 @@
|
||||||
|
|
||||||
<!-- Basic Module -->
|
<!-- Basic Module -->
|
||||||
<div class="tab-pane fade in active" id="basic">
|
<div class="tab-pane fade in active" id="basic">
|
||||||
|
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label muted"><%= t("personal_plugins.author") %></label>
|
<label class="control-label muted"><%= t("personal_plugins.author") %></label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<%= @member.name rescue ''%>
|
<%= @member.name rescue ''%>
|
||||||
<%= f.hidden_field :member_profile_id, :value => @member.id if !@member.nil? %>
|
<%= f.hidden_field :member_profile_id, :value => @member.id if !@member.nil? %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- year -->
|
<!-- year -->
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
|
@ -47,7 +47,7 @@
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<%= select_year((@project.year ? @project.year.to_i : DateTime.now.year), {:start_year => DateTime.now.year, :end_year => 1930}, {:name => 'project[year]',:class => 'span1'} ) %>
|
<%= select_year((@project.year ? @project.year.to_i : DateTime.now.year), {:start_year => DateTime.now.year, :end_year => 1930}, {:name => 'project[year]',:class => 'span1'} ) %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- project_category -->
|
<!-- project_category -->
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
|
@ -63,7 +63,7 @@
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<%= f.datetime_picker :period_start_date, :no_label => true, :format=>"yyyy/MM" %>
|
<%= f.datetime_picker :period_start_date, :no_label => true, :format=>"yyyy/MM" %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- period_end_date -->
|
<!-- period_end_date -->
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
|
@ -71,7 +71,7 @@
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<%= f.datetime_picker :period_end_date, :no_label => true, :format=>"yyyy/MM" %>
|
<%= f.datetime_picker :period_end_date, :no_label => true, :format=>"yyyy/MM" %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- url -->
|
<!-- url -->
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
|
@ -79,7 +79,7 @@
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<%= f.text_field :url , :class => "span5" %>
|
<%= f.text_field :url , :class => "span5" %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- keywords -->
|
<!-- keywords -->
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
|
@ -87,7 +87,7 @@
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<%= f.text_field :keywords %>
|
<%= f.text_field :keywords %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- language -->
|
<!-- language -->
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
|
@ -99,7 +99,7 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- abstract -->
|
<!-- abstract -->
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
|
@ -107,7 +107,7 @@
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<%= f.text_area :abstract, rows: 2, class: "input-block-level" %>
|
<%= f.text_area :abstract, rows: 2, class: "input-block-level" %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -140,13 +140,13 @@
|
||||||
<div class="tab-content language-area">
|
<div class="tab-content language-area">
|
||||||
|
|
||||||
<% @site_in_use_locales.each_with_index do |locale, i| %>
|
<% @site_in_use_locales.each_with_index do |locale, i| %>
|
||||||
|
|
||||||
<div class="<%= locale %> tab-pane fade <%= ( i == 0 ) ? "in active" : '' %>">
|
<div class="<%= locale %> tab-pane fade <%= ( i == 0 ) ? "in active" : '' %>">
|
||||||
|
|
||||||
<!-- project_title-->
|
<!-- project_title-->
|
||||||
<div class="control-group input-title">
|
<div class="control-group input-title">
|
||||||
<label class="control-label muted"><%= t("personal_project.project_title") %></label>
|
<label class="control-label muted"><%= t("personal_project.project_title") %></label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<%= f.fields_for :project_title_translations do |f| %>
|
<%= f.fields_for :project_title_translations do |f| %>
|
||||||
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_project.project_title"), value: (@project.project_title_translations[locale] rescue nil) %>
|
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_project.project_title"), value: (@project.project_title_translations[locale] rescue nil) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
@ -156,7 +156,7 @@
|
||||||
<!-- job_title-->
|
<!-- job_title-->
|
||||||
<div class="control-group input-title">
|
<div class="control-group input-title">
|
||||||
<label class="control-label muted"><%= t("personal_project.job_title") %></label>
|
<label class="control-label muted"><%= t("personal_project.job_title") %></label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<%= f.fields_for :job_title_translations do |f| %>
|
<%= f.fields_for :job_title_translations do |f| %>
|
||||||
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_project.job_title"), value: (@project.job_title_translations[locale] rescue nil) %>
|
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_project.job_title"), value: (@project.job_title_translations[locale] rescue nil) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
@ -166,7 +166,7 @@
|
||||||
<!-- participator-->
|
<!-- participator-->
|
||||||
<div class="control-group input-title">
|
<div class="control-group input-title">
|
||||||
<label class="control-label muted"><%= t("personal_project.participator") %></label>
|
<label class="control-label muted"><%= t("personal_project.participator") %></label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<%= f.fields_for :participator_translations do |f| %>
|
<%= f.fields_for :participator_translations do |f| %>
|
||||||
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_project.participator"), value: (@project.participator_translations[locale] rescue nil) %>
|
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_project.participator"), value: (@project.participator_translations[locale] rescue nil) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
@ -176,7 +176,7 @@
|
||||||
<!-- unit-->
|
<!-- unit-->
|
||||||
<div class="control-group input-title">
|
<div class="control-group input-title">
|
||||||
<label class="control-label muted"><%= t("personal_project.unit") %></label>
|
<label class="control-label muted"><%= t("personal_project.unit") %></label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<%= f.fields_for :unit_translations do |f| %>
|
<%= f.fields_for :unit_translations do |f| %>
|
||||||
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_project.unit"), value: (@project.unit_translations[locale] rescue nil) %>
|
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_project.unit"), value: (@project.unit_translations[locale] rescue nil) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
@ -191,7 +191,7 @@
|
||||||
<%= f.text_area locale, rows: 2, class: "input-block-level", value: (@project.note_translations[locale] rescue nil) %>
|
<%= f.text_area locale, rows: 2, class: "input-block-level", value: (@project.note_translations[locale] rescue nil) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -209,7 +209,7 @@
|
||||||
<%= f.fields_for :project_files, project_file do |f| %>
|
<%= f.fields_for :project_files, project_file do |f| %>
|
||||||
<%= render :partial => 'form_file', :object => project_file, :locals => {:f => f, :i => i} %>
|
<%= render :partial => 'form_file', :object => project_file, :locals => {:f => f, :i => i} %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<hr>
|
<hr>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
@ -233,34 +233,30 @@
|
||||||
<%= f.hidden_field :user_id, :value => params[:user_id] if !params[:user_id].blank? %>
|
<%= f.hidden_field :user_id, :value => params[:user_id] if !params[:user_id].blank? %>
|
||||||
<input type="hidden" name="referer_url" value="<%= request.referer %>">
|
<input type="hidden" name="referer_url" value="<%= request.referer %>">
|
||||||
<%= f.submit t('submit'), class: 'btn btn-primary' %>
|
<%= 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" %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% content_for :page_specific_javascript do %>
|
<script>
|
||||||
<script>
|
$('.main-forms').find('.add-on').tooltip().end().on('click', '.trigger, .delete_file, .remove_existing_record', function() {
|
||||||
$(document).ready(function() {
|
if($(this).hasClass('trigger')) {
|
||||||
$('.main-forms .add-on').tooltip();
|
var new_id = $(this).prev().attr('value');
|
||||||
$(document).on('click', '#add_file', function(){
|
var old_id = new RegExp("new_project_files", "g");
|
||||||
var new_id = $(this).prev().attr('value');
|
var on = $('.language-nav li.active').index();
|
||||||
var old_id = new RegExp("new_project_files", "g");
|
var le = $(this).parent('.add-btn').prev('.add-target').children('.start-line').length;
|
||||||
var on = $('.language-nav li.active').index();
|
$(this).prev().attr('value', parseInt(new_id) + 1);
|
||||||
var le = $(this).parent('.add-btn').prev('.add-target').children('.start-line').length;
|
$(this).parent().siblings('.add-target').append(("<%= escape_javascript(add_attribute 'form_file', f, :project_files) %>").replace(old_id, new_id));
|
||||||
$(this).prev().attr('value', parseInt(new_id) + 1);
|
$(this).parent('.add-btn').prev('.add-target').children('.start-line').eq(le).children('.input-append').find('.tab-content').each(function() {
|
||||||
$(this).parent().siblings('.add-target').append(("<%= escape_javascript(add_attribute 'form_file', f, :project_files) %>").replace(old_id, new_id));
|
$(this).children('.tab-pane').eq(on).addClass('in active').siblings().removeClass('in active');
|
||||||
$(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(){
|
formTip();
|
||||||
if(confirm("<%= I18n.t(:sure?)%>")){
|
$('.add-on').tooltip();
|
||||||
$(this).children('.should_destroy').attr('value', 1);
|
} else if($(this).hasClass('delete_file')) {
|
||||||
$(this).parents('.start-line').hide();
|
$(this).parents('.input-prepend').remove();
|
||||||
}
|
} else if($(this).hasClass('remove_existing_record')) {
|
||||||
});
|
if(confirm("<%= I18n.t(:sure?)%>")){
|
||||||
});
|
$(this).children('.should_destroy').attr('value', 1);
|
||||||
</script>
|
$(this).parents('.start-line').hide();
|
||||||
<% end %>
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
|
@ -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"
|
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"
|
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