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 lines
header_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 false
Third, you can turn off the edit button for each row.
quick_edit_button false
Fourth, if your model is read only, then you can turn off the new and edit buttons by adding the line
read_only true
Note 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 false
Sixth, you can turn off pagination via
pagination false
Seventh, you can turn off filtering via
table_filter false
Eighth, 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.

Posted in ,  | Tags , ,  | 1 comment | no trackbacks

Build is Up

Posted by jgehtland Sat, 21 Oct 2006 14:54:37 GMT

Yikes. So, I’ve been in Canada all weekend at a conference, and my hard drive had a catastrophic failure. I’ve been fighting it ever since, hence the extra two days to get the build up. We’ve had to remove two features from this build due to lost work: Lightbox support (as an alternate to Prototype Windows) and Bill Katz’s Authorization plugin (we’ll release an 0.0.6 ASAP with just that in it).

That being said, here’s what’s in 0.0.5:

  • Better error messages. We’re now dropping notes into the logs and on screen that tell you what happened as much as possible (no such relationship, no such type, Sparklines not installed, etc.). If you have a weird problem, check the log for anything that starts with “STREAMLINED”.
  • New relationship syntax. Don’t worry, the original syntax still works, but for all new models, use the new syntax. It looks like this: relationship :line_items, :view => {:name => :membership}, :summary => {:name => :list, :fields => [:customer, :amount]}
  • Sparklines Integration. This one requires RMagick to be installed and will try to tell you if it isn’t. It also requires you to install the Sparklines plugin to the app before you run it. The only graph we’ve implemented so far is a pie chart of the ratio of items associated to the total number of possible items. Here’s the syntax example: relationship :line_items, :summary => {:name => :graph, :type => :pie}
  • Optional pagination. There is a generator flag (—no-pagination) that will turn pagination off by default. Regardless of which you choose (on or off) you can override it in the _ui file. class line_item_ui < Streamlined::UI pagination true # or false end
  • Uses Rails’ model generators. If Streamlined tries to create a model class for you, it will use Rails’ model generator instead of the custom one previously provided. The models will now have unit and functional tests, etc.
  • Overlib integration. You simply specify one or more columns on your class as popup_columns, and fill in the body of _popup.html to display the appropriate information. Example: class LineItemUI << Streamlined_UI.rhtml popup_columns :name, :total end
  • acts_as_authenticated. If you choose this option (—authentication=AAA), Streamlined will attempt to install the plugin from the remote repository. It will then run the generator, which will create a model (user), a controller (account), and some login/logout views under app/views/account/. It will also create a migration for User, and one to add a default user (username=admin, password=admin). Make sure to run them before launching the app.

We’ll document all this much more thoroughly in the morning, but if you are just too anxious, you can get it now and hope these docs are enough.

Tags ,  | no comments | no trackbacks