=pod
GADS - Globally Accessible Data Store
Copyright (C) 2014 Ctrl O Ltd

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
=cut

package GADS::Column::String;

use Log::Report;
use Moo;
use MooX::Types::MooseLike::Base qw/:all/;

extends 'GADS::Column';

has textbox => (
    is     => 'rw',
    isa    => Bool,
    coerce => sub { $_[0] ? 1 : 0 },
);

after 'build_values' => sub {
    my ($self, $original) = @_;
    $self->string_storage(1);

    if ($original->{textbox})
    {
        $self->textbox(1);
    }
};

after 'write' => sub {
    my $self = shift;

    $self->schema->resultset('Layout')->find($self->id)->update({
        textbox => $self->textbox,
    });
};

1;


=pod
GADS - Globally Accessible Data Store
Copyright (C) 2014 Ctrl O Ltd

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
=cut

package GADS::Column::String;

use Log::Report;
use Moo;
use MooX::Types::MooseLike::Base qw/:all/;

extends 'GADS::Column';

has textbox => (
    is      => 'rw',
    isa     => Bool,
    default => 0,
    coerce  => sub { $_[0] ? 1 : 0 },
);

after 'build_values' => sub {
    my ($self, $original) = @_;
    $self->string_storage(1);

    if ($original->{textbox})
    {
        $self->textbox(1);
    }
};

after 'write' => sub {
    my $self = shift;

    $self->schema->resultset('Layout')->find($self->id)->update({
        textbox => $self->textbox,
    });
};

1;


Set default value for textbox option
Set default value for textbox option
