Add 'Insert below' option to invoice item line actions
This commit is contained in:
parent
3eac18929b
commit
9e1e3db08c
|
|
@ -172,9 +172,13 @@ class RemoveInvoiceContact implements PersistUI {
|
|||
}
|
||||
|
||||
class AddInvoiceItem implements PersistUI {
|
||||
AddInvoiceItem({this.invoiceItem});
|
||||
AddInvoiceItem({
|
||||
this.invoiceItem,
|
||||
this.index,
|
||||
});
|
||||
|
||||
final InvoiceItemEntity? invoiceItem;
|
||||
final int? index;
|
||||
}
|
||||
|
||||
class MoveInvoiceItem implements PersistUI {
|
||||
|
|
|
|||
|
|
@ -165,7 +165,11 @@ InvoiceEntity _updateEditing(InvoiceEntity? invoice, dynamic action) {
|
|||
|
||||
InvoiceEntity _addInvoiceItem(InvoiceEntity? invoice, AddInvoiceItem action) {
|
||||
final item = action.invoiceItem ?? InvoiceItemEntity();
|
||||
return invoice!.rebuild((b) => b..lineItems.add(item));
|
||||
if (action.index == null) {
|
||||
return invoice!.rebuild((b) => b..lineItems.add(item));
|
||||
} else {
|
||||
return invoice!.rebuild((b) => b..lineItems.insert(action.index!, item));
|
||||
}
|
||||
}
|
||||
|
||||
InvoiceEntity _addInvoiceItems(InvoiceEntity? invoice, AddInvoiceItems action) {
|
||||
|
|
|
|||
|
|
@ -1192,6 +1192,7 @@ class _InvoiceEditItemsDesktopState extends State<InvoiceEditItemsDesktop> {
|
|||
final sectionIndex =
|
||||
includedLineItems.indexOf(lineItems[index]);
|
||||
final options = {
|
||||
localization.insertBelow: MdiIcons.plus,
|
||||
if (widget.isTasks &&
|
||||
(lineItems[index].taskId ?? '').isNotEmpty)
|
||||
localization.viewTask: MdiIcons.chevronDoubleRight,
|
||||
|
|
@ -1232,6 +1233,8 @@ class _InvoiceEditItemsDesktopState extends State<InvoiceEditItemsDesktop> {
|
|||
index, lineItems.length - 2);
|
||||
} else if (action == localization.remove) {
|
||||
viewModel.onRemoveInvoiceItemPressed!(index);
|
||||
} else if (action == localization.insertBelow) {
|
||||
viewModel.addLineItem!(index + 1);
|
||||
}
|
||||
_updateTable();
|
||||
},
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ class InvoiceEditItemsVM extends EntityEditItemsVM {
|
|||
CompanyEntity? company,
|
||||
InvoiceEntity? invoice,
|
||||
int? invoiceItemIndex,
|
||||
Function? addLineItem,
|
||||
Function([int])? addLineItem,
|
||||
Function(int)? deleteLineItem,
|
||||
Function(int)? onRemoveInvoiceItemPressed,
|
||||
Function? clearSelectedInvoiceItem,
|
||||
|
|
@ -107,8 +107,13 @@ class InvoiceEditItemsVM extends EntityEditItemsVM {
|
|||
company: store.state.company,
|
||||
invoice: store.state.invoiceUIState.editing,
|
||||
invoiceItemIndex: store.state.invoiceUIState.editingItemIndex,
|
||||
addLineItem: () {
|
||||
store.dispatch(AddInvoiceItem(invoiceItem: InvoiceItemEntity()));
|
||||
addLineItem: ([int? index]) {
|
||||
store.dispatch(AddInvoiceItem(
|
||||
index: index,
|
||||
invoiceItem: InvoiceItemEntity().rebuild((b) => b
|
||||
..typeId = isTasks
|
||||
? InvoiceItemEntity.TYPE_TASK
|
||||
: InvoiceItemEntity.TYPE_STANDARD)));
|
||||
},
|
||||
deleteLineItem: null,
|
||||
onRemoveInvoiceItemPressed: (index) {
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ mixin LocalizationsProvider on LocaleCodeAware {
|
|||
static final Map<String, Map<String, String>> _localizedValues = {
|
||||
'en': {
|
||||
// STARTER: lang key - do not remove comment
|
||||
'insert_below': 'Insert Below',
|
||||
'aged_receivable_detailed_report': 'Aged Receivable Detailed Report',
|
||||
'aged_receivable_summary_report': 'Aged Receivable Summary Report',
|
||||
'client_balance_report': 'Client Balance Report',
|
||||
|
|
@ -110947,6 +110948,10 @@ mixin LocalizationsProvider on LocaleCodeAware {
|
|||
_localizedValues[localeCode]!['run_template'] ??
|
||||
_localizedValues['en']!['run_template']!;
|
||||
|
||||
String get insertBelow =>
|
||||
_localizedValues[localeCode]!['insert_below'] ??
|
||||
_localizedValues['en']!['insert_below']!;
|
||||
|
||||
// STARTER: lang field - do not remove comment
|
||||
|
||||
String lookup(String? key) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue