complete most of things

This commit is contained in:
BOHUNG 2020-03-19 22:35:41 +08:00
parent 365eefb1ee
commit 3fea4acee4
16 changed files with 151 additions and 175 deletions

View File

@ -4,8 +4,9 @@ class PersonalWritingsController < ApplicationController
writing_list = writings.collect do |writing|
{
"year" => writing.year,
"month" => writing.month,
"writing_title" => writing.writing_title,
"location" => writing.location,
"other" => writing.other,
"member" => (writing.member_profile.name rescue ""),
"link_to_show" => OrbitHelper.url_to_show(writing.to_param)
}
@ -15,8 +16,9 @@ class PersonalWritingsController < ApplicationController
"extras" => {
"widget-title" => t("module_name.personal_writing"),
"th_year" => t('personal_writing.year'),
"th_month" => t('personal_writing.month'),
"th_writing_title" => t('module_name.personal_writing'),
"th_location" => t('personal_writing.location'),
"th_other" => t('personal_writing.other'),
"th_member" => t('users.name'),
"th_detail" => t('detail')
},
@ -29,16 +31,10 @@ class PersonalWritingsController < ApplicationController
plugin = Writing.where(:is_hidden=>false).find_by(uid: params[:uid])
fields_to_show = [
"year",
"month",
"writing_title",
"location",
"participating_professor",
"participating_student",
"research_direction",
"facility",
"keywords",
"extension_no",
"other",
"url",
"note",
"file"
]

View File

@ -51,39 +51,13 @@ module Admin::PersonalWritingsHelper
rescue
value = {"zh_tw" => val}
end
writing.location_translations = value
writing.other_translations = value
when 6
value = {"en" => val}
when 7
begin
value["zh_tw"] = val
rescue
value = {"zh_tw" => val}
end
writing.participating_professor_translations = value
when 8
value = {"en" => val}
when 9
begin
value["zh_tw"] = val
rescue
value = {"zh_tw" => val}
end
writing.participating_student_translations = value
when 10
writing.year = val
when 11
writing.extension_no = val
when 12
writing.research_direction = val
when 13
writing.facility = val
when 14
when 7
writing.month = val
when 8
writing.url = val
when 15
writing.keywords = val
when 16
writing.note = val
end
end
writing.member_profile = mp

View File

@ -3,22 +3,14 @@ class Writing
include Mongoid::Timestamps
include OrbitModel::Status
include Slug
include OrbitCategory::Categorizable
belongs_to :member_profile
field :writing_title, :as=>:slug_title, localize: true
field :location, localize: true
field :participating_professor, localize: true
field :participating_student, localize: true
field :other, localize: true
field :month
field :year
field :language
field :keywords
field :extension_no
field :research_direction
field :facility
field :url
field :note
field :create_user_id, :type => BSON::ObjectId
field :update_user_id, :type => BSON::ObjectId
@ -45,8 +37,10 @@ class Writing
fields_to_show = [
"year",
"month",
"writing_title",
"location"
"other",
"url"
]
fields_to_remove = []

View File

@ -3,13 +3,14 @@
<%= stylesheet_link_tag "lib/main-forms" %>
<%= stylesheet_link_tag "lib/fileupload" %>
<%= stylesheet_link_tag "lib/main-list" %>
<link href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.3.0/css/font-awesome.min.css" media="screen" rel="stylesheet">
<link href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.3.0/css/font-awesome.min.css" media="print" rel="stylesheet">
<% end %>
<% content_for :page_specific_javascript do %>
<%= 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">
@ -32,47 +33,36 @@
<% @site_in_use_locales.each_with_index do |locale, i| %>
<div class="<%= locale %> tab-pane fade <%= ( i == 0 ) ? "in active" : '' %>">
<!-- lab_title-->
<!-- writing_title-->
<div class="control-group input-title">
<label class="control-label muted"><%= t("personal_writing.lab_title") %></label>
<label class="control-label muted"><%= t("personal_writing.writing_title") %></label>
<div class="controls">
<%= f.fields_for :lab_title_translations do |f| %>
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_writing.lab_title"), value: (@writing.lab_title_translations[locale] rescue nil) %>
<%= f.fields_for :writing_title_translations do |f| %>
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_writing.writing_title"), value: (@writing.writing_title_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
<!-- location-->
<!-- other-->
<div id="show_help_modal" class="modal fade">
<div class='modal-dialog'>
<div class='modal-content'>
<div class='modal-header'>
<button type='button' aria-hidden='true' class='close'>×</button>
<h4 class='modal-title'><%= t("personal_writing.other") %></h4>
</div>
<div class='modal-body'><%= t("personal_writing.other_hint") %></div>
<div class='modal-footer'><button type='button' class='btn btn-default'>Close</button></div>
</div>
</div>
</div>
<div class="control-group input-title">
<label class="control-label muted"><%= t("personal_writing.location") %></label>
<label class="control-label muted"><button tabindex="0" class="help_btn" data-target="#show_help_modal" style="cursor: pointer;padding: 0em 0.3em;font-size: 1.25em;border-radius: 1em;margin-left: 0.5em;background-color: #0088cc;border-color: #0088cc;color: white;font-family: FontAwesome;width: 1.5em;"><i aria-hidden="true" class="fa fa-question"></i></button><%= t("personal_writing.other") %></label>
<div class="controls">
<%= f.fields_for :location_translations do |f| %>
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_writing.location"), value: (@writing.location_translations[locale] rescue nil) %>
<%= f.fields_for :other_translations do |f| %>
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_writing.other"), value: (@writing.other_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
<!-- participating_professor-->
<div class="control-group input-title">
<label class="control-label muted"><%= t("personal_writing.participating_professor") %></label>
<div class="controls">
<%= f.fields_for :participating_professor_translations do |f| %>
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_writing.participating_professor"), value: (@writing.participating_professor_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
<!-- participating_student-->
<div class="control-group input-title">
<label class="control-label muted"><%= t("personal_writing.participating_student") %></label>
<div class="controls">
<%= f.fields_for :participating_student_translations do |f| %>
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_writing.participating_student"), value: (@writing.participating_student_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
</div>
<% end %>
@ -83,11 +73,11 @@
<div class="controls">
<!-- Exist -->
<% if @writing && !@writing.lab_files.blank? %>
<% if @writing && !@writing.writing_files.blank? %>
<div class="exist">
<% @writing.lab_files.each_with_index do |lab_file, i| %>
<%= f.fields_for :lab_files, lab_file do |f| %>
<%= render :partial => 'form_file', :object => lab_file, :locals => {:f => f, :i => i} %>
<% @writing.writing_files.each_with_index do |writing_file, i| %>
<%= f.fields_for :writing_files, writing_file do |f| %>
<%= render :partial => 'form_file', :object => writing_file, :locals => {:f => f, :i => i} %>
<% end %>
<% end %>
<hr>
@ -98,7 +88,7 @@
<div class="add-target">
</div>
<p class="add-btn">
<%= hidden_field_tag 'plugin_file_field_count', @writing.lab_files.count %>
<%= hidden_field_tag 'plugin_file_field_count', @writing.writing_files.count %>
<a id="add_file" class="trigger btn btn-small btn-primary"><i class="icons-plus"></i> <%= t(:add) %></a>
</p>
</div>
@ -123,7 +113,13 @@
<!-- Basic Module -->
<div class="tab-pane fade in active" id="basic">
<!-- Category -->
<div class="control-group">
<label class="control-label muted"><%= t(:category) %></label>
<div class="controls">
<%= select_category(f, @module_app) %>
</div>
</div>
<% if !@member.nil? %>
<div class="control-group big-group">
@ -152,31 +148,13 @@
<%= select_year((@writing.year ? @writing.year.to_i : DateTime.now.year), {:start_year => (DateTime.now.year+5), :end_year => 1930}, {:name => 'writing[year]', :class => 'span1'} ) %>
</div>
</div>
<!-- extension_no -->
<!-- month -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_writing.extension_no") %></label>
<label class="control-label muted"><%= t("personal_writing.month") %></label>
<div class="controls">
<%= f.text_field :extension_no %>
<%= select_month((@writing.month ? @writing.month.to_i : DateTime.now.month) ,:field_name => 'month', :prefix => 'writing' ) %>
</div>
</div>
<!-- research_direction -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_writing.research_direction") %></label>
<div class="controls">
<%= f.text_field :research_direction %>
</div>
</div>
<!-- facility -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_writing.facility") %></label>
<div class="controls">
<%= f.text_field :facility %>
</div>
</div>
<!-- url -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_writing.url") %></label>
@ -184,23 +162,6 @@
<%= f.text_field :url , :class => "span6" %>
</div>
</div>
<!-- keywords -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_writing.keywords") %></label>
<div class="controls">
<%= f.text_field :keywords %>
</div>
</div>
<!-- note -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_writing.note") %></label>
<div class="controls">
<%= f.text_area :note, rows: 2, class: "input-block-level" %>
</div>
</div>
</div>
<!-- Status Module -->
@ -231,11 +192,11 @@
$('.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_lab_files", "g");
var old_id = new RegExp("new_writing_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, :lab_files) %>").replace(old_id, new_id));
$(this).parent().siblings('.add-target').append(("<%= escape_javascript(add_attribute 'form_file', f, :writing_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');
});
@ -249,4 +210,18 @@
}
}
});
$(document).ready(function(){
$('.help_btn').click(function(){
$('#show_help_modal').modal('show');
return false;
});
$('#show_help_modal .close').off("click").on('click',function(){
$('#show_help_modal').modal('hide');
return false;
});
$('#show_help_modal .modal-footer button').off("click").on('click',function(){
$('#show_help_modal').modal('hide');
return false;
});
})
</script>

View File

@ -1,6 +1,8 @@
<% @writings.each do |writing| %>
<tr id="<%= dom_id writing %>" class="<%= writing.is_hidden ? "checkHide" : "" %>">
<td><%= writing.category.title rescue "" %></td>
<td><%= writing.year %></td>
<td><%= writing.month %></td>
<td>
<%= link_to writing.writing_title, OrbitHelper.url_to_plugin_show(writing.to_param,'personal_writing'), target: "blank"%>
<div class="quick-edit">
@ -10,7 +12,6 @@
</ul>
</div>
</td>
<td><%= writing.location %></td>
<td><%= writing.member_profile.name rescue "" %></td>
</tr>
<% end %>

View File

@ -1,4 +1,4 @@
<%= form_for @writing, url:'/admin/labs/'+@writing.id.to_s, html: {class: "form-horizontal main-forms previewable"} do |f| %>
<%= form_for @writing, url:'/admin/writings/'+@writing.id.to_s, html: {class: "form-horizontal main-forms previewable"} do |f| %>
<fieldset>
<%= render partial: 'form', locals: {f: f} %>
</fieldset>

View File

@ -3,7 +3,7 @@
<%= stylesheet_link_tag "lib/main-list" %>
<% end %>
<%= form_for(:lab_intro, :url => update_frontend_setting_admin_labs_path, :method => "post", html: {class: "form-horizontal main-forms previewable"} ) do |f| %>
<%= form_for(:writing_intro, :url => update_frontend_setting_admin_writings_path, :method => "post", html: {class: "form-horizontal main-forms previewable"} ) do |f| %>
<fieldset>
<!-- Input Area -->
<div class="input-area">

View File

@ -1,13 +1,14 @@
<table class="table main-list">
<thead>
<tr>
<th class="span1"><%= t(:category) %></th>
<th class="span1"><%= t('personal_writing.year') %></th>
<th class="span1"><%= t('personal_writing.month') %></th>
<th class="span3"><%= t('module_name.personal_writing') %></th>
<th class="span1"><%= t('personal_writing.location') %></th>
<th class="span1"><%= t('users.name') %></th>
</tr>
</thead>
<tbody id="tbody_labs" class="sort-holder">
<tbody id="tbody_writings" class="sort-holder">
<%= render 'writing' %>
</tbody>
</table>
@ -20,23 +21,23 @@
<span class="caret"></span>
</button>
<div class="dropdown-menu upload-box">
<form action="/admin/labs/import_from_excel" method="post" enctype="multipart/form-data">
<form action="/admin/writings/import_from_excel" method="post" enctype="multipart/form-data">
<%= hidden_field_tag :authenticity_token, form_authenticity_token %>
<input type="file" name="import_file" >
<button class="btn btn-primary" type="submit"><%= t(:submit) %></button>
<a class="" href="/admin/labs/download_excel_format.xlsx">Download excel format</a>
<a class="" href="/admin/writings/download_excel_format.xlsx">Download excel format</a>
</form>
</div>
</div>
<%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t(:new_), new_admin_lab_path, :class => 'btn btn-primary' %>
<%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t(:new_), new_admin_writing_path, :class => 'btn btn-primary' %>
</div>
<div class="pagination pagination-centered">
<%= content_tag :div, paginate(@labs), class: "pagination pagination-centered" %>
<%= content_tag :div, paginate(@writings), class: "pagination pagination-centered" %>
</div>
</div>
<% if params[:error] == "1" %>
<script type="text/javascript">
alert("File cannot be imported. File has more than 500 entries. Please seperate the entries in different files.");
window.location.href = "<%= admin_labs_url %>"
window.location.href = "<%= admin_writings_url %>"
</script>
<% end %>

View File

@ -1,4 +1,4 @@
<%= form_for @writing, url: admin_labs_path, html: {class: "form-horizontal main-forms previewable"} do |f| %>
<%= form_for @writing, url: admin_writings_path, html: {class: "form-horizontal main-forms previewable"} do |f| %>
<fieldset>
<%= render partial: 'form', locals: {f: f} %>
</fieldset>

View File

@ -7,17 +7,17 @@
<%
if has_access?
@labs = Writing.where(member_profile_id: @member.id).desc(:year).page(params[:page]).per(10)
@writings = Writing.where(member_profile_id: @member.id).desc(:year).page(params[:page]).per(10)
else
@labs = Writing.where(is_hidden: false, member_profile_id: @member.id).desc(:year).page(params[:page]).per(10)
@writings = Writing.where(is_hidden: false, member_profile_id: @member.id).desc(:year).page(params[:page]).per(10)
end
%>
<% if has_access? %>
<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_labs_path(member_profile_id: @member.id.to_s, disable: 'true') ) %>
<%= link_to('Show', '#', :class => "btn btn-mini list-active-btn disabled", "data-check-action" => "list-be-show", :rel => toggle_hide_admin_labs_path(member_profile_id: @member.id.to_s, disable: 'false') ) %>
<%= link_to('Hide', '#', :class => "btn btn-mini list-active-btn disabled", "data-check-action" => "list-be-hide", :rel => toggle_hide_admin_writings_path(member_profile_id: @member.id.to_s, disable: 'true') ) %>
<%= link_to('Show', '#', :class => "btn btn-mini list-active-btn disabled", "data-check-action" => "list-be-show", :rel => toggle_hide_admin_writings_path(member_profile_id: @member.id.to_s, disable: 'false') ) %>
</div>
</div>
<% end -%>
@ -29,12 +29,13 @@
<th><input type="checkbox" /></th>
<% end -%>
<th class="span2"><%= t('personal_writing.year') %></th>
<th class="span2"><%= t('personal_writing.month') %></th>
<th class="span4"><%= t('module_name.personal_writing') %></th>
<th><%= t('personal_writing.location') %></th>
<th class="span2"><%= t('personal_writing.other') %></th>
</tr>
</thead>
<tbody>
<% @labs.each do |writing| %>
<% @writings.each do |writing| %>
<tr id="<%= dom_id writing %>" class="<%= writing.is_hidden ? "checkHide" : "" %>">
<% if has_access? %>
<td>
@ -42,18 +43,19 @@
</td>
<% end %>
<td><%= writing.year %></td>
<td><%= writing.month %></td>
<td>
<%= link_to writing.lab_title, OrbitHelper.url_to_plugin_show(writing.to_param,'personal_writing'), target: "blank"%>
<%= link_to writing.writing_title, OrbitHelper.url_to_plugin_show(writing.to_param,'personal_writing'), target: "blank"%>
<div class="quick-edit">
<ul class="nav nav-pills hide">
<% if has_access? %>
<li><%= link_to t('edit'), '/admin/members/'+@member.to_param+'/labs/'+writing.id+'/edit' %></li>
<li><%= link_to t(:delete_), admin_lab_path(id: writing.id, member_profile_id: @member.id), method: :delete, remote: true, data: { confirm: t('sure?') } %></li>
<li><%= link_to t('edit'), '/admin/members/'+@member.to_param+'/writings/'+writing.id+'/edit' %></li>
<li><%= link_to t(:delete_), admin_writing_path(id: writing.id, member_profile_id: @member.id), method: :delete, remote: true, data: { confirm: t('sure?') } %></li>
<% end %>
</ul>
</div>
</td>
<td><%= writing.location %></td>
<td><%= writing.other %></td>
</tr>
<% end %>
</tbody>
@ -63,13 +65,13 @@
<div class="bottomnav clearfix">
<% if has_access? %>
<div class="action pull-right">
<%= link_to content_tag(:i, nil, :class => 'icon-edit') +' '+ t('setting'),'/admin/members/'+@member.to_param+'/labs/frontend_setting', :class => 'btn btn-primary' %>
<%= link_to content_tag(:i, nil, :class => 'icon-edit') +' '+ t('setting'),'/admin/members/'+@member.to_param+'/writings/frontend_setting', :class => 'btn btn-primary' %>
<%= link_to content_tag(:i, nil, :class => 'icon-plus') +' '+ t('new_'),
'/admin/members/'+@member.to_param+'/labs/new', :class => 'btn btn-primary' %>
'/admin/members/'+@member.to_param+'/writings/new', :class => 'btn btn-primary' %>
</div>
<% end %>
<div class="pagination pagination-centered">
<%= paginate @labs, :params => {:direction => params[:direction], :sort => params[:sort] } %>
<%= paginate @writings, :params => {:direction => params[:direction], :sort => params[:sort] } %>
</div>
</div>

View File

@ -2,19 +2,15 @@ en:
module_name:
personal_writing: Writing
personal_writing:
book_title : "Book Title"
lab_title : "Writing Title"
other: Other
other_hint: 其他欄請填寫 頁數及出版社 或 期刊名及第幾頁 或 研討會名稱 或 學位名稱 等
writing_title : "Writing Title"
extracted_chapters : "Extracted Chapters"
location : "Location"
participating_professor : "Participating Professor"
participating_student : "Participating Student"
extension_no : "Extension Number"
research_direction : "Research Direction"
facility : "Facility"
publishers : "Publishers"
authors : "Authors"
tags : "Tags"
year : "Year"
month: "Month"
language : "Language"
isbn : "ISSN(ISBN)"
vol_no : "Vol.No"
@ -22,11 +18,9 @@ en:
form_to_start : "From"
form_to_end : "To"
total_pages : "Total Pages"
keywords : "Keywords"
abstract : "Abstract"
publication_date : "Date of Publication"
url : "Reference URL"
note : "Note"
level_type : "Level Type"
author_type : "Author Type"
from : "From"
@ -37,7 +31,7 @@ en:
pages : "Pages"
book_paper_type : "Book Paper Type"
frontend:
labs: "Writing Frontend"
writings: "Writing Frontend"
create_success : "Successfully Create"
update_success : "Successfully Update"

View File

@ -2,17 +2,14 @@ zh_tw:
module_name:
personal_writing: 其他著作
personal_writing:
lab_title : "實驗室名稱"
other: 其他
other_hint: 其他欄請填寫 頁數及出版社 或 期刊名及第幾頁 或 研討會名稱 或 學位名稱 等
writing_title : "著作名稱"
extracted_chapters : "Extracted Chapters"
participating_professor : "參與教授"
participating_student : "參與學生"
research_direction : "研究方向"
facility : "設備"
extension_no : "分機"
location : "位置"
authors : "作者"
tags : "領域"
year : "年度"
month: "月份"
language : "語言"
isbn : "ISSN(ISBN)"
vol_no : "卷數"
@ -20,11 +17,9 @@ zh_tw:
form_to_start : "起"
form_to_end : "迄"
total_pages : "總頁數"
keywords : "關鍵字"
abstract : "摘要"
publication_date : "發表日期"
url : "參考連結"
note : "記事"
level_type : "期刊類別"
author_type : "作者類別"
from : "起"
@ -33,7 +28,7 @@ zh_tw:
file_name : "檔案名稱"
description : "描述"
frontend:
labs: "實驗室前台"
writings: "實驗室前台"
create_success : "新增完成!!"
update_success : "更新完成!!"

View File

@ -0,0 +1,24 @@
<table class="table table-hover table-striped writing-conferences-index">
<caption><h1>{{widget-title}}</h1></caption>
<thead>
<tr>
<th class="col-md-2">{{th_year}}</th>
<th class="col-md-2">{{th_month}}</th>
<th class="col-md-3">{{th_writing_title}}</th>
<th class="col-md-2">{{th_other}}</th>
<th class="col-md-3">{{th_member}}</th>
<th class="col-md-2"></th>
</tr>
</thead>
<tbody data-level="0" data-list="writings">
<tr>
<td>{{year}}</td>
<td>{{month}}</td>
<td>{{writing_title}}</td>
<td>{{other}}</td>
<td>{{member}}</td>
<th><a href="{{link_to_show}}">{{th_detail}}</a></th>
</tr>
</tbody>
</table>
{{pagination_goes_here}}

View File

@ -0,0 +1,12 @@
{
"frontend": [
{
"filename" : "index",
"name" : {
"zh_tw" : "1. 列表",
"en" : "1. List"
},
"thumbnail" : "thumb.png"
}
]
}

View File

@ -0,0 +1,8 @@
<table class="table table-striped plugin-show-table">
<tbody data-list="plugin_datas" data-level="0">
<tr>
<th class="{{title_class}}">{{title}}</th>
<td class="{{value_class}}">{{value}}</td>
</tr>
</tbody>
</table>

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB