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