diff --git a/app/assets/images/caption.gif b/app/assets/images/caption.gif new file mode 100644 index 0000000..d479c91 Binary files /dev/null and b/app/assets/images/caption.gif differ diff --git a/app/assets/images/th_bg.gif b/app/assets/images/th_bg.gif new file mode 100644 index 0000000..b95ad1e Binary files /dev/null and b/app/assets/images/th_bg.gif differ diff --git a/app/controllers/admin/experiments_controller.rb b/app/controllers/admin/experiments_controller.rb index 41980b1..9ae9f31 100644 --- a/app/controllers/admin/experiments_controller.rb +++ b/app/controllers/admin/experiments_controller.rb @@ -47,7 +47,7 @@ class Admin::ExperimentsController < OrbitAdminController @subject = Subject.find(params[:id]) bps = create_params 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.update_attributes(bps) @subject.save diff --git a/app/controllers/experiments_controller.rb b/app/controllers/experiments_controller.rb index bbf0ac7..1cc9541 100644 --- a/app/controllers/experiments_controller.rb +++ b/app/controllers/experiments_controller.rb @@ -18,6 +18,13 @@ class ExperimentsController < ApplicationController "id_to_show" => url } 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), "subject" => subject.title, @@ -25,7 +32,8 @@ class ExperimentsController < ApplicationController "category" => subject.category.title, "direction" => subject.direction, "statuses" => statuses, - "members" => members + "members" => members, + "co_professors" => co_professors } end { @@ -36,7 +44,8 @@ class ExperimentsController < ApplicationController "th_category" => t('category'), "th_subject" => t('experiment.subject'), "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 } @@ -71,12 +80,20 @@ class ExperimentsController < ApplicationController "id_to_show" => url } 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 [] { "data" => { "subject" => subject.title, "img_src" => subject.image.thumb.url || "/assets/experiment-default.jpg", + "display" => subject.image.thumb.url.nil? ? "display:none;" : "", "category" => subject.category.title, "facility" => subject.facility, "direction" => subject.direction, @@ -93,11 +110,14 @@ class ExperimentsController < ApplicationController "th_student" => t('experiment.student'), "th_link" => t('link'), "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, "subject_links" => subject_links, "members" => members, + "co_professors" => co_professors, "url_to_edit" => url_to_edit, "statuses" => statuses } @@ -124,7 +144,14 @@ class ExperimentsController < ApplicationController { "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), "subject" => subject.title, @@ -133,7 +160,8 @@ class ExperimentsController < ApplicationController "direction" => subject.direction, "statuses" => statuses, "postdate" => subject.created_at.strftime('%Y-%m-%d'), - "members" => members + "members" => members, + "co_professors" => co_professors } end { diff --git a/app/models/subject.rb b/app/models/subject.rb index 2ba6e61..289e7c2 100644 --- a/app/models/subject.rb +++ b/app/models/subject.rb @@ -16,7 +16,7 @@ class Subject field :direction , localize: true field :student, localize: true field :email_member_ids - + field :co_professor_ids mount_uploader :image, ImageUploader has_many :subject_links, :autosave => true, :dependent => :destroy @@ -26,7 +26,9 @@ class Subject before_save :clean_values - + def co_professors + MemberProfile.find(self.co_professor_ids) rescue [] + end def email_members MemberProfile.find(self.email_member_ids) rescue [] end diff --git a/app/views/admin/experiments/_form.html.erb b/app/views/admin/experiments/_form.html.erb index 97092d4..8ecfbaa 100644 --- a/app/views/admin/experiments/_form.html.erb +++ b/app/views/admin/experiments/_form.html.erb @@ -30,6 +30,9 @@
  • <%= t(:image) %>
  • +
  • + <%= t(:tags) %>(<%=t("experiment.area")%>) +
  • @@ -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[co_professor_ids][]', email_members: @subject.co_professors,index:'1',select_name:'co_professors'} %> +
    +
    @@ -84,7 +92,7 @@
    - + <%= select_tags(f, @module_app) %>
    @@ -132,7 +140,9 @@ <% end %> +
    +
    @@ -188,7 +198,7 @@ <%= f.label :facility ,t('experiment.facility'), :class => "control-label muted" %> <%= f.fields_for :facility_translations do |f| %>
    - <%= 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) %>
    <% end %> @@ -198,7 +208,7 @@ <%= f.label :direction ,t('experiment.direction'), :class => "control-label muted" %> <%= f.fields_for :direction_translations do |f| %>
    - <%= 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) %>
    <% end %> @@ -206,7 +216,7 @@ <%= f.label :student ,t('experiment.student'), :class => "control-label muted" %> <%= f.fields_for :student_translations do |f| %>
    - <%= 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) %>
    <% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 7506882..72178e1 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -11,3 +11,4 @@ en: facility: Facility direction: Research Direction student: Student + area: Area diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index b8cbd85..3fc2c81 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -11,3 +11,4 @@ zh_tw: facility: 設備 direction: 研究目標 student: 學生 + area: 領域 diff --git a/modules/experiment/_widget1.html.erb b/modules/experiment/_widget1.html.erb new file mode 100644 index 0000000..c62f9e7 --- /dev/null +++ b/modules/experiment/_widget1.html.erb @@ -0,0 +1,27 @@ +
    +

    + {{widget-title}} +

    + + + + + + + + + + + + + + + + + + +
    {{th_category}} {{th_subject}} {{th_direction}}{{th_postdate}}
    {{category}}{{subject}}{{direction}}{{postdate}}
    +
    + More +
    +
    \ No newline at end of file diff --git a/modules/experiment/experiment.scss b/modules/experiment/experiment.scss new file mode 100644 index 0000000..8300fd8 --- /dev/null +++ b/modules/experiment/experiment.scss @@ -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%); + } + } + } + } +} \ No newline at end of file diff --git a/modules/experiment/index.html.erb b/modules/experiment/index.html.erb new file mode 100644 index 0000000..d11601c --- /dev/null +++ b/modules/experiment/index.html.erb @@ -0,0 +1,41 @@ +
    + +

    {{page-title}}

    + + + + + + + + + + + + + + + + + + +
    {{th_image}}{{th_category}}{{th_subject}}{{th_direction}}{{th_professor1}}
    +
    + +
    +
    + {{category}} + + {{subject}} + + {{direction}} + + + {{name}} + +
    +
    + +{{pagination_goes_here}} + + diff --git a/modules/experiment/index2.html.erb b/modules/experiment/index2.html.erb new file mode 100644 index 0000000..728de6d --- /dev/null +++ b/modules/experiment/index2.html.erb @@ -0,0 +1,33 @@ +
    + +

    {{page-title}}

    + + + + + + + + + + + + + + +
    {{th_subject}}{{th_professor1}}{{th_professor2}}
    + {{subject}} + + + {{name}} + + + + {{name}} + +
    +
    + +{{pagination_goes_here}} + + diff --git a/modules/experiment/info.json b/modules/experiment/info.json new file mode 100644 index 0000000..fd136ed --- /dev/null +++ b/modules/experiment/info.json @@ -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" + } + ] +} \ No newline at end of file diff --git a/modules/experiment/show.html.erb b/modules/experiment/show.html.erb new file mode 100644 index 0000000..bc67eb3 --- /dev/null +++ b/modules/experiment/show.html.erb @@ -0,0 +1,86 @@ +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    {{category}}

    {{th_area}}{{area}}
    {{th_subject}}{{subject}}
    {{th_tel}}{{tel}}
    {{th_venue}}{{venue}}
    {{th_professor1}} + + {{name}} + +
    {{th_professor2}} + + {{name}} + +
    {{th_facility}}{{facility}}
    {{th_direction}}{{direction}}
    {{th_student}} + {{student}} +
    {{th_image}}
    {{th_link}} + {{link_title}}
    +
    +
    + +{{link_to_edit}} + \ No newline at end of file diff --git a/modules/experiment/show_old.html.erb b/modules/experiment/show_old.html.erb new file mode 100644 index 0000000..f1461e5 --- /dev/null +++ b/modules/experiment/show_old.html.erb @@ -0,0 +1,54 @@ +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    {{th_image}}
    {{th_category}}{{category}}
    {{th_subject}}{{subject}}
    {{th_tel}}{{tel}}
    {{th_venue}}{{venue}}
    {{th_professor1}} + + {{name}} + +
    {{th_facility}}{{facility}}
    {{th_direction}}{{direction}}
    {{th_student}} + {{student}} +
    {{th_link}} + {{link_title}}
    +
    +
    + +{{link_to_edit}} diff --git a/modules/experiment/thumbs/thumb.png b/modules/experiment/thumbs/thumb.png new file mode 100644 index 0000000..266af56 Binary files /dev/null and b/modules/experiment/thumbs/thumb.png differ