5 use FS::Record qw( fields qsearch );
7 @ISA = ( $FS::UI::Base::_lock );
11 FS::UI::Base - Base class for all user-interface objects
15 use FS::UI::SomeInterface;
16 use FS::UI::some_table;
18 $interface = new FS::UI::some_table;
20 $error = $interface->browse;
21 $error = $interface->search;
22 $error = $interface->view;
23 $error = $interface->edit;
24 $error = $interface->process;
28 An FS::UI::Base object represents a user interface object. FS::UI::Base
29 is intended as a base class for table-specfic classes to inherit from, i.e.
30 FS::UI::cust_main. The simplest case, which will provide a default UI for your
31 new table, is as follows:
33 package FS::UI::table_name;
36 @ISA = qw( FS::UI::Base );
37 sub db_table { 'table_name'; }
39 Currently available interfaces are:
40 FS::UI::Gtk, an X-Windows UI implemented using the Gtk+ toolkit
41 FS::UI::CGI, a web interface implemented using CGI.pm, etc.
58 my @fields = $self->list_fields;
60 #begin browse-specific stuff
62 $self->title( "Browse ". $self->db_names ) unless $self->title;
63 my @records = qsearch ( $self->db_table, {} );
65 #end browse-specific stuff
67 $self->addwidget ( new FS::UI::_Text ( $self->db_description ) );
69 my @header = $self->list_header;
70 my @headerspan = $self->list_headerspan;
71 my %callback = $self->db_callback;
75 my $table = new FS::UI::_Tableborder (
76 'rows' => 1 + scalar(@records),
77 'columns' => $columns || scalar(@fields),
81 foreach my $header ( @header ) {
82 my $headerspan = shift(@headerspan) || 1;
84 0, $c, new FS::UI::_Text ( $header ), 1, $headerspan
91 foreach my $record ( @records ) {
93 foreach my $field ( @fields ) {
94 my $value = $record->getfield($field);
96 if ( $callback{$field} ) {
97 $widget = &{ $callback{$field} }( $value, $record );
99 $widget = new FS::UI::_Text ( $value );
101 $table->attach( $r, $c++, $widget, 1, 1 );
106 $self->addwidget( $table );
119 if ( defined($value) ) {
120 $self->{'title'} = $value;
133 push @{ $self->{'Widgets'} }, $widget;
138 sub db_description {}
149 fields( $self->db_table );
157 sub list_headerspan {
159 map 1, $self->list_header;
168 $Id: Base.pm,v 1.1 1999-08-04 09:03:53 ivan Exp $
172 This documentation is incomplete.
174 There should be some sort of per-(freeside)-user preferences and the ability
175 for specific FS::UI:: modules to put their own values there as well.
179 L<FS::UI::Gtk>, L<FS::UI::CGI>
184 Revision 1.1 1999-08-04 09:03:53 ivan
185 initial checkin of module files for proper perl installation
187 Revision 1.1 1999/01/20 09:30:36 ivan
188 skeletal cross-UI UI code.