Skip to content
Snippets Groups Projects
Unverified Commit d36417e4 authored by shall0pass's avatar shall0pass Committed by GitHub
Browse files

[Feature] Add option to control the "cleared state" in Rules (#482)

parent 54559478
No related branches found
No related tags found
No related merge requests found
...@@ -133,7 +133,8 @@ export default function TransactionList({ ...@@ -133,7 +133,8 @@ export default function TransactionList({
if ( if (
newTransaction[field] == null || newTransaction[field] == null ||
newTransaction[field] === '' || newTransaction[field] === '' ||
newTransaction[field] === 0 newTransaction[field] === 0 ||
newTransaction[field] === false
) { ) {
newTransaction[field] = diff[field]; newTransaction[field] = diff[field];
} }
......
...@@ -284,7 +284,8 @@ let actionFields = [ ...@@ -284,7 +284,8 @@ let actionFields = [
'date', 'date',
'amount', 'amount',
'category', 'category',
'account' 'account',
'cleared'
].map(field => [field, mapField(field)]); ].map(field => [field, mapField(field)]);
function ActionEditor({ ops, action, editorStyle, onChange, onDelete, onAdd }) { function ActionEditor({ ops, action, editorStyle, onChange, onDelete, onAdd }) {
let { field, op, value, type, error, inputKey = 'initial' } = action; let { field, op, value, type, error, inputKey = 'initial' } = action;
......
...@@ -7,6 +7,7 @@ import Autocomplete from 'loot-design/src/components/Autocomplete'; ...@@ -7,6 +7,7 @@ import Autocomplete from 'loot-design/src/components/Autocomplete';
import CategoryAutocomplete from 'loot-design/src/components/CategorySelect'; import CategoryAutocomplete from 'loot-design/src/components/CategorySelect';
import { View, Input } from 'loot-design/src/components/common'; import { View, Input } from 'loot-design/src/components/common';
import DateSelect from 'loot-design/src/components/DateSelect'; import DateSelect from 'loot-design/src/components/DateSelect';
import { Checkbox } from 'loot-design/src/components/forms';
import PayeeAutocomplete from 'loot-design/src/components/PayeeAutocomplete'; import PayeeAutocomplete from 'loot-design/src/components/PayeeAutocomplete';
import RecurringSchedulePicker from 'loot-design/src/components/RecurringSchedulePicker'; import RecurringSchedulePicker from 'loot-design/src/components/RecurringSchedulePicker';
...@@ -149,6 +150,16 @@ export default function GenericInput({ ...@@ -149,6 +150,16 @@ export default function GenericInput({
} }
break; break;
case 'boolean':
content = (
<Checkbox
checked={value}
value={value}
onChange={e => onChange(!value)}
/>
);
break;
default: default:
if (multi) { if (multi) {
content = ( content = (
......
...@@ -57,6 +57,8 @@ export function mapField(field, opts) { ...@@ -57,6 +57,8 @@ export function mapField(field, opts) {
return 'amount (inflow)'; return 'amount (inflow)';
case 'amount-outflow': case 'amount-outflow':
return 'amount (outflow)'; return 'amount (outflow)';
case 'cleared':
return 'cleared';
default: default:
return field; return field;
} }
...@@ -154,6 +156,10 @@ export function parse(item) { ...@@ -154,6 +156,10 @@ export function parse(item) {
let parsed = item.value == null ? '' : item.value; let parsed = item.value == null ? '' : item.value;
return { ...item, value: parsed }; return { ...item, value: parsed };
} }
case 'boolean': {
let parsed = item.value;
return { ...item, value: parsed };
}
default: default:
} }
...@@ -174,6 +180,10 @@ export function unparse({ error, inputKey, ...item }) { ...@@ -174,6 +180,10 @@ export function unparse({ error, inputKey, ...item }) {
let unparsed = item.value == null ? '' : item.value; let unparsed = item.value == null ? '' : item.value;
return { ...item, value: unparsed }; return { ...item, value: unparsed };
} }
case 'boolean': {
let unparsed = item.value == null ? false : item.value;
return { ...item, value: unparsed };
}
default: default:
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment