app/views/imports/donations/_pending.html.haml in artfully_ose-1.2.0 vs app/views/imports/donations/_pending.html.haml in artfully_ose-1.3.0.pre1
- old
+ new
@@ -16,28 +16,75 @@
%h3 This import is pending your approval
Click "Approve" to import this data into Artful.ly
.span3
= link_to "Approve", approve_import_path(import), :data => {:confirm => "Are you sure you want to approve this import?"}, :class => "btn btn-success btn-large"
- %table.table.table-bordered.table-striped
- %tr
- %th Email
- %th First
- %th Last
- %th Date
- %th Amount
- %th Type
- %th
- - @imported_rows.each_with_index do |imported_row, index|
- - row = ParsedRow.new(@import.headers, imported_row.content)
+ - existing_campaigns = {}
+ - new_campaigns = {}
+ - no_campaigns = []
+ - @imported_rows.each_with_index do |imported_row, index|
+ - row = ParsedRow.new(@import.headers, imported_row.content)
+ - if row.campaign.present?
+ - if existing_campaigns.has_key?(row.campaign)
+ - existing_campaigns[row.campaign] << row
+ - elsif new_campaigns.has_key?(row.campaign)
+ - new_campaigns[row.campaign] << row
+ - elsif Campaign.exists?(:name => row.campaign, :organization_id => current_user.current_organization.id )
+ - existing_campaigns[row.campaign] = [row]
+ - else
+ - new_campaigns[row.campaign] = [row]
+ - else
+ - no_campaigns << row
+
+
+ - if new_campaigns.any?
+ %h2 New Campaigns
+ %legend These campaigns will be added to your account along with their donations
+ %table.table.table-bordered.table-striped
%tr
- %td=row.email
- %td=row.first
- %td=row.last
- %td=row.donation_date
- %td=number_as_cents row.amount
- %td=row.donation_type
- %td
- =icon_link_to("", "#row#{index}", 'fa-search-plus', '', '', {'data-toggle' => 'modal'})
- =render :partial => "imports/shared/inspect_modal", :locals => {:row => row, :index => index, :keys => ParsedRow::DONATION_FIELDS.keys }
- = will_paginate @imported_rows
+ %th Name
+ %th # of Donations
+ %th
+ - new_campaigns.each_with_index do |(campaign, rows), index|
+ %tr
+ %td=campaign
+ %td
+ %span.round_tag{:style => 'background-color: #357EC7'} #{rows.length}
+ %td
+ =link_to "Preview", "#new_campaign_#{index}", 'data-toggle' => 'modal', :class => "btn btn-small"
+ .modal{:id => "new_campaign_#{index}"}
+ .modal-header
+ .close{'data-dismiss'=>'modal'} x
+
+ .modal-body
+ =render :partial => "imports/donations/preview", :locals => {:rows => rows }
+ %br
+
+ - if existing_campaigns.any?
+ %h2 Existing Campaigns
+ %legend These campaigns already exist and new donations will be added
+ %table.table.table-bordered.table-striped
+ %tr
+ %th Name
+ %th # of Donations
+ %th
+ - existing_campaigns.each_with_index do |(campaign, rows), index|
+ %tr
+ %td=campaign
+ %td
+ %span.round_tag{:style => 'background-color: #357EC7'} #{rows.length}
+ %td
+ =link_to "Preview", "#existing_campaign_#{index}", 'data-toggle' => 'modal', :class => "btn btn-small"
+ .modal{:id => "existing_campaign_#{index}"}
+ .modal-header
+ .close{'data-dismiss'=>'modal'} x
+
+ .modal-body
+ =render :partial => "imports/donations/preview", :locals => {:rows => rows}
+ %br
+
+ - if no_campaigns.any?
+ %h2 Unclassified Donations
+ - no_campaigns = no_campaigns.paginate(:page => params[:page], :per_page => 50)
+ =render :partial => "imports/donations/preview", :locals => {:rows => no_campaigns}
+ =will_paginate no_campaigns