-
Transactions
+
+
Transactions
+
+
+
+
- Importer
+ Importer
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -90,6 +101,7 @@ import {
BButtonToolbar,
BFormSelect,
BFormFile,
+ BPagination,
} from 'bootstrap-vue-next'
import SortButton from './../components/SortButton.vue'
@@ -100,11 +112,33 @@ const order = ref(null)
const sort = ref(null)
const page = ref(1)
const pages = ref(null)
-const limit = ref(null)
+const limit = ref(10)
const form = ref(null)
const formShow = ref(false)
const endpoint = `/api/transaction`
+const defineLimits = () => {
+ let v = []
+
+ for (let i of [10, 20, 50, 100]) {
+ v.push({value: i, text: i})
+ }
+
+ return v
+}
+
+const limits = defineLimits()
+
+const updatePage = (event, value) => {
+ page.value = value
+ refresh()
+}
+
+const updateLimit = () => {
+ page.value = 1
+ refresh()
+}
+
const refresh = () => {
fetch(`${endpoint}?${new URLSearchParams({
order: order.value,
@@ -238,37 +272,53 @@ const fields = [
{
key: 'date',
label: 'Date',
+ width: '90px',
render: (item) => renderDate(item.date),
},
- {
- key: 'accounted_at',
- label: 'Comptabilisé',
- render: (item) => renderDate(item.accounted_at),
- },
{
key: 'short_label',
- label: 'Libelle simplifie',
- },
- {
- key: 'label',
- label: 'Libelle',
- },
- {
- key: 'information',
- label: 'Informations',
+ width: '150px',
+ label: 'Libellé',
},
{
key: 'operation_type',
+ width: '120px',
label: 'Type',
},
{
key: 'debit',
label: 'Débit',
+ width: '120px',
+ thClasses: ['text-end'],
+ tdClasses: ['text-end'],
},
{
key: 'credit',
label: 'Crédit',
+ width: '120px',
+ thClasses: ['text-end'],
+ tdClasses: ['text-end'],
},
+ {
+ key: 'category',
+ label: 'Catégorie',
+ width: '120px',
+ render: (item) => {
+ if (item.category !== null) {
+ return item.category.label
+ }
+ },
+ },
+ {
+ key: 'bank_account',
+ label: 'Compte',
+ width: '120px',
+ render: (item) => {
+ if (item.bank_account !== null) {
+ return item.bank_account.label
+ }
+ },
+ }
]
onMounted(() => {
diff --git a/frontend/js/views/UsersView.vue b/frontend/js/views/UsersView.vue
index 150edbb..138ec63 100644
--- a/frontend/js/views/UsersView.vue
+++ b/frontend/js/views/UsersView.vue
@@ -3,7 +3,7 @@
Utilisateurs
- Ajouter
+ Ajouter
diff --git a/frontend/scss/main.scss b/frontend/scss/main.scss
index 8317f1c..1fe6891 100644
--- a/frontend/scss/main.scss
+++ b/frontend/scss/main.scss
@@ -17,6 +17,7 @@
#app, main {
min-height: 100vh;
max-height: 100vh;
+ overflow: hidden;
}
$nav-size: 300px;
@@ -25,6 +26,22 @@ $nav-size: 300px;
width: $nav-size;
}
+.crud {
+ &-list {
+ width: calc(100vw - $nav-size);
+ height: calc(100vh - 90px);
+ overflow: auto;
+
+ thead th {
+ position: sticky;
+ top: 0;
+ z-index: 1;
+ }
+ }
+}
+
#body {
width: calc(100vw - $nav-size);
+ max-height: 100vh;
+ overflow: scroll;
}
diff --git a/web/controller/bank_account/controller.go b/web/controller/bank_account/controller.go
index f0147d8..adb4045 100644
--- a/web/controller/bank_account/controller.go
+++ b/web/controller/bank_account/controller.go
@@ -16,7 +16,6 @@ func (ctrl *Controller) Config() crud.Configuration {
Model: model.BankAccount{},
Models: []model.BankAccount{},
ValidOrders: []string{"id", "label"},
- ValidLimits: []int{20, 50, 100},
DefaultLimit: 20,
CreateModel: func() interface{} {
return new(model.BankAccount)
diff --git a/web/controller/category/controller.go b/web/controller/category/controller.go
index 17df9a9..8af958e 100644
--- a/web/controller/category/controller.go
+++ b/web/controller/category/controller.go
@@ -16,8 +16,7 @@ func (ctrl *Controller) Config() crud.Configuration {
Model: model.Category{},
Models: []model.Category{},
ValidOrders: []string{"id", "label"},
- ValidLimits: []int{20, 50, 100},
- DefaultLimit: 20,
+ DefaultLimit: 100,
CreateModel: func() interface{} {
return new(model.Category)
},
diff --git a/web/controller/crud/config.go b/web/controller/crud/config.go
index 224b805..9b08342 100644
--- a/web/controller/crud/config.go
+++ b/web/controller/crud/config.go
@@ -1,5 +1,7 @@
package crud
+import "gorm.io/gorm"
+
type Configuration struct {
Model interface{}
Models any
@@ -9,6 +11,7 @@ type Configuration struct {
DefaultSort string
DefaultLimit int
CreateModel func() interface{}
+ ListQuery func(*gorm.DB)
}
func (c *Configuration) GetDefaultOrder() string {
@@ -27,6 +30,14 @@ func (c *Configuration) GetDefaultSort() string {
return "asc"
}
+func (c *Configuration) GetValidLimits() []int {
+ if len(c.ValidLimits) > 0 {
+ return c.ValidLimits
+ }
+
+ return []int{10, 20, 50, 100}
+}
+
func (c *Configuration) IsValidOrder(value string) bool {
for _, v := range c.ValidOrders {
if v == value {
@@ -38,7 +49,7 @@ func (c *Configuration) IsValidOrder(value string) bool {
}
func (c *Configuration) IsValidLimit(value int) bool {
- for _, v := range c.ValidLimits {
+ for _, v := range c.GetValidLimits() {
if v == value {
return true
}
diff --git a/web/controller/crud/crud.go b/web/controller/crud/crud.go
index a70a3c4..405b4ba 100644
--- a/web/controller/crud/crud.go
+++ b/web/controller/crud/crud.go
@@ -50,6 +50,10 @@ func (ctrl *Controller) List(c echo.Context) error {
Desc: sort == "desc",
})
+ if ctrl.Config.ListQuery != nil {
+ ctrl.Config.ListQuery(db)
+ }
+
data := ListData{
Limit: ctrl.Config.DefaultLimit,
Order: order,
diff --git a/web/controller/transaction/controller.go b/web/controller/transaction/controller.go
index 219c7af..6ae717b 100644
--- a/web/controller/transaction/controller.go
+++ b/web/controller/transaction/controller.go
@@ -10,6 +10,7 @@ import (
"gitnet.fr/deblan/budget/database/manager"
"gitnet.fr/deblan/budget/database/model"
"gitnet.fr/deblan/budget/web/controller/crud"
+ "gorm.io/gorm"
)
type Controller struct {
@@ -21,13 +22,16 @@ func (ctrl *Controller) Config() crud.Configuration {
Model: model.Transaction{},
Models: []model.Transaction{},
ValidOrders: []string{"accounted_at", "short_label", "label", "reference", "information", "operation_type", "debit", "credit", "date"},
- ValidLimits: []int{20, 50, 100},
DefaultLimit: 20,
DefaultOrder: "date",
DefaultSort: "desc",
CreateModel: func() interface{} {
return new(model.Transaction)
},
+ ListQuery: func(db *gorm.DB) {
+ db.Joins("BankAccount")
+ db.Joins("Category")
+ },
}
}