fatfreecrm/fat_free_crm

View on GitHub
app/views/entities/attach.js.haml

Summary

Maintainability
Test Coverage
- partial = params[:assets].singularize

- if @attached
  - if partial == "task"
    - if @attachment.completed?
      - view = "completed"
    - elsif @attachment.my?(current_user)
      - view = "pending"
    - else
      - view = "assigned"
    $('#tasks').prepend('#{ j render(partial: "tasks/#{view}", collection: [ @attachment ], locals: { bucket: @attachment.computed_bucket }) }');


  - else
    $('##{h params[:assets]}').prepend('#{ j render(partial: "#{params[:assets]}/#{partial}", collection: [ @attachment ]) }');
    - if called_from_landing_page?(:accounts)
      = refresh_sidebar_for(:accounts, :show)
    - elsif called_from_landing_page?(:campaigns)
      = refresh_sidebar_for(:campaigns, :show)

$('##{partial}_#{h params[:asset_id]}').effect("highlight", { duration:1500 });