Merge branch 'desktop' into desktop_work

This commit is contained in:
Harry Bomrah 2013-02-27 11:51:56 +08:00
commit 7ef02d3108
61 changed files with 381 additions and 169 deletions

View File

@ -0,0 +1,21 @@
function update_cates_and_tags()
{
$('.select_option,.select_all').removeAttr('disabled');
$(".select_all:checked").each(function( obj ) {
$(this).parent().siblings('label').find('.select_option').attr('disabled',true);
$(this).parent().siblings('label').find('.select_option').removeAttr('checked');
});
$(".select_option:checked").each(function( obj ) {
$(this).parent().siblings('label').find('.select_all').attr('disabled',true);
$(this).parent().siblings('label').find('.select_all').removeAttr('checked');
});
}
function rebind(){
$("#widget_data_source_category,#widget_data_source_tag,#app_page_category,#app_page_tag").find('input').change(function(){update_cates_and_tags()});
}
$(document).ready(function(){
update_cates_and_tags();
rebind();
});

View File

@ -43,7 +43,7 @@ $("#tag_list select").live('change', function() {
}); });
$("select.widget_field_select").live('change', function() { $("select.widget_field_select").live('change', function() {
$.getScript(get_object_path() + '/reload_after_widget_field_changed?widget_field_value='+ $(this).val()+'&dom_id=' + $(this).attr("id") + '&field_seri=' +$(this).attr('field_seri')); $.getScript(get_object_path() + '/reload_after_widget_field_changed?widget_field_value='+ $(this).val()+'&dom_id=' + $(this).attr("id") + '&field_seri=' +$(this).attr('field_seri')+ '&module_app_id=' +$("#page_module_app_id,page_part_module_app_id").val());
}); });
$('.part_kind').live('click', function() { $('.part_kind').live('click', function() {

View File

@ -54,6 +54,7 @@ class Admin::PagePartsController < ApplicationController
end end
def update def update
@part = PagePart.find(params[:id]) @part = PagePart.find(params[:id])
params[:page_part][:widget_field] = params[:page_part][:widget_field].zip( params[:page_part][:widget_field_type],params[:page_part][:widget_field_is_link] ) if params[:page_part][:widget_field] params[:page_part][:widget_field] = params[:page_part][:widget_field].zip( params[:page_part][:widget_field_type],params[:page_part][:widget_field_is_link] ) if params[:page_part][:widget_field]
@ -63,6 +64,17 @@ class Admin::PagePartsController < ApplicationController
if params[:page_part][:module_app].blank? if params[:page_part][:module_app].blank?
params[:page_part][:module_app] = nil params[:page_part][:module_app] = nil
end end
if params[:page_part][:tag].include?("nil")
params[:page_part][:tag] = []
end
if params[:page_part][:category].include?("nil")
params[:page_part][:category] = []
end
params[:page_part][:widget_field].each{|t| t[2] = (t[2]=="true" ? true : false )}
if @part.update_attributes(params[:page_part]) if @part.update_attributes(params[:page_part])
set_children_sub_menu(@part) if @part.public_r_tag && @part.public_r_tag.eql?('sub_menu') set_children_sub_menu(@part) if @part.public_r_tag && @part.public_r_tag.eql?('sub_menu')
flash.now[:notice] = t('update.success.content') flash.now[:notice] = t('update.success.content')
@ -96,6 +108,7 @@ class Admin::PagePartsController < ApplicationController
@part = PagePart.find params[:id] @part = PagePart.find params[:id]
@choosen_field = params[:widget_field_value] @choosen_field = params[:widget_field_value]
@module_app = @part.module_app @module_app = @part.module_app
@module_app = ModuleApp.find params[:module_app_id] if @module_app.nil?
end end
def reload_widgets def reload_widgets

View File

@ -96,6 +96,14 @@ helper Admin::PagePartsHelper
params[:page][:frontend_field] = params[:page][:frontend_field].zip( params[:page][:frontend_field_type] ) if params[:page][:frontend_field] params[:page][:frontend_field] = params[:page][:frontend_field].zip( params[:page][:frontend_field_type] ) if params[:page][:frontend_field]
params[:page][:frontend_field_type] = nil params[:page][:frontend_field_type] = nil
if params[:page][:tag].include?("nil")
params[:page][:tag] = []
end
if params[:page][:category].include?("nil")
params[:page][:category] = []
end
if @item.update_attributes(params[:page]) if @item.update_attributes(params[:page])
flash[:notice] = t('update.success.page') flash[:notice] = t('update.success.page')
respond_to do |format| respond_to do |format|
@ -172,4 +180,12 @@ helper Admin::PagePartsHelper
end end
end end
def reload_widget_field
@index = params[:field_seri].to_i
@page = Page.find params[:id]
@choosen_field = params[:widget_field_value]
@module_app = @page.module_app
@module_app = ModuleApp.find params[:module_app_id] if @module_app.nil?
end
end end

View File

@ -10,12 +10,33 @@ class DefaultWidgetController< OrbitWidgetController
@page_part.module_app.enable_frontend? @page_part.module_app.enable_frontend?
end end
def query_for_default_widget
ori_class_name = @default_widget["query"].split('.')[0]
result = nil
result_objects = nil
if !params["tag_id"].blank?
@tags = Tag.find(params["tag_id"]) rescue nil
result_ids = nil
if params["category_id"].blank?
result_ids = @tags.collect{|tag| tag.send(ori_class_name.downcase.pluralize).entries.collect{|t| t.id}}.flatten
else
result_ids = @tags.collect{|tag| tag.send(ori_class_name.downcase.pluralize).where(:category_id=>params["category_id"]).available_for_lang(I18n.locale).can_display.collect{|t| t.id}}.flatten
end
result = eval("#{ori_class_name}.where(:id=>result_ids)")
elsif params["category_id"].blank?
result = eval(@default_widget["query"])
else
result = eval("#{ori_class_name}.where(:category_id=>params['category_id'])")
end
result.available_for_lang(I18n.locale).can_display
end
def default_widget def default_widget
if !params[:id].blank? if !params[:id].blank?
redirect_to eval("#{@page_part.module_app.widget_fields_link_method['title']['method']}('#{params[:id]}', {inner: #{params[:inner] || true}})") redirect_to eval("#{@page_part.module_app.widget_fields_link_method['title']['method']}('#{params[:id]}', {inner: #{params[:inner] || true}})")
else else
@tag_class = nil @tag_class = nil
@default_widget = @page_part.module_app.get_default_widget @default_widget = @page_part.module_app.get_default_widget
@widget_image_field = @default_widget["image"] || @default_widget[:image] @widget_image_field = @default_widget["image"] || @default_widget[:image]
case @page_part case @page_part
@ -29,9 +50,11 @@ class DefaultWidgetController< OrbitWidgetController
@data_limit = @page_part.widget_data_count.is_a?(Fixnum) ? @page_part.widget_data_count : (@page_part.widget_data_count.to_i rescue 3) @data_limit = @page_part.widget_data_count.is_a?(Fixnum) ? @page_part.widget_data_count : (@page_part.widget_data_count.to_i rescue 3)
end end
if @paginate if @paginate
@data = eval(@default_widget["query"]).includes(@widget_image_field).page(params[:page_main]).per(@data_limit).desc(:created_at) @data = query_for_default_widget.includes(@widget_image_field).page(params[:page_main]).per(@data_limit)
# @data = query_for_default_widget.limit(@data_limit).includes(@widget_image_field)
else else
@data = eval(@default_widget["query"]).limit(@data_limit).includes(@widget_image_field).desc(:created_at) @data = eval(@default_widget["query"]).includes(@widget_image_field).page(params[:page_main]).per(@data_limit).desc(:created_at)
# @data = eval(@default_widget["query"]).limit(@data_limit).includes(@widget_image_field).desc(:created_at)
end end
case params[:type] case params[:type]
when "typeA" when "typeA"

View File

@ -21,11 +21,10 @@ module Admin::PagePartsHelper
end end
end end
def field_link_switch(i,object_name,field_name,local_item=nil,prefill_value=nil) def link_to_field_switch(i,object_name,field_name,local_item=nil,prefill_value=nil) #link_to_field is for showing
local_item = @part if local_item.nil? && @part local_item = @part if local_item.nil? && @part
local_item = @page if local_item.nil? && @page local_item = @page if local_item.nil? && @page
res = '' res = ''
choosen_value = prefill_value || (local_item[:widget_field][i][0] rescue nil) choosen_value = prefill_value || (local_item[:widget_field][i][0] rescue nil)
if choosen_value if choosen_value
@ -38,13 +37,13 @@ module Admin::PagePartsHelper
if choosen_field_is_link if choosen_field_is_link
value = case local_item value = case local_item
when Page when Page
local_item[:frontend_field][i][2] local_item[:frontend_field][i][2] rescue false
when PagePart when PagePart
local_item[:widget_field][i][2] local_item[:widget_field][i][2] rescue false
end end
res = label_tag '' do res = label_tag '' do
check_box_tag("#{object_name}[#{field_name}_is_link][]", value = "true", value) + I18n.t("default_widget.field_is_link") check_box_tag("#{object_name}[#{field_name}_is_link][]", "true", value) + I18n.t("default_widget.field_is_link")
end end
else # choosen_field_not_link else # choosen_field_not_link
res = hidden_field_tag "#{object_name}[#{field_name}_is_link][]", 'false' res = hidden_field_tag "#{object_name}[#{field_name}_is_link][]", 'false'
@ -84,17 +83,17 @@ module Admin::PagePartsHelper
def tag_checked_value(part,radio_value) def tag_checked_value(part,radio_value)
if radio_value.blank? if radio_value.blank?
(part.nil? || part[:tag].blank?)? true : false (part.nil? || part[:tag].blank?) ? true : false
else else
part and (part[:tag] == radio_value.to_s) ? true : false part and (part[:tag].include?(radio_value.to_s)) ? true : false
end end
end end
def category_checked_value(part,radio_value) def category_checked_value(part,radio_value)
if radio_value.blank? if radio_value.blank?
(part.nil? || part[:category].blank?)? true : false (part.nil? || part[:category].blank?) ? true : false
else else
part and (part[:category] == radio_value.to_s) ? true : false part and (part[:category].include?(radio_value.to_s)) ? true : false
end end
end end
@ -117,6 +116,19 @@ module Admin::PagePartsHelper
end end
end end
def nil_checkbox_button(part,tag_or_cate)
field_name = case part
when PagePart
'page_part'
when Page
'page'
end
content_tag :label,:class=>"radio inline" do
op = check_box_tag("#{field_name}[#{tag_or_cate}][]", 'nil' , eval("#{tag_or_cate}_checked_value(part,'')"),:class=>'select_all')
op << I18n.t("default_widget.no_value")
end
end
def nil_radio_button(part,tag_or_cate) def nil_radio_button(part,tag_or_cate)
field_name = case part field_name = case part
when PagePart when PagePart

View File

@ -6,7 +6,7 @@ module DefaultWidgetHelper
def link_to_field(row_data,field, switch, options=nil) def link_to_field(row_data,field, switch, options=nil)
method_ary = @page_part.module_app.widget_fields_link_method method_ary = @page_part.module_app.widget_fields_link_method
field = field.to_sym field = field.to_sym
if(method_ary.has_key?(field) and (switch == "true")) if(method_ary.has_key?(field) and (switch == true))
url = case method_ary[field][:args] url = case method_ary[field][:args]
when nil # no args when nil # no args
get_data_link(method_ary[field]["method"], options) get_data_link(method_ary[field]["method"], options)

View File

@ -8,8 +8,8 @@ class Page < Item
field :content, localize: true field :content, localize: true
field :app_frontend_url field :app_frontend_url
field :theme_id, :type => BSON::ObjectId, :default => nil field :theme_id, :type => BSON::ObjectId, :default => nil
field :category, :default => '' field :category,type: Array, :default => []
field :tag, :default => '' field :tag, type: Array,:default => []
field :view_count, :type => Integer, :default => 0 field :view_count, :type => Integer, :default => 0
field :page_title, localize: true field :page_title, localize: true

View File

@ -11,6 +11,8 @@ class PagePart
field :public_r_tag_option, :default => nil field :public_r_tag_option, :default => nil
field :page_title, localize: true field :page_title, localize: true
field :widget_path field :widget_path
field :category,type: Array, :default => []
field :tag, type: Array,:default => []
field :widget_style field :widget_style
field :widget_field , :type => Array field :widget_field , :type => Array

View File

@ -2,11 +2,9 @@
<% when PagePart %> <% when PagePart %>
<% object_name = 'page_part' %> <% object_name = 'page_part' %>
<% field_name = 'widget_field' %> <% field_name = 'widget_field' %>
<% data_count = 'widget_data_count' %>
<% when Page %> <% when Page %>
<% object_name = 'page' %> <% object_name = 'page' %>
<% field_name = 'frontend_field' %> <% field_name = 'frontend_field' %>
<% data_count = 'frontend_data_count' %>
<% end %> <% end %>
<div class="style_switch control-group"> <div class="style_switch control-group">
@ -37,20 +35,9 @@
<%= select_tag "#{object_name}[#{field_name}_type][]", widget_fiield_type_options(i), :include_blank => true %> <br /> <%= select_tag "#{object_name}[#{field_name}_type][]", widget_fiield_type_options(i), :include_blank => true %> <br />
</span> </span>
<span class="span5 link_switch_holder"> <span class="span5 link_switch_holder">
<%= field_link_switch(i,object_name,field_name) %> <%= link_to_field_switch(i,object_name,field_name) %>
</span> </span>
</div><br/> </div><br/>
<% end %> <% end %>
<br/>
<div class="rows clear">
<span class="span4">
<%= label_tag t("default_widget.widget_data_count") %>
</span>
</div>
<div class="rows clear">
<span class="span4">
<%= text_field_tag "#{object_name}[#{data_count}]",object.send(data_count) %>
</span>
</div>
</div> </div>
</div> </div>

View File

@ -19,3 +19,5 @@
</div> </div>
<% end %> <% end %>
<%=javascript_include_tag "inc/update_cates_and_tags.js" %>

View File

@ -45,3 +45,8 @@
<div id="widget_setting"> <div id="widget_setting">
<%= render :partial => 'widget_setting' ,:locals=>{:f=>f,:object=>@part} %> <%= render :partial => 'widget_setting' ,:locals=>{:f=>f,:object=>@part} %>
</div> </div>
<div class="control-group" id='data_count'>
<%= render :partial=>'admin/pages/data_count_field',:locals=>{:field_name=>"page_part[widget_data_count]",:field_value=>@part.widget_data_count } %>
</div>

View File

@ -10,9 +10,9 @@
<div class="well controls"> <div class="well controls">
<% if @categories %> <% if @categories %>
<fieldset> <fieldset>
<%= nil_radio_button(object,:category) %> <%= nil_checkbox_button(object,:category) %>
<%= content_tag_for(:label, @categories,:class=>"radio inline") do |category|%> <%= content_tag_for(:label, @categories,:class=>"radio inline") do |category|%>
<%= radio_button_tag("#{field_name}[category]", category.id, category_checked_value(object,category.id) )%> <%= check_box_tag("#{field_name}[category][]", category.id, category_checked_value(object,category.id),:class=>'select_option' )%>
<%= category.title%> <%= category.title%>
<% end %> <% end %>
</fieldset> </fieldset>

View File

@ -10,9 +10,9 @@
<div class="well controls"> <div class="well controls">
<% if @categories %> <% if @categories %>
<fieldset> <fieldset>
<%= nil_radio_button(object,:tag) %> <%= nil_checkbox_button(object,:tag) %>
<%= content_tag_for(:label, @tags,:class=>"radio inline") do |tag|%> <%= content_tag_for(:label, @tags,:class=>"radio inline") do |tag|%>
<%= radio_button_tag("#{field_name}[tag]", tag.id, tag_checked_value(object,tag.id) ) %> <%= check_box_tag("#{field_name}[tag][]", tag.id, tag_checked_value(object,tag.id),:class=>'select_option' ) %>
<%= tag[I18n.locale]%> <%= tag[I18n.locale]%>
<% end if @tags%> <% end if @tags%>
</fieldset> </fieldset>

View File

@ -2,4 +2,8 @@
<%= render 'admin/items/site_map_left_bar' %> <%= render 'admin/items/site_map_left_bar' %>
<% end -%> <% end -%>
<%= render 'edit' %> <%= render 'edit' %>

View File

@ -1 +1 @@
$("#<%= params[:dom_id] %>").parents(".rows").find(".link_switch_holder").html("<%= j field_link_switch(@index,'page_part','widget_field',nil,@choosen_field) %>"); $("#<%= params[:dom_id] %>").parents(".rows").find(".link_switch_holder").html("<%= j link_to_field_switch(@index,'page_part','widget_field',nil,@choosen_field) %>");

View File

@ -2,7 +2,7 @@
$('#widget_list select').html("<%= j options_for_select(@module_app.widgets.collect{|k,v| [I18n.t(v['i18n']),k]},@part.widget_path) %>"); $('#widget_list select').html("<%= j options_for_select(@module_app.widgets.collect{|k,v| [I18n.t(v['i18n']),k]},@part.widget_path) %>");
$("#widget_data_source_category").html("<%= j render :partial => 'widget_data_source_category',:locals=>{:object=>@part} %>"); $("#widget_data_source_category").html("<%= j render :partial => 'widget_data_source_category',:locals=>{:object=>@part} %>");
$("#widget_data_source_tag").html("<%= j render :partial => 'widget_data_source_tag',:locals=>{:object=>@part} %>"); $("#widget_data_source_tag").html("<%= j render :partial => 'widget_data_source_tag',:locals=>{:object=>@part} %>");
$("#data_count").html("<%= j render :partial => 'admin/pages/data_count_field',:locals=>{:field_name=>'page_part[widget_data_count]',:field_value=>@part.widget_data_count } %>");
<% if @part %> <% if @part %>
<% if show_default_widget_setting_panel %> <% if show_default_widget_setting_panel %>
$('#widget_setting').html("<%= j render :partial => 'default_widget_style_panel' %>"); $('#widget_setting').html("<%= j render :partial => 'default_widget_style_panel' %>");
@ -16,3 +16,5 @@
$('#widget_setting').html("<%=j render :partial=> 'reset',:locals=>{:label_i18n=>'default_widget.select_widget_style'}%>"); $('#widget_setting').html("<%=j render :partial=> 'reset',:locals=>{:label_i18n=>'default_widget.select_widget_style'}%>");
$('#widget_list select').html("<%= j options_for_select([]) %>"); $('#widget_list select').html("<%= j options_for_select([]) %>");
<% end %> <% end %>
update_cates_and_tags();
rebind();

View File

@ -0,0 +1,6 @@
<label for="<%= field_name %>" class="control-label">
<%= t("default_widget.widget_data_count") %>
</label>
<div class="controls">
<%= select_tag(field_name,options_for_select(@module_app.get_registration.get_data_count,field_value )) %>
</div>

View File

@ -66,6 +66,9 @@
<%= render :partial => 'frontend_setting', :locals=>{:object=>@item,:f=>f} %> <%= render :partial => 'frontend_setting', :locals=>{:object=>@item,:f=>f} %>
</div> </div>
<div class="control-group" id='data_count'>
<%= render :partial=>'data_count_field',:locals=>{:field_name=>"page[frontend_data_count]",:field_value=>@item.frontend_data_count} %>
</div>
<div class="control-group"> <div class="control-group">
<%= f.label :is_published, "#{t('front_page.is_published')} ?", :class => 'control-label' %> <%= f.label :is_published, "#{t('front_page.is_published')} ?", :class => 'control-label' %>
@ -109,3 +112,4 @@
</div> </div>
</div> </div>
<%=javascript_include_tag "inc/update_cates_and_tags.js" %>

View File

@ -1,6 +1,7 @@
<% if @module_app %> <% if @module_app %>
$('#app_page_category').html("<%= j render :partial => 'admin/page_parts/widget_data_source_category' ,:locals=>{:object=>@page}%>"); $('#app_page_category').html("<%= j render :partial => 'admin/page_parts/widget_data_source_category' ,:locals=>{:object=>@page}%>");
$('#app_page_tag').html("<%= j render :partial => 'admin/page_parts/widget_data_source_tag',:locals=>{:object=>@page} %>"); $('#app_page_tag').html("<%= j render :partial => 'admin/page_parts/widget_data_source_tag',:locals=>{:object=>@page} %>");
$("#data_count").html("<%= j render :partial => 'admin/pages/data_count_field',:locals=>{:field_name=>'page[frontend_data_count]',:field_value=>@page.frontend_data_count} %>");
<% if !@module_app.app_pages.blank? %> <% if !@module_app.app_pages.blank? %>
$('#app_page_url').html("<%= escape_javascript(select 'page', 'app_frontend_url', options_for_select(@app_frontend_urls, @app_frontend_urls.first)) %>"); $('#app_page_url').html("<%= escape_javascript(select 'page', 'app_frontend_url', options_for_select(@app_frontend_urls, @app_frontend_urls.first)) %>");
@ -31,3 +32,5 @@
$('#app_page_url').html("<%= t('default_widget.no_support_setting')%>"); $('#app_page_url').html("<%= t('default_widget.no_support_setting')%>");
$('#frontend_setting').html("<%= j render :partial => 'custom_frontend_setting' %>"); $('#frontend_setting').html("<%= j render :partial => 'custom_frontend_setting' %>");
<% end %> <% end %>
update_cates_and_tags();
rebind();

View File

@ -0,0 +1 @@
$("#<%= params[:dom_id] %>").parents(".rows").find(".link_switch_holder").html("<%= j link_to_field_switch(@index,'page','frontend_field',nil,@choosen_field) %>");

View File

@ -13,5 +13,4 @@
<% end %> <% end %>
<% end %> <% end %>
</ul> </ul>
<div class="more">more</div>
<% end %> <% end %>

View File

@ -11,5 +11,4 @@
<% end %> <% end %>
<% end %> <% end %>
</ul> </ul>
<div class="more">more</div>
<% end %> <% end %>

View File

@ -2,3 +2,6 @@
<% if @paginate %> <% if @paginate %>
<%= paginate @data, :param_name => :page_main, :params => {:same_page_id => @page_id} %> <%= paginate @data, :param_name => :page_main, :params => {:same_page_id => @page_id} %>
<% end %> <% end %>
<% if @page_part.module_app %>
<%= @page_part.module_app.get_registration.default_widget_setting.link_to_more_tag(request,params) %>
<% end %>

View File

@ -11,7 +11,7 @@
<li class="d_cate"><a callback-method='' href="" class="widget_fn wh3 hh3" id='d_publication' onclick="return false;"><span class="widget_icon"><img src="" alt="Publication" id="publication_icon" width="30" height="30"/></span></a> <li class="d_cate"><a callback-method='' href="" class="widget_fn wh3 hh3" id='d_publication' onclick="return false;"><span class="widget_icon"><img src="" alt="Publication" id="publication_icon" width="30" height="30"/></span></a>
<ul class="dock_child hh3 thmc4" style="width: 180px;"> <ul class="dock_child hh3 thmc4" style="width: 180px;">
<li class="dock_item"><a callback-method='initializeJournalPapers' href="<%= panel_personal_journal_desktop_journal_p_path %>" class="widget_fn wh3 hh3" id='d_journal_p' custom-load="journal" onclick="return false;"><span class="widget_icon"><img src="" alt="Journal Papers" id="journal_p_icon" width="30" height="30"/></span></a></li> <li class="dock_item"><a callback-method='initializeJournalPapers' href="<%= panel_personal_journal_desktop_journal_window_path %>" class="widget_fn wh3 hh3" id='d_journal_p' custom-load="journal" onclick="return false;"><span class="widget_icon"><img src="" alt="Journal Papers" id="journal_p_icon" width="30" height="30"/></span></a></li>
<li class="dock_item"><a callback-method='initializeConference' href="<%= panel_personal_conference_desktop_conference_window_path %>" class="widget_fn wh3 hh3" id='d_conference_p' custom-load="conference" onclick="return false;"><span class="widget_icon"><img src="" alt="Conference Papers" id="conference_p_icon" width="30" height="30"/></span></a></li> <li class="dock_item"><a callback-method='initializeConference' href="<%= panel_personal_conference_desktop_conference_window_path %>" class="widget_fn wh3 hh3" id='d_conference_p' custom-load="conference" onclick="return false;"><span class="widget_icon"><img src="" alt="Conference Papers" id="conference_p_icon" width="30" height="30"/></span></a></li>

View File

@ -90,6 +90,7 @@ Orbit::Application.routes.draw do
get 'reload_themes' get 'reload_themes'
get 'reload_after_module_changed',:action=>'reload_frontend_pages' get 'reload_after_module_changed',:action=>'reload_frontend_pages'
get 'reload_after_list_changed',:action=> 'reload_front_end_setting' get 'reload_after_list_changed',:action=> 'reload_front_end_setting'
get 'reload_after_widget_field_changed',:action=> 'reload_widget_field'
end end
end end

View File

@ -5,54 +5,4 @@ FactoryGirl.definition_file_paths = Dir["#{Rails.root}/vendor/built_in_modules/*
FactoryGirl.find_definitions FactoryGirl.find_definitions
Dir["#{Rails.root}/vendor/built_in_modules/*/db/seeds.rb"].each { |seed| load seed }
ConferenceCoAuthorRelation.destroy_all
ConferenceCoAuthor.destroy_all
ConferencePaperType.destroy_all
WritingConferenceFile.destroy_all
WritingConference.destroy_all
#Dir[Rails.root.join("spec/factories/*.rb")].each {|f| require f}
2.times do
FactoryGirl.create(:conference_paper_type)
end
10.times do
FactoryGirl.create(:conference_co_author_relation)
end
50.times do
FactoryGirl.create(:conference_co_author)
end
50.times do
FactoryGirl.create(:writing_conference)
end
puts "Success!"
# =======
#
#CoAuthorRelation.destroy_all
#CoAuthor.destroy_all
#JournalLevelType.destroy_all
#WritingJournalFile.destroy_all
#WritingJournal.destroy_all
#
#10.size.times do
# FactoryGirl.create(:journal_level)
#end
#
#10.times do
# FactoryGirl.create(:journal_relation)
#end
#
#50.times do
# FactoryGirl.create(:journal)
#end
#
#50.times do
# FactoryGirl.create(:journal_co_author)
#end
#puts "Success!"

View File

@ -3,6 +3,7 @@ require "orbit_app/dsl"
require "orbit_app/helper/renderer" require "orbit_app/helper/renderer"
require "orbit_app/helper/side_bar_renderer" require "orbit_app/helper/side_bar_renderer"
require "orbit_app/helper/context_link_renderer" require "orbit_app/helper/context_link_renderer"
require "orbit_app/helper/default_widget_tag_helper"
require "orbit_app/module/side_bar" require "orbit_app/module/side_bar"
require "orbit_app/module/widget" require "orbit_app/module/widget"
require "orbit_app/module/front_end" require "orbit_app/module/front_end"

View File

@ -0,0 +1,12 @@
module DefaultWidgetTagHelper
include Renderer
include AdminHelper
def link_to_more_tag(req,params)
@request = req
@params =params
content_tag :div,:class=> 'more' do
link_to I18n.t(@more_link[:label_i18n]),eval(@more_link[:path_method])
end
end
end

View File

@ -28,7 +28,7 @@ module OrbitApp
end end
class DataSheet class DataSheet
attr_reader :name,:key,:base_path,:module_label attr_reader :name,:key,:base_path,:module_label,:data_count
def initialize(name, &block) def initialize(name, &block)
@name = name @name = name
@ -36,6 +36,7 @@ module OrbitApp
@side_bar = nil @side_bar = nil
@front_end_app_pages = nil @front_end_app_pages = nil
@module_label = 'rulingcom.errors.init.module_app_noname' @module_label = 'rulingcom.errors.init.module_app_noname'
@data_count = 1..15 # as default
block.arity < 1 ? instance_eval(&block) : block.call(self) if block_given? block.arity < 1 ? instance_eval(&block) : block.call(self) if block_given?
setup_module_app setup_module_app
end end
@ -86,6 +87,10 @@ module OrbitApp
@front_end_app_pages.nil? ? [] : @front_end_app_pages.to_module_app_format @front_end_app_pages.nil? ? [] : @front_end_app_pages.to_module_app_format
end end
def get_data_count
@data_count
end
def get_widget_by_path(path) def get_widget_by_path(path)
if @widget_set if @widget_set
@widget_set.find_by_path(path) @widget_set.find_by_path(path)
@ -94,6 +99,14 @@ module OrbitApp
end end
end end
def default_widget_setting
@widget_set.default_widget_setting
end
def widget_setting
@widget_set
end
def get_widgets def get_widgets
@widget_set.nil? ? {} : @widget_set.to_module_app_format @widget_set.nil? ? {} : @widget_set.to_module_app_format
end end
@ -127,7 +140,7 @@ module OrbitApp
# @default_widget = widget_set.default_widget # @default_widget = widget_set.default_widget
end end
%w{module_label category base_url version organization author intro update_info}.each do |field| %w{data_count module_label category base_url version organization author intro update_info}.each do |field|
define_method(field){|var| instance_variable_set( "@" + field, var)} define_method(field){|var| instance_variable_set( "@" + field, var)}
end end

View File

@ -34,6 +34,10 @@ module OrbitApp
define_method(field){|var| instance_variable_set( "@" + field, var)} define_method(field){|var| instance_variable_set( "@" + field, var)}
end end
# def data_count(var)
# @data_count = var
# end
def find_by_path(path) def find_by_path(path)
@widgets.each do |widget| @widgets.each do |widget|
return widget if widget.name == path return widget if widget.name == path
@ -48,6 +52,10 @@ module OrbitApp
eval(@tags_query) rescue nil eval(@tags_query) rescue nil
end end
def default_widget_setting
@default_widget
end
def default_widget(&block) def default_widget(&block)
@default_widget = DefaultWidget.new(&block) @default_widget = DefaultWidget.new(&block)
end end
@ -85,6 +93,7 @@ module OrbitApp
end end
class DefaultWidget class DefaultWidget
include DefaultWidgetTagHelper
STYLE = ["typeA","typeB_style2","typeB_style3","typeB_style4","typeC"] STYLE = ["typeA","typeB_style2","typeB_style3","typeB_style4","typeC"]
def initialize(&block) def initialize(&block)
@ -95,9 +104,10 @@ module OrbitApp
block.arity < 1 ? instance_eval(&block) : block.call(self) if block_given? block.arity < 1 ? instance_eval(&block) : block.call(self) if block_given?
end end
def more_link_to(label_i18n,path_method)
@more_link[:label_i18n] = label_i18n def link_to_more(*args)
@more_link[:path_method] = path_method @more_link[:label_i18n] = (args[1] ? args[1][:title_i18n] : 'default_widget.default_link_to_more' )
@more_link[:path_method] = args[0]
end end
def self.get_interface_args def self.get_interface_args
@ -106,7 +116,7 @@ module OrbitApp
end end
def to_module_app_format def to_module_app_format
{"query"=>@query,"image"=>@image} rescue nil {"query"=>@query,"image"=>@image,"more_link"=>@more_link} rescue nil
end end
def link_field(field_name,setting) def link_field(field_name,setting)

View File

@ -190,6 +190,25 @@ namespace :migrate do
end end
end end
task :convert_cate_tag_type => :environment do
[Page,PagePart].each do |obj|
obj.all.each do |pp|
if pp.category.blank?
pp.category = []
else
pp.category = [pp.category]
end
if pp.tag.blank?
pp.tag = []
else
pp.tag = [pp.tag]
end
pp.save
end
end
end
task :clean_parts => :environment do task :clean_parts => :environment do
PagePart.where(widget_style: /\d/, kind: 'module_widget').each{|part| part.update_attributes({kind: 'text', widget_style: nil, widget_field: nil})} PagePart.where(widget_style: /\d/, kind: 'module_widget').each{|part| part.update_attributes({kind: 'text', widget_style: nil, widget_field: nil})}
PagePart.where(widget_style: /\d/).each{|part| part.update_attributes({widget_style: nil, widget_field: nil})} PagePart.where(widget_style: /\d/).each{|part| part.update_attributes({widget_style: nil, widget_field: nil})}

View File

@ -27,6 +27,7 @@ zh_tw:
approval_setting: 審核權限 approval_setting: 審核權限
tags: 標籤 tags: 標籤
default_widget: default_widget:
to_more: 更多
bulletin_category_with_title: 分類 bulletin_category_with_title: 分類
title: 標題 title: 標題
postdate: 張貼日期 postdate: 張貼日期

View File

@ -18,6 +18,7 @@ module Announcement
end end
category ["BulletinCategory"] category ["BulletinCategory"]
data_count 3..10
widgets do widgets do
default_widget do default_widget do
@ -26,6 +27,7 @@ module Announcement
field :postdate field :postdate
link_field :title,{:method => 'panel_announcement_front_end_bulletin_path',:args=>:self} link_field :title,{:method => 'panel_announcement_front_end_bulletin_path',:args=>:self}
link_field :bulletin_category_with_title,{:method => 'panel_announcement_front_end_bulletins_path',:args=>{:category_id => [:bulletin_category,:id]}} link_field :bulletin_category_with_title,{:method => 'panel_announcement_front_end_bulletins_path',:args=>{:category_id => [:bulletin_category,:id]}}
link_to_more 'panel_announcement_front_end_bulletins_path',:title_i18n=> 'announcement.default_widget.to_more'
end end
categories_query 'BulletinCategory.all' categories_query 'BulletinCategory.all'

View File

@ -1,7 +1,7 @@
class Panel::PersonalConference::Desktop::ConferencePagesController < ApplicationController class Panel::PersonalConference::Desktop::ConferencePagesController < ApplicationController
def index def index
@view_by = params[:view] @view_by = params[:view]
@writing_conferences = WritingConference.all @writing_conferences = WritingConference.where(create_user_id: current_user.id)
if @view_by.nil? if @view_by.nil?
@writing_conferences = @writing_conferences.asc(:paper_title) @writing_conferences = @writing_conferences.asc(:paper_title)

View File

@ -8,7 +8,7 @@
</ul> </ul>
</div> </div>
</div> </div>
<%= submit_tag "Back", :type => "button", class: "bt-cancel fn_btn ini_input hp hh2 thmtxt" %> <%= submit_tag "Back", :type => "button", "ajax-remote" => "get", :href => panel_personal_conference_desktop_conference_co_authors_path, class: "bt-cancel fn_btn ini_input hp hh2 thmtxt" %>
</div> </div>
</div> </div>

View File

@ -1,7 +1,7 @@
<div class="toolbar hh2"> <div class="toolbar hh2">
<div class="fn_g hp"> <div class="fn_g hp">
<%= f.submit "Save", name: "commit", value: "Save", class: "fn_btn ini_input hp hh2 thmc2 thmtxt" %> <%= f.submit "Save", name: "commit", value: "Save", class: "fn_btn ini_input hp hh2 thmc2 thmtxt" %>
<%= submit_tag "Cancel", :type => "button", class: "bt-cancel fn_btn ini_input hp hh2 thmtxt" %> <%= submit_tag "Cancel", :type => "button", "ajax-remote" => "get", :href => panel_personal_conference_desktop_conference_co_authors_path, class: "bt-cancel fn_btn ini_input hp hh2 thmtxt" %>
</div> </div>
</div> </div>
<div id="new_co_author" class="s_grid_con s_form vp"> <div id="new_co_author" class="s_grid_con s_form vp">

View File

@ -3,7 +3,7 @@
<%= f.submit t("save"), name: "commit", value: "Save", class: "fn_btn ini_input hp hh2 thmc2 thmtxt" %> <%= f.submit t("save"), name: "commit", value: "Save", class: "fn_btn ini_input hp hh2 thmc2 thmtxt" %>
<!-- class: bt-cancle can't be remove --> <!-- class: bt-cancle can't be remove -->
<% if not @writing_conference.new_record? %> <% if not @writing_conference.new_record? %>
<%= submit_tag t("cancel"), :type => "button", class: "bt-cancel ini_input hp hh2 thmadm thmtxt" %> <%= submit_tag t("cancel"), :type => "button", "ajax-remote" => "get", :href => panel_personal_conference_desktop_conference_pages_path, class: "bt-cancel ini_input hp hh2 thmadm thmtxt" %>
<% end %> <% end %>
</div> </div>
<div class="hh2 hp sdm"> <div class="hh2 hp sdm">
@ -146,7 +146,7 @@
<%= select_year((@writing_conference.year ? @writing_conference.year.to_i : DateTime.now.year), {:start_year => DateTime.now.year, :end_year => 1930}, {:name => 'writing_conference[year]', :class => "s_grid_4 s_grid"} ) %> <%= select_year((@writing_conference.year ? @writing_conference.year.to_i : DateTime.now.year), {:start_year => DateTime.now.year, :end_year => 1930}, {:name => 'writing_conference[year]', :class => "s_grid_4 s_grid"} ) %>
</li> </li>
<li class="s_grid_row"><input class="s_grid s_grid_6" type="text" placeholder=<%= t("tags") %>><span class="icon-plus input_append"></li> <li class="s_grid_row"><input class="s_grid s_grid_6" type="text" placeholder=<%= t("personal_conference.tags") %>><span class="icon-plus input_append"></li>
<li class="s_grid_row"> <li class="s_grid_row">
<%= f.text_area :abstract, size: "20x22", placeholder: t("personal_conference.abstract"), class: "s_grid_6 s_grid full_height"%> <%= f.text_area :abstract, size: "20x22", placeholder: t("personal_conference.abstract"), class: "s_grid_6 s_grid full_height"%>

View File

@ -0,0 +1,25 @@
ConferenceCoAuthorRelation.destroy_all
ConferenceCoAuthor.destroy_all
ConferencePaperType.destroy_all
WritingConferenceFile.destroy_all
WritingConference.destroy_all
2.times do
FactoryGirl.create(:conference_paper_type)
end
10.times do
FactoryGirl.create(:conference_co_author_relation)
end
50.times do
FactoryGirl.create(:conference_co_author)
end
50.times do
FactoryGirl.create(:writing_conference)
end
puts "Conference sample data import success!"

View File

@ -1,5 +0,0 @@
class Panel::PersonalJournal::Desktop::JournalPController < ApplicationController
def journal_p
render panel_personal_journal_desktop_journal_p_path, :layout => false
end
end

View File

@ -1,7 +1,16 @@
class Panel::PersonalJournal::Desktop::JournalPagesController < ApplicationController class Panel::PersonalJournal::Desktop::JournalPagesController < ApplicationController
def index def index
@writing_journal = WritingJournal.where(create_user_id: current_user.id) @writing_journals = WritingJournal.where(create_user_id: current_user.id)
@level_types = JournalLevelType.all @level_types = JournalLevelType.all
@view_by = params[:view]
if @view_by.nil?
@writing_journals = @writing_journals.asc(:paper_title)
else
@writing_journals = @writing_journals.asc(@view_by).asc(:paper_title)
end
@level_types = ConferencePaperType.all
respond_to do |format| respond_to do |format|
format.html { render :layout => false} format.html { render :layout => false}
@ -73,37 +82,6 @@ class Panel::PersonalJournal::Desktop::JournalPagesController < ApplicationContr
render :json => {success: true, msg: t('delete.success.paper')} render :json => {success: true, msg: t('delete.success.paper')}
end end
def get_journals_json
publications = WritingJournal.where(create_user_id: current_user.id)
sort_publications= Hash.new
data = Array.new
publications.each do |publication|
if sort_publications[publication.journal_title].nil?
sort_publications[publication.journal_title] = Array.new
end
sort_publications[publication.journal_title] <<
{ title: publication.paper_title,
keywords: publication.keywords,
abstract: publication.abstract,
coauthors: publication.authors,
year: publication.year,
url_edit: edit_panel_personal_journal_desktop_journal_page_path(publication),
url_delete: panel_personal_journal_desktop_journal_page_path(publication),
files: publication.writing_journal_files.collect{|file|
{title: file.title, url: file.file.url, icon: check_file_type(file.file.url)}
}
}
end
sort_publications.each do |journal, papers|
data << {title: journal, papers: papers}
end
render json: JSON.pretty_generate(data)
end
def journal_type def journal_type
level_types = JournalLevelType.all level_types = JournalLevelType.all
all_journal_lists = WritingJournal.where(create_user_id: current_user.id) all_journal_lists = WritingJournal.where(create_user_id: current_user.id)

View File

@ -0,0 +1,5 @@
class Panel::PersonalJournal::Desktop::JournalWindowsController < ApplicationController
def journal_window
render panel_personal_journal_desktop_journal_window_path, :layout => false
end
end

View File

@ -0,0 +1,74 @@
module Panel::PersonalJournal::Desktop::JournalPagesHelper
def publication_record publication, view
content_tag :li,
:class => "list_t_item" do
marker + \
content(publication, view) + \
edit_or_delete(publication)
end
end
def marker
content_tag :div,
:class => "list_item_action"
content_tag(:a, "", :class => "icon-check-empty") + \
content_tag(:a, "", :class => "icon-star-empty")
end
def content publication, view
case view
when "journal_title"
des = content_tag(:div, publication.journal_title,
:class => "list_t_des")
when "keywords"
des = content_tag(:div, publication.keywords,
:class => "list_t_des")
when "abstract"
des = content_tag(:div, publication.abstract,
:class => "list_t_des")
when "file"
des = content_tag(:div, link_publication_file(publication),
:class => "list_t_des")
else
end
content_tag(:div, publication.paper_title,
:class => "list_t_title") + des
end
def edit_or_delete publication
content_tag :div,
:class => "list_item_function" do
content_tag(:a, t("edit"),
:class => "journal_paper_edit admbg2 admtxt",
:href => edit_panel_personal_journal_desktop_journal_page_path(publication),
"ajax-remote" => "get") + \
content_tag(:a, t("delete"),
"ajax-remote" => "delete",
"confirm-message" => t("sure?"),
"callback-method" => "paperDelete",
:class => "journal_paper_delete admbg2 admtxt",
:href => panel_personal_journal_desktop_journal_page_path(publication))
end
end
def link_publication_file publication
publication.writing_journal_files.map{|file|
link_to(image_tag(check_file_type(file.file.url)) + \
content_tag(:span, file.title, :class => "filetitle"),
file.file.url,
:class => "file",
"target" => "_blank")
}.inject(:+)
end
def check_file_type file
if not file.nil?
file_type = MIME::Types.type_for(file).first.to_s.split("/")[1]
file_type = "/assets/ft-icons/#{file_type}/#{file_type}-48_32.png"
else
file_type = ""
end
end
end

View File

@ -47,11 +47,11 @@ class WritingJournal
current_user = update_user_id current_user = update_user_id
end end
authors_db = CoAuthor.where(:name_id => current_user).map(&:co_author) authors_db = JournalCoAuthor.where(:name_id => current_user).map(&:co_author)
authors_list.delete(User.find(current_user).name) authors_list.delete(User.find(current_user).name)
authors_list = authors_list.delete_if{|author| authors_db.include?author} authors_list = authors_list.delete_if{|author| authors_db.include?author}
authors_list.each do |author| authors_list.each do |author|
CoAuthor.new(:co_author => author, :name_id => current_user).save JournalCoAuthor.new(:co_author => author, :name_id => current_user).save
end end
end end

View File

@ -1,4 +1,4 @@
<%= f.text_field :journal_co_author_relation %> <%= f.text_field :relation %>
<!-- <!--
<#%= f.fields_for :journal_co_author_relation_translations do |f| %> <#%= f.fields_for :journal_co_author_relation_translations do |f| %>
<#%= f.text_field locale, <#%= f.text_field locale,

View File

@ -1,3 +1,3 @@
<%= form_for(@journal_co_author_relation, url: panel_personal_journal_desktop_journal_co_author_relations_path, html:{"form-type"=>"ajax_form", "callback-method"=>"coauthorRelationForm"} ) do |f| %> <%= form_for(@journal_co_author_relation, url: panel_personal_journal_desktop_journal_co_author_relations_path, html:{"form-type"=>"ajax_form", "callback-method"=>"coauthorRelationForm"} ) do |f| %>
<%= render partial: 'panel/personal_journal/desktop/journal_co_author_relations/form' , locals: {:f => f}%> <%= render partial: 'form' , locals: {:f => f}%>
<% end %> <% end %>

View File

@ -6,8 +6,8 @@
<li class="s_grid_row"> <li class="s_grid_row">
<div class="form_space" id="form_space_<%= i.to_s %>"><%= journal_co_author_relation.relation %></div> <div class="form_space" id="form_space_<%= i.to_s %>"><%= journal_co_author_relation.relation %></div>
<div class="list_item_function"> <div class="list_item_function">
<%= link_to 'Edit', edit_panel_personal_journal_desktop_journal_co_author_relation_path(co_author_relation), :class => "bt-edit-type admbg2 admtxt", "content-holder"=>"#form_space_"+i.to_s, "ajax-remote"=>"get" %> <%= link_to 'Edit', edit_panel_personal_journal_desktop_journal_co_author_relation_path(journal_co_author_relation), :class => "bt-edit-type admbg2 admtxt", "content-holder"=>"#form_space_"+i.to_s, "ajax-remote"=>"get" %>
<%= link_to 'Destroy', panel_personal_journal_desktop_journal_co_author_relation_path(co_author_relation), "confirm-message"=>'Are you sure?', "ajax-remote"=>"delete", :class=>"bt-delete admbg2 admtxt" %> <%= link_to 'Destroy', panel_personal_journal_desktop_journal_co_author_relation_path(journal_co_author_relation), "confirm-message"=>'Are you sure?', "ajax-remote"=>"delete", :class=>"bt-delete admbg2 admtxt" %>
</div> </div>
</li> </li>
<% if ( i % 6 ) == 5 %> <% if ( i % 6 ) == 5 %>

View File

@ -1,3 +1,3 @@
<%= form_for(@journal_co_author_relation, url: panel_personal_journal_desktop_journal_co_author_relation_path(@co_author_relation), html:{"form-type"=>"ajax_form", "callback-method"=>"coauthorRelationEditForm"} ) do |f| %> <%= form_for(@journal_co_author_relation, url: panel_personal_journal_desktop_journal_co_author_relation_path(@journal_co_author_relation), html:{"form-type"=>"ajax_form", "callback-method"=>"coauthorRelationEditForm"} ) do |f| %>
<%= render partial: 'panel/personal_journal/desktop/journal_co_author_relations/form' , locals: {:f => f}%> <%= render partial: 'form' , locals: {:f => f}%>
<% end %> <% end %>

View File

@ -8,7 +8,7 @@
</ul> </ul>
</div> </div>
</div> </div>
<%= submit_tag "Back", :type => "button", class: "bt-cancel fn_btn ini_input hp hh2 thmtxt" %> <%= submit_tag "Back", :type => "button", "ajax-remote" => "get", :href => panel_personal_journal_desktop_journal_co_authors_path, class: "fn_btn ini_input hp hh2 thmtxt" %>
</div> </div>
</div> </div>

View File

@ -1,7 +1,7 @@
<div class="toolbar hh2"> <div class="toolbar hh2">
<div class="fn_g hp"> <div class="fn_g hp">
<%= f.submit "Save", name: "commit", value: "Save", class: "fn_btn ini_input hp hh2 thmc2 thmtxt" %> <%= f.submit "Save", name: "commit", value: "Save", class: "fn_btn ini_input hp hh2 thmc2 thmtxt" %>
<%= submit_tag "Cancel", :type => "button", class: "bt-cancel fn_btn ini_input hp hh2 thmtxt" %> <%= submit_tag "Cancel", :type => "button", "ajax-remote" => "get", :href => panel_personal_journal_desktop_journal_co_authors_path, class: "fn_btn ini_input hp hh2 thmtxt" %>
</div> </div>
</div> </div>
<div id="new_co_author" class="s_grid_con s_form vp"> <div id="new_co_author" class="s_grid_con s_form vp">

View File

@ -17,7 +17,7 @@
<ul class="info"> <ul class="info">
<li><div class="name"><%= co_author.co_author %></div></li> <li><div class="name"><%= co_author.co_author %></div></li>
<li><div class="email"><i class="icon-envelope"></i> <%= co_author.email %></div></li> <li><div class="email"><i class="icon-envelope"></i> <%= co_author.email %></div></li>
<li><div class="relations"><i class="icon-user"></i> <%= @journal_co_author_relations.find(co_author.co_author_relations_id).relation unless co_author.co_author_relations_id.nil?%></div></li> <li><div class="relations"><i class="icon-user"></i> <%= @journal_co_author_relations.find(co_author.journal_co_author_relations_id).relation unless co_author.journal_co_author_relations_id.nil?%></div></li>
</ul> </ul>
<div class="list_item_function"> <div class="list_item_function">
<%= link_to 'Edit', edit_panel_personal_journal_desktop_journal_co_author_path(co_author), :class => "bt-edit admbg2 admtxt", "ajax-remote"=>"get" %> <%= link_to 'Edit', edit_panel_personal_journal_desktop_journal_co_author_path(co_author), :class => "bt-edit admbg2 admtxt", "ajax-remote"=>"get" %>

View File

@ -1,9 +1,8 @@
<div class="toolbar hh2"> <div class="toolbar hh2">
<div class="fn_g hp"> <div class="fn_g hp">
<%= f.submit "Save", name: "commit", value: "Save", class: "fn_btn ini_input hp hh2 thmc2 thmtxt" %> <%= f.submit "Save", name: "commit", value: "Save", class: "fn_btn ini_input hp hh2 thmc2 thmtxt" %>
<!-- class: bt-cancle can't be remove -->
<% if not @writing_journal.new_record? %> <% if not @writing_journal.new_record? %>
<%= submit_tag "Cancel", :type => "button", class: "bt-cancel ini_input hp hh2 thmadm thmtxt" %> <%= submit_tag "Cancel", :type => "button", "ajax-remote" => "get", :href => panel_personal_journal_desktop_journal_pages_path, class: "ini_input hp hh2 thmadm thmtxt" %>
<% end %> <% end %>
</div> </div>
<div class="hh2 hp sdm"> <div class="hh2 hp sdm">
@ -143,7 +142,7 @@
</li> </li>
<li class="s_grid_row"> <li class="s_grid_row">
<%= f.text_field :tags, size: "20", placeholder: t("personal_journal.tags"), class: "s_grid_6 s_grid"%> <li class="s_grid_row"><input class="s_grid s_grid_6" type="text" placeholder=<%= t("personal_journal.tags") %>><span class="icon-plus input_append"></li>
<span class="icon-plus input_append"></span> <span class="icon-plus input_append"></span>
</li> </li>
<li class="s_grid_row"> <li class="s_grid_row">

View File

@ -41,11 +41,11 @@
<div class="sdm_t hh2">View</div> <div class="sdm_t hh2">View</div>
<div class="admbg sdm_o"> <div class="admbg sdm_o">
<ul id="journal_view_selection"> <ul id="journal_view_selection">
<li><a class="hp hh2 admtxt" href="journal">Journal</a></li> <li><%= link_to "Journal", panel_personal_journal_desktop_journal_pages_path + "?view=journal_title", :class => "hp hh2 admtxt", "ajax-remote" => "get" %></li>
<li><a class="hp hh2 admtxt" href="title">Title</a></li> <li><%= link_to "Title", panel_personal_journal_desktop_journal_pages_path + "?view=paper_title", :class => "hp hh2 admtxt", "ajax-remote" => "get" %></li>
<li><a class="hp hh2 admtxt" href="file">File</a></li> <li><%= link_to "File", panel_personal_journal_desktop_journal_pages_path + "?view=file", :class => "hp hh2 admtxt", "ajax-remote" => "get" %></li>
<li><a class="hp hh2 admtxt" href="keywords">Keywords</a></li> <li><%= link_to "Keywords", panel_personal_journal_desktop_journal_pages_path + "?view=keywords", :class => "hp hh2 admtxt", "ajax-remote" => "get" %></li>
<li><a class="hp hh2 admtxt" href="abstract">Abstract</a></li> <li><%= link_to "Abstract", panel_personal_journal_desktop_journal_pages_path + "?view=abstract", :class => "hp hh2 admtxt", "ajax-remote" => "get" %></li>
</ul> </ul>
</div> </div>
</div> </div>
@ -81,7 +81,9 @@
<div class="scrollbar sb_h vp"><div class="track"><div class="thumb thmc2"><div class="end"></div></div></div></div> <div class="scrollbar sb_h vp"><div class="track"><div class="thumb thmc2"><div class="end"></div></div></div></div>
<div class="viewport"> <div class="viewport">
<div class="overview"> <div class="overview">
<% @writing_journals.each do |w| %>
<%= publication_record w, @view_by%>
<% end %>
</div> </div>
</div> </div>
</div> </div>

View File

@ -2,7 +2,7 @@ Rails.application.routes.draw do
namespace :panel do namespace :panel do
namespace :personal_journal do namespace :personal_journal do
namespace :desktop do namespace :desktop do
match 'journal_p'=>'journal_p#journal_p' match 'journal_window'=>'journal_windows#journal_window'
match 'get_journals_json' => 'journal_pages#get_journals_json' match 'get_journals_json' => 'journal_pages#get_journals_json'
match 'journal_type' => 'journal_pages#journal_type' match 'journal_type' => 'journal_pages#journal_type'
resources :journal_pages, except: :show resources :journal_pages, except: :show

View File

@ -0,0 +1,23 @@
JournalCoAuthorRelation.destroy_all
JournalCoAuthor.destroy_all
JournalLevelType.destroy_all
WritingJournalFile.destroy_all
WritingJournal.destroy_all
10.size.times do
FactoryGirl.create(:journal_level)
end
10.times do
FactoryGirl.create(:journal_co_author_relation)
end
50.times do
FactoryGirl.create(:writing_journal)
end
50.times do
FactoryGirl.create(:journal_co_author)
end
puts "Journal sample data import success!"

View File

@ -2,7 +2,7 @@
types = ["friend", "teacher", "student", "schoolmate", "parent", "best friend", "instructor", "labmate", "TA", "mate"] types = ["friend", "teacher", "student", "schoolmate", "parent", "best friend", "instructor", "labmate", "TA", "mate"]
FactoryGirl.define do FactoryGirl.define do
factory(:journal_co_author_relation, class: "CoAuthorRelation") do |f| factory(:journal_co_author_relation, class: "JournalCoAuthorRelation") do |f|
f.sequence(:relation_translations) do |n| f.sequence(:relation_translations) do |n|
{ zh_tw: "#{types[n%types.size]}", { zh_tw: "#{types[n%types.size]}",
en: "#{types[n%types.size]}" } en: "#{types[n%types.size]}" }

View File

@ -8,13 +8,13 @@ email = Array.new 51,""
email= email.map do |p| Faker::Internet.email end email= email.map do |p| Faker::Internet.email end
FactoryGirl.define do FactoryGirl.define do
factory(:journal_co_author, class: "CoAuthor") do |f| factory(:journal_co_author, class: "JournalCoAuthor") do |f|
f.sequence(:co_author_translations) do |n| f.sequence(:co_author_translations) do |n|
{ zh_tw: "#{name_tw[n]}", { zh_tw: "#{name_tw[n]}",
en: "#{name_en[n]}" } en: "#{name_en[n]}" }
end end
f.sequence(:co_author_relations_id) do |n| "#{CoAuthorRelation.all[n%CoAuthorRelation.count].id}" end f.sequence(:journal_co_author_relations_id) do |n| "#{JournalCoAuthorRelation.all[n%JournalCoAuthorRelation.count].id}" end
f.sequence(:email) do |n| "#{email[n]}" end f.sequence(:email) do |n| "#{email[n]}" end
f.name_id BSON::ObjectId('4f45f3b9e9d02c5db9000067') #user_id, this is Chris' account f.name_id BSON::ObjectId('4f45f3b9e9d02c5db9000067') #user_id, this is Chris' account
end end

View File

@ -7,7 +7,7 @@ data_json = JSON.parse(data)
rand = Random.new rand = Random.new
FactoryGirl.define do FactoryGirl.define do
factory :journal, class: "WritingJournal" do |f| factory :writing_journal, class: "WritingJournal" do |f|
f.sequence(:paper_title_translations) do |n| f.sequence(:paper_title_translations) do |n|
{ zh_tw: "#{data_json[n]["paper_title"]}_tw", { zh_tw: "#{data_json[n]["paper_title"]}_tw",
en: "#{data_json[n]["paper_title"]}_en" } en: "#{data_json[n]["paper_title"]}_en" }