avo-hq / avo Goto Github PK
View Code? Open in Web Editor NEWBuild Ruby on Rails apps 10x faster
Home Page: https://avohq.io
License: Other
Build Ruby on Rails apps 10x faster
Home Page: https://avohq.io
License: Other
Scenario:
bin/webpack-dev-server
/avocado
Avo depends on Webpacker in test environment, which causes normal app without Webpacker installation to fail.
Puma caught this error: undefined method `javascript_pack_tag' for #<ActionView::Base:0x00000000026ef8>
Did you mean? javascript_path
javascript_tag (ActionView::Template::Error)
/Users/thachchau/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/manifester-0.1.7/lib/manifester/helper.rb:109:in `javascript_manifest_tag'
/Users/thachchau/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/avo-1.3.4/app/views/layouts/avo/application.html.erb:12:in `___sers_thachchau__asdf_installs_ruby_______lib_ruby_gems_______gems_avo_______app_views_layouts_avo_application_html_erb___3104381627434387194_79640'
Manually update this code snippet helps the test to pass
def manifester
@manifester ||= ::Manifester::Instance.new(
root_path: ROOT_PATH,
public_output_dir: "avo-packs",
cache_manifest: Rails.env.production?,
fallback_to_webpacker: -> { false }
)
end
Development works well, as expected. Please have a look if you have time ๐ฏ
And thanks for the awesome work ๐
Hi,
The avo gem depends on the ISO gem. If Iโm not mistaken, the dependency is missing in the gemspec file.
regards,
Nicolas
The initial field declaration API on actions was the block notation.
fields do
boolean :notify_user
textarea :message, default: 'Your account has been marked as inactive.'
end
The second iteration (that wasn't really published at all) got the def
treatment.
def fields(request)
f.boolean :notify_user, default: true
f.text :message, default: 'Your account has been marked as inactive.'
end
After talking with Thomas Klemm, he suggested we use a different type, more familiar type of declaration.
fields do |field|
field.boolean :notify_user, default: true
field.text :message, default: 'Your account has been marked as inactive.'
This ๐ looks very familiar to rails developers (kind of like form do |f|
).
There are some caveats though. Because the fields
method is being run only at boot time, you don't have any control over it on runtime.
Example: Let's say you have a TicketResource
that can have multiple types of attributes, and some are optional. You might not have all tickets with all the data filled in. Let's say the ticket might/might not have the email
attribute.
You might have an action that marks the ticket as resolved and if the ticket has an email
attribute present you might want to send a message to it.
The requirement here is to show the textarea field on the action if the ticket has the email
attribute present and have it hidden (or disabled) if that attribute is missing.
You can't really implement that requirement if the fields registration is being done on boot time. You can only do that at runtime when you have access to that model
object.
Go back to the def fields
API. This way we can instantiate the fields on runtime. This API also allows us to pass in more than just that model. We can pass the params
, request
, or a custom context
object and build the fields based on those objects if we want to.
the action might look something like this.
class MarkResolved < Avo::BaseAction
self.name = 'Mark ticket resolved'
def handle(models:, fields:)
models.each do |model|
model.update resolved: true
model.send_resolved_notification fields[:message] if fields[:notify_user]
end
succeed 'Perfect!'
end
def fields(field, model:, **args)
# Show the fields only if it was accessed on one model and that model has the `email` attribute present
if models.blank? && model.email.present?
field.boolean :notify_user, default: true
field.text :message, default: 'The ticket was resolved.'
end
end
end
The args
can hold multiple named arguments like the request
, params
, context
, models
(if multiple were selected).
fields
API for Resource
objects?I don't think it's wise to use different APIs for declaring fields on Resource
s and Action
s. They have to be implemented the same way in both classes, so I'm proposing to change it there as well, bringing the advantages of runtime updates too.
when saving a boolean group field, instead of booleans it saves the string values of the booleans
something related
https://stackoverflow.com/questions/53182837/ruby-rails-saving-json-and-parsing-it-back-to-boolean-values-in-view
The flow is this one:
data
changesThe modal works only for the initial request.
I have a model named business_places
. The class name of the generated controller is wrong and crashes the app.
Steps to reproduce the behavior:
bin/rails generate avo:resource business_place
app/controllers/avo/business_places_controller.rb
class Avo::Business placesController < Avo::ResourcesController
which is obviously wrong.First line should read class Avo::BusinessPlacesController < Avo::ResourcesController
First line reads as class Avo::Business placesController < Avo::ResourcesController
which is obviously wrong.
Avo version: 1.2.8
Rails version: 6.1.3
Ruby version: 2.7.2
At the moment Avo supports custom filters that are separate classes. That might get tedious at some point.
Rails already has scopes. We might be able to implement filters really quick as one-liners inside the Resource
class without building that whole clunky-at-times Filter
class.
The Filter
class can still be present in the app for more complex filters that can't be configured from one scope.
Some inspiration here:
From #414
The custom field generator generates several view components that are used to render the field. It would be nice if the generator could make use of a configuration option that allows the directory of these generated components to change. Currently, it places the components in app/components
, but in my apps, I put components in different directories, such as app/view_components
or app/frontend/components
.
When using array enums Avo won't display them properly
Steps to reproduce the behavior:
enum status: [:draft, :published, :archived]
field :status, as: :select, enum: ::Product.statuses
See the enum
See the empty dash
Avo version: 1.1.0
When I attach an image to a post (even on your demo site) it appears as clickable one and also inserts the hyperlink as well.
That hyperlink can be then edited as caption, otherwise it stays and shows as a link to image.
However we do not need that caption or link. Indeed, we do not want to have image clickable either.
How can this be fixed?
Your default images in demo are not clickable and do not show any hyperlinks or captions - we want to replicate exactly the same behaviour but failed to do that locally on our own app as well as in your online demo as stated above.
Please help.
This focuses on fixing the rewrite bugs and bringing on improvements
We're rewriting Avo with Hotwire. This should make it a lot easier to update & extend.
Let's start on the next tier of fields:
waiting
, running
, or finished
IsoCountryCodes
)Hi,
The Avo::ApplicationMailer
should inherits ::ActionMailer::Base
(missing the ::
)
This is failing some tools such as erd (https://github.com/voormedia/rails-erd) as the Avo::ApplicationMailer
can't be loaded
irb(main):004:0> Avo::ApplicationMailer
Traceback (most recent call last):
2: from (irb):3
1: from (irb):4:in `rescue in irb_binding'
NameError (uninitialized constant Avo::ActionMailer)
Did you mean? ActionView
Regards,
Nicolas
The user should be able to add & change the belongs to relation inline in the edit view.
We're working towards v1.0 coming mid/late march.
Hi,
I'm trying to use the file field with a shrine column and I keep getting an error of
undefined method 'attached?' for nil class.
I'm not sure if it's a problem on my end or if it's because of the gem.
Setup is straight forward, installed shrine gem, did a database migration to add image_data as a json column to my Post model and then used the file field on the shrine virtual attribute (column is :image_data)
file :image, is_image: true
Fields left for the Hotwire rewrite
Hi,
Imagine you have a resource has_and_belongs_to_many
with option class_name
At the moment, the linked resource can't be found.
Resource should be found the same way the has_many
field
it should be like this
avo/lib/avo/app/fields/has_many.rb
Lines 45 to 46 in 779951c
Regards,
Nicolas
Unit tests for rails
Unit & integration tests for the whole UI.
Right now we have a webpacker pipeline that plugs into the asset pipeline of the app.
The issue with this that when the app's asset pipeline is triggered it also triggers avo's pipeline and we don't want that. We need to allow the customer to enable this behaviour when he needs it.
Have an independent webpacker asset pipeline that we can trigger it when we want it when we build for release and have the dev server for dev.
Settle on a public API for declaring fields and other things
It's related to hotwired/turbo#249.
Steps to reproduce the behavior:
TO be able to click the attach button
Button is disabled
Avo version: 1.3.5
Rails version:
Ruby version:
Add the ability for devs to add their own custom fields to Avo
belongs_to
has_one
has_many
has_many_through
has_one_through
has_and_belongs_to_many
has_many
polymorphicWe are using Friendly IDs gem to make friendly URLs for one of our model - Page. So we have:
class Page < ApplicationRecord
extend FriendlyId
friendly_id :name, use: :slugged
end
However if we try to manage Page resource using Avo it fails to find page id.
We tried to create a class and add extend as follows:
class Avo::ApplicationController < ActionController::Base
extend FriendlyId
friendly_id :name, use: :slugged
end
But this throwas an error.
Eventually I found a temporary solution to hack one of the avo classes as follows:
def set_model
@model = if @resource.model_class.name == 'Page'
eager_load_files(@resource, @resource.model_class).friendly.find params[:id]
else
eager_load_files(@resource, @resource.model_class).find params[:id]
end
end
Please can we have a proper solution so we can use both your gem and Friendly IDs gem in a number of our commercial applications? Many thanks in advance.
The value can be removed by selecting the content of datetime field and press delete and then esc to close the datepicker. Be aware that this issue is related only to datetime field and not date.
Also pondering to make the fields wider... Not sure
Originally posted by @adrianthedev in #77 (comment)
Avo shows custom tools license warning banner if used on root path /
even if it's not using custom tools.
Steps to reproduce the behavior:
avo.rb
initializer edit the root_path
to /
/avo
You should not see the banner.
You will see the banner.
Avo version:
Rails version:
Ruby version:
.or
operator doesn't work for queries that use joins. The following error is thrown.
Relation passed to #or must be structurally compatible. Incompatible values: [:joins]
Refresh previous Vue tests
This should work for create
and (later on) action fields.
We need to add some client side validations to our fields.
The rules are:
required
which will not allow the user to submit the form if the field is not filled andreadonly
. The field will not show up in the create
or update
views.nullable
. Not a validation rule per se, but we can do it in this ticket. This should convert empty values ''
to null
in the db.Hi,
The belongs_to
field relation is not working.
Looking at the code, I think the error is right here:
avo/lib/avo/app/fields/belongs_to.rb
Line 25 in 017aa12
As we can see, the name is used to find the resource. I think this is a mistake as the name could be anything.
The relation's class name should be used (as it is for the has_many
field)
Something like this :
class_name = model._reflections[id.to_s].options[:class_name].present? ? model._reflections[id.to_s].options[:class_name] : model._reflections[id.to_s].name
App.get_resources.find { |r| r.class == "Avo::Resources::#{class_name.to_s.camelcase.singularize}".safe_constantize }
For our initial release we should have a few fields available out of the box.
This is a list of good initial fields. Let's just add them.
Hi,
The Avo configuration uses the iso gem.
In the locale_tag
method, this gem is used but should use the global scope
cf
Line 48 in f934862
example :
irb(main):007:0> Avo.configuration.locale_tag
Traceback (most recent call last):
1: from (irb):7
NameError (uninitialized constant Avo::Configuration::ISO)
irb(main):008:0>
The result is that the default locale is changed to en
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.