AF
Ash Framework•2mo ago
Pako

Can the Admin UI show calculations?

I have two resources; One acting as a course template and one for actualized, planned courses. Both have a price attribute with the intention that if an actualized course does not have a price it will use the default price from its template. This works fine when looking at the result of a read action in iex but the Admin UI doesn't want to show that calculation anywhere. Is this just not part of what AshAdmin is meant to do? This is not really a breaking issue as I will have to write my own dashboard UI on top of this anyway, it would've just been nice to be able to quickly check AshAdmin to see if changes in my resources work as intended.
10 Replies
ken-kost
ken-kost•2mo ago
🤔 do you have public? true on your calculations?
Pako
PakoOP•2mo ago
Huh, I didn't even know you could/had to do that. I tried
calculations do
calculate :price_net, :money do
public? true

expr(...)
end
end
calculations do
calculate :price_net, :money do
public? true

expr(...)
end
end
and moving public? true into the calculations block but in both cases the compiler gets angry because public? doesn't exist
ZachDaniel
ZachDaniel•2mo ago
calculations do
calculate :price_net, :money do
public? true

calculation expr(...)
end
end
calculations do
calculate :price_net, :money do
public? true

calculation expr(...)
end
end
it should work
Pako
PakoOP•2mo ago
Just tried that and it compiles but the calculation still does not show anywhere in the Admin UI
No description
No description
Pako
PakoOP•2mo ago
Huh, that page implies all calculations are included by default. I didn't explicitly overwrite that. Thank you very much for pointing this page out in general though. I was not aware that there is this much control over how AshAdmin handles resources!
ZachDaniel
ZachDaniel•2mo ago
Oh, you want table_columns -- nvm
Pako
PakoOP•2mo ago
I just tried explicitly telling it to show the calculation and that worked. weird. it shows up as a separate box below the resource itself
ZachDaniel
ZachDaniel•2mo ago
Yeah Are you looking to edit the show page or the table? They are done differently IIRC
Pako
PakoOP•2mo ago
I mainly just wanted to see calculations somewhere so I can quickly check if my calculations work properly instead of having to run the app through iex not sure which message to mark as solution, I think I'll go with the one that has the doc link?

Did you find this page helpful?