# NEVER EDIT this file.  It was generated and will be overwritten without
# notice upon regeneration of this application.  You have been warned.
package JobAd::GEN::AuthUsers;

use strict;

use base 'JobAd';

use JobAd::Model::auth_users qw(
    $AUTH_USERS
);

#-----------------------------------------------------------------
# $self->do_main(  )
#-----------------------------------------------------------------
sub do_main {
    my ( $self ) = @_;

    $self->stash->view->template( 'results.tt' );
    $self->stash->view->title( 'Auth Users' );

    my $retval = {
        headings       => [
            'User Name',
            'Active',
        ],
        header_options => [
            {
                text => 'Add',
                link => $self->location() . "/add",
            },
        ],
    };

    my $schema = $self->get_schema();
    my @rows   = $AUTH_USERS->get_listing( { schema => $schema } );

    foreach my $row ( @rows ) {
        my $id = $row->id;
        push(
            @{ $retval->{rows} }, {
                data => [
                    $row->user_name,
                    $row->active,
                ],
                options => [
                    {
                        text => 'Edit',
                        link => $self->location() . "/edit/$id",
                    },
                    {
                        text => 'Delete',
                        link => $self->location() . "/delete/$id",
                    },
                ],
            }
        );
    }

    $self->stash->view->data( $retval );
} # END do_main

#-----------------------------------------------------------------
# $self->form( $row )
#-----------------------------------------------------------------
sub form {
    my ( $self, $row ) = @_;

    my $selections = $AUTH_USERS->get_form_selections(
            { schema => $self->get_schema() }
    );

    return {
        row        => $row,
        legend => $self->path_info =~ /edit/i ? 'Edit' : 'Add',
        fields     => [
            {
                options => [
                    { label => 'Yes', value => '1' },
                    { label => 'No', value => '0' },
                ],
                name => 'active',
                label => 'Active',
                type => 'select',
                is => 'boolean',
            },
            {
                name => 'user_name',
                label => 'User Name',
                type => 'text',
                is => 'varchar',
            },
            {
                name => 'passwd',
                label => 'Passwd',
                type => 'text',
                is => 'varchar',
            },
            {
                name => 'crypt',
                label => 'Crypt',
                type => 'text',
                is => 'varchar',
            },
            {
                name => 'first_name',
                label => 'First Name',
                type => 'text',
                is => 'varchar',
            },
            {
                name => 'last_name',
                label => 'Last Name',
                type => 'text',
                is => 'varchar',
            },
            {
                name => 'email',
                label => 'Email',
                type => 'text',
                is => 'varchar',
            },
        ],
    };
} # END form


1;

=head1 NAME

JobAd::GEN::AuthUsers - generated support module for JobAd::AuthUsers

=head1 SYNOPSIS

In JobAd::AuthUsers:

    use JobAd::GEN::AuthUsers qw(
        do_main
        form
    );

=head1 DESCRIPTION

This module was generated by bigtop and IS subject to regeneration.
Use it in JobAd::AuthUsers to provide the methods below.
They are exported by default.

=head1 METHODS

=over 4

=item do_main

=item form


=back

=head1 AUTHOR

Generated by bigtop and subject to regeneration.

=cut

