From b9c8d9d657dcdcaf24ee72185a4592705cea62bf Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 6 Nov 2012 14:26:37 +0800 Subject: [PATCH 001/136] plugin edit --- .../personal_journal/back_end/writing_journals_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/built_in_modules/personal_journal/app/controllers/panel/personal_journal/back_end/writing_journals_controller.rb b/vendor/built_in_modules/personal_journal/app/controllers/panel/personal_journal/back_end/writing_journals_controller.rb index b9e250da9..27e7e53da 100644 --- a/vendor/built_in_modules/personal_journal/app/controllers/panel/personal_journal/back_end/writing_journals_controller.rb +++ b/vendor/built_in_modules/personal_journal/app/controllers/panel/personal_journal/back_end/writing_journals_controller.rb @@ -229,7 +229,7 @@ class Panel::PersonalJournal::BackEnd::WritingJournalsController < OrbitBackendC if @writing_journal.save if params[:writing_journal][:user_id] - format.html { redirect_to(admin_users_new_interface_url(:id=>params[:writing_journal][:user_id],:show_plugin_profile=>Journal)) } + format.html { redirect_to(admin_users_new_interface_url(:id=>params[:writing_journal][:user_id],:show_plugin_profile=>'Journal')) } else format.html { redirect_to(panel_personal_journal_back_end_writing_journals_url) } end From dafe28ffb5ac81cc8196dd37578ea30935d34545 Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Thu, 8 Nov 2012 18:59:19 +0800 Subject: [PATCH 002/136] add_more ok --- .../admin/users_new_interface_controller.rb | 4 +- app/helpers/attribute_fields_helper.rb | 103 +++++++++------ app/helpers/attribute_values_helper.rb | 68 ++++++++++ app/models/user/attribute_field.rb | 66 ++++++++-- app/models/user/attribute_value.rb | 105 ++++++++------- .../admin/infos/_attribute_field.html.erb | 15 ++- app/views/admin/infos/_form.html.erb | 2 +- .../admin/users_new_interface/_form.html.erb | 122 ++++++------------ .../_show_sub_role.html.erb | 2 +- config/locales/zh_tw.yml | 8 +- config/mongoid.yml | 1 + spec/models/attribute_value_spec.rb | 94 +++++++++----- 12 files changed, 373 insertions(+), 217 deletions(-) create mode 100644 app/helpers/attribute_values_helper.rb diff --git a/app/controllers/admin/users_new_interface_controller.rb b/app/controllers/admin/users_new_interface_controller.rb index 323271d2b..0d3699b87 100644 --- a/app/controllers/admin/users_new_interface_controller.rb +++ b/app/controllers/admin/users_new_interface_controller.rb @@ -35,7 +35,6 @@ class Admin::UsersNewInterfaceController < ApplicationController attribute_values = @user.attribute_values attribute_values.each{|att_val| - binding.pry if att_val.id.to_s == '5052dab52b5c49ae9d000006' @profile_data.push({:name => att_val.attribute_field.title,:value =>att_val.get_value_by_locale(I18n.locale.to_s)}) if att_val.attribute_field.attribute.key=="profile" rescue false } @@ -79,7 +78,7 @@ class Admin::UsersNewInterfaceController < ApplicationController # @user.attribute_values.build(value) # } # @user.rebuild_sub_roles_from_attribute_values!(attribute_values) - binding.pry + # binding.pry if @user.save flash[:notice] = t('admin.create_success_user') redirect_to :action => :index @@ -104,6 +103,7 @@ class Admin::UsersNewInterfaceController < ApplicationController def update @user = User.find(params[:id]) + @user.update_attributes(params[:user]) attribute_values_key = params[:user].has_key?('new_attribute_values') ? 'new_attribute_values' : 'attribute_values' attribute_values = params[:user].delete(attribute_values_key) diff --git a/app/helpers/attribute_fields_helper.rb b/app/helpers/attribute_fields_helper.rb index 323d26a39..a1d68b56e 100644 --- a/app/helpers/attribute_fields_helper.rb +++ b/app/helpers/attribute_fields_helper.rb @@ -1,6 +1,4 @@ #encoding: utf-8 -# require ActionView::Helpers::FormTagHelper - module AttributeFieldsHelper include ActionView::Helpers::FormTagHelper include ActionView::Helpers::FormOptionsHelper @@ -49,8 +47,8 @@ module AttributeFieldsHelper end def render_checkbox - @prefiled_value ||=[] + # @prefiled_value = @prefiled_value.keys unless @prefiled_value ==[] # begin # markup_value = eval(self.markup_value) # rescue @@ -92,8 +90,7 @@ module AttributeFieldsHelper end def render_select - - prompt = @panel_setting[:prompt][I18n.locale] rescue nil + prompt = @panel_setting["initial"][I18n.locale.to_s] rescue nil @markup_options.merge!(:prompt => prompt) unless prompt.nil? # markup_value = (self.markup_value.is_a?(Hash) ? self.markup_value : eval(self.markup_value) )rescue {} # check self[:option_list].collect{|p| [p[1][I18n.locale.to_s],p[0]]} @@ -102,38 +99,31 @@ module AttributeFieldsHelper def render_text_area control_group_wrapper do |key,value| - if(add_more and value.is_a?(Hash)) - values = value - values.each_with_index.collect do |value,index| - place_holder= @panel_setting["placeholder"][key] - text_area_tag(get_field_name_base + (key.nil? ? '' : "[#{key}][#{index}]"), value.last,@markup_options.merge(:placeholder=>place_holder)) - end.join.html_safe - else + # if(add_more and value.is_a?(Hash)) + # values = value + # values.each_with_index.collect do |value,index| + # place_holder= @panel_setting["placeholder"][key] + # text_area_tag(get_field_name_base + (key.nil? ? '' : "[#{key}][#{index}]"), value.last,@markup_options.merge(:placeholder=>place_holder)) + # end.join.html_safe + # else value = can_muti_lang_input ? @prefiled_value[key] : @prefiled_value key = can_muti_lang_input ? "[#{key}]" : "" place_holder= @panel_setting["placeholder"][I18n.locale.to_s] rescue '' text_area_tag(get_field_name_base + key, value,@markup_options.merge(:placeholder=>place_holder)) - end + # end end end def render_text_field - control_group_wrapper do |key,value| + control_group_wrapper do |key,value,add_more_counter| if(add_more) - values = value - result = "" - unless values.nil? - result = values.each_with_index.collect do |value,index| - place_holder= @panel_setting["placeholder"][key] - text_field_tag(get_field_name_base + (key.nil? ? '' : "[#{key}][#{index}]"), value.last,@markup_options.merge(:placeholder=>place_holder)) - end.join.html_safe - end - result + place_holder= @panel_setting["placeholder"][key] + text_field_tag(get_field_name_base + (key.nil? ? '' : "[][#{key}]"), value,@markup_options.merge(:placeholder=>place_holder)) + link_to( (content_tag :i,'',:class=>"icon-trash"),'#',:class=> "btn removeInput") else - value = (can_muti_lang_input ? @prefiled_value[key] : @prefiled_value) rescue nil - key_field = can_muti_lang_input ? "[#{key}]" : "" - place_holder= @panel_setting["placeholder"][key] rescue '' - text_field_tag(get_field_name_base + key_field, value,@markup_options.merge(:placeholder=>place_holder)) + value = (can_muti_lang_input ? @prefiled_value[key] : @prefiled_value) rescue nil + key_field = can_muti_lang_input ? "[#{key}]" : "" + place_holder= @panel_setting["placeholder"][key] rescue '' + text_field_tag(get_field_name_base + key_field, value,@markup_options.merge(:placeholder=>place_holder)) end end end @@ -147,25 +137,40 @@ protected result.html_safe end + def controls_wrapper(&block) - result = "
" + loop_time = self.add_more ? @attribute_value.add_more_counter : 1 + result = '' + result << "
" if self.add_more + result << "
" + loop_time.times do |loop_counter| if can_muti_lang_input result << "
" - result << "
" + result << "
" VALID_LOCALES.collect do |key| + value = @prefiled_value[key.to_s] rescue nil div_class = ["tab-pane" ,"fade"].join(" ") div_class << (key == I18n.locale.to_s ? " active in" : '') - result << content_tag(:div,yield(key,value),:class=>div_class,:id=>"tab"+id.to_s+"_#{key}") - end - + if self.add_more + div_class << " input-append #{add_more_tab(:input_field,loop_counter,key)}" + # binding.pry + add_more_field_value = @prefiled_value[loop_counter][key] rescue '' + result << content_tag(:div,yield(key,add_more_field_value,loop_counter),:class=>div_class)#,:id=>"tab"+id.to_s+"_#{key}_#{loop_counter}" + else + result << content_tag(:div,yield(key,value),:class=>div_class,:id=>"tab"+id.to_s+"_#{key}") + end + end # of VALID_LOCALES.collect for tabed input result << "
" + result << "" + link_entry = self.add_more ? "#{add_more_tab(:tab_btn,loop_counter,key)}" : "#tab"+id.to_s+"_#{key}" + result << content_tag(:li,link_to(I18n.t("langs."+key),link_entry,:data=>{:toggle=>"tab"}),:class=>(key == I18n.locale.to_s ? "active" : nil)) + end # of VALID_LOCALES.collect for tabs + result << "" + result << "
" # @prefiled_value.collect do |key,value| # result << yield(key,value) @@ -173,14 +178,19 @@ protected else result << yield end - if can_add_more + if can_add_more and (loop_counter == loop_time-1) + temp_field_name = get_basic_field_name_base + '[temp]' result << '' - result << ' Add' + result << ''+I18n.t("admin.infos.add")+' ' + result << hidden_field_tag("#{temp_field_name}[count]",loop_time,:class=>"list_count") + result << hidden_field_tag("#{temp_field_name}[count]",get_basic_field_name_base,:class=>"field_name") result << '' end + end # of loop_time result << "
" + result << "
" if self.add_more result.html_safe - end + end # of def controls_wrapper(&block) def control_group_wrapper(&block) div_class = can_muti_lang_input ? "control-group language-swich" : "control-group" @@ -200,6 +210,23 @@ protected end end + def add_more_tab(mode,counter,key) + case mode + when :input_field + get_pairing_tab_class(:suffix=>['','tab'+counter.to_s,key].join('-')) + when :tab_btn + ".#{get_pairing_tab_class(:suffix=>['','tab'+counter.to_s,key].join('-'))}" + end + end + + def get_pairing_tab_class(opts) + prefix = opts[:prefix] + suffix = opts[:suffix] + str = get_basic_field_name_base.gsub("[","-").gsub("]",'') + str = prefix.nil? ? str : prefix+ str + suffix.nil? ? str : str + suffix + end + def get_basic_field_name_base if @new_attribute "user[new_attribute_values][#{@index}]" diff --git a/app/helpers/attribute_values_helper.rb b/app/helpers/attribute_values_helper.rb new file mode 100644 index 000000000..f2ea0832b --- /dev/null +++ b/app/helpers/attribute_values_helper.rb @@ -0,0 +1,68 @@ +module AttributeValuesHelper + def show_west_calender + date = get_date + case self.attribute_field["typeC"]["format"] + when 'format1' # Y/M/D h:m + date.strftime("%Y/%m/%d %H:%M") + when 'format2' # Y/M/D + date.strftime("%Y/%m/%d") + when 'format3' # Y/M + date.strftime("%Y/%m") + when 'format4' # Y + date.strftime("%Y") + end # of case west cal format + end + + def show_minguo_calendar + get_minguo + date = get_date + year_str = "" + unless date.year == 1912 + m_year = (date.year - 1912).abs.to_s + I18n.t("admin.infos.date.minguo_calendar.year") + year_str = minguo_format_year(m_year) + end + get_minguo_year + minguo_m_y_d_time + end + + def get_minguo_year + date = get_date + m_year = (date.year - 1911).abs + year_end = I18n.t("admin.infos.date.minguo_calendar.year") + case + when date.year <1912 + I18n.t("admin.infos.date.minguo_calendar.before") + (m_year+1).to_s + year_end + when date.year ==1912 + I18n.t("admin.infos.date.minguo_calendar.first_year") + when date.year >1912 + I18n.t("admin.infos.date.minguo_calendar.after")+ (m_year).to_s + year_end + end # of case tw_claendar year + end + + def minguo_m_y_d_time + date = get_date + case self.attribute_field["typeC"]["format"] + when 'format1' # Y/M/D h:m + date.strftime(" %m/%d %H:%M") + when 'format2' # Y/M/D + date.strftime(" %m/%d") + when 'format3' # Y/M + date.strftime(" %m#{I18n.t("admin.infos.date.minguo_calendar.month")}") + when 'format4' # Y + '' + end # of case + end + + def get_date_by_format + case I18n.locale + when :zh_tw + case + when self.attribute_field["typeC"]["claendar"] == "west_claendar" + show_west_calender + when self.attribute_field["typeC"]["claendar"] == "tw_claendar" + show_minguo_calendar + end #case self.attribute_field["typeC"]["claendar"] + when :en + show_west_calender + end + end +end \ No newline at end of file diff --git a/app/models/user/attribute_field.rb b/app/models/user/attribute_field.rb index a94a38a28..3cef5f1d4 100644 --- a/app/models/user/attribute_field.rb +++ b/app/models/user/attribute_field.rb @@ -13,10 +13,10 @@ class AttributeField field :built_in, :type => Boolean, :default => false field :disabled, :type => Boolean, :default => false field :to_delete,:type=> Boolean,:default => false - field :typeA,:type=> Hash,:default=>{} + field :typeA,:type=> Hash,:default=>{:cross_lang=>false} field :typeB,:type=> Hash,:default=>{} - field :typeC,:type=> Hash,:default=>{:claendar=>"west_claendar"} - field :typeD,:type=> Hash,:default=>{} + field :typeC,:type=> Hash,:default=>{:claendar=>"west_claendar",:format=>"format3"} + field :typeD,:type=> Hash,:default=>{:cross_lang=>false} field :typeE,:type=> Hash,:default=>{} @@ -30,6 +30,11 @@ class AttributeField has_many :attribute_values,:autosave => true, :dependent => :destroy before_save :check_option_list # validates_uniqueness_of :key + + def markup_value + get_data["option_list"] + end + def add_more (get_data["add_more"] == "true" ? true : false) rescue false end @@ -47,11 +52,11 @@ class AttributeField (self.attribute.role.method(self[:key].pluralize.to_sym) && self.attribute.role.method(self[:key].pluralize+"_for_"+markup)) rescue false end - def markup_value=(var) - if !self_defined_markup_options? - self[:markup_value] = (eval(var) rescue {}) - end - end + # def markup_value=(var) + # if !self_defined_markup_options? + # self[:markup_value] = (eval(var) rescue {}) + # end + # end def option_list if self_defined_markup_options? @@ -82,7 +87,7 @@ class AttributeField end def role - self.attribute.role + self.attribute.role end def panel @@ -138,7 +143,48 @@ class AttributeField # def select_list_options # self.list_options.to_a.join(', ') # end - + + def add_more_convert(opt) + case opt + when :to_add_more + self.attribute_values.each do |av| + VALID_LOCALES.each do |loc| + splited_str = av[loc].split(",") rescue [] + av["val"] = [] if av["val"].nil? + splited_str.each_with_index{|value,index| av["val"][index] = av["val"][index].nil? ? {loc=>value} : av["val"][index].merge(loc=>value) } + # av[loc] = Hash[splited_str.each_with_index.map{|t,index| [index.to_s,t]}] rescue {"0"=>av[loc].to_s} + end + av.save + end #of self.attribute_values.each + when :to_no_add_more + self.attribute_values.each do |av| + VALID_LOCALES.each do |loc| + if av["val"].kind_of? Array + av[loc] = av["val"].collect{|t| t[loc]}.join(",") + else + av[loc] = av["val"] + end + # av[loc] = av["val"].invert.keys.join(",") rescue av["val"] + # av.save(:validate => false) + end + av.unset("val") + av.save + end #of self.attribute_values.each + end + end + + def typeA=(var) + if self["typeA"]["add_more"] != var["add_more"] + case var["add_more"] + when "true" #from no-add_more to add_more + add_more_convert(:to_add_more) + else #from add_more to no-add_more + add_more_convert(:to_no_add_more) + end # of case + end # of if + self["typeA"] = var + end + def is_built_in? self.built_in end diff --git a/app/models/user/attribute_value.rb b/app/models/user/attribute_value.rb index d6500fbf1..7b5d4caf6 100644 --- a/app/models/user/attribute_value.rb +++ b/app/models/user/attribute_value.rb @@ -1,9 +1,8 @@ class AttributeValue - include Mongoid::Document include Mongoid::Timestamps include Mongoid::MultiParameterAttributes - + include AttributeValuesHelper field :key belongs_to :attribute_field @@ -14,48 +13,52 @@ class AttributeValue # NO_MULTI_TAG = ["select","date","radio_button","checkbox","date_durnation"] - def data_proc - # binding.pry - # binding.pry if self.attribute_field.markup == 'radio_button' - # if self.attribute_field - case self.attribute_field.markup - when 'text_field','text_area' - # binding.pry - self[:temp_data].each{|key,val| - self[key] = val - } unless self[:temp_data].nil? - when 'select','date','radio_button' - self["val"] = self[:temp_data] - when 'checkbox' - self["val"] = self[:temp_data].keys rescue {} - end #end of case - else # if not locale - case self.attribute_field.markup - when 'text_field','text_area' - self["val"] = self[:temp_data] - when 'select','date','radio_button' - self["val"] = self[:temp_data] - when 'checkbox' - self["val"] = self[:temp_data].keys rescue {} - end #end of case - # end #of if self.attribute_field - self.unset('temp_data') + def add_more_counter + index_max = self["val"].count rescue 0 + index_max == 0 ? 1 : index_max end - def value - - result="" - if self.attribute_field.locale && (self.attribute_field.markup == "text_field" || self.attribute_field.markup == "text_area") - result= Hash[VALID_LOCALES.collect{|lang| [lang,self[lang.to_sym]]}] - else - result = self["val"] - end - result + def data_proc + unless self[:temp_data].nil? + case self.attribute_field.markup + when 'text_field','text_area' + if self.attribute_field.add_more + self["val"] = self["temp_data"] + else # if not add_more + self[:temp_data].each{|key,val| + self[key] = val + } if(!self.attribute_field.get_data[:cross_lang]) + self["val"] = self[:temp_data] if(self.attribute_field.get_data[:cross_lang]) + end # of self.attribute_field.add_more + + when 'select','date','radio_button' + self["val"] = self[:temp_data] + when 'checkbox' + self["val"] = self[:temp_data].keys + end #end of case self.attribute_field.markup + end # of self[:temp_data].nil? + self.unset('temp_data') + self.unset('temp') + end #of data_proc + + def value(index = nil) + result = case self.attribute_field.markup + when 'text_field','text_area' + if self.attribute_field.add_more and (self.attribute_field.markup == "text_field") + index.nil? ? self["val"] : self["val"][index] + # self.attribute_field.get_data[:cross_lang] ? Hash[VALID_LOCALES.collect{|lang| [lang,self[lang.to_sym]]}] : self["val"] #if !self.attribute_field.get_data[:cross_lang] + else + self.attribute_field.get_data[:cross_lang] ? self["val"] : Hash[VALID_LOCALES.collect{|lang| [lang,self[lang.to_sym]]}] + end + when 'select','date','radio_button' + self["val"] + when 'checkbox' + self["val"] + end #end of case self.attribute_field.markup end def value=(value) #save everything to temp_data waiting for futher process - # binding self[:temp_data] = value end @@ -70,27 +73,32 @@ class AttributeValue self[(field[0].to_s.delete "=")] = field[1] end end - - def get_value_by_locale(locale) + + def get_value_by_locale(locale,add_more_index=nil) case self.attribute_field.markup when "text_field" - self.attribute_field.locale ? self[locale.to_s] : self.value + case self.attribute_field.add_more + when true + add_more_index.nil? ? self.value.collect{|t| t[locale]}.join(",") : self.value(add_more_index)[locale] + when false + self.attribute_field.locale ? self[locale.to_s] : self.value + end when "select" - markup_values = self.attribute_field.self_defined_markup_options? ? self.attribute_field.markup_value : eval(self.attribute_field.markup_value) + markup_values = self.attribute_field.self_defined_markup_options? ? self.attribute_field.markup_value : self.attribute_field.markup_value markup_values[self.value][locale.to_s] rescue 'NoData' when "text_area" self.attribute_field.locale ? self[locale.to_s] : self.value when "date" - Date.new(self[:val]["(1i)"].to_i,self[:val]["(2i)"].to_i,self[:val]["(3i)"].to_i) rescue nil + get_date_by_format when "addr" self.value when "radio_button" - markup_values = eval(self.attribute_field.markup_value) - markup_values[:value][locale.to_s] + markup_values = self.attribute_field.markup_value + markup_values[self.value][locale.to_s] when "checkbox" markup_values = self.attribute_field.markup_value - self[:value].keys.collect{|key| markup_values[key][locale.to_s]}.join(",") + self.value.collect{|key| markup_values[key][locale.to_s]}.join(",") when "date_durnation" self.value else @@ -113,5 +121,10 @@ class AttributeValue # end # end # end + protected + + def get_date + Date.new(self[:val]["(1i)"].to_i,self[:val]["(2i)"].to_i,self[:val]["(3i)"].to_i) rescue nil + end end diff --git a/app/views/admin/infos/_attribute_field.html.erb b/app/views/admin/infos/_attribute_field.html.erb index 95d602683..f8c7a701d 100644 --- a/app/views/admin/infos/_attribute_field.html.erb +++ b/app/views/admin/infos/_attribute_field.html.erb @@ -33,8 +33,8 @@
- <%= render :partial=> "placeholder_block",:locals=>{:field_name=>"info[attribute_fields][#{attribute_field_counter}][typeD][placeholder]",:values=>attribute_field["typeD"]["placeholder"]} %> + <%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:field_name=>"info[attribute_fields][#{attribute_field_counter}][typeD][placeholder]",:values=>attribute_field["typeD"]["placeholder"]} %> <% end %> <%= content_tag :div,:class=>show_type_panel(attribute_field,"typeE") do%> - <%= render :partial=>"list_block",:locals=>{:field_name=>"info[attribute_fields][#{attribute_field_counter}][typeE][option_list]",:values=>attribute_field["option_list"]}%> + <%= render :partial=>"shared/attribute_field/list_block",:locals=>{:field_name=>"info[attribute_fields][#{attribute_field_counter}][typeE][option_list]",:values=>attribute_field["option_list"]}%> <% end %>
<%= hidden_field "info[attribute_fields][#{attribute_field_counter}]","id",:value=>attribute_field.id%> diff --git a/app/views/admin/infos/_list_block.html.erb b/app/views/shared/attribute_field/_list_block.html.erb similarity index 100% rename from app/views/admin/infos/_list_block.html.erb rename to app/views/shared/attribute_field/_list_block.html.erb diff --git a/app/views/admin/infos/_placeholder_block.html.erb b/app/views/shared/attribute_field/_placeholder_block.html.erb similarity index 100% rename from app/views/admin/infos/_placeholder_block.html.erb rename to app/views/shared/attribute_field/_placeholder_block.html.erb diff --git a/config/mongoid.yml b/config/mongoid.yml index a809bc065..75c5ef809 100644 --- a/config/mongoid.yml +++ b/config/mongoid.yml @@ -2,7 +2,7 @@ defaults: &defaults host: localhost # slaves: # - host: slave1.local - port: 27017 + port: 37017 # - host: slave2.local # port: 27019 From 996a69f5954ece9540d640f31178cc2b143c065b Mon Sep 17 00:00:00 2001 From: Rueshyna Date: Fri, 23 Nov 2012 10:44:48 +0800 Subject: [PATCH 127/136] add co-author json --- .../desktop/co_authors_controller.rb | 14 +++++++++++ .../desktop/journal_pages/_form.html.erb | 25 ++++++++++--------- config/routes.rb | 1 + 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/app/controllers/desktop/co_authors_controller.rb b/app/controllers/desktop/co_authors_controller.rb index 1c74314e1..ccda3786e 100644 --- a/app/controllers/desktop/co_authors_controller.rb +++ b/app/controllers/desktop/co_authors_controller.rb @@ -62,4 +62,18 @@ class Desktop::CoAuthorsController < ApplicationController format.json { head :no_content } end end + + def get_co_authors_json + @co_authors = CoAuthor.where(name_id: current_user.id) + data = Array.new + + @co_authors.each do |co_author| + data << { + author: co_author.co_author, + email: co_author.email, + type: co_author.type + } + end + render json: JSON.pretty_generate(data) + end end diff --git a/app/views/desktop/journal_pages/_form.html.erb b/app/views/desktop/journal_pages/_form.html.erb index 223bea04a..b6320c6a0 100644 --- a/app/views/desktop/journal_pages/_form.html.erb +++ b/app/views/desktop/journal_pages/_form.html.erb @@ -1,7 +1,8 @@
<%= f.submit "Save", name: "commit", value: "Save", class: "fn_btn hh2 thmc2 thmtxt" %> - +
Entry Year
@@ -48,10 +49,10 @@
  • - <%= f.text_area :paper_title, size: "20x2", value: @writing_journal.paper_title ||= "Paper Title", class: "s_grid_6 s_grid"%> + <%= f.text_area :paper_title, size: "20x2", placeholder: "Paper Title", class: "s_grid_6 s_grid"%>
  • - <%= f.text_field :journal_title, size: "20" ,value: @writing_journal.journal_title ||= "Journal Title", class: "s_grid_6 s_grid"%> + <%= f.text_field :journal_title, size: "20", placeholder: "Journal Title", class: "s_grid_6 s_grid"%>
  • @@ -85,34 +86,34 @@
  • - <%= label_tag("", "ISSN(ISBN)", class: "s_grid_2 s_grid") %><%= f.text_field :isbn, size: "20" ,value: @writing_journal.isbn ||= "829872987", class: "s_grid_4 s_grid"%> + <%= label_tag("", "ISSN(ISBN)", class: "s_grid_2 s_grid") %><%= f.text_field :isbn, size: "20", placeholder: "829872987", class: "s_grid_4 s_grid"%>
  • - <%= label_tag("", "Volume No.", class: "s_grid_2 s_grid") %><%= f.text_field :vol_no, size: "20" ,value: @writing_journal.vol_no ||= "829872987", class: "s_grid_4 s_grid"%> + <%= label_tag("", "Volume No.", class: "s_grid_2 s_grid") %><%= f.text_field :vol_no, size: "20", placeholder: "829872987", class: "s_grid_4 s_grid"%>
  • - <%= label_tag("", "Issue No.", class: "s_grid_2 s_grid") %><%= f.text_field :issue_no, size: "20" ,value: @writing_journal.issue_no ||= "829872987", class: "s_grid_4 s_grid"%> + <%= label_tag("", "Issue No.", class: "s_grid_2 s_grid") %><%= f.text_field :issue_no, size: "20", placeholder:"829872987", class: "s_grid_4 s_grid"%>
  • - <%= label_tag("", "Total Pages", class: "s_grid_2 s_grid") %><%= f.text_field :total_pages, size: "20" ,value: @writing_journal.total_pages ||= "20", class: "s_grid_4 s_grid"%> + <%= label_tag("", "Total Pages", class: "s_grid_2 s_grid") %><%= f.text_field :total_pages, size: "20", placeholder:"20", class: "s_grid_4 s_grid"%>
  • - <%= label_tag("", "Pages", class: "s_grid_2 s_grid") %><%= label_tag("", "from", class: "s_grid_1 s_grid") %><%= f.text_field :form_to_start, size: "10" ,value: @writing_journal.form_to_start ||= "1", class: "s_grid_1 s_grid"%><%= label_tag("", "to", class: "s_grid_1 s_grid") %><%= f.text_field :form_to_end, size: "10" ,value: @writing_journal.form_to_end ||= "20", class: "s_grid_1 s_grid"%> + <%= label_tag("", "Pages", class: "s_grid_2 s_grid") %><%= label_tag("", "from", class: "s_grid_1 s_grid") %><%= f.text_field :form_to_start, size: "10", placeholder: "1", class: "s_grid_1 s_grid"%><%= label_tag("", "to", class: "s_grid_1 s_grid") %><%= f.text_field :form_to_end, size: "10", placeholder: "20", class: "s_grid_1 s_grid"%>
  • - <%= label_tag("", "Reference URL", class: "s_grid_2 s_grid") %><%= f.text_field :url, size: "20" ,value: @writing_journal.url ||= "www.sample.com", class: "s_grid_4 s_grid"%> + <%= label_tag("", "Reference URL", class: "s_grid_2 s_grid") %><%= f.text_field :url, size: "20", placeholder: "www.sample.com", class: "s_grid_4 s_grid"%>
  • - <%= f.text_area :authors, size: "20x2", value: @writing_journal.authors ||= "Authors", class: "s_grid_6 s_grid"%> + <%= f.text_area :authors, size: "20x2", placeholder: "Authors", class: "s_grid_6 s_grid"%>
  • @@ -184,14 +185,14 @@ -->
  • - <%= f.text_area :note, size: "20x2", value: @writing_journal.note ||= "Note", class: "s_grid_6 s_grid"%> + <%= f.text_area :note, size: "20x2", plcaeholder: "Note", class: "s_grid_6 s_grid"%>
  • - <%= f.text_area :abstract, size: "20x26", value: @writing_journal.abstract ||= "Abstract", class: "s_grid_6 s_grid"%> + <%= f.text_area :abstract, size: "20x26", placeholder: "Abstract", class: "s_grid_6 s_grid"%>
diff --git a/config/routes.rb b/config/routes.rb index 45dae242c..6b3280190 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -151,6 +151,7 @@ Orbit::Application.routes.draw do namespace :desktop do match "desktop" => "desktop#desktop" match '/journal_pages/get_journals_json' => 'journal_pages#get_journals_json' + match '/co_authors/get_co_authors_json' => 'co_authors#get_co_authors_json' match '/desktop'=>'desktop#desktop' match '/app_manager'=>'desktop#app_manager' match '/sections'=>'desktop#sections' From f38f32ac8b04a21c267ea8e510561caaae7a7dcc Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Fri, 23 Nov 2012 10:46:42 +0800 Subject: [PATCH 128/136] delete update --- .../javascripts/desktop/journal_pages.js.erb | 30 +++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/desktop/journal_pages.js.erb b/app/assets/javascripts/desktop/journal_pages.js.erb index cd04499e6..74438aa02 100644 --- a/app/assets/javascripts/desktop/journal_pages.js.erb +++ b/app/assets/javascripts/desktop/journal_pages.js.erb @@ -64,6 +64,26 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ // }) return false; }) + $("div[container=true]").unbind("click").on("click",".journal_paper_delete",function(){ + var delurl = $(this).attr("href"); + var parent = $(this).parent(); + o.confirm({ + buttons : ["Yes","No"], + highlighted : 2, + message : "Are you sure, you want to delete this paper?" + },function(value){ + if(value){ + $.ajax({ + url : delurl, + type : "DELETE", + success : function(){ + parent.slideOut(); + } + }) + } + }) + return false; + }) } @@ -89,7 +109,7 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ // li; $.each(journalData,function(i,journal){ $.each(journal.papers,function(j,paper){ - li = $('
  • '+journal.title+'
    '+paper.title+'
    Edit
  • '); + li = $('
  • '+journal.title+'
    '+paper.title+'
    Edit Delete
  • '); column.find("ul").append(li); if(counter%5==0){ $("#journal_p div#paper_list div.overview").append(column); @@ -118,7 +138,7 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ // var img = $(''); li.append(img); }) - li.append('Edit'); + li.append('Edit Delete'); column.find("ul").append(li); if(counter%5==0){ $("#journal_p div#paper_list div.overview").append(column); @@ -137,7 +157,7 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ // li; $.each(journalData,function(i,journal){ $.each(journal.papers,function(j,paper){ - li = $('
  • '+paper.title+'
    '+paper.keywords+'
    Edit
  • '); + li = $('
  • '+paper.title+'
    '+paper.keywords+'
    Edit Delete
  • '); column.find("ul").append(li); if(counter%5==0){ $("#journal_p div#paper_list div.overview").append(column); @@ -157,7 +177,7 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ // li; $.each(journalData,function(i,journal){ $.each(journal.papers,function(j,paper){ - li = $('
  • '+paper.title+'
    Edit
  • '); + li = $('
  • '+paper.title+'
    Edit Delete
  • '); column.find("ul").append(li); if(counter%5==0){ $("#journal_p div#paper_list div.overview").append(column); @@ -176,7 +196,7 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ // li; $.each(journalData,function(i,journal){ $.each(journal.papers,function(j,paper){ - li = $('
  • '+paper.title+'
    '+paper.abstract+'
    Edit
  • '); + li = $('
  • '+paper.title+'
    '+paper.abstract+'
    Edit Delete
  • '); column.find("ul").append(li); $("#journal_p div#paper_list div.overview").append(column); column = $('
      '); From 8009c6aa3450ee065dc0de488d14fbde225e1383 Mon Sep 17 00:00:00 2001 From: Rueshyna Date: Fri, 23 Nov 2012 12:28:36 +0800 Subject: [PATCH 129/136] fixed delete function --- app/controllers/desktop/co_authors_controller.rb | 8 ++++---- app/controllers/desktop/journal_pages_controller.rb | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/controllers/desktop/co_authors_controller.rb b/app/controllers/desktop/co_authors_controller.rb index ccda3786e..2ea928bc2 100644 --- a/app/controllers/desktop/co_authors_controller.rb +++ b/app/controllers/desktop/co_authors_controller.rb @@ -57,10 +57,10 @@ class Desktop::CoAuthorsController < ApplicationController @co_author = CoAuthor.find(params[:id]) @co_author.destroy - respond_to do |format| - format.html { redirect_to desktop_co_authors_url, :layout => false } - format.json { head :no_content } - end + #respond_to do |format| + # format.html { redirect_to desktop_co_authors_url, :layout => false } + # format.json { head :no_content } + #end end def get_co_authors_json diff --git a/app/controllers/desktop/journal_pages_controller.rb b/app/controllers/desktop/journal_pages_controller.rb index 6aa8c7fd4..dfd374719 100644 --- a/app/controllers/desktop/journal_pages_controller.rb +++ b/app/controllers/desktop/journal_pages_controller.rb @@ -80,6 +80,11 @@ class Desktop::JournalPagesController < ApplicationController end end + def destroy + @writing_journal = WritingJournal.find(params[:id]) + @writing_journal.destroy + end + def get_journals_json publications = WritingJournal.where(create_user_id: current_user.id) From 3933c048b076eaa8d99898120e6e1ea84df768a8 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Fri, 23 Nov 2012 13:22:01 +0800 Subject: [PATCH 130/136] delete fixed --- app/assets/javascripts/desktop/journal_pages.js.erb | 11 +++++++---- app/controllers/desktop/journal_pages_controller.rb | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/desktop/journal_pages.js.erb b/app/assets/javascripts/desktop/journal_pages.js.erb index 74438aa02..9b7c0a03a 100644 --- a/app/assets/javascripts/desktop/journal_pages.js.erb +++ b/app/assets/javascripts/desktop/journal_pages.js.erb @@ -50,7 +50,7 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ // return false; }) - $("div[container=true]").unbind("click").on("click",".journal_paper_edit",function(){ + $("div[container=true]").unbind(".edit").on("click.edit",".journal_paper_edit",function(){ $.ajax({ url : $(this).attr("href"), type : "get", @@ -64,7 +64,7 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ // }) return false; }) - $("div[container=true]").unbind("click").on("click",".journal_paper_delete",function(){ + $("div[container=true]").unbind(".delete").on("click.delete",".journal_paper_delete",function(){ var delurl = $(this).attr("href"); var parent = $(this).parent(); o.confirm({ @@ -76,8 +76,11 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ // $.ajax({ url : delurl, type : "DELETE", - success : function(){ - parent.slideOut(); + success : function(data){ + if(data.success){ + parent.hide("slide",function(){parent.remove();}); + o.notify(data.msg,"success"); + } } }) } diff --git a/app/controllers/desktop/journal_pages_controller.rb b/app/controllers/desktop/journal_pages_controller.rb index dfd374719..cebe3b6c6 100644 --- a/app/controllers/desktop/journal_pages_controller.rb +++ b/app/controllers/desktop/journal_pages_controller.rb @@ -83,6 +83,7 @@ class Desktop::JournalPagesController < ApplicationController def destroy @writing_journal = WritingJournal.find(params[:id]) @writing_journal.destroy + render :json => {success: true,msg: "Paper deleted successfully!"} end def get_journals_json From 6d861f8be0fd184e1df5a28027fe7e4b7ef53a67 Mon Sep 17 00:00:00 2001 From: Rueshyna Date: Mon, 26 Nov 2012 09:37:24 +0800 Subject: [PATCH 131/136] add paper status textfield --- app/controllers/desktop/journal_pages_controller.rb | 2 +- app/views/desktop/journal_pages/_form.html.erb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/controllers/desktop/journal_pages_controller.rb b/app/controllers/desktop/journal_pages_controller.rb index cebe3b6c6..6288cdbfc 100644 --- a/app/controllers/desktop/journal_pages_controller.rb +++ b/app/controllers/desktop/journal_pages_controller.rb @@ -83,7 +83,7 @@ class Desktop::JournalPagesController < ApplicationController def destroy @writing_journal = WritingJournal.find(params[:id]) @writing_journal.destroy - render :json => {success: true,msg: "Paper deleted successfully!"} + render :json => {success: true, msg: "Paper deleted successfully!"} end def get_journals_json diff --git a/app/views/desktop/journal_pages/_form.html.erb b/app/views/desktop/journal_pages/_form.html.erb index b6320c6a0..20fad7a19 100644 --- a/app/views/desktop/journal_pages/_form.html.erb +++ b/app/views/desktop/journal_pages/_form.html.erb @@ -171,6 +171,14 @@ <%= f.text_field :tag, size: "20", value: "Tag", class: "s_grid_6 s_grid"%> +
    • + +
    • From 046dbc9524b8d8b9d696e6068f0ecd2022e3e9da Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Mon, 26 Nov 2012 10:08:06 +0800 Subject: [PATCH 132/136] fix for showing subroles --- app/controllers/admin/infos_controller.rb | 1 + app/controllers/admin/roles_controller.rb | 3 ++- app/views/admin/attributes/edit.html.erb | 12 +++++++----- app/views/admin/attributes/index.html.erb | 2 +- app/views/admin/attributes/new.html.erb | 2 +- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/app/controllers/admin/infos_controller.rb b/app/controllers/admin/infos_controller.rb index cec5c5f4c..c08d13862 100644 --- a/app/controllers/admin/infos_controller.rb +++ b/app/controllers/admin/infos_controller.rb @@ -22,6 +22,7 @@ class Admin::InfosController < ApplicationController def edit @attribute = Info.find(params[:id]) + @attribute_fields_upper_object = [@attribute] render :template => 'admin/attributes/edit' end diff --git a/app/controllers/admin/roles_controller.rb b/app/controllers/admin/roles_controller.rb index abae1eced..3e8576c6a 100644 --- a/app/controllers/admin/roles_controller.rb +++ b/app/controllers/admin/roles_controller.rb @@ -5,7 +5,7 @@ class Admin::RolesController < ApplicationController before_filter :is_admin? before_filter :set_attribute, :only => [:index, :show, :new, :edit] helper Admin::AttributeValuesViewHelper - + def index @attributes = Role.all.entries render :template => 'admin/attributes/index' @@ -22,6 +22,7 @@ class Admin::RolesController < ApplicationController def edit @attribute = Role.find(params[:id]) + @attribute_fields_upper_object = @attribute.sub_roles render :template => 'admin/attributes/edit' end diff --git a/app/views/admin/attributes/edit.html.erb b/app/views/admin/attributes/edit.html.erb index f74890dc8..44ec57dfc 100644 --- a/app/views/admin/attributes/edit.html.erb +++ b/app/views/admin/attributes/edit.html.erb @@ -15,14 +15,16 @@
      <%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:values=>@attribute.title_translations,:class_ext=>"pull-left",:label_ext=>t("admin.infos.item_name"),:field_name=>"info[title_translations]"}%> - -
      -

      <%= t("admin.attributes")%>

      - <%= render :partial=>"shared/attribute_field/attribute_field",:collection=>@attribute.attribute_fields%> -
      + + <% @attribute_fields_upper_object.each do |attribute|%> +
      +

      <%= attribute.title+ t("admin.attributes")%>

      + <%= render :partial=>"shared/attribute_field/attribute_field",:collection=>attribute.attribute_fields%> +
      + <% end %>
      <%= link_to content_tag(:i,t("admin.infos.add_attribute_field"),:class=>"icon-plus icon-white"),admin_info_add_attribute_field_path(@attribute),:class=>"btn btn-primary",:remote => true%> diff --git a/app/views/admin/attributes/index.html.erb b/app/views/admin/attributes/index.html.erb index 41ed6e12b..e51d903bc 100644 --- a/app/views/admin/attributes/index.html.erb +++ b/app/views/admin/attributes/index.html.erb @@ -1,5 +1,5 @@ <% content_for :secondary do %> - <%= render 'admin/users/side_bar' %> + <%= render 'admin/users_new_interface/side_bar' %> <% end %>
      diff --git a/app/views/admin/attributes/new.html.erb b/app/views/admin/attributes/new.html.erb index 2e96e8f92..8cafdb592 100644 --- a/app/views/admin/attributes/new.html.erb +++ b/app/views/admin/attributes/new.html.erb @@ -1,5 +1,5 @@ <% content_for :secondary do %> - <%= render 'admin/users/side_bar' %> + <%= render 'admin/users_new_interface/side_bar' %> <% end %>
      From 1f0287dd7e1bf2ee7a23687ddc9fd0def953327e Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 26 Nov 2012 10:14:43 +0800 Subject: [PATCH 133/136] member selects --- .../admin/member_selects_controller.rb | 73 +++++++++ .../desktop_publications_controller.000.rb | 75 +++++++++ .../_member_select_result.html.erb | 40 +++++ .../_member_select_result_add.html.erb | 29 ++++ app/views/admin/member_selects/index.html.erb | 153 ++++++++++++++++++ .../member_selects/member_select_add.js.erb | 5 + .../member_select_result.html.erb | 40 +++++ .../member_select_search.js.erb | 4 + config/routes.rb | 5 + 9 files changed, 424 insertions(+) create mode 100644 app/controllers/admin/member_selects_controller.rb create mode 100644 app/controllers/desktop_publications_controller.000.rb create mode 100644 app/views/admin/member_selects/_member_select_result.html.erb create mode 100644 app/views/admin/member_selects/_member_select_result_add.html.erb create mode 100644 app/views/admin/member_selects/index.html.erb create mode 100644 app/views/admin/member_selects/member_select_add.js.erb create mode 100644 app/views/admin/member_selects/member_select_result.html.erb create mode 100644 app/views/admin/member_selects/member_select_search.js.erb diff --git a/app/controllers/admin/member_selects_controller.rb b/app/controllers/admin/member_selects_controller.rb new file mode 100644 index 000000000..a8ec10973 --- /dev/null +++ b/app/controllers/admin/member_selects_controller.rb @@ -0,0 +1,73 @@ +class Admin::MemberSelectsController < ApplicationController + + layout "new_admin" + + def index + + # @member_selects = OrbitApp::Module::Role.all + @member_selects = Role.excludes('disabled' => true) + + if(!params[:show_plugin_profile].nil?) + @right_partial = OrbitApp::Plugin::Registration.find_by_key(params[:show_plugin_profile]).profile_partial_path rescue 'plugin_summary' + else + @right_partial = "admin/users_new_interface/plugin_summary" + end + + @member_select_results = Role.excludes('disabled' => true) + @member_select_search_url = admin_member_selects_path + + + # @aa = User.where(:role_ids.in => [ "4f45f3b9e9d02c5db900001c"]) + + end + + # def show + + # @aa = admin_member_selects_path + + + # respond_to do |format| + # format.js{ render 'member_select_search' } + # end + + # end + + def member_select_add + + # @users = User.where(:ids.in => [params[:users].collect{|x| x[0]}]) + @users = params[:users].collect{|key,value| User.find key } rescue [] + # debugger + respond_to do |format| + format.js + end + + end + + def member_select_search + + @pdatas = params[:member_selects] + + @users = Role.excludes('disabled' => true) + + + # debugger + + # User.where(:role_ids.in => [ "4f45f3b9e9d02c5db900001c"]) + + # @users = User.where(:role_ids.in => [ "your role_id"]) + # @users.where(:sub_role_ids.in => [id, id, id]) + + + # @member_select_results = Role.excludes('disabled' => true) + @member_select_results = User.where(:sub_role_ids.in => params[:member_selects][:sub_role]) + + @member_select_search_url = admin_member_select_member_select_add_path('member_select_add') + + + respond_to do |format| + format.js + end + + end + +end diff --git a/app/controllers/desktop_publications_controller.000.rb b/app/controllers/desktop_publications_controller.000.rb new file mode 100644 index 000000000..fc3f36ab9 --- /dev/null +++ b/app/controllers/desktop_publications_controller.000.rb @@ -0,0 +1,75 @@ +class DesktopPublicationsController< ApplicationController + def journal_p + render "desktop/journal_p", :layout => false + end + + def journal_p_list + render "desktop/journal_pages/list", :layout => false + end + + def journal_p_add + debugger + render "desktop/journal_pages/add", :layout => false + end + + def books + render "desktop/books", :layout => false + end + + def books_list + render "desktop/books/list", :layout => false + end + + def books_add + render "desktop/books/add", :layout => false + end + + def seminar_p + render "desktop/seminar_p", :layout => false + end + + def seminar_p_list + render "desktop/seminar_pages/list", :layout => false + end + + def seminar_p_add + render "desktop/seminar_pages/add", :layout => false + end + + def create_journal + Journal.create(user_id: current_user.id, title: "Ice Cream Sandwich") + b = Array.new + b << {"success"=>"true"} + render :json=>b.to_json + end + + def getjournals + @journals = current_user.journals + data = Array.new + @journals.each do |journal| + @papers = journal.papers.all + data << {"title" => journal.title, "papers" => @papers} + end + render :json=>data.to_json + end + + def delete_journal + @journals = Journal.find("") + @journals.delete + b = Array.new + b << {"success"=>"true"} + render :json=>b.to_json + end + + def update_journal + @journal = Journal.find("4ff2d6ebbd98eb02b9000017") + @papers = @journal.papers + @papers.each do |paper| + paper.update_attributes(:user_id => current_user.id) + end + b = Array.new + + b << {"success"=>"true"} + render :json=>b.to_json + end +end diff --git a/app/views/admin/member_selects/_member_select_result.html.erb b/app/views/admin/member_selects/_member_select_result.html.erb new file mode 100644 index 000000000..6b38328d3 --- /dev/null +++ b/app/views/admin/member_selects/_member_select_result.html.erb @@ -0,0 +1,40 @@ +<% # encoding: utf-8 %> + +<%= form_for('member_select_search', :remote => true, :html => { :id => 'member_select_search', :class => 'member_select_search'} , :url => @member_select_search_url ) do |f| %> + + + + + + + +<% end %> + \ No newline at end of file diff --git a/app/views/admin/member_selects/_member_select_result_add.html.erb b/app/views/admin/member_selects/_member_select_result_add.html.erb new file mode 100644 index 000000000..2a032e38a --- /dev/null +++ b/app/views/admin/member_selects/_member_select_result_add.html.erb @@ -0,0 +1,29 @@ +<% # encoding: utf-8 %> + + +<%= form_for('member_select_search', :remote => true, :html => { :id => 'member_select_search', :class => 'member_select_search'} , :url => @member_select_search_url ) do |f| %> + + + <% @users.each do |users| %> + +
      +
      +
      +
      + + <% if users.avatar? %> + <%= image_tag(users.avatar.thumb.url,:class => "member-img") %> + <% else %> + <%= image_tag "person.png",:class => "member-img" %> + <% end %> + +
      + <%= label_tag "lab-user-#{users.id}", (users.name rescue ''),:class=>"member-name",:id=>nil -%> + <%= check_box_tag "[users][#{users.id}]", 'true', true,:class => "check" -%> +
      +
      + + <% end %> + +<% end %> + \ No newline at end of file diff --git a/app/views/admin/member_selects/index.html.erb b/app/views/admin/member_selects/index.html.erb new file mode 100644 index 000000000..bcc83e2ee --- /dev/null +++ b/app/views/admin/member_selects/index.html.erb @@ -0,0 +1,153 @@ +<% # encoding: utf-8 %> + + + + + + <% #results %> + +
      + + +
      + +
      +
      +
      +
      + Person +
      + + +
      +
      +
      + +
      + +
      + + +
      + + <% #results %> + +
      + + + + <% #search %> + +
      + +
      + + +<% content_for :page_specific_javascript do %> + + <%= stylesheet_link_tag "inc/permission-checkbox" %> + <%= javascript_include_tag "inc/permission-checkbox" %> + + + +<% end %> + + \ No newline at end of file diff --git a/app/views/admin/member_selects/member_select_add.js.erb b/app/views/admin/member_selects/member_select_add.js.erb new file mode 100644 index 000000000..e1414d347 --- /dev/null +++ b/app/views/admin/member_selects/member_select_add.js.erb @@ -0,0 +1,5 @@ +$("#users_checkbox_ary").html("<%= j render "member_select_result_add" %>"); +$("#search-results").modal('hide'); +$(document).ready(function() { +permissionCheckbox(); +}); \ No newline at end of file diff --git a/app/views/admin/member_selects/member_select_result.html.erb b/app/views/admin/member_selects/member_select_result.html.erb new file mode 100644 index 000000000..aebb9331f --- /dev/null +++ b/app/views/admin/member_selects/member_select_result.html.erb @@ -0,0 +1,40 @@ +<% # encoding: utf-8 %> +<% debugger %> + +<%= form_for('member_select_search', :remote => true, :html => { :id => 'member_select_search', :class => 'member_select_search'} , :url => @member_select_search_url ) do |f| %> + + + + + + + +<% end %> + \ No newline at end of file diff --git a/app/views/admin/member_selects/member_select_search.js.erb b/app/views/admin/member_selects/member_select_search.js.erb new file mode 100644 index 000000000..deca25868 --- /dev/null +++ b/app/views/admin/member_selects/member_select_search.js.erb @@ -0,0 +1,4 @@ +$("#search-results").html("<%= j render "member_select_result" %>"); +$(document).ready(function() { +permissionCheckbox(); +}); \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 27b87d901..07e3b503f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -133,6 +133,11 @@ Orbit::Application.routes.draw do get 'temp_edit' end end + + resources :member_selects do + match 'member_select_search' => "member_selects#member_select_search" ,:as => :member_select_search,:via => "post" + match 'member_select_add' => "member_selects#member_select_add" ,:as => :member_select_add,:via => "post" + end end # end admin From 9a684f54b441f28f84046c5f90c72859093b9d88 Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Mon, 26 Nov 2012 10:08:06 +0800 Subject: [PATCH 134/136] fix for showing subroles --- app/controllers/admin/infos_controller.rb | 1 + app/controllers/admin/roles_controller.rb | 3 ++- app/views/admin/attributes/edit.html.erb | 12 +++++++----- app/views/admin/attributes/index.html.erb | 2 +- app/views/admin/attributes/new.html.erb | 2 +- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/app/controllers/admin/infos_controller.rb b/app/controllers/admin/infos_controller.rb index cec5c5f4c..c08d13862 100644 --- a/app/controllers/admin/infos_controller.rb +++ b/app/controllers/admin/infos_controller.rb @@ -22,6 +22,7 @@ class Admin::InfosController < ApplicationController def edit @attribute = Info.find(params[:id]) + @attribute_fields_upper_object = [@attribute] render :template => 'admin/attributes/edit' end diff --git a/app/controllers/admin/roles_controller.rb b/app/controllers/admin/roles_controller.rb index abae1eced..3e8576c6a 100644 --- a/app/controllers/admin/roles_controller.rb +++ b/app/controllers/admin/roles_controller.rb @@ -5,7 +5,7 @@ class Admin::RolesController < ApplicationController before_filter :is_admin? before_filter :set_attribute, :only => [:index, :show, :new, :edit] helper Admin::AttributeValuesViewHelper - + def index @attributes = Role.all.entries render :template => 'admin/attributes/index' @@ -22,6 +22,7 @@ class Admin::RolesController < ApplicationController def edit @attribute = Role.find(params[:id]) + @attribute_fields_upper_object = @attribute.sub_roles render :template => 'admin/attributes/edit' end diff --git a/app/views/admin/attributes/edit.html.erb b/app/views/admin/attributes/edit.html.erb index f74890dc8..44ec57dfc 100644 --- a/app/views/admin/attributes/edit.html.erb +++ b/app/views/admin/attributes/edit.html.erb @@ -15,14 +15,16 @@
      <%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:values=>@attribute.title_translations,:class_ext=>"pull-left",:label_ext=>t("admin.infos.item_name"),:field_name=>"info[title_translations]"}%> - -
      -

      <%= t("admin.attributes")%>

      - <%= render :partial=>"shared/attribute_field/attribute_field",:collection=>@attribute.attribute_fields%> -
      + + <% @attribute_fields_upper_object.each do |attribute|%> +
      +

      <%= attribute.title+ t("admin.attributes")%>

      + <%= render :partial=>"shared/attribute_field/attribute_field",:collection=>attribute.attribute_fields%> +
      + <% end %>
      <%= link_to content_tag(:i,t("admin.infos.add_attribute_field"),:class=>"icon-plus icon-white"),admin_info_add_attribute_field_path(@attribute),:class=>"btn btn-primary",:remote => true%> diff --git a/app/views/admin/attributes/index.html.erb b/app/views/admin/attributes/index.html.erb index 41ed6e12b..e51d903bc 100644 --- a/app/views/admin/attributes/index.html.erb +++ b/app/views/admin/attributes/index.html.erb @@ -1,5 +1,5 @@ <% content_for :secondary do %> - <%= render 'admin/users/side_bar' %> + <%= render 'admin/users_new_interface/side_bar' %> <% end %>
      diff --git a/app/views/admin/attributes/new.html.erb b/app/views/admin/attributes/new.html.erb index 2e96e8f92..8cafdb592 100644 --- a/app/views/admin/attributes/new.html.erb +++ b/app/views/admin/attributes/new.html.erb @@ -1,5 +1,5 @@ <% content_for :secondary do %> - <%= render 'admin/users/side_bar' %> + <%= render 'admin/users_new_interface/side_bar' %> <% end %>
      From 9061448c5f1f422337d369d6d7ed662dba8d4796 Mon Sep 17 00:00:00 2001 From: Rueshyna Date: Mon, 26 Nov 2012 09:37:24 +0800 Subject: [PATCH 135/136] add paper status textfield --- app/controllers/desktop/journal_pages_controller.rb | 2 +- app/views/desktop/journal_pages/_form.html.erb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/controllers/desktop/journal_pages_controller.rb b/app/controllers/desktop/journal_pages_controller.rb index cebe3b6c6..6288cdbfc 100644 --- a/app/controllers/desktop/journal_pages_controller.rb +++ b/app/controllers/desktop/journal_pages_controller.rb @@ -83,7 +83,7 @@ class Desktop::JournalPagesController < ApplicationController def destroy @writing_journal = WritingJournal.find(params[:id]) @writing_journal.destroy - render :json => {success: true,msg: "Paper deleted successfully!"} + render :json => {success: true, msg: "Paper deleted successfully!"} end def get_journals_json diff --git a/app/views/desktop/journal_pages/_form.html.erb b/app/views/desktop/journal_pages/_form.html.erb index b6320c6a0..20fad7a19 100644 --- a/app/views/desktop/journal_pages/_form.html.erb +++ b/app/views/desktop/journal_pages/_form.html.erb @@ -171,6 +171,14 @@ <%= f.text_field :tag, size: "20", value: "Tag", class: "s_grid_6 s_grid"%> +
    • + +
    • From 8a79d7ff2e80cbe05b6a7533eb8d7fe56dbeb9df Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 26 Nov 2012 10:14:43 +0800 Subject: [PATCH 136/136] member selects --- .../admin/member_selects_controller.rb | 73 +++++++++ .../desktop_publications_controller.000.rb | 75 +++++++++ .../_member_select_result.html.erb | 40 +++++ .../_member_select_result_add.html.erb | 29 ++++ app/views/admin/member_selects/index.html.erb | 153 ++++++++++++++++++ .../member_selects/member_select_add.js.erb | 5 + .../member_select_result.html.erb | 40 +++++ .../member_select_search.js.erb | 4 + config/routes.rb | 5 + 9 files changed, 424 insertions(+) create mode 100644 app/controllers/admin/member_selects_controller.rb create mode 100644 app/controllers/desktop_publications_controller.000.rb create mode 100644 app/views/admin/member_selects/_member_select_result.html.erb create mode 100644 app/views/admin/member_selects/_member_select_result_add.html.erb create mode 100644 app/views/admin/member_selects/index.html.erb create mode 100644 app/views/admin/member_selects/member_select_add.js.erb create mode 100644 app/views/admin/member_selects/member_select_result.html.erb create mode 100644 app/views/admin/member_selects/member_select_search.js.erb diff --git a/app/controllers/admin/member_selects_controller.rb b/app/controllers/admin/member_selects_controller.rb new file mode 100644 index 000000000..a8ec10973 --- /dev/null +++ b/app/controllers/admin/member_selects_controller.rb @@ -0,0 +1,73 @@ +class Admin::MemberSelectsController < ApplicationController + + layout "new_admin" + + def index + + # @member_selects = OrbitApp::Module::Role.all + @member_selects = Role.excludes('disabled' => true) + + if(!params[:show_plugin_profile].nil?) + @right_partial = OrbitApp::Plugin::Registration.find_by_key(params[:show_plugin_profile]).profile_partial_path rescue 'plugin_summary' + else + @right_partial = "admin/users_new_interface/plugin_summary" + end + + @member_select_results = Role.excludes('disabled' => true) + @member_select_search_url = admin_member_selects_path + + + # @aa = User.where(:role_ids.in => [ "4f45f3b9e9d02c5db900001c"]) + + end + + # def show + + # @aa = admin_member_selects_path + + + # respond_to do |format| + # format.js{ render 'member_select_search' } + # end + + # end + + def member_select_add + + # @users = User.where(:ids.in => [params[:users].collect{|x| x[0]}]) + @users = params[:users].collect{|key,value| User.find key } rescue [] + # debugger + respond_to do |format| + format.js + end + + end + + def member_select_search + + @pdatas = params[:member_selects] + + @users = Role.excludes('disabled' => true) + + + # debugger + + # User.where(:role_ids.in => [ "4f45f3b9e9d02c5db900001c"]) + + # @users = User.where(:role_ids.in => [ "your role_id"]) + # @users.where(:sub_role_ids.in => [id, id, id]) + + + # @member_select_results = Role.excludes('disabled' => true) + @member_select_results = User.where(:sub_role_ids.in => params[:member_selects][:sub_role]) + + @member_select_search_url = admin_member_select_member_select_add_path('member_select_add') + + + respond_to do |format| + format.js + end + + end + +end diff --git a/app/controllers/desktop_publications_controller.000.rb b/app/controllers/desktop_publications_controller.000.rb new file mode 100644 index 000000000..fc3f36ab9 --- /dev/null +++ b/app/controllers/desktop_publications_controller.000.rb @@ -0,0 +1,75 @@ +class DesktopPublicationsController< ApplicationController + def journal_p + render "desktop/journal_p", :layout => false + end + + def journal_p_list + render "desktop/journal_pages/list", :layout => false + end + + def journal_p_add + debugger + render "desktop/journal_pages/add", :layout => false + end + + def books + render "desktop/books", :layout => false + end + + def books_list + render "desktop/books/list", :layout => false + end + + def books_add + render "desktop/books/add", :layout => false + end + + def seminar_p + render "desktop/seminar_p", :layout => false + end + + def seminar_p_list + render "desktop/seminar_pages/list", :layout => false + end + + def seminar_p_add + render "desktop/seminar_pages/add", :layout => false + end + + def create_journal + Journal.create(user_id: current_user.id, title: "Ice Cream Sandwich") + b = Array.new + b << {"success"=>"true"} + render :json=>b.to_json + end + + def getjournals + @journals = current_user.journals + data = Array.new + @journals.each do |journal| + @papers = journal.papers.all + data << {"title" => journal.title, "papers" => @papers} + end + render :json=>data.to_json + end + + def delete_journal + @journals = Journal.find("") + @journals.delete + b = Array.new + b << {"success"=>"true"} + render :json=>b.to_json + end + + def update_journal + @journal = Journal.find("4ff2d6ebbd98eb02b9000017") + @papers = @journal.papers + @papers.each do |paper| + paper.update_attributes(:user_id => current_user.id) + end + b = Array.new + + b << {"success"=>"true"} + render :json=>b.to_json + end +end diff --git a/app/views/admin/member_selects/_member_select_result.html.erb b/app/views/admin/member_selects/_member_select_result.html.erb new file mode 100644 index 000000000..6b38328d3 --- /dev/null +++ b/app/views/admin/member_selects/_member_select_result.html.erb @@ -0,0 +1,40 @@ +<% # encoding: utf-8 %> + +<%= form_for('member_select_search', :remote => true, :html => { :id => 'member_select_search', :class => 'member_select_search'} , :url => @member_select_search_url ) do |f| %> + + + + + + + +<% end %> + \ No newline at end of file diff --git a/app/views/admin/member_selects/_member_select_result_add.html.erb b/app/views/admin/member_selects/_member_select_result_add.html.erb new file mode 100644 index 000000000..2a032e38a --- /dev/null +++ b/app/views/admin/member_selects/_member_select_result_add.html.erb @@ -0,0 +1,29 @@ +<% # encoding: utf-8 %> + + +<%= form_for('member_select_search', :remote => true, :html => { :id => 'member_select_search', :class => 'member_select_search'} , :url => @member_select_search_url ) do |f| %> + + + <% @users.each do |users| %> + +
      +
      +
      +
      + + <% if users.avatar? %> + <%= image_tag(users.avatar.thumb.url,:class => "member-img") %> + <% else %> + <%= image_tag "person.png",:class => "member-img" %> + <% end %> + +
      + <%= label_tag "lab-user-#{users.id}", (users.name rescue ''),:class=>"member-name",:id=>nil -%> + <%= check_box_tag "[users][#{users.id}]", 'true', true,:class => "check" -%> +
      +
      + + <% end %> + +<% end %> + \ No newline at end of file diff --git a/app/views/admin/member_selects/index.html.erb b/app/views/admin/member_selects/index.html.erb new file mode 100644 index 000000000..bcc83e2ee --- /dev/null +++ b/app/views/admin/member_selects/index.html.erb @@ -0,0 +1,153 @@ +<% # encoding: utf-8 %> + + + + + + <% #results %> + +
      + + +
      + +
      +
      +
      +
      + Person +
      + + +
      +
      +
      + +
      + +
      + + +
      + + <% #results %> + +
      + + + + <% #search %> + +
      + +
      + + +<% content_for :page_specific_javascript do %> + + <%= stylesheet_link_tag "inc/permission-checkbox" %> + <%= javascript_include_tag "inc/permission-checkbox" %> + + + +<% end %> + + \ No newline at end of file diff --git a/app/views/admin/member_selects/member_select_add.js.erb b/app/views/admin/member_selects/member_select_add.js.erb new file mode 100644 index 000000000..e1414d347 --- /dev/null +++ b/app/views/admin/member_selects/member_select_add.js.erb @@ -0,0 +1,5 @@ +$("#users_checkbox_ary").html("<%= j render "member_select_result_add" %>"); +$("#search-results").modal('hide'); +$(document).ready(function() { +permissionCheckbox(); +}); \ No newline at end of file diff --git a/app/views/admin/member_selects/member_select_result.html.erb b/app/views/admin/member_selects/member_select_result.html.erb new file mode 100644 index 000000000..aebb9331f --- /dev/null +++ b/app/views/admin/member_selects/member_select_result.html.erb @@ -0,0 +1,40 @@ +<% # encoding: utf-8 %> +<% debugger %> + +<%= form_for('member_select_search', :remote => true, :html => { :id => 'member_select_search', :class => 'member_select_search'} , :url => @member_select_search_url ) do |f| %> + + + + + + + +<% end %> + \ No newline at end of file diff --git a/app/views/admin/member_selects/member_select_search.js.erb b/app/views/admin/member_selects/member_select_search.js.erb new file mode 100644 index 000000000..deca25868 --- /dev/null +++ b/app/views/admin/member_selects/member_select_search.js.erb @@ -0,0 +1,4 @@ +$("#search-results").html("<%= j render "member_select_result" %>"); +$(document).ready(function() { +permissionCheckbox(); +}); \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 6b3280190..9b584ebec 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -132,6 +132,11 @@ Orbit::Application.routes.draw do get 'temp_edit' end end + + resources :member_selects do + match 'member_select_search' => "member_selects#member_select_search" ,:as => :member_select_search,:via => "post" + match 'member_select_add' => "member_selects#member_select_add" ,:as => :member_select_add,:via => "post" + end end # end admin