.\" Automatically generated by Pod::Man 2.25 (Pod::Simple 3.16) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .ie \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .el \{\ . de IX .. .\} .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Jifty::View::Declare::CRUD 3pm" .TH Jifty::View::Declare::CRUD 3pm "2011-03-01" "perl v5.14.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Jifty::View::Declare::CRUD \- Provides typical CRUD views to a model .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 3 \& package App::View::User; \& use Jifty::View::Declare \-base; \& use base qw/ Jifty::View::Declare::CRUD /; \& \& template \*(Aqview\*(Aq => sub { \& # customize the view \& }; \& \& 1; \& \& package App::View::Tag; \& use Jifty::View::Declare \-base; \& use base qw/ Jifty::View::Declare::CRUD /; \& \& template \*(Aqview\*(Aq => 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(\*(AqUser\*(Aq); \& Jifty::View::Declare::CRUD\->mount_view(\*(AqCategory\*(Aq, \*(AqApp::View::Tag\*(Aq, \*(Aq/tag\*(Aq); \& \& # Another way to do the above, good for quick and dirty \& alias Jifty::View::Declare::CRUD under \*(Aq/admin/blog\*(Aq, { \& object_type => \*(AqBlogPost\*(Aq, \& }; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This 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. .PP Basically, you can use this class to do most (and maybe all) of the work you need to manipulate and view your records. .SH "METHODS" .IX Header "METHODS" .SS "mount_view \s-1MODELCLASS\s0 \s-1VIEWCLASS\s0 /path" .IX Subsection "mount_view MODELCLASS VIEWCLASS /path" Call this method in your application's view class to add the \s-1CRUD\s0 views you're looking for. Only the first argument is required. .PP Arguments: .IP "\s-1MODELCLASS\s0" 4 .IX Item "MODELCLASS" This is the name of the model that you want to generate the \s-1CRUD\s0 views for. This is the only required parameter. Leave off the parts of the class name prior to and including the \*(L"Model\*(R" part. (I.e., \f(CW\*(C`App::Model::User\*(C'\fR should be passed as just \f(CW\*(C`User\*(C'\fR). .IP "\s-1VIEWCLASS\s0" 4 .IX Item "VIEWCLASS" This is the name of the class that will be generated to hold the \s-1CRUD\s0 views of your model. If not given, it will be set to: \f(CW\*(C`App::View::\f(CIMODELCLASS\f(CW\*(C'\fR. If given, it should be the full name of the view class. .IP "/path" 4 .IX Item "/path" This is the path where you can reach the \s-1CRUD\s0 views for this model in your browser. If not given, this will be set to the model class name in lowercase letters. (I.e., \f(CW\*(C`User\*(C'\fR would be found at \f(CW\*(C`/user\*(C'\fR if not passed explicitly). .SS "object_type" .IX Subsection "object_type" This method returns the type of object this \s-1CRUD\s0 view has been generated for. This is normally the model class parameter that was passed to \*(L"mount_view\*(R". .SS "record_class" .IX Subsection "record_class" This is the full name of the model class these \s-1CRUD\s0 views are for. The default implementation returns: .PP .Vb 1 \& Jifty\->app_class(\*(AqModel\*(Aq, $self\->object_type); .Ve .PP You will want to override this (in addition to \*(L"object_type\*(R") if you want to provide \s-1CRUD\s0 views in a plugin, or from an external model class, or for one of the Jifty built-in models. .SS "fragment_for" .IX Subsection "fragment_for" This 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. .PP This will attempt to lookup a method named \f(CW\*(C`fragment_for_\f(CIFRAGMENT\f(CW\*(C'\fR, where \fI\s-1FRAGMENT\s0\fR is the argument passed. If that method exists, it's result is used as the returned path. .PP Otherwise, the \*(L"fragment_base_path\*(R" is joined to the passed fragment name to create the return value. .PP If you really want to mess with this, you may need to read the source code of this class. .SS "fragment_base_path" .IX Subsection "fragment_base_path" This is a helper for \*(L"fragment_for\*(R". It looks up the current template using \*(L"current_template\*(R" in Template::Declare::Tags, finds it's parent path and then returns that. .PP If you really want to mess with this, you may need to read the source code of this class. .ie n .SS "_get_record $id" .el .SS "_get_record \f(CW$id\fP" .IX Subsection "_get_record $id" Given an \f(CW$id\fR, returns a record object for the \s-1CRUD\s0 view's model class. .SS "display_columns [\s-1ACTION\s0]" .IX Subsection "display_columns [ACTION]" Returns a list of all the column names that this \s-1REST\s0 view should display. Defaults to all argument names for the provided \f(CW\*(C`ACTION\*(C'\fR. If there is no action provided, returns the \f(CW\*(C`record_class\*(C'\fR's \&\f(CW\*(C`readable_attributes\*(C'\fR. .SS "edit_columns \s-1ACTION\s0" .IX Subsection "edit_columns ACTION" Returns a list of all the columns that this \s-1REST\s0 view should display for update. Defaults to the \*(L"display_columns\*(R", without \f(CW\*(C`id\*(C'\fR. .SS "create_columns \s-1ACTION\s0" .IX Subsection "create_columns ACTION" Returns a list of all of the columns that this \s-1REST\s0 view should display for create. Defaults to \*(L"edit_columns\*(R". .ie n .SS "render_field mode => $mode, field => $field, action => $action" .el .SS "render_field mode => \f(CW$mode\fP, field => \f(CW$field\fP, action => \f(CW$action\fP" .IX Subsection "render_field mode => $mode, field => $field, action => $action" Renders 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 \f(CW\*(C`edit_field_post\*(C'\fR method, then it will be preferred over the generic \f(CW\*(C`edit_field\*(C'\fR method. .ie n .SS "view_field action => $action_object, field => $field_name" .el .SS "view_field action => \f(CW$action_object\fP, field => \f(CW$field_name\fP" .IX Subsection "view_field action => $action_object, field => $field_name" Displays the column as read-only. .ie n .SS "create_field action => $action_object, field => $field_name" .el .SS "create_field action => \f(CW$action_object\fP, field => \f(CW$field_name\fP" .IX Subsection "create_field action => $action_object, field => $field_name" Displays the column for a create form. .ie n .SS "edit_field action => $action_object, field => $field_name" .el .SS "edit_field action => \f(CW$action_object\fP, field => \f(CW$field_name\fP" .IX Subsection "edit_field action => $action_object, field => $field_name" Displays the column for an edit form. .SS "page_title" .IX Subsection "page_title" The title for the \s-1CRUD\s0 page .SH "TEMPLATES" .IX Header "TEMPLATES" .SS "index.html" .IX Subsection "index.html" Contains the master form and page region containing the list of items. This is mainly a wrapper for the \*(L"list\*(R" fragment. .SS "search" .IX Subsection "search" The search fragment displays a search screen connected to the search action of the module. If your subclass can \f(CW\*(C`search_fields\*(C'\fR, 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. .PP See Jifty::Action::Record::Search. .SS "view" .IX Subsection "view" This fragment displays the data held by a single model record. .SS "private template view_item_controls" .IX Subsection "private template view_item_controls" Used by the view fragment to show the edit link for each record. .SS "update" .IX Subsection "update" The update fragment displays a form for editing the data held within a single model record. .PP See Jifty::Action::Record::Update. .ie n .SS "edit_item_controls $record $action" .el .SS "edit_item_controls \f(CW$record\fP \f(CW$action\fP" .IX Subsection "edit_item_controls $record $action" The controls we should be rendering in the 'edit' region for a given fragment .SS "list" .IX Subsection "list" The list template provides an interactive list for showing a list of records in the record collection, adding new records, deleting records, and updating records. .SS "per_page" .IX Subsection "per_page" This routine returns how many items should be shown on each page of a listing. The default is 25. .SS "sort_header" .IX Subsection "sort_header" Sort by field toolbar .SS "predefined_search" .IX Subsection "predefined_search" The \fIprivate\fR template makes use of the \f(CW\*(C`predefined_search\*(C'\fR constant, which contains a list of hashref, each defines a collection in the format: .PP .Vb 10 \& { name => \*(Aqmy_list\*(Aq, \& label => "My List", \& collection => defer { \& # ... construct and return the collection \& } \& }, \& { name => \*(Aqmy_list2\*(Aq, \& label => "My List2", \& condition => [ \& { column => \*(Aqfoo\*(Aq value => \*(Aqbar\*(Aq }, \& # ... and your other Jifty::DBI::Collection limit args \& ] \& } .Ve .SS "search_region" .IX Subsection "search_region" This \fIprivate\fR template renders a region to show an expandable region for a search widget. .SS "new_item_region" .IX Subsection "new_item_region" This \fIprivate\fR template renders a region to show a the \f(CW\*(C`new_item\*(C'\fR template. .SS "no_items_found" .IX Subsection "no_items_found" Prints \*(L"No items found.\*(R" .ie n .SS "list_items $collection $item_path" .el .SS "list_items \f(CW$collection\fP \f(CW$item_path\fP" .IX Subsection "list_items $collection $item_path" Renders a div of class list with a region per item. .ie n .SS "paging_top $collection $page_number" .el .SS "paging_top \f(CW$collection\fP \f(CW$page_number\fP" .IX Subsection "paging_top $collection $page_number" Paging for your list, rendered at the top of the list .ie n .SS "paging_bottom $collection $page_number" .el .SS "paging_bottom \f(CW$collection\fP \f(CW$page_number\fP" .IX Subsection "paging_bottom $collection $page_number" Paging for your list, rendered at the bottom of the list .ie n .SS "create_item $action" .el .SS "create_item \f(CW$action\fP" .IX Subsection "create_item $action" Renders the action \f(CW$Action\fR, handing it the array ref returned by \*(L"display_columns\*(R". .ie n .SS "edit_item $action" .el .SS "edit_item \f(CW$action\fP" .IX Subsection "edit_item $action" Renders the action \f(CW$Action\fR, handing it the array ref returned by \*(L"display_columns\*(R". .SH "new_item" .IX Header "new_item" The new_item template provides a form for creating new model records. See Jifty::Action::Record::Create. .SH "SEE ALSO" .IX Header "SEE ALSO" Jifty::Action::Record::Create, Jifty::Action::Record::Search, Jifty::Action::Record::Update, Jifty::Action::Record::Delete, Template::Declare, Jifty::View::Declare::Helpers, Jifty::View::Declare .SH "LICENSE" .IX Header "LICENSE" Jifty is Copyright 2005\-2010 Best Practical Solutions, \s-1LLC\s0. Jifty is distributed under the same terms as Perl itself.