How to customize the look of the list view
Posted by Luis Sat, 21 Jul 2007 05:13:01 GMT
Whenever I talk to someone about Streamlined, they usually ask about how they can customize the look. I’m going to cover how to change the look of the list / index view as of the state of the edge before the 0.9 release comes out.
You can do this by creating a UI class for your model by executing “rake streamlined:model MODEL=your_model_name”. This will create a ModelUI class in app/streamlined and affects the views for that model.
If you’ve tried Streamlined before, then you’ll know that when you’re viewing the list view for a model, then you’ll see a paginated table that contains all the instances of the model. Each row has one instance, along with three buttons: one to go to the show view of the instance, the second to go to the edit view of the instance and a third to delete the instance. Below the table, there’s a few more buttons with the most important one being the one to create a new model instance.
There’s already pretty good documentation on how to modify which columns show up, so I’m going to focus on the other options.
First, you can add custom headers and/or custom footers by adding the linesheader_partials :list => 'shared/my_custom_header'
footer_partials :list => 'shared/my_custom_footer'and then of course creating the header / footer partial and putting it in the place you specified. Second, you can turn off the delete button for each row. Perhaps you want to ensure that users delete from the show view or perhaps users should not delete instances of your model at all. Do this with
quick_delete_button falseThird, you can turn off the edit button for each row.
quick_edit_button falseFourth, if your model is read only, then you can turn off the new and edit buttons by adding the line
read_only trueNote that you can still delete, so you’ll have to specify quick_delete_button false like above if you want that. I’m not sure if that’s the right behavior. Any thoughts on that? Fifth, you can turn off all the buttons that link to show/edit/delete by adding the line
table_row_buttons falseSixth, you can turn off pagination via
pagination falseSeventh, you can turn off filtering via
table_filter falseEighth, you can add custom CSS styles via
style_classes :list => {:row => 'person_row'}
which means that each row will have a CSS class person_row which you can then specify in a stylesheet.
That’s it for customizing the list view declaratively. I’ll make sure all of this gets into the wiki. Please let me know if I missed anything. If there’s another way you’d like to customize the list view, please add a ticket in Trac or leave a comment here.



