Finished
This commit is contained in:
parent
07877ae91d
commit
a68cba924b
|
@ -0,0 +1,41 @@
|
|||
class Admin::ProjectTypesController < OrbitAdminController
|
||||
def new
|
||||
@project_type = ProjectType.new
|
||||
@url = admin_project_types_path(@project_type)
|
||||
render :layout=>false
|
||||
end
|
||||
|
||||
def create
|
||||
@project_type = ProjectType.new(project_type_params)
|
||||
@project_type.save
|
||||
@project_types = ProjectType.all
|
||||
render :partial=>'list', :layout=>false
|
||||
end
|
||||
|
||||
def edit
|
||||
@project_type = ProjectType.find(params[:id])
|
||||
@url = admin_project_type_path(@project_type)
|
||||
render :layout=>false
|
||||
end
|
||||
|
||||
def update
|
||||
@project_type = ProjectType.find(params[:id])
|
||||
@project_type.update_attributes(project_type_params)
|
||||
@project_type.save
|
||||
@project_types = ProjectType.all
|
||||
render :partial=>'list', :layout=>false
|
||||
end
|
||||
|
||||
def destroy
|
||||
project_type = ProjectType.find(params[:id])
|
||||
project_type.destroy
|
||||
@project_types = ProjectType.all
|
||||
render :partial=>'list', :layout=>false
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def project_type_params
|
||||
params.require(:project_type).permit! rescue nil
|
||||
end
|
||||
end
|
|
@ -0,0 +1,89 @@
|
|||
class Admin::ProjectsController < OrbitMemberController
|
||||
layout "member_plugin"
|
||||
|
||||
before_action :set_plugin
|
||||
before_action :get_settings,:only => [:new, :edit, :setting]
|
||||
|
||||
def index
|
||||
@projects = Project.all
|
||||
end
|
||||
|
||||
def new
|
||||
@member = MemberProfile.find_by(:uid=>params['uid']) rescue nil
|
||||
@project = Project.new
|
||||
end
|
||||
|
||||
def create
|
||||
@member = MemberProfile.find(project_params['member_profile_id']) rescue nil
|
||||
@project = Project.new(project_params)
|
||||
@project.save
|
||||
redirect_to '/admin/members/'+@member.to_param+'/Project'
|
||||
end
|
||||
|
||||
def edit
|
||||
@member = MemberProfile.find_by(:uid=>params['uid']) rescue nil
|
||||
@project = Project.find(params[:id])
|
||||
end
|
||||
|
||||
def update
|
||||
@member = MemberProfile.find(project_params['member_profile_id']) rescue nil
|
||||
@project = Project.find(params[:id])
|
||||
@project.update_attributes(project_params)
|
||||
@project.save
|
||||
redirect_to '/admin/members/'+@member.to_param+'/Project'
|
||||
end
|
||||
|
||||
def destroy
|
||||
@project = Project.find(params[:id])
|
||||
@project.destroy
|
||||
end
|
||||
|
||||
def toggle_hide
|
||||
if params[:ids]
|
||||
@projects = Project.any_in(_id: params[:ids])
|
||||
|
||||
@projects.each do |project|
|
||||
project.is_hidden = params[:disable]
|
||||
project.save
|
||||
end
|
||||
end
|
||||
|
||||
render json: {"success"=>true}
|
||||
end
|
||||
|
||||
def setting
|
||||
end
|
||||
|
||||
def frontend_setting
|
||||
@member = MemberProfile.find_by(:uid=>params['uid']) rescue nil
|
||||
@intro = ProjectIntro.find_by(:member_profile_id=>@member.id) rescue nil
|
||||
@intro = @intro.nil? ? ProjectIntro.new({:member_profile_id=>@member.id}) : @intro
|
||||
end
|
||||
|
||||
def update_frontend_setting
|
||||
@member = MemberProfile.find(intro_params['member_profile_id']) rescue nil
|
||||
@intro = ProjectIntro.find_by(:member_profile_id=>@member.id) rescue nil
|
||||
@intro = @intro.nil? ? ProjectIntro.new({:member_profile_id=>@member.id}) : @intro
|
||||
@intro.update_attributes(intro_params)
|
||||
@intro.save
|
||||
redirect_to '/admin/members/'+@member.to_param+'/Project'
|
||||
end
|
||||
|
||||
def get_settings
|
||||
@project_types = ProjectType.all
|
||||
end
|
||||
|
||||
def set_plugin
|
||||
@plugin = OrbitApp::Plugin::Registration.all.select{|plugin| plugin.app_name.eql? 'Project'}.first
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def project_params
|
||||
params.require(:project).permit! rescue nil
|
||||
end
|
||||
|
||||
def intro_params
|
||||
params.require(:project_intro).permit! rescue nil
|
||||
end
|
||||
end
|
|
@ -0,0 +1,74 @@
|
|||
class PersonalProjectsController < ApplicationController
|
||||
def index
|
||||
projects = Project.where(:is_hidden=>false).all
|
||||
project_list = projects.collect do |project|
|
||||
{
|
||||
"duration" => project.duration,
|
||||
"project_title" => project.project_title,
|
||||
"job_title" => project.job_title,
|
||||
"participator" => project.participator,
|
||||
"authors" => project.member_profile.name,
|
||||
"link_to_show" => OrbitHelper.url_to_show(project.to_param)
|
||||
}
|
||||
end
|
||||
{
|
||||
"projects" => project_list,
|
||||
"extras" => {
|
||||
"widget-title" => t("module_name.personal_project"),
|
||||
"th_duration" => t('personal_project.period'),
|
||||
"th_project_title" => t("personal_project.project_title"),
|
||||
"th_job_title" => t('personal_project.job_title'),
|
||||
"th_participator" => t("personal_project.participator"),
|
||||
"th_authors" => t('users.name')
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
def show
|
||||
params = OrbitHelper.params
|
||||
project = Project.where(:is_hidden=>false).find_by(uid: params[:uid])
|
||||
|
||||
files = project.project_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" => {
|
||||
"project_title" => project.project_title,
|
||||
"project_type" => project.project_type.title,
|
||||
"job_title" => project.job_title,
|
||||
"participator" => project.participator,
|
||||
"unit" => project.unit,
|
||||
"year" => project.year,
|
||||
"language" => project.language,
|
||||
"keywords" => project.keywords,
|
||||
"abstract" => project.abstract,
|
||||
"duration" => project.duration,
|
||||
"url" => project.url,
|
||||
"note" => project.note,
|
||||
|
||||
"th_project_title" => t("personal_project.project_title"),
|
||||
"th_job_title" => t("personal_project.job_title"),
|
||||
"th_participator" => t("personal_project.participator"),
|
||||
"th_unit" => t("personal_project.unit"),
|
||||
"th_year" => t("personal_project.year"),
|
||||
"th_language" => t("personal_project.language"),
|
||||
"th_keywords" => t("personal_project.keywords"),
|
||||
"th_abstract" => t("personal_project.abstract"),
|
||||
"th_duration" => t("personal_project.period"),
|
||||
"th_url" => t("personal_project.url"),
|
||||
"th_note" => t("personal_project.note"),
|
||||
|
||||
"th_project_type" => t("personal_project.project_category"),
|
||||
"th_files" => t(:file_)
|
||||
}
|
||||
}
|
||||
end
|
||||
end
|
|
@ -0,0 +1,46 @@
|
|||
class Project
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
include OrbitModel::Status
|
||||
include Slug
|
||||
|
||||
belongs_to :project_type
|
||||
belongs_to :member_profile
|
||||
|
||||
field :project_title, as: :slug_title, localize: true
|
||||
field :job_title, localize: true
|
||||
field :participator, localize: true
|
||||
field :unit, localize: true
|
||||
|
||||
field :year
|
||||
field :language
|
||||
field :keywords
|
||||
field :abstract
|
||||
field :period_start_date, :type => Date
|
||||
field :period_end_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 :project_files, :autosave => true, :dependent => :destroy
|
||||
|
||||
accepts_nested_attributes_for :project_files, :allow_destroy => true
|
||||
|
||||
before_validation :add_http
|
||||
|
||||
def duration
|
||||
"#{self.period_start_date.strftime("%Y.%m")} ~ #{self.period_end_date.strftime("%Y.%m")}"
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def add_http
|
||||
unless self.url.blank? || self.url[/^http:\/\//] || self.url[/^https:\/\//]
|
||||
self.url = 'http://' + self.url
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,14 @@
|
|||
class ProjectFile
|
||||
|
||||
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 :project
|
||||
|
||||
end
|
|
@ -0,0 +1,4 @@
|
|||
class ProjectIntro < PersonalPluginIntro
|
||||
|
||||
|
||||
end
|
|
@ -0,0 +1,9 @@
|
|||
class ProjectType
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
|
||||
field :title, localize: true
|
||||
|
||||
has_many :projects
|
||||
|
||||
end
|
|
@ -0,0 +1,24 @@
|
|||
<%= form_for(@project_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_project.project_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 => (@project_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 %>
|
|
@ -0,0 +1,2 @@
|
|||
$('#project_types tbody').html("<%= j render :partial => '/admin/projects/list_project_type', :collection => @project_types %>");
|
||||
$('#project_type_modal').modal('hide');
|
|
@ -0,0 +1 @@
|
|||
$('#project_type_modal').html("<%= j render 'form' %>");
|
|
@ -0,0 +1 @@
|
|||
$('#project_type_modal').html("<%= j render 'form' %>");
|
|
@ -0,0 +1,262 @@
|
|||
<% # 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_project.year") %></label>
|
||||
<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'} ) %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- project_category -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("personal_project.project_category") %></label>
|
||||
<div class="controls">
|
||||
<%= f.select :project_type_id, @project_types.collect {|t| [ t.title, t.id ]} %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- period_start_date -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("personal_project.start_date") %></label>
|
||||
<div class="controls">
|
||||
<%= f.datetime_picker :period_start_date, :no_label => true, :format=>"yyyy/MM" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- period_end_date -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("personal_project.end_date") %></label>
|
||||
<div class="controls">
|
||||
<%= f.datetime_picker :period_end_date, :no_label => true, :format=>"yyyy/MM" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- url -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("personal_project.url") %></label>
|
||||
<div class="controls">
|
||||
<%= f.text_field :url , :class => "span5" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- keywords -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("personal_project.keywords") %></label>
|
||||
<div class="controls">
|
||||
<%= f.text_field :keywords %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- language -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("personal_project.language") %></label>
|
||||
<div class="controls">
|
||||
<select id="project_language" name="project[language]">
|
||||
<% @site_in_use_locales.each do |locale| %>
|
||||
<option value="<%= locale %>" <%= @project.language.eql?(locale.to_s) ? "selected" : ""%>><%= t(locale) %></option>
|
||||
<% end %>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- abstract -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("personal_project.abstract") %></label>
|
||||
<div class="controls">
|
||||
<%= f.text_area :abstract, rows: 2, class: "input-block-level" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- note -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("personal_project.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 @project.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" : '' %>">
|
||||
|
||||
<!-- project_title-->
|
||||
<div class="control-group input-title">
|
||||
<label class="control-label muted"><%= t("personal_project.project_title") %></label>
|
||||
<div class="controls">
|
||||
<%= 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) %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- job_title-->
|
||||
<div class="control-group input-title">
|
||||
<label class="control-label muted"><%= t("personal_project.job_title") %></label>
|
||||
<div class="controls">
|
||||
<%= 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) %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- participator-->
|
||||
<div class="control-group input-title">
|
||||
<label class="control-label muted"><%= t("personal_project.participator") %></label>
|
||||
<div class="controls">
|
||||
<%= 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) %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- unit-->
|
||||
<div class="control-group input-title">
|
||||
<label class="control-label muted"><%= t("personal_project.unit") %></label>
|
||||
<div class="controls">
|
||||
<%= 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) %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<% end %>
|
||||
|
||||
<!-- File -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t(:file_) %></label>
|
||||
<div class="controls">
|
||||
|
||||
<!-- Exist -->
|
||||
<% if @project && !@project.project_files.blank? %>
|
||||
<div class="exist">
|
||||
<% @project.project_files.each_with_index do |project_file, i| %>
|
||||
<%= f.fields_for :project_files, project_file do |f| %>
|
||||
<%= render :partial => 'form_file', :object => project_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', @project.project_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_project_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, :project_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 %>
|
|
@ -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>
|
|
@ -0,0 +1,8 @@
|
|||
<tr id="<%= dom_id list_project_type %>">
|
||||
<td><%= list_project_type.title %></td>
|
||||
<td class="span2">
|
||||
|
||||
<a href="<%= edit_admin_project_type_path(list_project_type) %>#project_type_modal" data-toggle="modal" data-remote="true" class="action"><%= t(:edit) %></a>
|
||||
<%= link_to t(:delete_), admin_project_type_path(list_project_type), "data-confirm" => t('sure?'), :method => :delete, :remote => true,:class=>"archive_toggle action" %>
|
||||
</td>
|
||||
</tr>
|
|
@ -0,0 +1,18 @@
|
|||
<% @projects.each do |project| %>
|
||||
<tr id="<%= dom_id project %>" class="<%= project.is_hidden ? "checkHide" : "" %>">
|
||||
<td><%= project.duration %></td>
|
||||
<td>
|
||||
<%= link_to project.project_title, OrbitHelper.url_to_plugin_show(project.to_param,'personal_project').to_s, target: "blank"%>
|
||||
<div class="quick-edit">
|
||||
<ul class="nav nav-pills hide">
|
||||
<li><%= link_to t('edit'), '/admin/members/'+project.member_profile.to_param+'/projects/'+project.id+'/edit' %></li>
|
||||
<li><%= link_to t(:delete_), admin_project_path(id: project.id, member_profile_id: project.member_profile.id), method: :delete, remote: true, data: { confirm: t('sure?') } %></li>
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
<td><%= project.job_title %></td>
|
||||
<td><%= project.participator %></td>
|
||||
<td><%= project.unit %></td>
|
||||
<td><%= project.member_profile.name %></td>
|
||||
</tr>
|
||||
<% end %>
|
|
@ -0,0 +1 @@
|
|||
$('#project_<%= @project.id.to_s%>').remove();
|
|
@ -0,0 +1,5 @@
|
|||
<%= form_for @project, url:'/admin/projects/'+@project.id.to_s, html: {class: "form-horizontal main-forms previewable"} do |f| %>
|
||||
<fieldset>
|
||||
<%= render partial: 'form', locals: {f: f} %>
|
||||
</fieldset>
|
||||
<% end %>
|
|
@ -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(:project_intro, :url => update_frontend_setting_admin_projects_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_project") %></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 %>
|
|
@ -0,0 +1,23 @@
|
|||
<table class="table main-list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="span2"><%= t('personal_project.period') %></th>
|
||||
<th class="span5"><%= t('personal_project.project_title') %></th>
|
||||
<th class="span1"><%= t('personal_project.job_title') %></th>
|
||||
<th class="span1"><%= t('personal_project.participator') %></th>
|
||||
<th class="span1"><%= t('personal_project.unit') %></th>
|
||||
<th class="span1"><%= t('users.name') %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="tbody_projects" class="sort-holder">
|
||||
<%= render :partial => 'project', :collection => @projects %>
|
||||
</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_project_setting_path, :class => 'btn btn-primary pull-right' %>
|
||||
</div>
|
||||
<div class="pagination pagination-centered">
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,5 @@
|
|||
<%= form_for @project, url: admin_projects_path, html: {class: "form-horizontal main-forms previewable"} do |f| %>
|
||||
<fieldset>
|
||||
<%= render partial: 'form', locals: {f: f} %>
|
||||
</fieldset>
|
||||
<% end %>
|
|
@ -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_project_type_path %>#project_type_modal" data-toggle="modal" data-remote="true"><i class="icon-plus"></i> <%= t('add')%></a>
|
||||
<span><%= t("personal_project.project_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="project_types" class="table table-striped">
|
||||
<tbody>
|
||||
<%= render :partial => 'list_project_type', :collection => @project_types %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="project_type_qe">
|
||||
<div style="display:none;" class="modal" id="project_type_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1 @@
|
|||
<%= render_view %>
|
|
@ -0,0 +1 @@
|
|||
<%= render_view %>
|
|
@ -0,0 +1,84 @@
|
|||
<% 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
|
||||
@projects = Project.where(member_profile_id: @member.id).desc(:year).page(params[:page]).per(10)
|
||||
else
|
||||
@projects = Project.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_projects_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_projects_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="span2"><%= t('personal_project.year') %></th>
|
||||
<th class="span4"><%= t('personal_project.project_title') %></th>
|
||||
<th class="span4"><%= t('personal_project.job_title') %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @projects.each do |project| %>
|
||||
<tr id="<%= dom_id project %>" class="<%= project.is_hidden ? "checkHide" : "" %>">
|
||||
<% if is_autorized_user %>
|
||||
<td>
|
||||
<%= check_box_tag 'to_change[]', project.id.to_s, false, :class => "list-check" %>
|
||||
</td>
|
||||
<% end %>
|
||||
<td><%= project.year %></td>
|
||||
<td>
|
||||
<%= link_to project.project_title, OrbitHelper.url_to_plugin_show(project.to_param,'personal_project').to_s, target: "blank"%>
|
||||
<div class="quick-edit">
|
||||
<ul class="nav nav-pills hide">
|
||||
<li><%= link_to t('edit'), '/admin/members/'+@member.to_param+'/projects/'+project.id+'/edit' %></li>
|
||||
<li><%= link_to t(:delete_), admin_project_path(id: project.id, member_profile_id: @member.id), method: :delete, remote: true, data: { confirm: t('sure?') } %></li>
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
<td><%= project.job_title %></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+'/projects/frontend_setting', :class => 'btn btn-primary' %>
|
||||
<%= link_to content_tag(:i, nil, :class => 'icon-plus') +' '+ t('new_'),
|
||||
'/admin/members/'+@member.to_param+'/projects/new', :class => 'btn btn-primary' %>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="pagination pagination-centered">
|
||||
<%= paginate @projects, :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>
|
|
@ -2,6 +2,28 @@ Rails.application.routes.draw do
|
|||
locales = Site.find_by(site_active: true).in_use_locales rescue I18n.available_locales
|
||||
scope "(:locale)", locale: Regexp.new(locales.join("|")) do
|
||||
namespace :admin do
|
||||
get 'project_setting' => "projects#setting"
|
||||
|
||||
resources :projects do
|
||||
collection do
|
||||
get 'toggle_hide' => 'projects#toggle_hide'
|
||||
end
|
||||
end
|
||||
|
||||
resources :members do
|
||||
collection do
|
||||
scope '(:name-:uid)' do
|
||||
resources :projects do
|
||||
collection do
|
||||
get 'frontend_setting' => 'projects#frontend_setting'
|
||||
post 'update_frontend_setting' => 'projects#update_frontend_setting'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
resources :project_types
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,7 +4,7 @@ module PersonalProject
|
|||
OrbitApp.registration "PersonalProject",:type=> 'ModuleApp' do
|
||||
module_label 'module_name.personal_project'
|
||||
base_url File.expand_path File.dirname(__FILE__)
|
||||
personal_plugin :enable => true, :sort_number => '15', :app_name=>"Project", :intro_app_name=>"PersonalProjectIntro",:path=>"/plugin/profile",:front_path=>"/profile",:admin_path=>"/admin/projects",:i18n=>'module_name.personal_project'
|
||||
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"
|
||||
organization "Rulingcom"
|
||||
|
@ -12,6 +12,8 @@ module PersonalProject
|
|||
intro "I am intro"
|
||||
update_info 'some update_info'
|
||||
|
||||
frontend_enabled
|
||||
icon_class_no_sidebar "icons-user"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue