Commit 435d6cc
committed
feat: allow custom field mappings
I would like to have some custom fields consistently through whole
application and I didn't find any way how to currently do this.
My reasoning is that writing AshBackpex resources should be as brief as
possible and I really hate the idea of adding `module` to i.e. each
field with date.
Ideal solution would be to have :field_mappings in Application config
which would be found by AshBackpex. But I suppose libraries shouldn't be
based on anything in application so I'm introducing new "attribute" for
resource named field_mappings working like this:
field_mappings: %{
Ash.Type.UtcDatetime => MyappWeb.Backpex.Fields.RelativeDateTime,
Ash.Type.UtcDatetimeUsec => MyappWeb.Backpex.Fields.RelativeDateTime,
Ash.Type.DateTime => MyappWeb.Backpex.Fields.RelativeDateTime,
Ash.Type.NaiveDateTime => MyappWeb.Backpex.Fields.RelativeDateTime
}
That way I can use my custom module with backpex macro which set this as
default for all my admin pages.
Simple test covering the functionality is included.1 parent c890795 commit 435d6cc
4 files changed
Lines changed: 109 additions & 51 deletions
File tree
- lib/ash_backpex/live_resource
- transformers
- test
- ash_backpex/live_resource
- support
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
309 | 309 | | |
310 | 310 | | |
311 | 311 | | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
312 | 318 | | |
313 | 319 | | |
314 | 320 | | |
| |||
Lines changed: 59 additions & 51 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
| 149 | + | |
149 | 150 | | |
150 | | - | |
151 | | - | |
152 | | - | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
153 | 157 | | |
154 | | - | |
155 | | - | |
| 158 | + | |
| 159 | + | |
156 | 160 | | |
157 | | - | |
158 | | - | |
| 161 | + | |
| 162 | + | |
159 | 163 | | |
160 | | - | |
161 | | - | |
| 164 | + | |
| 165 | + | |
162 | 166 | | |
163 | | - | |
164 | | - | |
| 167 | + | |
| 168 | + | |
165 | 169 | | |
166 | | - | |
167 | | - | |
| 170 | + | |
| 171 | + | |
168 | 172 | | |
169 | | - | |
170 | | - | |
| 173 | + | |
| 174 | + | |
171 | 175 | | |
172 | | - | |
173 | | - | |
| 176 | + | |
| 177 | + | |
174 | 178 | | |
175 | | - | |
176 | | - | |
| 179 | + | |
| 180 | + | |
177 | 181 | | |
178 | | - | |
179 | | - | |
| 182 | + | |
| 183 | + | |
180 | 184 | | |
181 | | - | |
182 | | - | |
| 185 | + | |
| 186 | + | |
183 | 187 | | |
184 | | - | |
185 | | - | |
| 188 | + | |
| 189 | + | |
186 | 190 | | |
187 | | - | |
188 | | - | |
| 191 | + | |
| 192 | + | |
189 | 193 | | |
190 | | - | |
191 | | - | |
| 194 | + | |
| 195 | + | |
192 | 196 | | |
193 | | - | |
194 | | - | |
| 197 | + | |
| 198 | + | |
195 | 199 | | |
196 | | - | |
197 | | - | |
| 200 | + | |
| 201 | + | |
198 | 202 | | |
199 | | - | |
200 | | - | |
| 203 | + | |
| 204 | + | |
201 | 205 | | |
202 | | - | |
203 | | - | |
| 206 | + | |
| 207 | + | |
204 | 208 | | |
205 | | - | |
206 | | - | |
| 209 | + | |
| 210 | + | |
207 | 211 | | |
208 | | - | |
209 | | - | |
| 212 | + | |
| 213 | + | |
210 | 214 | | |
211 | | - | |
212 | | - | |
| 215 | + | |
| 216 | + | |
213 | 217 | | |
214 | | - | |
215 | | - | |
| 218 | + | |
| 219 | + | |
216 | 220 | | |
217 | | - | |
218 | | - | |
| 221 | + | |
| 222 | + | |
219 | 223 | | |
220 | | - | |
221 | | - | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
222 | 230 | | |
223 | | - | |
224 | | - | |
| 231 | + | |
| 232 | + | |
225 | 233 | | |
226 | 234 | | |
227 | 235 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
106 | 116 | | |
107 | 117 | | |
108 | 118 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
0 commit comments