diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index cfa84071b..cf0276d97 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -16,12 +16,32 @@ class HomeworkAttachController < ApplicationController percent_m.to_s + "%" end @jours = @homework.journals_for_messages.order("created_on DESC") + @limit = 10 + @feedback_count = @jours.count + @feedback_pages = Paginator.new @feedback_count, @limit, params['page'] + @offset ||= @feedback_pages.offset + @jour = @jours[@offset, @limit] end - def destroyjours - @homework = HomeworkAttach.find(params[:homework_id]) - JournalsForMessage.delete_message(params[:object_id]) - redirect_to homework_attach_path(@homework) + def destroy + @journal_destroyed = JournalsForMessage.delete_message(params[:object_id]) + respond_to do |format| + format.js + end + end + + def addjours + @homework = HomeworkAttach.find(params[:jour_id]) + @homework.addjours User.current.id, params[:new_form][:user_message],0 + @jours = @homework.journals_for_messages.order("created_on DESC") + @limit = 10 + @feedback_count = @jours.count + @feedback_pages = Paginator.new @feedback_count, @limit, params['page'] + @offset ||= @feedback_pages.offset + @jour = @jours[@offset, @limit] + respond_to do |format| + format.js + end end end diff --git a/app/models/homework_attach.rb b/app/models/homework_attach.rb index b8e559dff..2e5ade8b3 100644 --- a/app/models/homework_attach.rb +++ b/app/models/homework_attach.rb @@ -9,4 +9,9 @@ class HomeworkAttach < ActiveRecord::Base "user_id" acts_as_attachable + def addjours user_id,message,status = 0 + jfm = self.journals_for_messages.build(:user_id => user_id,:notes =>message,:status => status) + jfm.save + jfm + end end diff --git a/app/views/homework_attach/_addjour.html.erb b/app/views/homework_attach/_addjour.html.erb new file mode 100644 index 000000000..a5e7bed66 --- /dev/null +++ b/app/views/homework_attach/_addjour.html.erb @@ -0,0 +1,93 @@ + + + + + +<%= form_for('new_form', :remote => true, :method => :post, + :url => {:controller => 'homework_attach', + :action => 'addjours', + :jour_id => homework_attach.id, + :sta => sta}) do |f|%> + +
+ <%= render :partial => 'words/pre_show', :locals => {:content => @content} %> +
+ + <% if User.current.logged? %> + + + + +
<%= f.text_area 'user_message', :rows => 3, :cols => 65, :value => "#{l(:label_leave_a_message)}", + :onfocus => "clearInfo('new_form_user_message','#{l(:label_leave_a_message)}')", + :onblur => "showInfo('new_form_user_message','#{l(:label_leave_a_message)}')", + :style => "resize: none;", :class => 'noline'%>
+ <%= f.text_field :reference_user_id, :style=>"display:none"%> + + + + +
<%= submit_tag l(:button_leave_meassge), + :name => nil , :class => "enterprise", + :onmouseout => "this.style.backgroundPosition = 'left top'", + :onmouseover => "this.style.backgroundPosition = 'left -31px'"%> + <%= submit_tag l(:button_clear), :name => nil, :class => "enterprise", + :onclick => "clearMessage('new_form_user_message');", + :onmouseout => "this.style.backgroundPosition = 'left top'", + :onmouseover => "this.style.backgroundPosition = 'left -31px'" %>
+ <% else %> +
+ <%= l(:label_user_login_tips) %> + <%= link_to l(:label_user_login_new), signin_path %> +
+ <% end %> +<% end %> diff --git a/app/views/homework_attach/_pre_show.html.erb b/app/views/homework_attach/_pre_show.html.erb new file mode 100644 index 000000000..1fb643183 --- /dev/null +++ b/app/views/homework_attach/_pre_show.html.erb @@ -0,0 +1,11 @@ + +<% unless content.nil?%> + + + + + + + +
<%= textilizable content %>
<%= hidden_field_tag 'reference_content', params[:reference_content], :value => content%>
+<% end %> diff --git a/app/views/homework_attach/_showjour.html.erb b/app/views/homework_attach/_showjour.html.erb new file mode 100644 index 000000000..f810082c9 --- /dev/null +++ b/app/views/homework_attach/_showjour.html.erb @@ -0,0 +1,64 @@ + +<% if jour.size > 0 %> + +<% end %> \ No newline at end of file diff --git a/app/views/homework_attach/addjours.js.erb b/app/views/homework_attach/addjours.js.erb new file mode 100644 index 000000000..e463237e5 --- /dev/null +++ b/app/views/homework_attach/addjours.js.erb @@ -0,0 +1,4 @@ +$('#message').html('<%= escape_javascript(render(:partial => 'showjour', :locals => {:jour =>@jour, :state => false} )) %>'); +$('#pre_show').html('<%= escape_javascript(render(:partial => 'pre_show', :locals => {:content => nil})) %>'); +$('#new_form_user_message').val(""); +$('#new_form_reference_user_id').val(""); \ No newline at end of file diff --git a/app/views/homework_attach/destroy.js.erb b/app/views/homework_attach/destroy.js.erb new file mode 100644 index 000000000..f3d9a7bef --- /dev/null +++ b/app/views/homework_attach/destroy.js.erb @@ -0,0 +1,11 @@ +<% if @journal_destroyed.nil? %> + alert('<%=l(:notice_failed_delete)%>'); +<% elsif (['Principal','Project', 'Bid', 'Contest', 'Softapplication','HomeworkAttach'].include? @journal_destroyed.jour_type)%> + var destroyedItem = $('#word_li_<%=@journal_destroyed.id%>') + destroyedItem.fadeOut(600,function(){ + destroyedItem.remove(); + }); +<% else %> + $('#message').html('<%= escape_javascript(render(:partial => 'showjour', :locals => {:jour => @jour, :state => false})) %>'); + $('#new_form_reference_user_id').val(""); +<% end %> diff --git a/app/views/homework_attach/show.html.erb b/app/views/homework_attach/show.html.erb index 93e3d0a70..1400176c2 100644 --- a/app/views/homework_attach/show.html.erb +++ b/app/views/homework_attach/show.html.erb @@ -1,4 +1,4 @@ -<%= render_flash_messages %> +