ecodev-front 0.0.97__tar.gz → 0.0.99__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/PKG-INFO +3 -2
  2. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/__init__.py +110 -99
  3. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/app_layout.py +38 -1
  4. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/constants.py +10 -7
  5. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/ids.py +7 -5
  6. ecodev_front-0.0.99/ecodev_front/tables/column_def.py +182 -0
  7. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/tables/data_table.py +62 -9
  8. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/pyproject.toml +1 -1
  9. ecodev_front-0.0.97/ecodev_front/tables/column_def.py +0 -83
  10. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/LICENSE.md +0 -0
  11. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/README.md +0 -0
  12. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/accordion.py +0 -0
  13. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/alert.py +0 -0
  14. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/app_header.py +0 -0
  15. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/app_logo.py +0 -0
  16. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/app_name.py +0 -0
  17. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/app_title.py +0 -0
  18. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/aside_buttons.py +0 -0
  19. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/aside_section.py +0 -0
  20. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/assets/dashAgGridComponentFunctions.js +0 -0
  21. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/button.py +0 -0
  22. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/card.py +0 -0
  23. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/container.py +0 -0
  24. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/display_utils.py +0 -0
  25. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/div.py +0 -0
  26. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/divider.py +0 -0
  27. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/documentation.py +0 -0
  28. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/download_button.py +0 -0
  29. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/drawer.py +0 -0
  30. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/footer.py +0 -0
  31. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/further_info.py +0 -0
  32. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/graphs/__init__.py +0 -0
  33. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/graphs/bar_chart.py +0 -0
  34. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/graphs/fig_helpers.py +0 -0
  35. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/graphs/fig_layout.py +0 -0
  36. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/graphs/graph.py +0 -0
  37. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/graphs/legend_position.py +0 -0
  38. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/graphs/pie_chart.py +0 -0
  39. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/graphs/plotly_tools.py +0 -0
  40. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/graphs/scatter.py +0 -0
  41. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/graphs/subplots.py +0 -0
  42. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/graphs/sunburst.py +0 -0
  43. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/group.py +0 -0
  44. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/icon.py +0 -0
  45. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/loading_overlay.py +0 -0
  46. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/login.py +0 -0
  47. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/modal.py +0 -0
  48. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/module.py +0 -0
  49. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/monitoring.py +0 -0
  50. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/nav_items.py +0 -0
  51. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/navbar.py +0 -0
  52. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/navbar_page_icon.py +0 -0
  53. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/navlink.py +0 -0
  54. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/notification.py +0 -0
  55. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/notifications.py +0 -0
  56. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/page.py +0 -0
  57. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/page_header.py +0 -0
  58. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/page_layout.py +0 -0
  59. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/report_value.py +0 -0
  60. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/search_bar.py +0 -0
  61. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/segment_control.py +0 -0
  62. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/select.py +0 -0
  63. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/shadow_box.py +0 -0
  64. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/shadow_button.py +0 -0
  65. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/stack.py +0 -0
  66. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/stepper.py +0 -0
  67. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/switch.py +0 -0
  68. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/tables/__init__.py +0 -0
  69. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/tables/data_table_button.py +0 -0
  70. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/tabs.py +0 -0
  71. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/text.py +0 -0
  72. {ecodev_front-0.0.97 → ecodev_front-0.0.99}/ecodev_front/upload_box.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: ecodev-front
3
- Version: 0.0.97
3
+ Version: 0.0.99
4
4
  Summary: Dash component helpers
5
5
  License: MIT
6
6
  Author: Amaury Salles
@@ -19,6 +19,7 @@ Classifier: Programming Language :: Python
19
19
  Classifier: Programming Language :: Python :: 3
20
20
  Classifier: Programming Language :: Python :: 3.11
21
21
  Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
22
23
  Classifier: Programming Language :: Python :: 3 :: Only
23
24
  Classifier: Topic :: Internet
24
25
  Classifier: Topic :: Internet :: WWW/HTTP
@@ -9,12 +9,12 @@ from ecodev_front.app_layout import dash_base_layout
9
9
  from ecodev_front.app_logo import app_logo
10
10
  from ecodev_front.app_name import APP_NAME
11
11
  from ecodev_front.app_title import app_header_name
12
- from ecodev_front.aside_section import aside_section
13
12
  from ecodev_front.aside_buttons import aside_buttons
14
13
  from ecodev_front.aside_buttons import CLOSE_ASIDE_BTN_ID
15
14
  from ecodev_front.aside_buttons import HIDE
16
15
  from ecodev_front.aside_buttons import OPEN_ASIDE_BTN_ID
17
16
  from ecodev_front.aside_buttons import SHOW
17
+ from ecodev_front.aside_section import aside_section
18
18
  from ecodev_front.button import button
19
19
  from ecodev_front.button import ButtonAction
20
20
  from ecodev_front.button import render_action_button
@@ -23,69 +23,70 @@ from ecodev_front.card import card_section
23
23
  from ecodev_front.card import card_title
24
24
  from ecodev_front.card import kpi
25
25
  from ecodev_front.card import macro_info
26
+ from ecodev_front.constants import ACTION
27
+ from ecodev_front.constants import ACTIVE
28
+ from ecodev_front.constants import ALLOW_STEP_CLICK
29
+ from ecodev_front.constants import BILLION
30
+ from ecodev_front.constants import CELL_CLICKED
31
+ from ecodev_front.constants import CELL_RENDERER_DATA
32
+ from ecodev_front.constants import CELL_VALUE_CHANGED
33
+ from ecodev_front.constants import CHECKED
26
34
  from ecodev_front.constants import CHILDREN
35
+ from ecodev_front.constants import CLICK_DATA
36
+ from ecodev_front.constants import COL_ID
37
+ from ecodev_front.constants import COLOR
38
+ from ecodev_front.constants import CONTENTS
39
+ from ecodev_front.constants import CREATED_AT
27
40
  from ecodev_front.constants import DATA
28
- from ecodev_front.constants import PATHNAME
29
- from ecodev_front.constants import N_CLICKS
30
- from ecodev_front.constants import VALUE
41
+ from ecodev_front.constants import DELETED
31
42
  from ecodev_front.constants import DISABLED
32
- from ecodev_front.constants import STYLE
33
- from ecodev_front.constants import ACTIVE
34
- from ecodev_front.constants import LOCAL
35
- from ecodev_front.constants import OPENED
36
- from ecodev_front.constants import CONTENTS
43
+ from ecodev_front.constants import DISPLAY
44
+ from ecodev_front.constants import ERROR
45
+ from ecodev_front.constants import FIGURE
37
46
  from ecodev_front.constants import FILENAME
38
- from ecodev_front.constants import TYPE
39
- from ecodev_front.constants import INDEX
40
- from ecodev_front.constants import ID
41
- from ecodev_front.constants import VISIBLE
42
- from ecodev_front.constants import CHECKED
43
47
  from ecodev_front.constants import HIDDEN
44
48
  from ecodev_front.constants import HREF
45
- from ecodev_front.constants import FIGURE
46
- from ecodev_front.constants import CLICK_DATA
47
- from ecodev_front.constants import ERROR
48
- from ecodev_front.constants import LOADING
49
- from ecodev_front.constants import ALLOW_STEP_CLICK
50
- from ecodev_front.constants import STEPS
49
+ from ecodev_front.constants import ICON
50
+ from ecodev_front.constants import ID
51
+ from ecodev_front.constants import INDEX
52
+ from ecodev_front.constants import INSERTED
51
53
  from ecodev_front.constants import LABEL
54
+ from ecodev_front.constants import LOADING
55
+ from ecodev_front.constants import LOCAL
56
+ from ecodev_front.constants import LOCAL_STORE
57
+ from ecodev_front.constants import LOGIN_PAGE_URL
58
+ from ecodev_front.constants import MAIN_ID
59
+ from ecodev_front.constants import MAIN_PAGE_URL
60
+ from ecodev_front.constants import MESSAGE
61
+ from ecodev_front.constants import MILLION
62
+ from ecodev_front.constants import N_CLICKS
63
+ from ecodev_front.constants import N_INTERVALS
64
+ from ecodev_front.constants import NEW_VALUE
65
+ from ecodev_front.constants import NOTIFICATION_ID
66
+ from ecodev_front.constants import OLD_VALUE
67
+ from ecodev_front.constants import OPENED
52
68
  from ecodev_front.constants import OPTIONS
69
+ from ecodev_front.constants import PATHNAME
53
70
  from ecodev_front.constants import REQUIRED
54
- from ecodev_front.constants import DISPLAY
55
- from ecodev_front.constants import SEND_NOTIFICATIONS
56
- from ecodev_front.constants import TITLE
57
- from ecodev_front.constants import ACTION
58
- from ecodev_front.constants import MESSAGE
59
- from ecodev_front.constants import ICON
60
- from ecodev_front.constants import COLOR
61
- from ecodev_front.constants import CREATED_AT
62
- from ecodev_front.constants import WITH_CLOSE_BUTTON
63
- from ecodev_front.constants import CELL_RENDERER_DATA
64
71
  from ecodev_front.constants import ROW_DATA
65
- from ecodev_front.constants import ROW_INDEX
66
- from ecodev_front.constants import CELL_CLICKED
67
- from ecodev_front.constants import CELL_VALUE_CHANGED
68
72
  from ecodev_front.constants import ROW_ID
69
- from ecodev_front.constants import COL_ID
73
+ from ecodev_front.constants import ROW_INDEX
74
+ from ecodev_front.constants import SEND_NOTIFICATIONS
70
75
  from ecodev_front.constants import SESSION_STORE
71
- from ecodev_front.constants import LOCAL_STORE
72
- from ecodev_front.constants import NOTIFICATION_ID
73
- from ecodev_front.constants import MAIN_PAGE_URL
74
- from ecodev_front.constants import LOGIN_PAGE_URL
76
+ from ecodev_front.constants import STAGING_ID
77
+ from ecodev_front.constants import STEPS
78
+ from ecodev_front.constants import STYLE
75
79
  from ecodev_front.constants import THOUSAND
76
- from ecodev_front.constants import MILLION
77
- from ecodev_front.constants import BILLION
80
+ from ecodev_front.constants import TITLE
78
81
  from ecodev_front.constants import TRILLION
82
+ from ecodev_front.constants import TYPE
83
+ from ecodev_front.constants import UNCHANGED
79
84
  from ecodev_front.constants import UPDATE_TYPE
80
- from ecodev_front.constants import INSERTED
81
85
  from ecodev_front.constants import UPDATED
82
- from ecodev_front.constants import DELETED
83
- from ecodev_front.constants import UNCHANGED
84
- from ecodev_front.constants import OLD_VALUE
85
- from ecodev_front.constants import NEW_VALUE
86
- from ecodev_front.constants import MAIN_ID
87
- from ecodev_front.constants import STAGING_ID
88
86
  from ecodev_front.constants import UPDATED_AT
87
+ from ecodev_front.constants import VALUE
88
+ from ecodev_front.constants import VISIBLE
89
+ from ecodev_front.constants import WITH_CLOSE_BUTTON
89
90
  from ecodev_front.container import container
90
91
  from ecodev_front.display_utils import get_magnitude
91
92
  from ecodev_front.display_utils import number_formatting
@@ -113,64 +114,67 @@ from ecodev_front.graphs import subplots
113
114
  from ecodev_front.graphs import subplots_y_axis_labels
114
115
  from ecodev_front.group import group
115
116
  from ecodev_front.icon import dash_icon
116
- from ecodev_front.ids import URL
117
- from ecodev_front.ids import TOKEN
118
- from ecodev_front.ids import HEADER_ID
119
- from ecodev_front.ids import LOGIN
120
- from ecodev_front.ids import USERNAME
121
- from ecodev_front.ids import PASSWORD
122
- from ecodev_front.ids import LOGIN_USERNAME_INPUT_ID
123
- from ecodev_front.ids import LOGIN_PASSWORD_INPUT_ID
124
- from ecodev_front.ids import LOGIN_BTN_ID
125
- from ecodev_front.ids import LOGOUT_BTN_ID
126
- from ecodev_front.ids import FOOTER_ID
127
- from ecodev_front.ids import PROJECT_HEADER_ID
128
- from ecodev_front.ids import MAIN_CONTENT_ID
129
- from ecodev_front.ids import PAGE
117
+ from ecodev_front.ids import ACCEPT
118
+ from ecodev_front.ids import ACCEPT_BTN
119
+ from ecodev_front.ids import ACCORDION
120
+ from ecodev_front.ids import ACCORDION_ITEM
121
+ from ecodev_front.ids import ACTION_ITEM
122
+ from ecodev_front.ids import ADD_BTN
130
123
  from ecodev_front.ids import APPSHELL
131
124
  from ecodev_front.ids import ASIDE
132
- from ecodev_front.ids import NAVBAR
133
- from ecodev_front.ids import HOME_BUTTON
134
- from ecodev_front.ids import MODULE_BUTTON
135
- from ecodev_front.ids import DOCUMENTATION
136
- from ecodev_front.ids import NOTIFICATION
137
- from ecodev_front.ids import USE
138
- from ecodev_front.ids import CONTINUE
139
- from ecodev_front.ids import SAVE
140
- from ecodev_front.ids import COLUMN
141
- from ecodev_front.ids import ACCEPT
142
- from ecodev_front.ids import REJECT
143
- from ecodev_front.ids import SUBMIT_BTN
125
+ from ecodev_front.ids import BUTTON
126
+ from ecodev_front.ids import CANCEL_BTN
127
+ from ecodev_front.ids import CHECKBOX
144
128
  from ecodev_front.ids import CLOSE_BTN
145
- from ecodev_front.ids import SAVE_BTN
146
- from ecodev_front.ids import CONTINUE_BTN
147
- from ecodev_front.ids import ACCEPT_BTN
129
+ from ecodev_front.ids import COLUMN
148
130
  from ecodev_front.ids import CONFIRM_BTN
149
- from ecodev_front.ids import CANCEL_BTN
131
+ from ecodev_front.ids import CONTINUE
132
+ from ecodev_front.ids import CONTINUE_BTN
150
133
  from ecodev_front.ids import DELETE_BTN
151
- from ecodev_front.ids import UPDATE_BTN
152
- from ecodev_front.ids import ADD_BTN
153
- from ecodev_front.ids import TABLE
134
+ from ecodev_front.ids import DIV
135
+ from ecodev_front.ids import DOCUMENTATION
136
+ from ecodev_front.ids import DRAWER
137
+ from ecodev_front.ids import ERROR_MODAL
138
+ from ecodev_front.ids import FOOTER_ID
139
+ from ecodev_front.ids import HEADER_ID
140
+ from ecodev_front.ids import HOME_BUTTON
141
+ from ecodev_front.ids import INTERVAL
154
142
  from ecodev_front.ids import LOADING_OVERLAY
143
+ from ecodev_front.ids import LOGIN
144
+ from ecodev_front.ids import LOGIN_BTN_ID
145
+ from ecodev_front.ids import LOGIN_PASSWORD_INPUT_ID
146
+ from ecodev_front.ids import LOGIN_USERNAME_INPUT_ID
147
+ from ecodev_front.ids import LOGOUT_BTN_ID
148
+ from ecodev_front.ids import MAIN_CONTENT_ID
155
149
  from ecodev_front.ids import MODAL
156
- from ecodev_front.ids import BUTTON
150
+ from ecodev_front.ids import MODULE_BUTTON
151
+ from ecodev_front.ids import MULTI_SELECT
152
+ from ecodev_front.ids import NAVBAR
153
+ from ecodev_front.ids import NOTIFICATION
154
+ from ecodev_front.ids import NULLIFY
157
155
  from ecodev_front.ids import OUTPUT
156
+ from ecodev_front.ids import PAGE
157
+ from ecodev_front.ids import PASSWORD
158
158
  from ecodev_front.ids import PLACEHOLDER
159
- from ecodev_front.ids import ACCORDION_ITEM
159
+ from ecodev_front.ids import PROJECT_HEADER_ID
160
+ from ecodev_front.ids import REJECT
161
+ from ecodev_front.ids import SAVE
162
+ from ecodev_front.ids import SAVE_BTN
163
+ from ecodev_front.ids import SEGMENTED_CONTROL
160
164
  from ecodev_front.ids import SELECT
161
- from ecodev_front.ids import NULLIFY
165
+ from ecodev_front.ids import STACK
166
+ from ecodev_front.ids import STEPPER
167
+ from ecodev_front.ids import SUBMIT_BTN
162
168
  from ecodev_front.ids import SWITCH
163
- from ecodev_front.ids import TEXT_INPUT
164
- from ecodev_front.ids import DRAWER
165
- from ecodev_front.ids import DIV
166
- from ecodev_front.ids import SEGMENTED_CONTROL
167
- from ecodev_front.ids import CHECKBOX
168
- from ecodev_front.ids import ACTION_ITEM
169
+ from ecodev_front.ids import TABLE
169
170
  from ecodev_front.ids import TAGS_INPUT
170
- from ecodev_front.ids import INTERVAL
171
- from ecodev_front.ids import ACCORDION
172
- from ecodev_front.ids import STACK
173
- from ecodev_front.ids import MULTI_SELECT
171
+ from ecodev_front.ids import TEXT
172
+ from ecodev_front.ids import TEXT_INPUT
173
+ from ecodev_front.ids import TOKEN
174
+ from ecodev_front.ids import UPDATE_BTN
175
+ from ecodev_front.ids import URL
176
+ from ecodev_front.ids import USE
177
+ from ecodev_front.ids import USERNAME
174
178
  from ecodev_front.loading_overlay import loading_overlay
175
179
  from ecodev_front.login import login
176
180
  from ecodev_front.login import login_card
@@ -213,6 +217,8 @@ from ecodev_front.tables import custom_column_def
213
217
  from ecodev_front.tables import DagColTypes
214
218
  from ecodev_front.tables import data_table
215
219
  from ecodev_front.tables import locale_fr_FR
220
+ from ecodev_front.tables.column_def import CELL_STYLE_CENTER
221
+ from ecodev_front.tables.column_def import CHECKBOX_COLUMN_DEF
216
222
  from ecodev_front.tables.data_table_button import dash_ag_grid_button
217
223
  from ecodev_front.text import app_title
218
224
  from ecodev_front.text import label_text
@@ -222,7 +228,6 @@ from ecodev_front.text import subtext
222
228
  from ecodev_front.text import subtitle
223
229
  from ecodev_front.text import text_title
224
230
  from ecodev_front.upload_box import upload_box
225
-
226
231
  __all__ = [
227
232
  'accordion',
228
233
  'accordion_item',
@@ -305,6 +310,8 @@ __all__ = [
305
310
  'vertical_stepper',
306
311
  'custom_column_def',
307
312
  'DagColTypes',
313
+ 'CELL_STYLE_CENTER',
314
+ 'CHECKBOX_COLUMN_DEF',
308
315
  'data_table',
309
316
  'locale_fr_FR',
310
317
  'app_title',
@@ -327,7 +334,7 @@ __all__ = [
327
334
  'send_notification',
328
335
  'ButtonAction',
329
336
  'dash_ag_grid_button',
330
-
337
+
331
338
  # Constants
332
339
  'CHILDREN',
333
340
  'DATA',
@@ -392,7 +399,8 @@ __all__ = [
392
399
  'MAIN_ID',
393
400
  'STAGING_ID',
394
401
  'UPDATED_AT',
395
-
402
+ 'N_INTERVALS',
403
+
396
404
  # IDs
397
405
  'URL',
398
406
  'TOKEN',
@@ -415,14 +423,15 @@ __all__ = [
415
423
  'MODULE_BUTTON',
416
424
  'DOCUMENTATION',
417
425
  'NOTIFICATION',
418
-
426
+ 'ERROR_MODAL',
427
+
419
428
  'USE',
420
429
  'CONTINUE',
421
430
  'SAVE',
422
431
  'COLUMN',
423
432
  'ACCEPT',
424
433
  'REJECT',
425
-
434
+
426
435
  'SUBMIT_BTN',
427
436
  'CLOSE_BTN',
428
437
  'SAVE_BTN',
@@ -433,7 +442,7 @@ __all__ = [
433
442
  'DELETE_BTN',
434
443
  'UPDATE_BTN',
435
444
  'ADD_BTN',
436
-
445
+
437
446
  'TABLE',
438
447
  'LOADING_OVERLAY',
439
448
  'MODAL',
@@ -455,4 +464,6 @@ __all__ = [
455
464
  'ACCORDION',
456
465
  'STACK',
457
466
  'MULTI_SELECT',
467
+ 'TEXT',
468
+ 'STEPPER',
458
469
  ]
@@ -8,16 +8,39 @@ import dash_mantine_components as dmc
8
8
  from dash import dcc
9
9
  from dash import html
10
10
 
11
+ from ecodev_front.button import ButtonAction
12
+ from ecodev_front.button import render_action_button
13
+ from ecodev_front.constants import ERROR
14
+ from ecodev_front.constants import INDEX
11
15
  from ecodev_front.constants import NOTIFICATION_ID
16
+ from ecodev_front.constants import TYPE
12
17
  from ecodev_front.ids import APPSHELL
13
18
  from ecodev_front.ids import ASIDE
19
+ from ecodev_front.ids import ERROR_MODAL
14
20
  from ecodev_front.ids import FOOTER_ID
15
21
  from ecodev_front.ids import HEADER_ID
22
+ from ecodev_front.ids import INTERVAL
16
23
  from ecodev_front.ids import MAIN_CONTENT_ID
24
+ from ecodev_front.ids import MODAL
17
25
  from ecodev_front.ids import NAVBAR
18
26
  from ecodev_front.ids import NOTIFICATION
27
+ from ecodev_front.ids import TEXT
19
28
  from ecodev_front.ids import TOKEN
20
29
  from ecodev_front.ids import URL
30
+ from ecodev_front.modal import modal
31
+
32
+
33
+ def get_error_monitor_component():
34
+ """
35
+ Get a hidden interval component to monitor errors.
36
+ This should be added to the main layout.
37
+ """
38
+ return dcc.Interval(
39
+ id={TYPE: INTERVAL, INDEX: ERROR},
40
+ interval=2000, # Check every 2 seconds
41
+ n_intervals=0,
42
+ disabled=False
43
+ )
21
44
 
22
45
 
23
46
  def dash_base_layout(stores: list[dcc.Store] = [],
@@ -40,7 +63,21 @@ def dash_base_layout(stores: list[dcc.Store] = [],
40
63
 
41
64
  html.Div(id=NOTIFICATION_ID),
42
65
  dmc.NotificationContainer(id=NOTIFICATION),
43
-
66
+ get_error_monitor_component(),
67
+ modal(
68
+ id={TYPE: MODAL, INDEX: ERROR},
69
+ children=[
70
+ dmc.Stack([
71
+ dmc.Text(
72
+ id={TYPE: TEXT, INDEX: ERROR},
73
+ size='sm',
74
+ style={'whiteSpace': 'pre-wrap', 'fontFamily': 'monospace'}
75
+ ),
76
+ render_action_button(index=ERROR_MODAL, action=ButtonAction.CLOSE)
77
+ ])
78
+ ],
79
+ size='lg',
80
+ ),
44
81
  dmc.AppShellHeader(id=HEADER_ID,
45
82
  style={'background-color': main_color},
46
83
  zIndex=100,
@@ -39,6 +39,7 @@ ICON = 'icon'
39
39
  COLOR = 'color'
40
40
  CREATED_AT = 'created_at'
41
41
  WITH_CLOSE_BUTTON = 'withCloseButton'
42
+ N_INTERVALS = 'n_intervals'
42
43
 
43
44
  """
44
45
  Table constants
@@ -50,6 +51,7 @@ CELL_CLICKED = 'cellClicked'
50
51
  CELL_VALUE_CHANGED = 'cellValueChanged'
51
52
  ROW_ID = 'rowId'
52
53
  COL_ID = 'colId'
54
+ SELECTED_ROWS = 'selectedRows'
53
55
 
54
56
  """
55
57
  Stores
@@ -108,7 +110,7 @@ __all__ = [
108
110
  'HIDDEN',
109
111
  'HREF',
110
112
  'FIGURE',
111
-
113
+
112
114
  'CLICK_DATA',
113
115
  'ERROR',
114
116
  'LOADING',
@@ -126,7 +128,8 @@ __all__ = [
126
128
  'COLOR',
127
129
  'CREATED_AT',
128
130
  'WITH_CLOSE_BUTTON',
129
-
131
+ 'N_INTERVALS',
132
+
130
133
  'CELL_RENDERER_DATA',
131
134
  'ROW_DATA',
132
135
  'ROW_INDEX',
@@ -134,19 +137,19 @@ __all__ = [
134
137
  'CELL_VALUE_CHANGED',
135
138
  'ROW_ID',
136
139
  'COL_ID',
137
-
140
+
138
141
  'SESSION_STORE',
139
142
  'LOCAL_STORE',
140
143
  'NOTIFICATION_ID',
141
-
144
+
142
145
  'MAIN_PAGE_URL',
143
146
  'LOGIN_PAGE_URL',
144
-
147
+
145
148
  'THOUSAND',
146
149
  'MILLION',
147
150
  'BILLION',
148
151
  'TRILLION',
149
-
152
+
150
153
  'UPDATE_TYPE',
151
154
  'INSERTED',
152
155
  'UPDATED',
@@ -157,4 +160,4 @@ __all__ = [
157
160
  'MAIN_ID',
158
161
  'STAGING_ID',
159
162
  'UPDATED_AT',
160
- ]
163
+ ]
@@ -22,7 +22,7 @@ HOME_BUTTON = 'home-button-id'
22
22
  MODULE_BUTTON = 'module-button'
23
23
  DOCUMENTATION = 'documentation'
24
24
  NOTIFICATION = 'notification'
25
-
25
+ ERROR_MODAL = 'error-modal'
26
26
 
27
27
  """
28
28
  Button Actions
@@ -69,7 +69,8 @@ INTERVAL = 'interval'
69
69
  ACCORDION = 'accordion'
70
70
  STACK = 'stack'
71
71
  MULTI_SELECT = 'multi-select'
72
-
72
+ TEXT = 'text'
73
+ STEPPER = 'stepper'
73
74
 
74
75
  __all__ = [
75
76
  'URL',
@@ -93,14 +94,14 @@ __all__ = [
93
94
  'MODULE_BUTTON',
94
95
  'DOCUMENTATION',
95
96
  'NOTIFICATION',
96
-
97
+
97
98
  'USE',
98
99
  'CONTINUE',
99
100
  'SAVE',
100
101
  'COLUMN',
101
102
  'ACCEPT',
102
103
  'REJECT',
103
-
104
+
104
105
  'SUBMIT_BTN',
105
106
  'CLOSE_BTN',
106
107
  'SAVE_BTN',
@@ -111,7 +112,7 @@ __all__ = [
111
112
  'DELETE_BTN',
112
113
  'UPDATE_BTN',
113
114
  'ADD_BTN',
114
-
115
+
115
116
  'TABLE',
116
117
  'LOADING_OVERLAY',
117
118
  'MODAL',
@@ -133,4 +134,5 @@ __all__ = [
133
134
  'ACCORDION',
134
135
  'STACK',
135
136
  'MULTI_SELECT',
137
+ 'TEXT'
136
138
  ]
@@ -0,0 +1,182 @@
1
+ """
2
+ Module implementing helper methods to create custom column definitions for Dash AG Grid tables
3
+ """
4
+ from enum import Enum
5
+ from enum import unique
6
+ from typing import Any
7
+ from typing import Dict
8
+ from typing import Optional
9
+
10
+ from ecodev_front.constants import COL_ID
11
+ from ecodev_front.tables.data_table import locale_fr_FR
12
+
13
+
14
+ @unique
15
+ class DagColTypes(str, Enum):
16
+ """
17
+ Enum listing the different filter types for a Dash AG Grid table
18
+ """
19
+ NUMERICAL = 'numerical'
20
+ DATE = 'date'
21
+
22
+
23
+ DAG_FILTERS = {
24
+ DagColTypes.NUMERICAL: 'agNumberColumnFilter',
25
+ DagColTypes.DATE: 'agDateColumnFilter'
26
+ }
27
+
28
+ DAG_TYPES = {
29
+ DagColTypes.NUMERICAL: 'numberColumn',
30
+ DagColTypes.DATE: 'dateString'
31
+ }
32
+
33
+
34
+ def custom_column_def(field: str | None = None,
35
+ header_name: Optional[str] = None,
36
+ width: Optional[int] = None,
37
+ dag_type: Optional[DagColTypes] = None,
38
+ sortable: Optional[bool] = False,
39
+ editable: bool | Dict = False,
40
+ value_formatter: Optional[str] = None,
41
+ locale: str = locale_fr_FR,
42
+ value_getter: Optional[str] = None,
43
+ cell_data_style: Optional[str] = None,
44
+ cell_renderer: Optional[str] = None,
45
+ cell_renderer_params: Optional[Dict] = None,
46
+ cell_style: Optional[Dict] = None,
47
+ cell_editor: Optional[str] = None,
48
+ cell_editor_params: Optional[Dict] = None,
49
+ single_click_edit: Optional[bool] = False,
50
+ pinned: Optional[str] = None,
51
+ checkbox_selection: Optional[bool] = False,
52
+ header_checkbox_selection: Optional[bool] = False,
53
+ suppress_movable: Optional[bool] = False,
54
+ suppress_menu: Optional[bool] = False,
55
+ header_tooltip: Optional[str] = None,
56
+ max_width: Optional[int] = None,
57
+ col_id: Optional[str] = None,
58
+ filter: Optional[bool] = None,
59
+ floating_filter: Optional[bool] = None,
60
+ other_params: Optional[dict] = {}) -> Dict[str, Any]:
61
+ """
62
+ Creates a column definition dictionary for Dash AG Grid.
63
+
64
+ Column definitions configure the behavior and appearance of individual columns
65
+ in the grid. See https://dash.plotly.com/dash-ag-grid/column-definitions
66
+
67
+ Args:
68
+ field (str): The field name that maps to a key in the row data. This is the
69
+ primary identifier linking the column to the data source.
70
+ header_name (Optional[str]): The display name shown in the column header.
71
+ Defaults to a title-cased version of `field` with underscores replaced by spaces.
72
+ header_tooltip (Optional[str]): The tooltip shown in the column header.
73
+ Defaults to None.
74
+ width (Optional[int]): The initial width of the column in pixels.
75
+ See https://dash.plotly.com/dash-ag-grid/column-sizing
76
+ max_width (Optional[int]): The maximum width of the column in pixels. Use max-width when
77
+ the default column size = 'responsiveSizeToFit'
78
+ col_id (Optional[str]): The ID of the column.
79
+ See https://dash.plotly.com/dash-ag-grid/column-ids
80
+ filter (Optional[bool]): If True, enables filtering when clicking the column header.
81
+ Defaults to True.
82
+ floating_filter (Optional[bool]): If True, enables the floating filter feature of the column
83
+ Defaults to True.
84
+ dag_type (Optional[DagColTypes]): The column data type (NUMERICAL or DATE).
85
+ Determines the appropriate filter type and value formatter.
86
+ sortable (Optional[bool]): If True, enables sorting when clicking the column header.
87
+ Defaults to False.
88
+ editable (bool | Dict): If True, allows cell editing. Can also be a dict with
89
+ a 'function' key for conditional editing based on row data.
90
+ See https://dash.plotly.com/dash-ag-grid/cell-editing
91
+ value_formatter (Optional[str]): A d3-format string or JS function to format
92
+ displayed cell values. For NUMERICAL type, specifies decimal precision.
93
+ See https://dash.plotly.com/dash-ag-grid/value-formatters
94
+ locale (str): The d3.formatLocale configuration for number/currency formatting.
95
+ Defaults to French locale (comma decimal, space thousands separator).
96
+ value_getter (Optional[str]): A JS function string to compute cell values from
97
+ row data, useful for calculated or derived columns.
98
+ See https://dash.plotly.com/dash-ag-grid/value-getters
99
+ cell_data_style (Optional[str]): Custom data style attribute for cells.
100
+ cell_renderer (Optional[str]): Name of a custom component to render cell content.
101
+ Use for buttons, links, or complex cell displays.
102
+ See https://dash.plotly.com/dash-ag-grid/cell-renderer-components
103
+ cell_renderer_params (Optional[Dict]): Parameters passed to the cellRenderer component.
104
+ cell_style (Optional[Dict]): CSS style dict applied to cells in this column.
105
+ See https://dash.plotly.com/dash-ag-grid/cell-styling
106
+ cell_editor (Optional[str]): Name of a custom editor component for cell editing.
107
+ See https://dash.plotly.com/dash-ag-grid/cell-editor-components
108
+ cell_editor_params (Optional[Dict]): Parameters passed to the cellEditor component.
109
+ single_click_edit (Optional[bool]): If True, enables single click edit when clicking the
110
+ column cell. Defaults to False.
111
+ other_params (Optional[dict]): Additional AG Grid column properties to merge
112
+ into the definition.
113
+ pinned (Optional[str]): Position of the column. Defaults to None.
114
+ Possible values are 'left', 'right', 'center'.
115
+ checkbox_selection (Optional[bool]): If True, enables checkbox selection when clicking the
116
+ column cell. Defaults to False.
117
+ header_checkbox_selection (Optional[bool]): If True, enables checkbox selection when
118
+ clicking the header. Defaults to False.
119
+ suppress_movable (Optional[bool]): If True, disables the movable feature of the column.
120
+ suppress_menu (Optional[bool]): If True, disables the menu feature of the column.
121
+
122
+ Returns:
123
+ Dict[str, Any]: A column definition dictionary compatible with Dash AG Grid's columnDefs.
124
+ """
125
+ return {
126
+ 'field': field,
127
+ 'headerName': header_name or field.replace('_', ' ').title() if field else '',
128
+ 'headerTooltip': header_tooltip,
129
+ 'width': width,
130
+ 'maxWidth': max_width,
131
+ COL_ID: col_id,
132
+ 'filter': filter or DAG_FILTERS.get(dag_type, True), # type: ignore[arg-type]
133
+ 'floatingFilter': floating_filter,
134
+ 'sortable': sortable,
135
+ 'editable': editable,
136
+ 'type': DAG_TYPES.get(dag_type), # type: ignore[arg-type]
137
+ 'valueFormatter': _get_value_formatter(dag_type, value_formatter, locale),
138
+ 'valueGetter': {'function': value_getter},
139
+ 'filterValueGetter': {'function': "d3.timeParse('%d/%m/%Y')(params.data.date)"} if
140
+ dag_type == DagColTypes.DATE else None,
141
+ 'cellDataStyle': cell_data_style,
142
+ 'cellRenderer': cell_renderer,
143
+ 'cellRendererParams': cell_renderer_params,
144
+ 'tooltipField': field,
145
+ 'cellStyle': cell_style,
146
+ 'cellEditor': cell_editor,
147
+ 'cellEditorParams': cell_editor_params,
148
+ 'singleClickEdit': single_click_edit,
149
+ 'pinned': pinned,
150
+ 'checkboxSelection': checkbox_selection,
151
+ 'headerCheckboxSelection': header_checkbox_selection,
152
+ 'suppressMovable': suppress_movable,
153
+ 'suppressMenu': suppress_menu,
154
+ } | (other_params or {})
155
+
156
+
157
+ def _get_value_formatter(dag_type: DagColTypes | None,
158
+ value_formatter: str | None,
159
+ locale: str
160
+ ) -> Optional[Dict[str, str]]:
161
+ """
162
+ Returns a value formatter based on the type of the column
163
+ """
164
+ if dag_type == DagColTypes.NUMERICAL:
165
+ return {'function': f"{locale}.format(',.{value_formatter}')(params.value)"}
166
+ return {'function': 'params.data.date'} if dag_type == DagColTypes.DATE else None
167
+
168
+
169
+ CELL_STYLE_CENTER = {
170
+ 'display': 'flex',
171
+ 'justifyContent': 'center',
172
+ 'alignItems': 'center',
173
+ }
174
+
175
+ CHECKBOX_COLUMN_DEF = custom_column_def(
176
+ max_width=50,
177
+ pinned='left',
178
+ checkbox_selection=True,
179
+ header_checkbox_selection=True,
180
+ suppress_movable=True,
181
+ suppress_menu=True,
182
+ )
@@ -4,7 +4,6 @@ Module implementing a generic Dash AG Grid table
4
4
  from typing import Any
5
5
  from typing import Dict
6
6
  from typing import List
7
- from typing import Optional
8
7
  from typing import Union
9
8
 
10
9
  import dash_ag_grid as dag
@@ -36,49 +35,96 @@ DAG_ENTERPRISE_AUTH = DashAgGridEnterprise()
36
35
 
37
36
 
38
37
  def data_table(id: str | dict,
39
- row_data: List[Dict] | Any,
38
+ row_data: list[dict[Any, Any]] | Any,
40
39
  column_defs: list[dict[Any, Any]] | None = None,
41
40
  default_col_def: dict | None = None,
41
+
42
42
  style: dict | None = None,
43
43
  row_style: dict | None = None,
44
44
  dash_grid_options: dict | None = None,
45
+
45
46
  pagination: bool = False,
46
47
  pagination_page_size: int = 5,
48
+
47
49
  tree_table: bool = False,
50
+
48
51
  floating_filter: bool = False,
49
52
  wrap_text: bool = False,
50
53
  theme: str = 'ag-theme-quartz',
51
54
  side_filter: bool = False,
52
55
  autogenerate_column_defs: bool = True,
53
- selected_rows: List[Dict] | Any = None,
56
+ selected_rows: list[dict[Any, Any]] | Any = None,
54
57
  auto_height: bool = False,
58
+
55
59
  hide_empty_cols: bool = False,
56
60
  empty_cols_to_show: list[str] = [],
57
- get_row_id: Optional[str] = None,
61
+
62
+ get_row_id: str | None = None,
63
+
58
64
  draggable: bool = False,
65
+
66
+ row_selection: str = 'single',
67
+ suppress_row_click_selection: bool = True,
68
+ group_selects_children: bool = True,
69
+
70
+ header_name: str = '',
71
+ default_expanded_depth: int = 0,
72
+ auto_group_column_field: str | None = None,
73
+
74
+
59
75
  **kwargs,
60
76
  ) -> dag.AgGrid:
61
77
  """
62
78
  Generic Dash AG Grid table
63
79
 
64
80
  Args:
81
+ id (str | dict): id of the table.
82
+ row_data (list[dict[Any, Any]] | Any): list of rows to display in the table.
83
+ column_defs (list[dict[Any, Any]]): list of column definitions.
84
+ default_col_def (dict): default column definition.
85
+ style (dict): style of the table.
86
+ row_style (dict): style of the rows.
87
+ dash_grid_options (dict): dash grid options.
88
+
89
+ pagination (bool): if True, adds pagination to the table.
90
+ pagination_page_size (int): length of the pagination.
91
+
92
+ tree_table (bool): if True, the table is a tree table.
93
+ header_name (str): name of the header of the tree table.
94
+ default_expanded_depth (int): default expanded depth of the tree table. Defaults to 0.
95
+ (0 = All collapsed, 1 = First level expanded, -1 = All expanded)
96
+ auto_group_column_field (str): field whose values will be used in the autogroup column.
97
+ If None, then then values of `path` will be used. Defaults to None.
98
+
65
99
  side_filter (bool): if True, adds a side bar with filtering options. Filters \
66
100
  will be generated for columns according to the config in column_defs. Overwrites
67
101
  the sidebar key in dash_grid_options
68
102
  autogenerate_column_defs (bool): if True, creates column_defs from row_data if \
69
103
  column_defs is not provided. Defaults to True.
70
- selected_rows (list): list of rows to select. Applies only to table with selectable \
71
- columns
104
+
72
105
  auto_height (list): if True, the grid to auto-sizes its height to the number of rows \
73
106
  displayed inside the grid. Overwrites the domLayout key in dash_grid_options and
74
107
  height in style
108
+ group_selects_children (bool): if True, then selecting a node will select all its \
109
+ children. Defaults to True.
110
+
75
111
  get_row_id (Optional[str]): js function to assign the `RowID` of each row in row_data \
76
112
  from the table's data. Ex : "params.data.id" to assign it to "id" field.
77
113
  See https://dash.plotly.com/dash-ag-grid/row-ids for more information.
114
+ selected_rows (list): list of rows to select. Applies only to table with selectable \
115
+ columns. selected_rows must be initialized to an empty list if no rows are selected.
116
+ row_selection (str): selection mode of the table. Defaults to 'single'.
117
+ Possible values are 'single', 'multiple' and 'singleRow'.
118
+ suppress_row_click_selection (bool): Prevents selecting a row by clicking anywhere on it.
119
+ Selection only happens via the checkbox. This avoids accidental selection when users click
120
+ to expand/collapse.
121
+
122
+ theme (str): theme of the table. Defaults to 'ag-theme-quartz'.
78
123
  """
79
124
 
80
125
  column_defs = column_defs or _create_default_column_definitions(
81
126
  row_data) if autogenerate_column_defs else []
127
+
82
128
  style = style
83
129
  default_col_def = default_col_def or {
84
130
  # enable floating filters by default
@@ -92,12 +138,14 @@ def data_table(id: str | dict,
92
138
 
93
139
  dash_grid_options = dash_grid_options or {
94
140
  'colResizeDefault': 'shift',
95
- 'rowSelection': 'single',
141
+ 'rowSelection': row_selection,
142
+ 'suppressRowClickSelection': suppress_row_click_selection,
96
143
  'headerHeight': 50,
97
144
  'groupHeaderHeight': 30,
98
145
  # Enables pagination
99
146
  'pagination': pagination,
100
147
  'paginationPageSize': pagination_page_size,
148
+ 'groupSelectsChildren': group_selects_children,
101
149
  }
102
150
 
103
151
  if side_filter:
@@ -106,13 +154,16 @@ def data_table(id: str | dict,
106
154
  if tree_table:
107
155
  dash_grid_options |= {
108
156
  'autoGroupColumnDef': {
157
+ 'field': auto_group_column_field,
158
+ 'headerName': header_name,
159
+ 'filterParams': {'treeList': True},
109
160
  'cellRendererParams': {
110
161
  'suppressCount': True,
111
162
  },
112
163
  },
113
164
  'getDataPath': {'function': 'getDataPath(params)'},
114
165
  'treeData': True,
115
- 'rowSelection': 'single',
166
+ 'groupDefaultExpanded': default_expanded_depth,
116
167
  }
117
168
 
118
169
  if auto_height:
@@ -155,14 +206,16 @@ def data_table(id: str | dict,
155
206
  licenseKey='',
156
207
  columnDefs=column_defs,
157
208
  rowData=row_data,
158
- selectedRows=selected_rows,
159
209
  defaultColDef=default_col_def,
160
210
  style=style,
161
211
  getRowStyle=row_style,
162
212
  columnSize='responsiveSizeToFit',
163
213
  dashGridOptions=dash_grid_options,
164
214
  className=theme,
215
+
165
216
  getRowId=get_row_id,
217
+ selectedRows=selected_rows or [],
218
+
166
219
  **kwargs,
167
220
  )
168
221
 
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "ecodev-front"
3
- version = "0.0.97"
3
+ version = "0.0.99"
4
4
  description = "Dash component helpers"
5
5
  authors = ["Amaury Salles <amaury.salles@gmail.com>",
6
6
  "Yoann Diep <yoann.diep@hotmail.fr>",
@@ -1,83 +0,0 @@
1
- """
2
- Module implementing helper methods to create custom column definitions for Dash AG Grid tables
3
- """
4
- from enum import Enum
5
- from enum import unique
6
- from typing import Any
7
- from typing import Dict
8
- from typing import Optional
9
-
10
- from ecodev_front.tables.data_table import locale_fr_FR
11
-
12
-
13
- @unique
14
- class DagColTypes(str, Enum):
15
- """
16
- Enum listing the different filter types for a Dash AG Grid table
17
- """
18
- NUMERICAL = 'numerical'
19
- DATE = 'date'
20
-
21
-
22
- DAG_FILTERS = {
23
- DagColTypes.NUMERICAL: 'agNumberColumnFilter',
24
- DagColTypes.DATE: 'agDateColumnFilter'
25
- }
26
-
27
- DAG_TYPES = {
28
- DagColTypes.NUMERICAL: 'numberColumn',
29
- DagColTypes.DATE: 'dateString'
30
- }
31
-
32
-
33
- def custom_column_def(field: str,
34
- header_name: Optional[str] = None,
35
- width: Optional[int] = None,
36
- dag_type: Optional[DagColTypes] = None,
37
- sortable: Optional[bool] = False,
38
- editable: bool | Dict = False,
39
- value_formatter: Optional[str] = None,
40
- locale: str = locale_fr_FR,
41
- value_getter: Optional[str] = None,
42
- cell_data_style: Optional[str] = None,
43
- cell_renderer: Optional[str] = None,
44
- cell_renderer_params: Optional[Dict] = None,
45
- cell_style: Optional[Dict] = None,
46
- cell_editor: Optional[str] = None,
47
- cell_editor_params: Optional[Dict] = None,
48
- other_params: Optional[dict] = {}) -> Dict[str, Any]:
49
- """
50
- Creates a custom def dict
51
- """
52
- return {
53
- 'field': field,
54
- 'headerName': header_name or field.replace('_', ' ').title(),
55
- 'width': width,
56
- 'filter': DAG_FILTERS.get(dag_type, True), # type: ignore[arg-type]
57
- 'sortable': sortable,
58
- 'editable': editable,
59
- 'type': DAG_TYPES.get(dag_type), # type: ignore[arg-type]
60
- 'valueFormatter': _get_value_formatter(dag_type, value_formatter, locale),
61
- 'valueGetter': {'function': value_getter},
62
- 'filterValueGetter': {'function': "d3.timeParse('%d/%m/%Y')(params.data.date)"} if
63
- dag_type == DagColTypes.DATE else None,
64
- 'cellDataStyle': cell_data_style,
65
- 'cellRenderer': cell_renderer,
66
- 'cellRendererParams': cell_renderer_params,
67
- 'tooltipField': field,
68
- 'cellStyle': cell_style,
69
- 'cellEditor': cell_editor,
70
- 'cellEditorParams': cell_editor_params
71
- } | other_params
72
-
73
-
74
- def _get_value_formatter(dag_type: DagColTypes | None,
75
- value_formatter: str | None,
76
- locale: str
77
- ) -> Optional[Dict[str, str]]:
78
- """
79
- Returns a value formatter based on the type of the column
80
- """
81
- if dag_type == DagColTypes.NUMERICAL:
82
- return {'function': f"{locale}.format(',.{value_formatter}')(params.value)"}
83
- return {'function': 'params.data.date'} if dag_type == DagColTypes.DATE else None
File without changes
File without changes