Transaction rules
This commit is contained in:
parent
c10bc4116d
commit
bea316e1e0
|
|
@ -202,6 +202,17 @@ abstract class TransactionRuleCriteriaEntity
|
|||
static const SEARCH_KEY_DESCRIPTION = 'description';
|
||||
static const SEARCH_KEY_AMOUNT = 'amount';
|
||||
|
||||
static const NUMBER_OPERATOR_EQUALS = '=';
|
||||
static const NUMBER_OPERATOR_GREATER_THAN = '>';
|
||||
static const NUMBER_OPERATOR_GREATER_THAN_OR_EQUALS = '>=';
|
||||
static const NUMBER_OPERATOR_LESS_THAN = '<';
|
||||
static const NUMBER_OPERATOR_LESS_THAN_OR_EQUALS = '<=';
|
||||
|
||||
static const STRING_OPERATOR_IS = 'is';
|
||||
static const STRING_OPERATOR_CONTAINS = 'contains';
|
||||
static const STRING_OPERATOR_STARTS_WITH = 'starts_with';
|
||||
static const STRING_OPERATOR_IS_EMPTY = 'is_empty';
|
||||
|
||||
@override
|
||||
@memoized
|
||||
int get hashCode;
|
||||
|
|
|
|||
|
|
@ -141,11 +141,58 @@ class _TransactionRuleEditState extends State<TransactionRuleEdit> {
|
|||
FormCard(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
if (transactionRule.rules.isNotEmpty) ...[
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
localization.field,
|
||||
style: Theme.of(context).textTheme.caption,
|
||||
)),
|
||||
Expanded(
|
||||
child: Text(
|
||||
localization.operator,
|
||||
style: Theme.of(context).textTheme.caption,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
localization.value,
|
||||
style: Theme.of(context).textTheme.caption,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 4),
|
||||
for (var rule in transactionRule.rules)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child:
|
||||
Text(localization.lookup(rule.searchKey)),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(localization.lookup(rule.operator)),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(rule.value),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
],
|
||||
OutlinedButton(
|
||||
onPressed: () {
|
||||
showDialog<TransactionRuleCriteriaEntity>(
|
||||
context: context,
|
||||
builder: (context) => _RuleCriteria());
|
||||
onPressed: () async {
|
||||
final rule =
|
||||
await showDialog<TransactionRuleCriteriaEntity>(
|
||||
context: context,
|
||||
builder: (context) => _RuleCriteria());
|
||||
|
||||
viewModel.onChanged(
|
||||
transactionRule.rebuild((b) => b..rules.add(rule)));
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
|
|
@ -261,8 +308,32 @@ class __RuleCriteriaState extends State<_RuleCriteria> {
|
|||
),
|
||||
],
|
||||
),
|
||||
DecoratedFormField(
|
||||
label: localization.value,
|
||||
initialValue: _criteria.value,
|
||||
keyboardType: TextInputType.text,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_criteria = _criteria.rebuild((b) => b..value = value);
|
||||
});
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Text(localization.cancel.toUpperCase()),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop(_criteria);
|
||||
},
|
||||
child: Text(localization.done.toUpperCase()),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,12 @@ mixin LocalizationsProvider on LocaleCodeAware {
|
|||
static final Map<String, Map<String, String>> _localizedValues = {
|
||||
'en': {
|
||||
// STARTER: lang key - do not remove comment
|
||||
'operator': 'Operator',
|
||||
'value': 'Value',
|
||||
'is': 'is',
|
||||
'contains': 'contains',
|
||||
'starts_with': 'starts with',
|
||||
'is_empty': 'is empty',
|
||||
'add_rule': 'Add Rule',
|
||||
'match_all_rules': 'Match All Rules',
|
||||
'match_all_rules_help':
|
||||
|
|
@ -90534,6 +90540,30 @@ mixin LocalizationsProvider on LocaleCodeAware {
|
|||
_localizedValues[localeCode]['add_rule'] ??
|
||||
_localizedValues['en']['add_rule'];
|
||||
|
||||
String get isWord =>
|
||||
_localizedValues[localeCode]['is'] ??
|
||||
_localizedValues['en']['is'];
|
||||
|
||||
String get contains =>
|
||||
_localizedValues[localeCode]['contains'] ??
|
||||
_localizedValues['en']['contains'];
|
||||
|
||||
String get startsWith =>
|
||||
_localizedValues[localeCode]['starts_with'] ??
|
||||
_localizedValues['en']['starts_with'];
|
||||
|
||||
String get isEmpty =>
|
||||
_localizedValues[localeCode]['is_empty'] ??
|
||||
_localizedValues['en']['is_empty'];
|
||||
|
||||
String get value =>
|
||||
_localizedValues[localeCode]['value'] ??
|
||||
_localizedValues['en']['value'];
|
||||
|
||||
String get operator =>
|
||||
_localizedValues[localeCode]['operator'] ??
|
||||
_localizedValues['en']['operator'];
|
||||
|
||||
// STARTER: lang field - do not remove comment
|
||||
|
||||
String lookup(String key) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue