houdini/client/js/nonprofits/payments/index/page.js
Bradley M. Kuhn fc77ee76d6 Relicense Javascript code in accordance with project's new license
The primary license of the project is changing to:
  AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later

The Additional Permission is designed to permit publicly distributed
Javascript code to be relicensed under LGPL-3.0-or-later, but not server-side
Javascript code.  As such, we've relicensed here static Javscript files under
LGPL-3.0-or-later, and those that run as part of build and/or server side
under AGPL-3.0-or-later.

Note that in future, Javascript files may be updated to be stronger copyleft
license with the Additional Permission, particularly if they adapted to run
on server side and/or turned into templates.  Of course, we'd seek public
discussion with the contributor community about such changes.

This commit is one of the many steps to relicense the entire codebase.

Documentation granting permission for this relicensing (from all past
contributors who hold copyrights) is on file with Software Freedom
Conservancy, Inc.
2018-03-25 15:10:40 -04:00

102 lines
2.7 KiB
JavaScript
Executable file

// License: LGPL-3.0-or-later
require('../../../components/date_range_picker')
require('../../../common/panels_layout')
require('./tour')
require('../../../common/restful_resource')
require('../../../refunds/create')
require('../../supporters/get_name')
require('./payment_details')
require('../../../components/tables/filtering/apply_filter')('payments')
require('../../../common/ajax/get_campaign_and_event_names_and_ids')(app.nonprofit_id)
require('../../supporters/index/import')
var format = require('../../../common/format')
appl.def('format', require('../../../common/format'))
appl.def('payments.index', function() {
appl.def('loading', true)
appl.ajax.index('payments').then(function(resp) {
appl.def('loading', false)
if(appl.payments.query.page > 1) {
var main_panel = document.querySelector('.mainPanel')
main_panel.scrollTop = main_panel.scrollHeight
}
})
})
appl.def('payments.clear_search_if_deleted', function(val) {
if(val === '') {
appl.def('payments.query', {search: '', page: 1})
appl.payments.index()
}
})
appl.def("payments", {
query: {page: 1},
concat_data: true
})
appl.def('filter_count', 0)
if(window.location.search)
ajax_from_params()
else
appl.payments.index()
appl.def('payments.toggle_panel', function(id, el){
var tr = el.parentNode
if(tr.hasAttribute('data-selected')) {
appl.close_side_panel()
tr.removeAttribute('data-selected','')
} else {
appl.ajax_payment_details.fetch(id)
$('.mainPanel').find('tr').removeAttr('data-selected')
tr.setAttribute('data-selected','')
var path = window.location.pathname + "?pid=" + id
window.history.pushState({},'payment id', path)
}
})
appl.def('readable_kind', function(kind, el) {
if(kind === "Donation") return "One-Time Donation"
else if(kind === "OffsitePayment") return "Offsite Donation"
else if(kind === "Ticket") return "Ticket Purchase"
else return format.camelToWords(kind)
})
appl.def('kind_icon_class', function(kind) {
if(kind === "Donation") return "fa-heart"
if(kind === "OffsitePayment") return "fa-money"
if(kind === "RecurringDonation") return "fa-refresh"
if(kind === "Ticket") return "fa-ticket"
if(kind === "Refund") return "fa-rotate-left"
})
appl.def('formatted_gross_amount', function(amt) {
if(amt < 0) {
return '(' + appl.cents_to_dollars(Math.abs(amt)) + ')'
} else {
return appl.cents_to_dollars(amt)
}
})
function ajax_from_params() {
var payment_id = utils.get_param('pid')
var supporter_id = utils.get_param('sid')
appl.is_loading()
if(supporter_id) {
appl.payments.query = {page: appl.payments.query.page, search: supporter_id}
appl.payments.index()
}
if(payment_id) {
appl.payments.index()
appl.ajax_payment_details.fetch(payment_id)
}
}