padrino / padrino-framework

Padrino is a full-stack ruby framework built upon Sinatra.
http://www.padrinorb.com
MIT License
3.36k stars 508 forks source link

New gui and jquery for admin #568

Closed DAddYE closed 11 years ago

DAddYE commented 13 years ago

The admin like now is great but doesn't fets all needs.

My idea is:

nesquena commented 13 years ago

Great idea!

dariocravero commented 12 years ago

Hi Davide,

I agree with you that the admin needs some changes and I'd like to help with that.

I can convert it to be a full Backbone application working in a single page environment. Now, that goes against your point of not using asynchronous calls to talk to the server but it will surely give a better user experience.

As for the theme, I was thinking in using twitter's bootstrap which in my opinion provides a solid base to have an app easily styled (and isn't hard to change if needed, e.g. for theming).

Digging a bit deeper, the javascript part could be either coffeescript or javascript (although I'm inclined to go the coffeescript way but we can let the user decide) and the templates could be parsed haml/erb (the server will keep haml and something like sprockets can convert it to a jst file on the fly -letting us reuse the existing tag helpers from padrino), ejs or eco.

What do you think guys? Cheers

DAddYE commented 12 years ago

Awesome Dario, it's a great idea! Feel free to start to write some code, we will merge it.

dariocravero commented 12 years ago

Great! :) I'll try to have something going by the end of the week and let you know...

DAddYE commented 12 years ago

Thanks!

DAddYE commented 12 years ago

Hey @dariocravero have you got time to look at that?

Thaaaaaaaaaaaaaaaaaaaaaaaaaaaanks!

dariocravero commented 12 years ago

Hey Davide!! Yes I did!! It's on its way.. It's just that we were looking at it with a friend (@tomparandyk) and a nice concept evolved from there so I'm working hard to make it happen. I'll put it here as soon as I can :)

DAddYE commented 12 years ago

Great, Im very curious to see something, ping me when I can! Thanks!

nesquena commented 12 years ago

Yeah I am also very curious to check it out. Thanks for putting that together @dariocravero

dariocravero commented 12 years ago

Thanks to you for the chance!.. I hope you like it as much as we're enjoying doing it!..

I think it's a nice redesign and rethought of the whole admin's flow. Hopefully it will help towards making Padrino become even more unique! :) Of course changes/suggestions will be more than welcome!..

minikomi commented 12 years ago

What do you think about easier support for adding/removing relations in admin?

I hacked together something just for my needs but it might be something to add using new admin specific from helpers?

I really like these multiple select dropdowns too.. http://harvesthq.github.com/chosen/

xavierRiley commented 12 years ago

In the spirit of agnostic Padrino, I'm not sure a backbone.js app is the best idea -- but I'd still love to see it!

I think the admin area could go a lot further toward the convenience of Django without losing too much flexibility. I've been working on something using naming conventions in the model to handle img uploads, mce fields etc. but it's still early days. I'll be putting it together as a plugin for general release as soon as I get the chance.

Would be much easier to customise the admin if the form fields were helper methods rather than 'static' erb/haml. This would also DRY the admin area views up significantly.

Is there a better place to discuss the future of the Padrino Admin than an issue thread? At the moment it's hard to see which direction its going in.

dariocravero commented 12 years ago

@minikomi, I see your point and I think it will be really good to have a way to handle the relations through the admin out of the box but the issue is that relations can be complex and tricky enough since they vary from depending on what you're using for your models, etc. Still I reckon it would be good to have something like that in.

@xavierRiley I agree with you in the fact that using Backbone ties the app to a vendor (actually, it's more than that: Backbone works on top of Underscore and jQuery/Zepto) isn't the best thing to do since the framework tries to be as agnostic as possible. On the other hand, I think that there will always be a trade-off (in this case, using a JS framework) when implementing this kind of solutions since it eases the development by using the framework's structure. I'm working hard to minimize the impact on the proposed new version while still providing a great user experience. Having said that, we could still create a no-JS version of the app if needed. I hope to be able to publish it for previewing in the following days. It will be great to get feedback on this :)

minikomi commented 12 years ago

Totally agree it's a sticky issue.. Which is why it might be a good way to go to give people the blocks they need to build their own rather than a single set way.

xavierRiley commented 12 years ago

Yes thinking about it, a more modular approach to the admin might work well.

If you take the view that you're just generating forms, then maybe having helper methods to output the various elements and widgets would make the dev process better.

ie. instead of the admin generating stuff like

f.label :my_thing
f.error_messages_for :my_thing
f.text_field {....}

maybe it could just have

admin_text_field(:my_thing, label)

admin_file_upload(:my_thing, label)

admin_text_field(:my_thing, label)

That way, you could have the various methods for relationships, add in custom logic for how to treat fields etc. More often than not, the input fields will be consistent throughout the admin area so this approach might work better. What do people think?

On Wed, Oct 12, 2011 at 3:45 PM, Adam Moore < reply@reply.github.com>wrote:

Totally agree it's a sticky issue.. Which is why it might be a good way to go to give people the blocks they need to build their own rather than a single set way.

Reply to this email directly or view it on GitHub:

https://github.com/padrino/padrino-framework/issues/568#issuecomment-2379982

Kyanmedia Ltd. Direct line: 01483 405217

Main number: 01483 548282 http://www.kyanmedia.com

Please note our new address: *_171 High Street__, _Guildford* GU1 3AJ****

Registered in _England_. Company number: 4575679

endoscient commented 12 years ago

Could it be very easy to be agnostic by leveraging fields_blocks like they are done in the StandardFormBuilder. For instance have something like this for accounts

= f.text_field_block :username
= f.text_field_block :email
= f.password_field_block :password
= f.password_field_block :password_confirmation, :caption => 'Confirmation'
= f.select_block :role, :options => access_control.roles
= f.submit_block "Save Changes"

Then just provide a default form builder like BootstrapFormBuilder to make a nice looking default, but still very easy to swap out and provide alternatives. Like https://gist.github.com/1282779 which I am using for my app currently.

nesquena commented 12 years ago

I like this idea, use the form builder system to allow new alternatives to be easily pluggable and interchangeable for admin. This could be really slick.

Maybe a base "admin form builder" which is then inherited by all the possible admin options...

DAddYE commented 12 years ago

Added here: f98ee9d82334d7a440ae1665132808fe80684c2c

We need to discuss about we should still support erb and slim for admin generation?

Still need to finish:

1) Sidebar for forms 2) Breadcrumbs

Good halloween to all!

WaYdotNET commented 12 years ago

YHEAA !!! very good work man!!!! but why you remove slim engine???

nesquena commented 12 years ago

Why would we remove support for erb and slim? Are you saying only users that generate with haml would be able to get admin?

WaYdotNET commented 12 years ago

IMHO : +1 slim (i use slim and haml in my project :D) Rewrite many times some code with different template engine is very very tedious :P:P

DAddYE commented 12 years ago

Yes, once we freeze admin I'll start to rewrite erb/slim.

According to me admin should be generated only in HAML without consider the engine of the layout. No?

WaYdotNET commented 12 years ago

i prefer slim... if you want , i rewrite to slim engine..

DAddYE commented 12 years ago

Yep now we should freeze features because is quite annoying rewrite x3 changes.

Now HAML is most common and well know so if I also prefer slim we eventually should follow what community want.

WaYdotNET commented 12 years ago

ok davide :D in my repo rewrite to slim... and if community request slim..it's work :P

dcu commented 11 years ago

is someone actively working on this?

WaYdotNET commented 11 years ago

I fork with twitter bootstrap into admin section

xavierRiley commented 11 years ago

It would probably be a good thing to mention what I got up to with this. I looked in creating a custom admin generator to fit in my ideas and ended up theming it with bootstrap. Unfortunately it won't translate to the default padrino admin but it might be a useful source of ideas to others. Credit goes to http://kyan.com for letting me hack on this in work time.

It's production ready - we've used it on three sites so far;

https://github.com/xavierRiley/Kyan-Padrino-Admin-Generators

Full instructions in the README and let me know if you have any problems trying it out.

nesquena commented 11 years ago

@xavierRiley Very cool thanks for the link

ujifgc commented 11 years ago

https://github.com/xavierRiley/Kyan-Padrino-Admin-Generators/blob/master/templates/haml/page/_form.haml.tt

It's not very cool, it's a mess. This is how a view should look like:

https://github.com/ujifgc/swift/blob/master/vendor/padrino-admin/generators/templates/haml/page/_form.haml.tt

This is a admin form builder for bootstrap2:

https://github.com/ujifgc/swift/blob/master/lib/admin_form_builder.rb

Im not saying it's perfect, but you should get the idea. Current admin form views are a flying mess.

xavierRiley commented 11 years ago

:) Agreed!

Forgot to mention that it's only finished in erb, and even then it could do with a clean up. Maybe try it out using erb and see what you think?

I should have also mentioned that what I'm putting forward was originally conceived as an internal thing for work, so it won't be anywhere near complete for other Padrino users, but it is a working bootstrap admin if you use Postgres, ActiveRecord, standard css and erb

If it looks like it would be useful to expand to HAML etc. please let me know.

ujifgc commented 11 years ago

https://github.com/xavierRiley/Kyan-Padrino-Admin-Generators/blob/master/templates/erb/page/_form.erb.tt

A view should be pretty and brief. This looks like an erb Inception.

The first thing to implement for bootstrap2 admin is bootstrap2 form builder with every option available in bs2 form components http://twitter.github.com/bootstrap/base-css.html#forms.

Then we can use it in any template language to write very nice views for admin pages.

If you continue to spawn views bloated with Ruby code you just drown in it.

xavierRiley commented 11 years ago

Yes all true, guilty as charged.

The reason for the Inception is that I was trying to extend Padrino to choose better interface elements based on the field types and name - so I could specify a model, generate a page and see date selectors, file uploads, positioning on lists etc. The rationale is better explained in the project readme.

I agree with @ujifgc that my contribution would be a poor base for extending Padrino in general, unless people decided that the extra interface elements were something they wanted to see in the core gem.

But... the techniques I've used might be helpful to other people investigating the problem and I'd be happy if they checked it out using the caveats I mentioned above and in the Readme.

In particular, I've given an example of how to extend the Padrino admin within a project without having to use a customised version of the gem which might help some people to experiment without fear of losing an upgrade path.

Thanks @ujifgc for the feedback

dariocravero commented 11 years ago

Closing this since the admin powered by Boostrap is already implemented and updates are being discussed in #1153 and #1154.