Bigtop

 view release on metacpan or  search on metacpan

lib/Bigtop/TentMaker.pm  view on Meta::CPAN

            warn "error: $@\n";
            return;
        }

    }

    $self->template_disable( 1 );

    return $self->stash->controller->data(
        $data_statement_table
        . '<!-- END DATA TABLE -->'
        . $quick_table
        . '<!-- END QUICK TABLE -->'
        . $new_divs 
        . $self->deparsed 
    );
}

sub do_update_statement {
    my $self      = shift;
    my $type      = shift;
    my $ancestors = shift;
    my $keyword   = shift;
    my $new_value = unescape( @_ );

    my $already_completed;

    eval {
        if ( not defined $new_value
                    or
             $new_value eq 'undef'
                    or
             $new_value eq 'undefined'
        ) {
            $tree->remove_statement(
                {
                    type    => $type,
                    ident   => $ancestors,
                    keyword => $keyword,
                }
            );
        }
        else {
            my $success = $tree->change_statement(
                {
                    type      => $type,
                    ident     => $ancestors,
                    keyword   => $keyword,
                    new_value => $new_value,
                }
            );

            if ( $type eq 'field'
                    and
                 ref $success eq 'ARRAY'
                    and
                 $success->[0] =~ /^date/
               )
            {
                # tell the tree so it can update these:
                #   controller uses calendar plugin
                #   form has a name (the table's name)
                #   form has extra_keys key javascript
                #   field's html_form_type is text
                #   and either date_select_text or is

                my $result = $tree->field_became_date(
                    {
                        ident   => $ancestors,
                        trigger => $success->[0],
                    }
                );

                # make jason here
                my ( $jsons, $keywords_used ) = _make_json_center( $result );
                my $json = "[\n" . join( ",\n", @{ $jsons } ) . "\n]\n";

                $already_completed = 1;

                $self->deparsed( Bigtop::Deparser->deparse( $tree ) );
                $self->update_backends( $tree );

                $self->template_disable( 1 );
                $self->stash->controller->data( $json . $self->deparsed );
            }

            if ( $type eq 'method'
                    and
                 $keyword eq 'paged_conf'
                    and
                 ref $success eq 'ARRAY'
            ) {
                my ( $json_center ) = _make_json_center(
                    [
                        "app_conf_value::$success->[0]",
                        $success->[1]
                    ]
                );
                my $json = "[\n" . join( ",\n", @{ $json_center } ) . "\n]\n";

                $already_completed = 1;

                $self->deparsed( Bigtop::Deparser->deparse( $tree ) );
                $self->update_backends( $tree );

                $self->template_disable( 1 );
                $self->stash->controller->data( $json . $self->deparsed );
            }
        }
    };
    if ( $@ ) {
        warn "Error changing statement: $@\n";
    }

    if ( $already_completed ) {
        return $self->stash->controller->data();
    }
    else {
        return $self->complete_update();
    }
}



( run in 1.151 second using v1.01-cache-2.11-cpan-ceb78f64989 )