Skip to content

Open source personal finance application

apply parent category color to child

Ilya Komichev79d87afabf42
diff --git a/src/components/categories/form/CategoryForm.vue b/src/components/categories/form/CategoryForm.vue
index 715ee8af..16430a68 100644
--- a/src/components/categories/form/CategoryForm.vue
+++ b/src/components/categories/form/CategoryForm.vue
@@ -29,6 +29,7 @@ export default {
showParents: false,
showColors: false,
showIcons: false,
+ applyChildColor: true,
filter: null,
category: {
color: '',
@@ -117,6 +118,18 @@ export default {
db.ref(`users/${uid}/categories/${id}`).set(categoriesValues)
+ if (this.applyChildColor) {
+ const childIds = this.$store.getters.getChildCategoriesIds(id)
+ const categories = this.$store.state.categories.items
+ for (const childId of childIds) {
+ const category = categories[childId]
+ db.ref(`users/${uid}/categories/${childId}`).set({
+ ...category,
+ color: categoriesValues.color
+ })
+ }
+ }
+
this.$store.commit('setCategoryEditId', null)
this.$store.dispatch('setActiveTab', 'categories')
@@ -215,6 +228,14 @@ ComponentWrap
.inputModal__icon: div(:class="category.icon", :style="{ color: category.color }")
.inputModal__label {{ $lang.categories.form.icon.label }}
+ template(v-if="$store.getters.getChildCategoriesIds(categoryId).length")
+ .form-line._p0._clean
+ Checkbox(
+ v-model="applyChildColor"
+ :title="$lang.categories.form.childColor"
+ :alt="true"
+ )
+
template(v-if="$store.getters.getChildCategoriesIds(categoryId).length === 0")
.form-line._p0._clean
Checkbox(
diff --git a/src/lang/en.json b/src/lang/en.json
index da6d9ad1..24bbc7b7 100644
--- a/src/lang/en.json
+++ b/src/lang/en.json
@@ -125,6 +125,7 @@
},
"lastUsed": "Show in last used categories",
"quickSelector": "Show in trnForm quick selector",
+ "childColor": "Apply color to all child categories",
"save": "Save"
}
},
diff --git a/src/lang/ru.json b/src/lang/ru.json
index 9442eda1..e64bbc19 100644
--- a/src/lang/ru.json
+++ b/src/lang/ru.json
@@ -125,6 +125,7 @@
},
"lastUsed": "Показывать в списке последних использованных категорий",
"quickSelector": "Добавить в быстрый выбор при создании транзакции",
+ "childColor": "Применить цвет ко всем дочерних категориям",
"save": "Сохранить"
}
},