Merge pull request #414 from foodcoop1040/ftc

Add a button to add all ordergroups to a new finanacial transaction c…
This commit is contained in:
wvengen 2016-03-07 19:45:45 +01:00
commit 0b70ce39a8
3 changed files with 25 additions and 6 deletions

View file

@ -2,7 +2,7 @@
- content_for :javascript do - content_for :javascript do
:javascript :javascript
var ordergroup = "#{escape_javascript(render('ordergroup'))}" var ordergroup = $($.parseHTML("#{escape_javascript(render('ordergroup'))}"));
$(function() { $(function() {
$(document).on('touchclick', 'a[data-remove-transaction]', function() { $(document).on('touchclick', 'a[data-remove-transaction]', function() {
@ -11,7 +11,21 @@
}); });
$(document).on('touchclick', 'a[data-add-transaction]', function() { $(document).on('touchclick', 'a[data-add-transaction]', function() {
$('#ordergroups').append(ordergroup); ordergroup.clone().appendTo('#ordergroups');
return false;
});
$(document).on('touchclick', 'a[data-add-all-ordergroups]', function() {
var value = prompt("#{escape_javascript(heading_helper(FinancialTransaction, :amount))}:");
if (value === null)
return false;
$('#ordergroups > tbody > tr').remove();
var options = ordergroup.find('td > select > option').each(function() {
var row = ordergroup.clone();
row.find('td > input').val(value);
row.find('td > select').val(this.value);
row.appendTo('#ordergroups');
});
return false; return false;
}); });
}); });
@ -25,12 +39,15 @@
= text_field_tag :note, params[:note], class: 'input-xlarge', required: 'required' = text_field_tag :note, params[:note], class: 'input-xlarge', required: 'required'
%p %p
%table#ordergroups{:style => "width:20em"} %table#ordergroups{:style => "width:20em"}
%thead
%tr %tr
%th= heading_helper FinancialTransaction, :ordergroup %th= heading_helper FinancialTransaction, :ordergroup
%th= heading_helper FinancialTransaction, :amount %th= heading_helper FinancialTransaction, :amount
%tbody
= render :partial => 'ordergroup', :collection => [1, 2, 3] = render :partial => 'ordergroup', :collection => [1, 2, 3]
%p %p
= link_to t('.new_ordergroup'), '#', 'data-add-transaction' => true, class: 'btn' = link_to t('.new_ordergroup'), '#', 'data-add-transaction' => true, class: 'btn'
= link_to t('.add_all_ordergroups'), '#', 'data-add-all-ordergroups' => true, class: 'btn'
.form-actions .form-actions
= submit_tag t('.save'), class: 'btn btn-primary' = submit_tag t('.save'), class: 'btn btn-primary'
= link_to t('ui.or_cancel'), finance_ordergroups_path = link_to t('ui.or_cancel'), finance_ordergroups_path

View file

@ -754,6 +754,7 @@ de:
paragraph: Hier kannst du der Bestellgruppe <b>%{name}</b> Geld gutschreiben/abziehen. paragraph: Hier kannst du der Bestellgruppe <b>%{name}</b> Geld gutschreiben/abziehen.
title: Neue Transaktion title: Neue Transaktion
new_collection: new_collection:
add_all_ordergroups: Alle Bestellgruppen hinzufügen
new_ordergroup: Weitere Bestellgruppe hinzufügen new_ordergroup: Weitere Bestellgruppe hinzufügen
save: Transaktionen speichern save: Transaktionen speichern
sidebar: Hier kannst Du mehrere Konten gleichzeitig aktualsieren. Z.B. alle Überweisungen der Bestellgruppen aus einem Kontoauszug. sidebar: Hier kannst Du mehrere Konten gleichzeitig aktualsieren. Z.B. alle Überweisungen der Bestellgruppen aus einem Kontoauszug.

View file

@ -767,6 +767,7 @@ en:
paragraph: Here you can credit and debit money for the ordergroup <b>%{name}</b>. paragraph: Here you can credit and debit money for the ordergroup <b>%{name}</b>.
title: New transaction title: New transaction
new_collection: new_collection:
add_all_ordergroups: Add all ordergroups
new_ordergroup: Add new ordergroup new_ordergroup: Add new ordergroup
save: Save transaction save: Save transaction
sidebar: Here you can update more accounts at the same time. For example all transfers of the ordergroup from one account statement. sidebar: Here you can update more accounts at the same time. For example all transfers of the ordergroup from one account statement.