desktop lab
This commit is contained in:
parent
ac5f30d51a
commit
ea0ead04fc
|
@ -1,4 +1,5 @@
|
||||||
class Admin::LabsController < OrbitMemberController
|
class Admin::LabsController < OrbitMemberController
|
||||||
|
include Admin::PersonalLabsHelper
|
||||||
layout "member_plugin"
|
layout "member_plugin"
|
||||||
|
|
||||||
before_action :set_lab, only: [:show, :edit , :update, :destroy]
|
before_action :set_lab, only: [:show, :edit , :update, :destroy]
|
||||||
|
@ -15,28 +16,48 @@ class Admin::LabsController < OrbitMemberController
|
||||||
def new
|
def new
|
||||||
@member = MemberProfile.find_by(:uid=>params['uid']) rescue nil
|
@member = MemberProfile.find_by(:uid=>params['uid']) rescue nil
|
||||||
@lab = Lab.new
|
@lab = Lab.new
|
||||||
|
if params[:desktop]
|
||||||
|
render :layout => false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@member = MemberProfile.find(lab_params['member_profile_id']) rescue nil
|
@member = MemberProfile.find(lab_params['member_profile_id']) rescue nil
|
||||||
@lab = Lab.new(lab_params)
|
@lab = Lab.new(lab_params)
|
||||||
@lab.save
|
@lab.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 = @lab.member_profile rescue nil
|
@member = @lab.member_profile rescue nil
|
||||||
|
if params[:desktop]
|
||||||
|
render :layout => false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@member = @lab.member_profile rescue nil
|
@member = @lab.member_profile rescue nil
|
||||||
@lab.update_attributes(lab_params)
|
@lab.update_attributes(lab_params)
|
||||||
@lab.save
|
@lab.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
|
||||||
@lab.destroy
|
@lab.destroy
|
||||||
|
respond_to do |format|
|
||||||
|
format.html { redirect_to(admin_labs_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::PersonalLabsController < DesktopAdminController
|
||||||
|
include Admin::PersonalLabsHelper
|
||||||
|
|
||||||
|
def menu
|
||||||
|
user = OrbitHelper.current_user
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"title" => "List",
|
||||||
|
"layout" => "list"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title" => "Add/Edit",
|
||||||
|
"layout" => "form",
|
||||||
|
"new_path" => "/admin/members/#{user.member_profile.to_param}/labs/new"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def list
|
||||||
|
get_paper_list
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -0,0 +1,27 @@
|
||||||
|
module Admin::PersonalLabsHelper
|
||||||
|
|
||||||
|
def get_paper_list
|
||||||
|
user = current_user.nil? ? OrbitHelper.current_user : current_user
|
||||||
|
user_profile = user.member_profile
|
||||||
|
labs = Lab.where(:member_profile_id => user_profile.id)
|
||||||
|
labs = labs.collect do |l|
|
||||||
|
files = l.lab_files.collect do |lf|
|
||||||
|
{
|
||||||
|
"title" => lf.title,
|
||||||
|
"description" => lf.description,
|
||||||
|
"link" => lf.file.url,
|
||||||
|
"extension" => (lf.file.url.split(".").last rescue "")
|
||||||
|
}
|
||||||
|
end
|
||||||
|
{
|
||||||
|
"id" => l.id.to_s,
|
||||||
|
"edit_url" => "/#{I18n.locale.to_s}/admin/members/#{user_profile.to_param}/labs/#{l.to_param}/edit",
|
||||||
|
"delete_url" => "/#{I18n.locale.to_s}/admin/labs/#{l.id.to_s}",
|
||||||
|
"paper_title" => l.lab_title,
|
||||||
|
"keywords" => l.keywords,
|
||||||
|
"files" => files
|
||||||
|
}
|
||||||
|
end
|
||||||
|
labs
|
||||||
|
end
|
||||||
|
end
|
|
@ -5,7 +5,7 @@
|
||||||
<%= stylesheet_link_tag "lib/main-list" %>
|
<%= stylesheet_link_tag "lib/main-list" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% content_for :page_specific_javascript do %>
|
<% content_for :page_specific_javascript do %>
|
||||||
<%= 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 %>
|
||||||
|
@ -13,7 +13,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>
|
||||||
|
@ -30,14 +30,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">
|
||||||
|
@ -45,7 +45,7 @@
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<%= select_year((@lab.year ? @lab.year.to_i : DateTime.now.year), {:start_year => DateTime.now.year, :end_year => 1930}, {:name => 'lab[year]', :class => 'span1'} ) %>
|
<%= select_year((@lab.year ? @lab.year.to_i : DateTime.now.year), {:start_year => DateTime.now.year, :end_year => 1930}, {:name => 'lab[year]', :class => 'span1'} ) %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- extension_no -->
|
<!-- extension_no -->
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
|
@ -61,7 +61,7 @@
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<%= f.text_field :research_direction %>
|
<%= f.text_field :research_direction %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- facility -->
|
<!-- facility -->
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
|
@ -69,7 +69,7 @@
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<%= f.text_field :facility %>
|
<%= f.text_field :facility %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- url -->
|
<!-- url -->
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
|
@ -77,7 +77,7 @@
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<%= f.text_field :url , :class => "span6" %>
|
<%= f.text_field :url , :class => "span6" %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- keywords -->
|
<!-- keywords -->
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
|
@ -85,7 +85,7 @@
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<%= f.text_field :keywords %>
|
<%= f.text_field :keywords %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- note -->
|
<!-- note -->
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
|
@ -93,7 +93,7 @@
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<%= f.text_area :note, rows: 2, class: "input-block-level" %>
|
<%= f.text_area :note, rows: 2, class: "input-block-level" %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -125,13 +125,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" : '' %>">
|
||||||
|
|
||||||
<!-- lab_title-->
|
<!-- lab_title-->
|
||||||
<div class="control-group input-title">
|
<div class="control-group input-title">
|
||||||
<label class="control-label muted"><%= t("personal_lab.lab_title") %></label>
|
<label class="control-label muted"><%= t("personal_lab.lab_title") %></label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<%= f.fields_for :lab_title_translations do |f| %>
|
<%= f.fields_for :lab_title_translations do |f| %>
|
||||||
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_lab.lab_title"), value: (@lab.lab_title_translations[locale] rescue nil) %>
|
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_lab.lab_title"), value: (@lab.lab_title_translations[locale] rescue nil) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
@ -141,7 +141,7 @@
|
||||||
<!-- location-->
|
<!-- location-->
|
||||||
<div class="control-group input-title">
|
<div class="control-group input-title">
|
||||||
<label class="control-label muted"><%= t("personal_lab.location") %></label>
|
<label class="control-label muted"><%= t("personal_lab.location") %></label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<%= f.fields_for :location_translations do |f| %>
|
<%= f.fields_for :location_translations do |f| %>
|
||||||
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_lab.location"), value: (@lab.location_translations[locale] rescue nil) %>
|
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_lab.location"), value: (@lab.location_translations[locale] rescue nil) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
@ -151,7 +151,7 @@
|
||||||
<!-- participating_professor-->
|
<!-- participating_professor-->
|
||||||
<div class="control-group input-title">
|
<div class="control-group input-title">
|
||||||
<label class="control-label muted"><%= t("personal_lab.participating_professor") %></label>
|
<label class="control-label muted"><%= t("personal_lab.participating_professor") %></label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<%= f.fields_for :participating_professor_translations do |f| %>
|
<%= f.fields_for :participating_professor_translations do |f| %>
|
||||||
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_lab.participating_professor"), value: (@lab.participating_professor_translations[locale] rescue nil) %>
|
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_lab.participating_professor"), value: (@lab.participating_professor_translations[locale] rescue nil) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
@ -161,7 +161,7 @@
|
||||||
<!-- participating_student-->
|
<!-- participating_student-->
|
||||||
<div class="control-group input-title">
|
<div class="control-group input-title">
|
||||||
<label class="control-label muted"><%= t("personal_lab.participating_student") %></label>
|
<label class="control-label muted"><%= t("personal_lab.participating_student") %></label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<%= f.fields_for :participating_student_translations do |f| %>
|
<%= f.fields_for :participating_student_translations do |f| %>
|
||||||
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_lab.participating_student"), value: (@lab.participating_student_translations[locale] rescue nil) %>
|
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_lab.participating_student"), value: (@lab.participating_student_translations[locale] rescue nil) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
@ -184,11 +184,11 @@
|
||||||
<%= f.fields_for :lab_files, lab_file do |f| %>
|
<%= f.fields_for :lab_files, lab_file do |f| %>
|
||||||
<%= render :partial => 'form_file', :object => lab_file, :locals => {:f => f, :i => i} %>
|
<%= render :partial => 'form_file', :object => lab_file, :locals => {:f => f, :i => i} %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<hr>
|
<hr>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<!-- Add -->
|
<!-- Add -->
|
||||||
<div class="add-target">
|
<div class="add-target">
|
||||||
</div>
|
</div>
|
||||||
|
@ -207,34 +207,29 @@
|
||||||
<%= 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_lab_files", "g");
|
||||||
var new_id = $(this).prev().attr('value');
|
var on = $('.language-nav li.active').index();
|
||||||
var old_id = new RegExp("new_lab_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, :lab_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, :lab_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(){
|
$('.add-on').tooltip();
|
||||||
if(confirm("<%= I18n.t(:sure?)%>")){
|
} else if($(this).hasClass('delete_file')) {
|
||||||
$(this).children('.should_destroy').attr('value', 1);
|
$(this).parents('.input-prepend').remove();
|
||||||
$(this).parents('.start-line').hide();
|
} 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 %>
|
}
|
||||||
|
});
|
||||||
|
</script>
|
|
@ -7,6 +7,7 @@ module PersonalLab
|
||||||
personal_plugin :enable => true, :sort_number => '30', :app_name=>"Lab", :intro_app_name=>"PersonalLabIntro",:path=>"/plugin/personal_lab/profile",:front_path=>"/profile",:admin_path=>"/admin/labs",:i18n=>'module_name.personal_lab', :module_app_name=>'PersonalLab'
|
personal_plugin :enable => true, :sort_number => '30', :app_name=>"Lab", :intro_app_name=>"PersonalLabIntro",:path=>"/plugin/personal_lab/profile",:front_path=>"/profile",:admin_path=>"/admin/labs",:i18n=>'module_name.personal_lab', :module_app_name=>'PersonalLab'
|
||||||
|
|
||||||
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