Comments (9)
sure, if we look at the ActiveRecord adapter
https://github.com/TrestleAdmin/trestle/blob/master/lib/trestle/adapters/active_record_adapter.rb
all methods (except default_attributes
) looks pretty trivial to reproduce with sequel related methods...
i can even try to do it but hope for any approvements from contributors before i dedicate some time for this
from trestle.
i think it is little early to make a PR because i didn't test it enough, so here is just a snippet with sequel adapter code
https://gist.github.com/okliv/4822101ec49d16056fc56ad540ad7ca3
full list of changes to get it work is here: https://gist.github.com/okliv/52465d38a116688edf0033985e273d27
and UPD 2 (about auth plugin). i get it work too.
all changes i made for now (on auth plugin side) to get it expectably work are listed here https://gist.github.com/okliv/dbdcbb52076beaa9523ea972ca301203
from trestle.
I believe its possible to create a sequel adapter following the pattern at
'lib/trestle/adapters' and setting it on the :default_adapter config option on a project, right?
from trestle.
As @rennanoliveira mentioned, creating an adapter will be the correct way to do this. I'd definitely love to have a Sequel adapter included in Trestle core, although I'm not myself particularly familiar with it, so if you'd love to have a go then that'd be great.
If you find any of the adapter abstractions insufficient for Sequel, please let me know and we can try to make the necessary changes.
from trestle.
Today i have successfully seen my sequel model's data under /admin route so i can confirm it has a potential to be a frontend for sequel. during this quick test i had some errors too... mostly, NoMethodError
for my sequel model class (i defined all missing methods, except model_name
, "manually" for now just to remove exceptions):
#lib/trestle/resource.rb:155:in `default_model_name'
#fixed with Sequel::Model.plugin :active_model
model_name
#lib/trestle/attribute.rb:30:in `inheritance_column?'
inheritance_column
#lib/trestle/form/fields/check_box.rb:23:in `block (2 levels) in field'
human_attribute_name(attr)
So, i think, this methods need to be extracted to adapter too (or, will it be better to extend sequel class definition?)
In a few days i will try to test more deeply (for example, for now i've defined default_attributes
as a simple Attribute.new()
collection because reflections mapping for sequel models need more time)
going to test search and auth plugins...
UPD (search-plugin):
search is very basic one (not parametric) so there is no any problems at all (but, honestly, i need much more functional search like ransack-based for ActiveAdmin or https://github.com/djellemah/philtre for sequel)
as a quick workaround for now for me (just because there is only one text field that can be used for search) i've done this:
#after i added a "philtre" gem
search do |q|
Philtre.new( eval("{#{q}}") ).apply( MySequelModel.dataset )
end
and now i can simply input into the search field something like this: title_like: "bread"
or id: 1234
and filtering works with title LIKE "%bread%"
or ID=1234
search snippets according to the philtre
syntax. it is not very user friendly (especially, for the end-user), but in my case, something - is better than nothing
auth will try to look tomorrow...
from trestle.
It sounds like you're making some good progress @okliv. If it's alright, I'd love to see what your Adapter
class looks like so far. Feel free to start a PR if you're so inclined.
-
For
model_name
andhuman_attribute_name
, these methods come from ActiveModel and IMO are pretty important for I18n. I'll look into how we can make these methods work even when the model doesn't define them. This would also entail making ActiveModel an explicit dependency (which should not be an issue since Rails is already a dependency). -
inheritance_column
will almost definitely need to be moved into theAdapter
class somehow. The methodsinheritance_column
andprimary_key
are used by theAttribute
class to determine when to show fields in the automatic tables and forms, so perhaps we should have methods such asshow_in_table?(attribute)
andshow_in_form?(attribute)
onAdapter
. This would allow adapters to also define additional logic for hidden fields if required.
What about auth and, especially, search plugins? Will it be comparable simple to adapt too, how do you think?
The trestle-search plugin at this stage has a "bring your own search method" approach, so I don't foresee any issues there.
For trestle-auth, I see one instance (https://github.com/TrestleAdmin/trestle-auth/blob/master/lib/trestle/auth/controller_methods.rb#L17) where I need to add an extra configuration block. Otherwise the configuration blocks should provide enough flexibility to bring your own User
class with a non-ActiveRecord ORM.
from trestle.
I've just pushed a heap of commits that should pave the way for completing Sequel adapter support. I still need to finish testing in my Sequel demo app, but it's looking good so far.
from trestle.
Given the latest changes I have made to Trestle, here is my SequelAdapter
module so far: https://gist.github.com/spohlenz/0b218de7a1636f5757bd6d30cc1abbb5
from trestle.
I've pushed a SequelAdapter
to master (https://github.com/TrestleAdmin/trestle/blob/master/lib/trestle/adapters/sequel_adapter.rb).
It can be used by adding the following line to your trestle.rb
:
config.default_adapter = Trestle::Adapters.compose(Trestle::Adapters::SequelAdapter)
from trestle.
Related Issues (20)
- uninitialized constant custom field rails 7 HOT 3
- Changing date format HOT 3
- Option to disable form as "show" view? HOT 1
- My custom helper not is recognized HOT 2
- How i use concerns at trestle? HOT 1
- Remove Multiple Records From MODEL Page
- WebSockets / action_cable support? HOT 2
- Pagination for a custom index View
- Fix typo for Vietnamese locale HOT 1
- Direct upload or chunked file upload support? HOT 2
- Fails without sassc-rails
- Unable to locate favicon.ico in public folder HOT 1
- Best Way To Provide a Select Dropdown for belongs_to that is optional HOT 2
- Filter with a select list
- Enum Radio Button Missing Current Selection HOT 11
- Errors on check_box fields not displaying HOT 2
- Customize navbar HOT 3
- Mongoid support HOT 2
- Use importmap in Trestle HOT 6
- Fix Brazilian Portuguese translation
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from trestle.