foodcoop-adam/foodsoft

View on GitHub
lib/foodsoft_messages/app/views/messages/new.haml

Summary

Maintainability
Test Coverage
- content_for :javascript do
  :javascript
    $(function() {
      $('#message_recipient_tokens').select2_remote({
        tags: true,
        remote_url: '#{users_path(:format => :json)}',
        remote_init: #{search_data(@message.recipients, proc {|u| show_user u})[:results].to_json},
      });

      $('#message_sent_to_all').on('change', function() {
        if ($(this).is(':checked')) {
          $('#recipients').slideUp();
        } else {
          $('#recipients').slideDown();
        }
      });
    });

- title t('.title')

= simple_form_for @message do |f|
  - if FoodsoftConfig[:mailing_list].blank?
    = f.input :sent_to_all, :as => :boolean
  - else
    %b= t('.list.desc', list: mail_to(FoodsoftConfig[:mailing_list])).html_safe
    %br/
    %small{:style => "color:grey"}
      = t '.list.subscribe_msg'
      %br/
      - if FoodsoftConfig[:mailing_list_subscribe].blank?
        = t('.list.subscribe', link: link_to(t('.list.wiki'), wiki_page_path('MailingListe'))).html_safe
      - else
        = t('.list.mail', email: mail_to(FoodsoftConfig[:mailing_list_subscribe])).html_safe

  #recipients
    = f.input :recipient_tokens
    -#= f.input :group_id, :as => :select, :collection => Group.undeleted.order('type DESC, name ASC').all.reject { |g| g.memberships.empty? }
  = f.input :private
  = f.input :subject, input_html: {class: 'input-xxlarge'}
  = f.input :body, input_html: {class: 'input-xxlarge'}
  .form-actions
    = f.submit class: 'btn btn-primary'
    = link_to t('ui.or_cancel'), :back