From e5815dccd76ec4df6731a632ed98f0f7aabb24bc Mon Sep 17 00:00:00 2001 From: JiangRu Date: Wed, 3 Dec 2014 17:52:16 +0800 Subject: [PATCH] desktop conference --- .../images/desktop/personal_conference.svg | 15 +++ .../admin/writing_conferences_controller.rb | 20 +++- .../personal_conferences_controller.rb | 23 +++++ .../admin/personal_conferences_helper.rb | 30 ++++++ .../admin/writing_conferences/_form.html.erb | 93 +++++++++---------- lib/personal_conference/engine.rb | 1 + 6 files changed, 132 insertions(+), 50 deletions(-) create mode 100644 app/assets/images/desktop/personal_conference.svg create mode 100644 app/controllers/desktop/personal_conferences_controller.rb create mode 100644 app/helpers/admin/personal_conferences_helper.rb diff --git a/app/assets/images/desktop/personal_conference.svg b/app/assets/images/desktop/personal_conference.svg new file mode 100644 index 0000000..823708f --- /dev/null +++ b/app/assets/images/desktop/personal_conference.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/controllers/admin/writing_conferences_controller.rb b/app/controllers/admin/writing_conferences_controller.rb index 82aa57e..d01287f 100644 --- a/app/controllers/admin/writing_conferences_controller.rb +++ b/app/controllers/admin/writing_conferences_controller.rb @@ -1,5 +1,6 @@ class Admin::WritingConferencesController < OrbitMemberController layout "member_plugin" + include Admin::PersonalConferencesHelper before_action :set_writing_conference, only: [:show, :edit , :update, :destroy] before_action :set_plugin @@ -15,24 +16,39 @@ class Admin::WritingConferencesController < OrbitMemberController def new @member = MemberProfile.find_by(:uid=>params['uid']) rescue nil @writing_conference = WritingConference.new + + if params[:desktop] + render :layout => false + end end def create @member = MemberProfile.find(conference_params['member_profile_id']) rescue nil @writing_conference = WritingConference.new(conference_params) @writing_conference.save - redirect_to params['referer_url'] + if params[:desktop] == "true" + render json: get_paper_list.to_json + else + redirect_to params['referer_url'] + end end def edit @member = @writing_conference.member_profile + if params[:desktop] + render :layout => false + end end def update @member = @writing_conference.member_profile @writing_conference.update_attributes(conference_params) @writing_conference.save - redirect_to params['referer_url'] + if params[:desktop] == "true" + render json: get_paper_list.to_json + else + redirect_to params['referer_url'] + end end def destroy diff --git a/app/controllers/desktop/personal_conferences_controller.rb b/app/controllers/desktop/personal_conferences_controller.rb new file mode 100644 index 0000000..cb460d3 --- /dev/null +++ b/app/controllers/desktop/personal_conferences_controller.rb @@ -0,0 +1,23 @@ +class Desktop::PersonalConferencesController < DesktopAdminController + include Admin::PersonalConferencesHelper + + def menu + user = OrbitHelper.current_user + [ + { + "title" => "List", + "layout" => "list" + }, + { + "title" => "Add/Edit", + "layout" => "form", + "new_path" => "/admin/members/#{user.member_profile.to_param}/writing_conferences/new" + } + ] + end + + def list + get_paper_list + end + +end \ No newline at end of file diff --git a/app/helpers/admin/personal_conferences_helper.rb b/app/helpers/admin/personal_conferences_helper.rb new file mode 100644 index 0000000..2a7eb3d --- /dev/null +++ b/app/helpers/admin/personal_conferences_helper.rb @@ -0,0 +1,30 @@ +module Admin::PersonalConferencesHelper + + def get_paper_list + user = current_user.nil? ? OrbitHelper.current_user : current_user + user_profile = user.member_profile + conferences = WritingConference.where(:member_profile_id => user_profile.id) + conferences = conferences.collect do |c| + files = c.writing_conference_files.collect do |wcf| + { + "title" => wcf.title, + "description" => wcf.description, + "link" => wcf.file.url, + "extension" => (wcf.file.url.split(".").last rescue "") + } + end + + { + "id" => c.id.to_s, + "edit_url" => "/#{I18n.locale.to_s}/admin/members/#{user_profile.to_param}/writing_conferences/#{c.to_param}/edit", + "delete_url" => "/#{I18n.locale.to_s}/admin/writing_conferences/#{c.id.to_s}", + "paper_title" => c.paper_title, + "conference_title" => c.conference_title, + "keywords" => c.keywords, + "abstract" => c.abstract, + "files" => files + } + end + conferences + end +end \ No newline at end of file diff --git a/app/views/admin/writing_conferences/_form.html.erb b/app/views/admin/writing_conferences/_form.html.erb index 06818ab..1c85919 100644 --- a/app/views/admin/writing_conferences/_form.html.erb +++ b/app/views/admin/writing_conferences/_form.html.erb @@ -7,7 +7,7 @@ <% content_for :page_specific_javascript do %> <%= javascript_include_tag "lib/bootstrap-datetimepicker" %> <%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %> - <%= javascript_include_tag "lib/bootstrap-fileupload" %> + <%= javascript_include_tag "lib/bootstrap-fileupload" %> <%= javascript_include_tag "lib/file-type" %> <%= javascript_include_tag "lib/module-area" %> <% end %> @@ -15,7 +15,7 @@
- +
- +
@@ -61,7 +61,7 @@ <% end %> <% end %>
- +
@@ -75,7 +75,7 @@ <% end %> <% end %>
- +
@@ -89,7 +89,7 @@ <% end %> <% end %>
- +
@@ -97,7 +97,7 @@
<%= f.text_field :number_of_authors, :class=>'span1' %>
-
+
@@ -105,7 +105,7 @@
<%= f.datetime_picker :period_start_date, :no_label => true, :format=>"yyyy/MM/dd", :placeholder=>"YYYY/MM/DD" %>
-
+
@@ -113,7 +113,7 @@
<%= f.datetime_picker :period_end_date, :no_label => true, :format=>"yyyy/MM/dd", :placeholder=>"YYYY/MM/DD" %>
-
+
@@ -121,7 +121,7 @@
<%= f.datetime_picker :publication_date, :no_label => true, :format=>"yyyy/MM/dd", :placeholder=>"YYYY/MM/DD" %>
-
+
@@ -133,7 +133,7 @@ <% end %>
- +
@@ -141,7 +141,7 @@
<%= f.text_field :isbn %>
-
+
@@ -149,7 +149,7 @@
<%= f.text_field :isi_number %>
-
+
@@ -157,7 +157,7 @@
<%= f.text_field :url , :class => "span6" %>
-
+
@@ -165,7 +165,7 @@
<%= f.text_field :keywords, :class => "span6" %>
-
+
@@ -173,7 +173,7 @@
<%= f.text_area :abstract, rows: 2, class: "input-block-level" %>
-
+
@@ -181,7 +181,7 @@
<%= f.text_area :note, rows: 2, class: "input-block-level" %>
-
+ @@ -216,7 +216,7 @@
<% @site_in_use_locales.each_with_index do |locale, i| %> - +
"> @@ -286,7 +286,7 @@ <%= f.fields_for :writing_conference_files, archive_file_multiple do |f| %> <%= render :partial => 'form_file', :object => archive_file_multiple, :locals => {:f => f, :i => i} %> <% end %> - <% end %> + <% end %>
<% end %> @@ -303,46 +303,43 @@
- +
<%= f.hidden_field :user_id, :value => params[:user_id] if !params[:user_id].blank? %> <%= f.submit t('submit'), class: 'btn btn-primary' %> - <%= link_to t('cancel'), get_go_back, :class=>"btn" %> + <%= link_to t('cancel'), get_go_back, :class=>"btn" %>
-<% content_for :page_specific_javascript do %> - -<% end %> + formTip(); + $('.add-on').tooltip(); + } else if($(this).hasClass('delete_file')) { + $(this).parents('.input-prepend').remove(); + } else if($(this).hasClass('remove_existing_record')) { + if(confirm("<%= I18n.t(:sure?)%>")){ + $(this).children('.should_destroy').attr('value', 1); + $(this).parents('.start-line').hide(); + } + } + }); + diff --git a/lib/personal_conference/engine.rb b/lib/personal_conference/engine.rb index 65f165c..1af46fc 100644 --- a/lib/personal_conference/engine.rb +++ b/lib/personal_conference/engine.rb @@ -7,6 +7,7 @@ module PersonalConference personal_plugin :enable => true, :sort_number => '6', :app_name=>"WritingConference", :intro_app_name=>"PersonalConferenceIntro",:path=>"/plugin/personal_conference/profile",:front_path=>"/profile",:admin_path=>"/admin/writing_conferences",:i18n=>'module_name.personal_conference', :module_app_name=>'PersonalConference' version "0.1" + desktop_enabled true organization "Rulingcom" author "RD dep" intro "I am intro"