|
NAMEJifty::View::Declare::CRUD - Provides typical CRUD views to a modelSYNOPSISpackage App::View::User; use Jifty::View::Declare -base; use base qw/ Jifty::View::Declare::CRUD /; template 'view' => sub { # customize the view }; 1; package App::View::Tag; use Jifty::View::Declare -base; use base qw/ Jifty::View::Declare::CRUD /; template 'view' => sub { # customize the view }; 1; package App::View; use Jifty::View::Declare -base; use Jifty::View::Declare::CRUD; # If you have customizations, this is a good way... Jifty::View::Declare::CRUD->mount_view('User'); Jifty::View::Declare::CRUD->mount_view('Category', 'App::View::Tag', '/tag'); # Another way to do the above, good for quick and dirty alias Jifty::View::Declare::CRUD under '/admin/blog', { object_type => 'BlogPost', }; DESCRIPTIONThis class provides a set of views that may be used by a model to display Create/Read/Update/Delete views using the Template::Declare templating language.Basically, you can use this class to do most (and maybe all) of the work you need to manipulate and view your records. METHODSmount_view MODELCLASS VIEWCLASS /pathCall this method in your application's view class to add the CRUD views you're looking for. Only the first argument is required.Arguments:
object_typeThis method returns the type of object this CRUD view has been generated for. This is normally the model class parameter that was passed to "mount_view".record_classThis is the full name of the model class these CRUD views are for. The default implementation returns:Jifty->app_class('Model', $self->object_type); You will want to override this (in addition to "object_type") if you want to provide CRUD views in a plugin, or from an external model class, or for one of the Jifty built-in models. fragment_forThis is a helper that returns the path to a given fragment. The only argument is the name of the fragment. It returns a absolute base path to the fragment page.This will attempt to lookup a method named "fragment_for_FRAGMENT", where FRAGMENT is the argument passed. If that method exists, it's result is used as the returned path. Otherwise, the "fragment_base_path" is joined to the passed fragment name to create the return value. If you really want to mess with this, you may need to read the source code of this class. fragment_base_pathThis is a helper for "fragment_for". It looks up the current template using "current_template" in Template::Declare::Tags, finds it's parent path and then returns that.If you really want to mess with this, you may need to read the source code of this class. _get_record $idGiven an $id, returns a record object for the CRUD view's model class.display_columns [ACTION]Returns a list of all the column names that this REST view should display. Defaults to all argument names for the provided "ACTION". If there is no action provided, returns the "record_class"'s "readable_attributes".edit_columns ACTIONReturns a list of all the columns that this REST view should display for update. Defaults to the "display_columns", without "id".create_columns ACTIONReturns a list of all of the columns that this REST view should display for create. Defaults to "edit_columns".render_field mode => $mode, field => $field, action => $actionRenders a particular field in a given mode (read, create, edit). This attempts to dispatch directly to a method with the given field name. For example, if the subclass has, say, an "edit_field_post" method, then it will be preferred over the generic "edit_field" method.view_field action => $action_object, field => $field_nameDisplays the column as read-only.create_field action => $action_object, field => $field_nameDisplays the column for a create form.edit_field action => $action_object, field => $field_nameDisplays the column for an edit form.page_titleThe title for the CRUD pageTEMPLATESindex.htmlContains the master form and page region containing the list of items. This is mainly a wrapper for the "list" fragment.searchThe search fragment displays a search screen connected to the search action of the module. If your subclass can "search_fields", then that method will be called and the return value (which should be a list) will be used as a list of fields to render. Otherwise, all the fields of the Search action are displayed.See Jifty::Action::Record::Search. viewThis fragment displays the data held by a single model record.private template view_item_controlsUsed by the view fragment to show the edit link for each record.updateThe update fragment displays a form for editing the data held within a single model record.See Jifty::Action::Record::Update. edit_item_controls $record $actionThe controls we should be rendering in the 'edit' region for a given fragmentlistThe list template provides an interactive list for showing a list of records in the record collection, adding new records, deleting records, and updating records.per_pageThis routine returns how many items should be shown on each page of a listing. The default is 25.sort_headerSort by field toolbarpredefined_searchThe private template makes use of the "predefined_search" constant, which contains a list of hashref, each defines a collection in the format:{ name => 'my_list', label => "My List", collection => defer { # ... construct and return the collection } }, { name => 'my_list2', label => "My List2", condition => [ { column => 'foo' value => 'bar' }, # ... and your other Jifty::DBI::Collection limit args ] } search_regionThis private template renders a region to show an expandable region for a search widget.new_item_regionThis private template renders a region to show a the "new_item" template.no_items_foundPrints "No items found."list_items $collection $item_pathRenders a div of class list with a region per item.paging_top $collection $page_numberPaging for your list, rendered at the top of the listpaging_bottom $collection $page_numberPaging for your list, rendered at the bottom of the listcreate_item $actionRenders the action $Action, handing it the array ref returned by "display_columns".edit_item $actionRenders the action $Action, handing it the array ref returned by "display_columns".new_itemThe new_item template provides a form for creating new model records. See Jifty::Action::Record::Create.SEE ALSOJifty::Action::Record::Create, Jifty::Action::Record::Search, Jifty::Action::Record::Update, Jifty::Action::Record::Delete, Template::Declare, Jifty::View::Declare::Helpers, Jifty::View::DeclareLICENSEJifty is Copyright 2005-2010 Best Practical Solutions, LLC. Jifty is distributed under the same terms as Perl itself.
Visit the GSP FreeBSD Man Page Interface. |