Gapp
view release on metacpan or search on metacpan
lib/Gapp/Form/Context.pm view on Meta::CPAN
87888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
$self
->meta->throw_error(
'you must supply a value'
)
if
@_
<= 2;
my
(
$name
,
$attr
) =
split
/\./,
$path
;
my
$node
=
$self
->get_node(
$name
);
return
if
!
$node
;
$node
->modify(
$attr
,
$value
);
# $self->_value_changed( $path, $value ) if ! $self->in_update( $path );
}
sub
update {
my
(
$self
,
$stash
) =
@_
;
for
my
$path
(
$stash
->elements ) {
next
if
$path
eq
''
;
my
$value
=
$stash
->fetch(
$path
);
# $self->set_in_update( $path, 1 );
$self
->modify(
$path
,
$value
);
# $self->set_in_update( $path, 0 );
}
}
sub
update_from_stash {
my
$self
=
shift
;
cluck
'$cx->update_from_stash( $stash ) deprecated, use $cx->update( $stash )'
;
$self
->update(
@_
);
}
1;
lib/Gapp/Form/Stash.pm view on Meta::CPAN
32333435363738394041424344454647484950515253545556575859606162636465666768
default
=> 0,
);
# if the context has updated the stash
after
'store'
=>
sub
{
$_
[0]->set_modified(1) };
after
'delete'
=>
sub
{
$_
[0]->set_modified(1) };
sub
update {
my
(
$self
,
$cx
) =
@_
;
for
my
$field
(
$self
->elements ) {
try
{
my
$value
=
$cx
->lookup(
$field
);
$self
->store(
$field
,
$value
);
}
}
$self
->set_modified( 0 );
}
sub
update_from_context {
my
$self
=
shift
;
cluck
'$stash->update_from_context( $cx ) deprecated, use $stash->update( $cx ) instead'
;
$self
->update(
@_
);
}
1;
lib/Gapp/Meta/Widget/Native/Role/FormField.pm view on Meta::CPAN
535455565758596061626364656667686970717273
$self
->on_change->(
$self
)
if
$self
->on_change;
}
}
before
_apply_signals
=>
sub
{
my
(
$self
) =
@_
;
$self
->_connect_changed_handler
if
$self
->can(
'_connect_changed_handler'
);
};
sub
update {
my
(
$self
) =
@_
;
$self
->set_is_updating( 1 );
$self
->stash_to_widget(
$self
->form->stash )
if
$self
->field;
$self
->set_is_updating( 0 );
}
sub
enable {
my
(
$self
) =
@_
;
$self
->gobject->set_sensitive( 1 );
lib/Gapp/Meta/Widget/Native/Trait/Form.pm view on Meta::CPAN
153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
my
$stash
=
$self
->stash;
for
my
$w
(
$self
->find_fields ) {
$stash
->store(
$w
->field,
undef
)
if
!
$stash
->contains(
$w
->field );
}
$stash
->set_modified( 0 );
}
# update the values in the form
sub
update {
my
(
$self
) = (
@_
);
# update the stash if we have a context
$self
->stash->update(
$self
->context )
if
$self
->context;
# update the widgets from the stash
$self
->update_from_stash;
}
# update the values in the form (don't update the stash first)
sub
update_from_stash {
my
(
$self
) =
@_
;
# update the values in the form
for
my
$w
(
$self
->find_fields ) {
$w
->set_is_updating( 1 );
$w
->stash_to_widget(
$self
->stash )
if
$w
->field;
$w
->set_is_updating( 0 );
}
}
sub
update_stash {
my
(
$self
) =
shift
;
warn
'$form->update_stash deprecated, use $form->sync_stash'
;
$self
->sync_stash(
@_
);
}
sub
sync_stash {
my
(
$self
) =
@_
;
my
$stash
=
$self
->stash;
( run in 0.600 second using v1.01-cache-2.11-cpan-49f99fa48dc )