app/helpers/gift_helper.rb
# it could be nice with a popup dialog box with three choices. a) hide and keep balance, b) destroy and update balance, c) cancel
# but no build in JS function for this
# must send a/b choice to util/delete_gift. must cancel require on c
# some maybe useful links:
# - http://www.pjmccormick.com/nicer-rails-confirm-dialogs-and-not-just-delete-methods
# - http://stackoverflow.com/questions/7435859/custom-rails-confirm-box-with-rails-confirm-override
# - http://rors.org/demos/custom-confirm-in-rails
# todo: delete - moved to GiftsCtrl in angularJS
it could be nice with a popup dialog box with three choices. a) hide and keep balance, b) destroy and update balance, c) cancel
but no build in JS function for this
must send a/b choice to util/delete_gift.
it could be nice with a popup dialog box with three choices . a ) hide and keep balance b ) destroy and update balance c ) cancel but no build in JS function for this must send a / b choice to util / delete_gift .
def link_to_delete_gift (gift)
    confirm_delete_gift_options = { :price => nil, :currency => 'USD' }
    if gift.received_at and nil
      directions = []
      gift.api_gifts.each do |ag|
        directions << 'giver' if login_user_ids.index(ag.user_id_giver)
        directions << 'receiver' if login_user_ids.index(ag.user_id_receiver)
      end
      directions = directions.uniq
      return nil if directions.size == 0 
      if directions.size == 2
        keyno = 2
      else
        keyno = 1
        direction = directions.first
        user_names = gift.api_gifts.
            collect { |ag| direction == 'giver' ?  ag.receiver.short_user_name : ag.giver.short_user_name}.
            join(', ')
        confirm_delete_gift_options[:user_name] = user_names
      end
    else
      keyno = 2
    end
    confirm_delete_gift_key = ".confirm_delete_gift_#{keyno}"
    link_to t('.delete_gift'), util_delete_gift_path(:gift_id => gift.id),
            :id => "gift-#{gift.id}-delete-link", :class => "gift-action-link",
            :remote => true,
            :data => { :confirm => t(confirm_delete_gift_key, confirm_delete_gift_options), :type => :script }, :format => :js,
            :method => :post
  end
def link_to_delete_gift ( gift ) confirm_delete_gift_options = { :price => nil , :currency => 'USD' } if gift . received_at and nil directions = [ ] gift . api_gifts . each do | ag | directions << 'giver' if login_user_ids . index ( ag . user_id_giver ) directions << 'receiver' if login_user_ids . index ( ag . user_id_receiver ) end directions = directions . uniq return nil if directions . size == 0 if directions . size == 2 keyno = 2 else keyno = 1 direction = directions . first user_names = gift . api_gifts . collect { | ag | direction == 'giver' ? ag . receiver . short_user_name : ag . giver . short_user_name } . join ( ', ' ) confirm_delete_gift_options [ :user_name ] = user_names end else keyno = 2 end confirm_delete_gift_key = ".confirm_delete_gift_#{keyno}" link_to t ( '.delete_gift' ) , util_delete_gift_path ( :gift_id => gift . id ) , :id => "gift-#{gift.id}-delete-link" , :class => "gift-action-link" , :remote => true , :data => { :confirm => t ( confirm_delete_gift_key , confirm_delete_gift_options ) , :type => :script } , :format => :js , :method => :post end
it could be nice with a popup dialog box with three choices.
it could be nice with a popup dialog box with three choices .
# confirm delete texts # - confirm_delete_gift_1 if delete gift effects user balance # - confirm_delete_gift_2 if delete gift does not effect user balance # todo: check if login users are givers or # error # no confirm box - login users are giver and receiver of gift
gift
<not_specific>