Skip to content

Commit

Permalink
Bankimport: fix modal dialogs
Browse files Browse the repository at this point in the history
related to #343, probably fixes #329
  • Loading branch information
tpokorra committed Aug 27, 2019
1 parent 3ed1109 commit db53404
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
3 changes: 1 addition & 2 deletions js-client/src/forms/Finance/Gift/GiftEntry/BankImport.html
Expand Up @@ -10,7 +10,7 @@ <h2>{caption}</h2>
<div class="col format_currency">{val_a_transaction_amount_n}</div>
<div class="col-6">{val_a_description_c}</div>
<div class="col-1">
<button type="button" class="btn btn-primary" onclick="edit_gift_trans({val_a_order_i})">
<button type="button" class="btn btn-primary" onclick="edit_gift_trans({val_a_statement_key_i},{val_a_order_i})">
<i class="fa fa-wrench"></i>
</button>
</div>
Expand Down Expand Up @@ -184,7 +184,6 @@ <h4>{detail}</h4>

</div>
<div class="modal-footer">
<button edit-only class="btn btn-danger" onclick="delete_trans(this)">{forms.delete}</button>
<button class="btn btn-primary" onclick="save_edit_trans(this)">{forms.save}</button>
<button class="btn btn-light" onclick="$(this).closest('.modal').modal('hide')">{forms.close}</button>
</div>
Expand Down
26 changes: 11 additions & 15 deletions js-client/src/forms/Finance/Gift/GiftEntry/BankImport.js
Expand Up @@ -79,6 +79,12 @@ function display_list() {
})
}

function updateTransaction(StatementKey, OrderId) {
// somehow the original window stays gray when we return from this modal.
$('.modal-backdrop').remove();
edit_gift_trans(StatementKey, OrderId);
}

function format_item(item) {
let row = format_tpl($("[phantom] .tpl_row").clone(), item);
// let view = format_tpl($("[phantom] .tpl_view").clone(), item);
Expand All @@ -101,7 +107,6 @@ function new_trans_detail(trans_order) {
p['a_detail_i'] = $('#modal_space .tpl_edit_trans .detail_col > *').length;
let tpl_edit_raw = format_tpl( $('[phantom] .tpl_edit_trans_detail').clone(), p );
$('#modal_space').append(tpl_edit_raw);
$('.modal').modal('hide');
let sclass = $('#modal_space > .tpl_edit_trans [name=MatchAction]:checked').val();
tpl_edit_raw.append( $('<input type=hidden name=AMatchAction value="'+ sclass + '">') );
tpl_edit_raw.find('[action]').val('create');
Expand All @@ -112,10 +117,10 @@ function new_trans_detail(trans_order) {

/////

function edit_gift_trans(trans_order) {
function edit_gift_trans(statement_key, trans_order) {
let x = {
"ALedgerNumber":window.localStorage.getItem('current_ledger'),
"AStatementKey":$('#bank_number_id').val(),
"AStatementKey":statement_key,
"AOrderNumber": trans_order
};
// on open of a edit modal, we get new data,
Expand All @@ -126,7 +131,7 @@ function edit_gift_trans(trans_order) {
transaction['p_donor_name_c'] = transaction['DonorKey'] + ' ' + transaction['DonorName'];
transaction['p_donor_key_n'] = transaction['DonorKey'];
let tpl_edit_raw = format_tpl( $('[phantom] .tpl_edit_trans').clone(), transaction);
console.log(transaction);

for (detail of parsed.ADetails) {
let tpl_trans_detail = format_tpl( $('[phantom] .tpl_trans_detail_row').clone(), detail );
tpl_edit_raw.find('.detail_col').append(tpl_trans_detail);
Expand Down Expand Up @@ -155,7 +160,6 @@ function edit_gift_trans_detail(statement_id, order_id, detail_id) {
let sclass = $('#modal_space > .modal [name=MatchAction]:checked').val();
tpl_edit_raw.append( $('<input type=hidden name=AMatchAction value="'+ sclass + '">') );
$('#modal_space').append(tpl_edit_raw);
$('.modal').modal('hide');
tpl_edit_raw.find('[action]').val('update');
tpl_edit_raw.modal('show');
update_requireClass(tpl_edit_raw, sclass);
Expand Down Expand Up @@ -201,8 +205,7 @@ function save_edit_trans_detail(obj_modal) {
parsed = JSON.parse(result.data.d);
if (parsed.result == true) {
display_message(i18next.t('forms.saved'), "success");
$('#modal_space .modal').modal('hide');
display_list();
updateTransaction(payload['AStatementKey'], payload['AOrder']);
}
else if (parsed.result == false) {
display_error(parsed.AVerificationResult);
Expand All @@ -223,8 +226,8 @@ function delete_trans_detail(obj_modal) {
api.post('serverMFinance.asmx/TBankImportWebConnector_MaintainTransactionDetail', payload).then(function (data) {
parsed = JSON.parse(data.data.d);
if (parsed.result) {
$('#modal_space .modal').modal('hide');
display_message(i18next.t('forms.deleted'), "success");
updateTransaction(payload['AStatementKey'], payload['AOrder']);
} else {
display_error(parsed.AVerificationResult);
}
Expand Down Expand Up @@ -319,10 +322,3 @@ function transform_to_gift() {
});

}

/////

// when closing a detail we wanna reopen the transaction
$(document).on('hidden.bs.modal', '.modal.tpl_edit_trans_detail', function () {
edit_gift_trans( $(this).find('[name=a_order_i]').val() );
})

0 comments on commit db53404

Please sign in to comment.