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({
if (
newTransaction[field] == null ||
newTransaction[field] === '' ||
newTransaction[field] === 0
newTransaction[field] === 0 ||
newTransaction[field] === false
) {
newTransaction[field] = diff[field];
}
......
......@@ -284,7 +284,8 @@ let actionFields = [
'date',
'amount',
'category',
'account'
'account',
'cleared'
].map(field => [field, mapField(field)]);
function ActionEditor({ ops, action, editorStyle, onChange, onDelete, onAdd }) {
let { field, op, value, type, error, inputKey = 'initial' } = action;
......
......@@ -7,6 +7,7 @@ import Autocomplete from 'loot-design/src/components/Autocomplete';
import CategoryAutocomplete from 'loot-design/src/components/CategorySelect';
import { View, Input } from 'loot-design/src/components/common';
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 RecurringSchedulePicker from 'loot-design/src/components/RecurringSchedulePicker';
......@@ -149,6 +150,16 @@ export default function GenericInput({
}
break;
case 'boolean':
content = (
<Checkbox
checked={value}
value={value}
onChange={e => onChange(!value)}
/>
);
break;
default:
if (multi) {
content = (
......
......@@ -57,6 +57,8 @@ export function mapField(field, opts) {
return 'amount (inflow)';
case 'amount-outflow':
return 'amount (outflow)';
case 'cleared':
return 'cleared';
default:
return field;
}
......@@ -154,6 +156,10 @@ export function parse(item) {
let parsed = item.value == null ? '' : item.value;
return { ...item, value: parsed };
}
case 'boolean': {
let parsed = item.value;
return { ...item, value: parsed };
}
default:
}
......@@ -174,6 +180,10 @@ export function unparse({ error, inputKey, ...item }) {
let unparsed = item.value == null ? '' : item.value;
return { ...item, value: unparsed };
}
case 'boolean': {
let unparsed = item.value == null ? false : item.value;
return { ...item, value: unparsed };
}
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