From 49e65ab628109e77ee63e4ed3facda89924c20ab Mon Sep 17 00:00:00 2001 From: BOHUNG Date: Sun, 8 Mar 2020 11:26:46 +0800 Subject: [PATCH] add fields in R2 lab.Puts template file into plugin. --- app/assets/images/caption.gif | Bin 0 -> 621 bytes app/assets/images/th_bg.gif | Bin 0 -> 171 bytes .../admin/experiments_controller.rb | 2 +- app/controllers/experiments_controller.rb | 38 ++++++- app/models/subject.rb | 6 +- app/views/admin/experiments/_form.html.erb | 20 +++- config/locales/en.yml | 1 + config/locales/zh_tw.yml | 1 + modules/experiment/_widget1.html.erb | 27 +++++ modules/experiment/experiment.scss | 105 ++++++++++++++++++ modules/experiment/index.html.erb | 41 +++++++ modules/experiment/index2.html.erb | 33 ++++++ modules/experiment/info.json | 30 +++++ modules/experiment/show.html.erb | 86 ++++++++++++++ modules/experiment/show_old.html.erb | 54 +++++++++ modules/experiment/thumbs/thumb.png | Bin 0 -> 4075 bytes 16 files changed, 431 insertions(+), 13 deletions(-) create mode 100644 app/assets/images/caption.gif create mode 100644 app/assets/images/th_bg.gif create mode 100644 modules/experiment/_widget1.html.erb create mode 100644 modules/experiment/experiment.scss create mode 100644 modules/experiment/index.html.erb create mode 100644 modules/experiment/index2.html.erb create mode 100644 modules/experiment/info.json create mode 100644 modules/experiment/show.html.erb create mode 100644 modules/experiment/show_old.html.erb create mode 100644 modules/experiment/thumbs/thumb.png diff --git a/app/assets/images/caption.gif b/app/assets/images/caption.gif new file mode 100644 index 0000000000000000000000000000000000000000..d479c915b7f855409f0a38c85ead733303a81fcd GIT binary patch literal 621 zcmZ?wbhEHb6krfwc;?3N>C>kVA3nT)|Nivp)308=x_|%vqeqY4ym|Ba^XHErKmPsu z_sf?rr%s((vu4fBn>XLSeS6`;g%>Yg96fsU;>C+QckVoY{``?6M~)pkcIeQdS+iy> zTC`~8%9VTe>^X7b#JqX)wr<__{Q2|!`}e_foIH8*_3PJ{FJHc5#ft6Q zx9{A!>-+cbTXt?acKqay-8=T~+xPhK<9++~UA=mB$BrG(o;|yD>(<=4bC)e!_V3@n z!-o$)dGciG(xqR&e*O9L=eKX)e*OCO@*x~IN4cD4(M?3S+U7-T05R( zVB$X@;-JhVAmAe9e8Y}|;efoL5fd}Bi`+ze+hYf`1Xl@(yGTxStop)mskecXnMX@N zQ&8nZzq|tnS7Jh=1JH32Hwu1yP&AMcH8Zg&RCa4<(@^9TRCzMp+f%!j=f%fQ;r&WY QJUk9Zf;|M88yOg^0k_raJOBUy literal 0 HcmV?d00001 diff --git a/app/assets/images/th_bg.gif b/app/assets/images/th_bg.gif new file mode 100644 index 0000000000000000000000000000000000000000..b95ad1e01561fb3134dc8455ca133638bedb56bc GIT binary patch literal 171 zcmV;c095}+Nk%w1VFmya0K^;sn3$Ny$H%m^w49urr>Cc?s;Z!%pq7@F#l^+Z(b1cm zo58`slarIm%F4gLzqq)#rlzK^udlAIuA!l!tgNiY#>SnUot~ba$jHdx;NYX9qs+|A z|Ns900000000000A^8LW000~SEC2ui00saO000FjASaGwX`X1RuBP({QIQBz0Zki4 ZXvWYGhRXmDuqXfr#$tmBR1ldE06U-yP)h&+ literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..266af5606742714c262a949cd58aedc2b84b1959 GIT binary patch literal 4075 zcmcgvYdBPE`=8Q@or=MZk}-~jIXD}qFebzhVvsZ#jA2HMW=0OFFbKQkR5@2;7{)1- z&=wM+oMYofvU8{uIS&7&UHkuj*w_2v{qU~qTI;!=weH`2-_Lz|o)v3@JtZh0Apin_ z1kKIRw!l~h+!g!w0MC|jUMDb!Q%!MHJBk;Th7Tlwj65ms1cm?>ZoCb zunI6C_z=xP0tt2@SbL8Ul825b)X)H;M@Iny{0US%gzoQ04nooOq2J}A0DAj1918i) zLM7=#|1t_^Wdkvx1QH+`FocQ+LK6wmREHte5jyHR$`Dlq5&=i5!Vy|3NCZkl3xz;J zeq2yMTcD>G$`+0Jp$nMlLw%^!02CZfqtReAH5et(8;;b`(SajW;i{@C0EbEtgG|NK zRmedyKP8|EK^}p`04k9}hHOj3yHkRx`cS~qzn0)1U}g2UU~4vB3<+^0l07N3pzZMdwOTYGka&sUi3z0mL%#bLMf?Z- z>ZS-JMhk;Ms+p<-HXx1FOpGw9+S;btnx?86+SLrFqmAt8Lvxw>O#9Ok(U(6adi=}!UB|h@GFIv~ z3by;zyIaw_j2w*cMtljDe@vCYYBBN{3B_}Vjo?=y5{HRi5Qzi{pS+umos~BYBNJa& zkB#!~P<#uqTbUmXSksK04_O}zQA=O@9o_oaC^d(oz7rtA`(Fz|ZJl&3e@9oBUHof} zii!$-7EjmN-Q6)UF+u6`U4kzeZoO$!*c@J5RNonGEUj;m*6pneu6?<%aM4#VPAhUf8>TQU zggnVU*>r`u;}8-A-Gko$zozhV-1BvXNA*K07ecJnTNzBq!E9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