-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add transactions batch-editor (#126)
* feat: add transactions batch-editor Fixes #125 * validate slug is a number * add DangerZone and Discard button to batch editor * add transactions multi-select * chore: update svelte-currency-input * fix tests * remove existing highlight * add ability to delete multiple transactions * remove error props from Account and Asset forms * add ability to edit multiple transactions * increase hit area of checkboxes * Danger zone: camelCase class name * add batch-edit tests * add test assertion and update comments * remove redundant test steps
- Loading branch information
Showing
36 changed files
with
1,085 additions
and
250 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<script lang="ts"> | ||
import FormSelect from './FormSelect.svelte'; | ||
import { LOCALE } from '$lib/helpers/misc'; | ||
export let date: Date = new Date(); | ||
export let name: string; | ||
export let disabled: boolean = false; | ||
$: inputDate = new Date(`${thisYear}-${thisMonth}-${thisDate}`).getTime() / 1000; | ||
let thisYear = date.getUTCFullYear(); | ||
const years = [ | ||
// Past 15 years | ||
...Array.from(Array(15).keys()) | ||
.map((i) => thisYear - 1 - i) | ||
.reverse(), | ||
thisYear, | ||
// Next 15 years | ||
...Array.from(Array(15).keys()).map((i) => thisYear + 1 + i) | ||
]; | ||
let thisMonth = date.getUTCMonth() + 1; | ||
let months = Array.from(Array(12).keys()).map((i) => i + 1); // 12 months in a year | ||
let thisDate = date ? date.getUTCDate() : new Date().getUTCDate(); | ||
const days = Array.from(Array(31).keys()).map((i) => i + 1); // 31 days in a month | ||
const getDateSelects = (dates: number[]) => { | ||
const isMonth = dates.length === 12; | ||
return dates.map((date) => { | ||
return { | ||
label: isMonth | ||
? `${date} - ${new Date(thisYear, date - 1, 1).toLocaleString(LOCALE, { | ||
month: 'short' | ||
})}` // e.g. "9 - Sep" | ||
: date.toString(), | ||
value: date | ||
}; | ||
}); | ||
}; | ||
</script> | ||
|
||
<div class="form__date-field"> | ||
<input type="hidden" {name} value={inputDate} /> | ||
<FormSelect name="yearSelect" options={getDateSelects(years)} {disabled} bind:value={thisYear} /> | ||
<FormSelect | ||
name="monthSelect" | ||
options={getDateSelects(months)} | ||
{disabled} | ||
bind:value={thisMonth} | ||
/> | ||
<FormSelect name="dateSelect" options={getDateSelects(days)} {disabled} bind:value={thisDate} /> | ||
</div> | ||
|
||
<style lang="scss"> | ||
div.form__date-field { | ||
display: grid; | ||
grid-template-columns: repeat(3, 1fr); | ||
column-gap: 4px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<script lang="ts"> | ||
import FormInputCheckbox from './FormInputCheckbox.svelte'; | ||
export let name: string; | ||
export let label: string; | ||
export let checked: boolean; | ||
export let required: boolean = false; | ||
export let disabled: boolean = false; | ||
export let indeterminate: boolean = false; | ||
</script> | ||
|
||
<div class="form__editable-field"> | ||
<slot /> | ||
<FormInputCheckbox {name} {label} {required} {disabled} {indeterminate} bind:checked /> | ||
</div> | ||
|
||
<style lang="scss"> | ||
div.form__editable-field { | ||
display: grid; | ||
grid-template-columns: auto max-content; | ||
column-gap: 8px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<div class="form__field-flags"> | ||
<slot /> | ||
</div> | ||
|
||
<style lang="scss"> | ||
div.form__field-flags { | ||
display: flex; | ||
flex-direction: column; | ||
row-gap: 4px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.