Add messaging to order (closes #327)

This commit is contained in:
Patrick Gansterer 2015-02-19 00:53:57 +01:00
parent 65c7673a41
commit 124f77f2ab
4 changed files with 32 additions and 21 deletions

View file

@ -0,0 +1,20 @@
-# this needs to be in a separate file from show.html.erb to allow deface overrides
- content_for :javascript do
:javascript
function activate_search(view, placeholder) {
new List(document.body, {
valueNames: ['name'],
engine: 'unlist',
plugins: [
['reset', {highlightClass: 'btn-primary'}],
['delay', {delayedSearchTime: 500}],
],
// make large pages work too (as we don't have paging)
page: 10000,
indexAsync: true
});
$('#query').attr('placeholder', placeholder);
}
$(function() {
activate_search('#{j @view}', '#{j t(".search_placeholder.#{@view}")}');
});

View file

@ -79,25 +79,5 @@
#new_comment= render partial: 'order_comments/form', locals: { order_comment: @order.comments.build(user: current_user)}
= link_to_top
- content_for :javascript do
:javascript
function activate_search(view, placeholder) {
new List(document.body, {
valueNames: ['name'],
engine: 'unlist',
plugins: [
['reset', {highlightClass: 'btn-primary'}],
['delay', {delayedSearchTime: 500}],
],
// make large pages work too (as we don't have paging)
page: 10000,
indexAsync: true
});
$('#query').attr('placeholder', placeholder);
}
$(function() {
activate_search('#{j @view}', '#{j t(".search_placeholder.#{@view}")}');
});
= render 'show_js'
= render 'shared/articles_by/common', order: @order

View file

@ -40,6 +40,13 @@ class Message < ActiveRecord::Base
add_recipients Group.find(group_id).users unless group_id.blank?
end
def order_id=(order_id)
@order_id = order_id
for ordergroup in Order.find(order_id).ordergroups
add_recipients ordergroup.users
end
end
def recipient_tokens=(ids)
@recipient_tokens = ids
add_recipients ids.split(",").collect { |id| User.find(id) }

View file

@ -0,0 +1,4 @@
/ insert_after 'erb:contains("title t(\'.title\'")'
- content_for :actionbar do
- if FoodsoftMessages.enabled?
= link_to_new_message message_params: {order_id: @order.id}