add fields in R2 lab.Puts template file into plugin.

This commit is contained in:
BOHUNG 2020-03-08 11:26:46 +08:00
parent 6722f49ca2
commit 49e65ab628
16 changed files with 431 additions and 13 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 621 B

BIN
app/assets/images/th_bg.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 B

View File

@ -47,7 +47,7 @@ class Admin::ExperimentsController < OrbitAdminController
@subject = Subject.find(params[:id]) @subject = Subject.find(params[:id])
bps = create_params bps = create_params
bps[:email_member_ids] = bps[:email_member_ids].blank? ? [] : bps[:email_member_ids] bps[:email_member_ids] = bps[:email_member_ids].blank? ? [] : bps[:email_member_ids]
bps[:co_professor_ids] = bps[:co_professor_ids].blank? ? [] : bps[:co_professor_ids]
# @subject[:email_member_ids] = @subject[:email_member_ids].blank? ? [] : @subject[:email_member_ids] # @subject[:email_member_ids] = @subject[:email_member_ids].blank? ? [] : @subject[:email_member_ids]
@subject.update_attributes(bps) @subject.update_attributes(bps)
@subject.save @subject.save

View File

@ -18,6 +18,13 @@ class ExperimentsController < ApplicationController
"id_to_show" => url "id_to_show" => url
} }
end end
co_professors = subject.co_professors.collect do |member|
url = !member_page.nil? ? "/" + I18n.locale.to_s + member_page.url + "/" + member.to_param : "#"
{
"name" => member.name,
"id_to_show" => url
}
end
{ {
"link_to_show" => OrbitHelper.url_to_show(subject.to_param), "link_to_show" => OrbitHelper.url_to_show(subject.to_param),
"subject" => subject.title, "subject" => subject.title,
@ -25,7 +32,8 @@ class ExperimentsController < ApplicationController
"category" => subject.category.title, "category" => subject.category.title,
"direction" => subject.direction, "direction" => subject.direction,
"statuses" => statuses, "statuses" => statuses,
"members" => members "members" => members,
"co_professors" => co_professors
} }
end end
{ {
@ -36,7 +44,8 @@ class ExperimentsController < ApplicationController
"th_category" => t('category'), "th_category" => t('category'),
"th_subject" => t('experiment.subject'), "th_subject" => t('experiment.subject'),
"th_direction" => t('experiment.direction'), "th_direction" => t('experiment.direction'),
"th_professor1" => t('experiment.professor1') "th_professor1" => t('experiment.professor1'),
"th_professor2" => t('experiment.professor2')
}, },
"total_pages" => subjects.total_pages "total_pages" => subjects.total_pages
} }
@ -71,12 +80,20 @@ class ExperimentsController < ApplicationController
"id_to_show" => url "id_to_show" => url
} }
end end
co_professors = subject.co_professors.collect do |member|
url = !member_page.nil? ? "/" + I18n.locale.to_s + member_page.url + "/" + member.to_param : "#"
{
"name" => member.name,
"id_to_show" => url
}
end
tags = subject.tags.map{|tag| { "tag" => tag.name } } rescue [] tags = subject.tags.map{|tag| { "tag" => tag.name } } rescue []
{ {
"data" => { "data" => {
"subject" => subject.title, "subject" => subject.title,
"img_src" => subject.image.thumb.url || "/assets/experiment-default.jpg", "img_src" => subject.image.thumb.url || "/assets/experiment-default.jpg",
"display" => subject.image.thumb.url.nil? ? "display:none;" : "",
"category" => subject.category.title, "category" => subject.category.title,
"facility" => subject.facility, "facility" => subject.facility,
"direction" => subject.direction, "direction" => subject.direction,
@ -93,11 +110,14 @@ class ExperimentsController < ApplicationController
"th_student" => t('experiment.student'), "th_student" => t('experiment.student'),
"th_link" => t('link'), "th_link" => t('link'),
"th_professor1" => t('experiment.professor1'), "th_professor1" => t('experiment.professor1'),
"th_professor2" => t('experiment.professor2') "th_professor2" => t('experiment.professor2'),
"th_area" => t('experiment.area'),
"area" => tags.map{|t| t['tag']}.join(' / ')
}, },
"tags" => tags, "tags" => tags,
"subject_links" => subject_links, "subject_links" => subject_links,
"members" => members, "members" => members,
"co_professors" => co_professors,
"url_to_edit" => url_to_edit, "url_to_edit" => url_to_edit,
"statuses" => statuses "statuses" => statuses
} }
@ -124,7 +144,14 @@ class ExperimentsController < ApplicationController
{ {
"name" => member.name "name" => member.name
} }
end end
co_professors = subject.co_professors.collect do |member|
url = !member_page.nil? ? "/" + I18n.locale.to_s + member_page.url + "/" + member.to_param : "#"
{
"name" => member.name,
"id_to_show" => url
}
end
{ {
"link_to_show" => OrbitHelper.widget_item_url(subject.to_param), "link_to_show" => OrbitHelper.widget_item_url(subject.to_param),
"subject" => subject.title, "subject" => subject.title,
@ -133,7 +160,8 @@ class ExperimentsController < ApplicationController
"direction" => subject.direction, "direction" => subject.direction,
"statuses" => statuses, "statuses" => statuses,
"postdate" => subject.created_at.strftime('%Y-%m-%d'), "postdate" => subject.created_at.strftime('%Y-%m-%d'),
"members" => members "members" => members,
"co_professors" => co_professors
} }
end end
{ {

View File

@ -16,7 +16,7 @@ class Subject
field :direction , localize: true field :direction , localize: true
field :student, localize: true field :student, localize: true
field :email_member_ids field :email_member_ids
field :co_professor_ids
mount_uploader :image, ImageUploader mount_uploader :image, ImageUploader
has_many :subject_links, :autosave => true, :dependent => :destroy has_many :subject_links, :autosave => true, :dependent => :destroy
@ -26,7 +26,9 @@ class Subject
before_save :clean_values before_save :clean_values
def co_professors
MemberProfile.find(self.co_professor_ids) rescue []
end
def email_members def email_members
MemberProfile.find(self.email_member_ids) rescue [] MemberProfile.find(self.email_member_ids) rescue []
end end

View File

@ -30,6 +30,9 @@
<li> <li>
<a href="#imageupload" data-toggle="tab"><%= t(:image) %></a> <a href="#imageupload" data-toggle="tab"><%= t(:image) %></a>
</li> </li>
<li>
<a href="#tag" data-toggle="tab"><%= t(:tags) %>(<%=t("experiment.area")%>)</a>
</li>
</ul> </ul>
<!-- Module --> <!-- Module -->
@ -53,7 +56,12 @@
<%= render partial: 'admin/member_selects/email_selection_box', locals: {field: 'subject[email_member_ids][]', email_members: @subject.email_members} %> <%= render partial: 'admin/member_selects/email_selection_box', locals: {field: 'subject[email_member_ids][]', email_members: @subject.email_members} %>
</div> </div>
</div> </div>
<div class="control-group">
<label class="control-label muted"><%= t("experiment.professor2") %></label>
<div class="controls">
<%= render partial: 'admin/member_selects/email_selection_box', locals: {field: 'subject[co_professor_ids][]', email_members: @subject.co_professors,index:'1',select_name:'co_professors'} %>
</div>
</div>
</div> </div>
@ -84,7 +92,7 @@
<!-- Tag --> <!-- Tag -->
<div class="control-group"> <div class="control-group">
<label class="control-label muted">Tag</label> <label class="control-label muted"><%=t(:tags)%></label>
<%= select_tags(f, @module_app) %> <%= select_tags(f, @module_app) %>
</div> </div>
@ -132,7 +140,9 @@
<% end %> <% end %>
</div> </div>
<div class="tab-pane fade" id="area-tags">
</div>
</div> </div>
@ -188,7 +198,7 @@
<%= f.label :facility ,t('experiment.facility'), :class => "control-label muted" %> <%= f.label :facility ,t('experiment.facility'), :class => "control-label muted" %>
<%= f.fields_for :facility_translations do |f| %> <%= f.fields_for :facility_translations do |f| %>
<div class="controls"> <div class="controls">
<%= f.text_area locale, :class=>'input-block-level', :value => (@subject.facility_translations[locale] rescue nil) %> <%= f.text_area locale, :class=>'input-block-level ckeditor', :value => (@subject.facility_translations[locale] rescue nil) %>
</div> </div>
<% end %> <% end %>
</div> </div>
@ -198,7 +208,7 @@
<%= f.label :direction ,t('experiment.direction'), :class => "control-label muted" %> <%= f.label :direction ,t('experiment.direction'), :class => "control-label muted" %>
<%= f.fields_for :direction_translations do |f| %> <%= f.fields_for :direction_translations do |f| %>
<div class="controls"> <div class="controls">
<%= f.text_area locale, :class=>'input-block-level', :value => (@subject.direction_translations[locale] rescue nil) %> <%= f.text_area locale, :class=>'input-block-level ckeditor', :value => (@subject.direction_translations[locale] rescue nil) %>
</div> </div>
<% end %> <% end %>
</div> </div>
@ -206,7 +216,7 @@
<%= f.label :student ,t('experiment.student'), :class => "control-label muted" %> <%= f.label :student ,t('experiment.student'), :class => "control-label muted" %>
<%= f.fields_for :student_translations do |f| %> <%= f.fields_for :student_translations do |f| %>
<div class="controls"> <div class="controls">
<%= f.text_area locale, :class=>'input-block-level', :value => (@subject.student_translations[locale] rescue nil) %> <%= f.text_area locale, :class=>'input-block-level ckeditor', :value => (@subject.student_translations[locale] rescue nil) %>
</div> </div>
<% end %> <% end %>
</div> </div>

View File

@ -11,3 +11,4 @@ en:
facility: Facility facility: Facility
direction: Research Direction direction: Research Direction
student: Student student: Student
area: Area

View File

@ -11,3 +11,4 @@ zh_tw:
facility: 設備 facility: 設備
direction: 研究目標 direction: 研究目標
student: 學生 student: 學生
area: 領域

View File

@ -0,0 +1,27 @@
<div class="widget-experiments widget1">
<h3 class="widget-title">
<span>{{widget-title}}</span>
</h3>
<table class="table">
<thead>
<tr>
<th class="w-annc__th w-annc__th"> {{th_category}}</th>
<th class="w-annc__th w-annc__th"> {{th_subject}}</th>
<th class="w-annc__th w-annc__th"> {{th_direction}}</th>
<th>{{th_postdate}}</th>
</tr>
</thead>
<tbody data-level="0" data-list=subjects>
<tr>
<td>{{category}}</td>
<td><a class="widget-content-title" href="{{link_to_show}}" target="_blank">{{subject}}</a></td>
<td>{{direction}}</td>
<td>{{postdate}}</td>
</tr>
</tbody>
</table>
<div class="w-annc__more-wrap clearfix">
<a class="btn btn-primary pull-right" href="{{more_url}}">More</a>
</div>
</div>

View File

@ -0,0 +1,105 @@
@charset "utf-8";
@import "../initial";
// Lab MODULES
// Widget
.widget-experiments{
&.widget1{
h3{
@extend .unity-title;
}
table{
th{
background-color: $theme-color-main;
color: $theme-white;
font-size: $font-15;
font-family: $main-font;
border: none;
white-space: nowrap;
}
td {
font-size: $font-15;
a{
color: $theme-color-main;
}
.btn-primary{
background-color: $theme-color-second;
border-color: darken( $theme-color-second , 5%);
color: $theme-white;
margin-bottom: 6px;
&:hover{
background-color:darken( $theme-color-second , 5%);
}
}
}
}
}
}
// Index
.experiment-index{
h3{
@extend .unity-title;
}
table{
th{
background-color: $theme-color-main;
color: $theme-white;
font-size: $font-15;
font-family: $main-font;
border: none;
white-space: nowrap;
}
td {
font-size: $font-15;
a{
color: $theme-color-main;
}
.btn-primary{
background-color: $theme-color-second;
border-color: darken( $theme-color-second , 5%);
color: $theme-white;
margin-bottom: 6px;
&:hover{
background-color:darken( $theme-color-second , 5%);
}
}
}
.img-wrap{
@media (min-width: $screen-lg){
height: 174px;
}
@media (max-width: $screen-lg){
img{
position: static!important;
}
}
}
}
}
// Show
.show-experiments{
table{
th{
border-right: 2px solid $theme-color-main;
color: $theme-color-main;
font-size: $font-15;
font-family: $main-font;
}
td{
font-size: $font-15;
padding-left: 1em;
.btn-primary{
background-color: $theme-color-second;
border-color: darken( $theme-color-second , 5%);
margin-bottom: 6px;
&:hover{
background-color:darken( $theme-color-second , 5%);
}
}
}
}
}

View File

@ -0,0 +1,41 @@
<div class="experiment-index">
<table class="table table-hover table-striped">
<h3>{{page-title}}</h3>
<thead>
<tr>
<th class="col-sm-2">{{th_image}}</th>
<th class="col-sm-2">{{th_category}}</th>
<th class="col-sm-3">{{th_subject}}</th>
<th class="col-sm-3">{{th_direction}}</th>
<th class="col-sm-2">{{th_professor1}}</th>
</tr>
</thead>
<tbody data-level="0" data-list="subjects">
<tr>
<td>
<div class="img-wrap bullseye">
<img src="{{img_src}}">
</div>
</td>
<td>
<span class="category">{{category}}</span>
</td>
<td>
<a class="index-content-title" href="{{link_to_show}}">{{subject}}</a>
</td>
<td>
{{direction}}
</td>
<td data-list="members" data-level="1">
<a class="btn btn-primary btn-xs" href="{{id_to_show}}">
<span class="icons-user">{{name}}</span>
</a>
</td>
</tr>
</tbody>
</table>
</div>
{{pagination_goes_here}}

View File

@ -0,0 +1,33 @@
<div class="experiment-index">
<table class="table table-hover table-striped">
<h3>{{page-title}}</h3>
<thead>
<tr>
<th class="col-sm-3">{{th_subject}}</th>
<th class="col-sm-2">{{th_professor1}}</th>
<th class="col-sm-2">{{th_professor2}}</th>
</tr>
</thead>
<tbody data-level="0" data-list="subjects">
<tr>
<td>
<a class="index-content-title" href="{{link_to_show}}">{{subject}}</a>
</td>
<td data-list="members" data-level="1">
<a class="btn btn-primary btn-xs" href="{{id_to_show}}">
<span class="icons-user">{{name}}</span>
</a>
</td>
<td data-list="co_professors" data-level="1">
<a class="btn btn-primary btn-xs" href="{{id_to_show}}">
<span class="icons-user">{{name}}</span>
</a>
</td>
</tr>
</tbody>
</table>
</div>
{{pagination_goes_here}}

View File

@ -0,0 +1,30 @@
{
"frontend": [
{
"filename" : "index",
"name" : {
"zh_tw" : "1. 列表 ( 圖片,主題,研究目標,參與教授 )",
"en" : "1. Thumbnail ( Picture,Title,Research direction, Participating professors )"
},
"thumbnail" : "thumb.png"
},
{
"filename" : "index2",
"name" : {
"zh_tw" : "2. 列表 ( 主題,參與教授,協同參與教授 )",
"en" : "2. Thumbnail ( title, Participating professors ,collaborative participating professors)"
},
"thumbnail" : "thumb.png"
}
],
"widgets" : [
{
"filename" : "_widget1",
"name" : {
"zh_tw" : "1. 列表 ( 模組標題, 列表 )",
"en" : "1. List (widget-title, list)"
},
"thumbnail" : "thumb.png"
}
]
}

View File

@ -0,0 +1,86 @@
<div class="show-experiments">
<table data-list="tags" data-level="1">
<caption><h1>{{category}}</h1></caption>
<tr>
<th>{{th_area}}</th>
<td>{{area}}</td>
</tr>
<tr>
<th>{{th_subject}}</th>
<td>{{subject}}</td>
</tr>
<tr>
<th>{{th_tel}}</th>
<td>{{tel}}</td>
</tr>
<tr>
<th>{{th_venue}}</th>
<td>{{venue}}</td>
</tr>
<tr>
<th>{{th_professor1}}</th>
<td class="post-related" data-level="0" data-list="members">
<a class="btn btn-primary btn-xs" href="{{id_to_show}}">
<span class="icons-user">{{name}}</span>
</a>
</td>
</tr>
<tr>
<th>{{th_professor2}}</th>
<td class="post-related" data-level="0" data-list="co_professors">
<a class="btn btn-primary btn-xs" href="{{id_to_show}}">
<span class="icons-user">{{name}}</span>
</a>
</td>
</tr>
<tr>
<th>{{th_facility}}</th>
<td>{{facility}}</td>
</tr>
<tr>
<th>{{th_direction}}</th>
<td>{{direction}}</td>
</tr>
<tr>
<th>{{th_student}}</th>
<td>
<span class="icons-users">{{student}}</span>
</td>
</tr>
<tr>
<th>{{th_image}}</th>
<td class="pull-left"><img src="{{img_src}}" style="{{display}}"></td>
</tr>
<tr>
<th>{{th_link}}</th>
<td class="post-related" data-list="subject_links" data-level="0">
<a class="btn btn-primary btn-sm" href="{{link_url}}" target="_blank">{{link_title}}</a><br/>
</td>
</tr>
</table>
</div>
{{link_to_edit}}
<style>
.show-experiments caption{
padding-top: 8px;
padding-bottom: 8px;
color: #777;
text-align: left;
}
.show-experiments caption h1{
background: url(/assets/caption.gif) no-repeat 0 4px transparent;
padding-left: 30px;
color: #000;
font-size: 20px;
font-family: "微軟正黑體", "新細明體", sans-serif;
}
.show-experiments td{
padding: 0.5em .5rem;
padding: 8px 15px;
text-align: left;
color: #333;
vertical-align: top;
background: url(/assets/th_bg.gif) top left no-repeat;
}
</style>

View File

@ -0,0 +1,54 @@
<div class="show-experiments">
<table data-list="tags" data-level="1">
<tr>
<th class="col-md-3">{{th_image}}</th>
<td class="col-md-9 pull-left"><img src="{{img_src}}"></td>
</tr>
<tr>
<th>{{th_category}}</th>
<td>{{category}}</td>
</tr>
<tr>
<th>{{th_subject}}</th>
<td>{{subject}}</td>
</tr>
<tr>
<th>{{th_tel}}</th>
<td>{{tel}}</td>
</tr>
<tr>
<th>{{th_venue}}</th>
<td>{{venue}}</td>
</tr>
<tr>
<th>{{th_professor1}}</th>
<td class="post-related" data-level="0" data-list="members">
<a class="btn btn-primary btn-xs" href="{{id_to_show}}">
<span class="icons-user">{{name}}</span>
</a>
</td>
</tr>
<tr>
<th>{{th_facility}}</th>
<td>{{facility}}</td>
</tr>
<tr>
<th>{{th_direction}}</th>
<td>{{direction}}</td>
</tr>
<tr>
<th>{{th_student}}</th>
<td>
<span class="icons-users">{{student}}</span>
</td>
</tr>
<tr>
<th>{{th_link}}</th>
<td class="post-related" data-list="subject_links" data-level="0">
<a class="btn btn-primary btn-sm" href="{{link_url}}" target="_blank">{{link_title}}</a><br/>
</td>
</tr>
</table>
</div>
{{link_to_edit}}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB