fixes added and working admin interface
This commit is contained in:
parent
0072a97a3a
commit
8ada3f86b6
3 changed files with 21 additions and 9 deletions
|
@ -86,10 +86,14 @@ sub valid_read {
|
|||
},
|
||||
);
|
||||
my $associations = $valid_org->entity->associations;
|
||||
my $assoc = {
|
||||
lis => defined $associations ? $associations->lis : 0,
|
||||
};
|
||||
|
||||
$c->stash(
|
||||
valid_org => $valid_org,
|
||||
transactions => $transactions,
|
||||
associations => $associations,
|
||||
associations => $assoc,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -104,6 +108,7 @@ sub valid_edit {
|
|||
$validation->required('postcode')->postcode;
|
||||
$validation->optional('pending');
|
||||
$validation->optional('is_local');
|
||||
$validation->optional('is_lis');
|
||||
|
||||
if ( $validation->has_error ) {
|
||||
$c->flash( error => 'The validation has failed' );
|
||||
|
@ -123,9 +128,12 @@ sub valid_edit {
|
|||
pending => defined $validation->param('pending') ? 0 : 1,
|
||||
is_local => $validation->param('is_local'),
|
||||
});
|
||||
$valid_org->entity->update_or_create_related( 'associations', {
|
||||
lis => $validation->param('is_lis'),
|
||||
});
|
||||
} );
|
||||
} finally {
|
||||
if ( @_ ) {
|
||||
if ( @_ ) {use Devel::Dwarn; Dwarn \@_;
|
||||
$c->flash( error => 'Something went wrong Updating the Organisation' );
|
||||
} else {
|
||||
$c->flash( success => 'Updated Organisation' );
|
||||
|
|
|
@ -126,10 +126,14 @@ sub lis_load {
|
|||
|
||||
my $entity = $c->stash->{api_user}->entity;
|
||||
my $entity_type_object = $entity->type_object;
|
||||
my $orgs_lis = $valid_org = $c->schema->resultset('Entity')->find( $c->param('lis') );
|
||||
my $orgs_lis = $c->schema->resultset('EntityAssociation')->search(
|
||||
{
|
||||
'lis' => 1,
|
||||
},
|
||||
);
|
||||
|
||||
# need: organisations only, with name, latitude, and longitude
|
||||
my $org_rs = $orgs_lis->associations->search_related('entity',
|
||||
my $org_rs = $orgs_lis->search_related('entity',
|
||||
{
|
||||
'entity.type' => 'organisation',
|
||||
'organisation.latitude' => { -between => [
|
||||
|
@ -154,7 +158,7 @@ sub lis_load {
|
|||
|
||||
$org_rs->result_class('DBIx::Class::ResultClass::HashRefInflator');
|
||||
|
||||
my $suppliers = [ map {
|
||||
my $locations = [ map {
|
||||
{
|
||||
latitude => $_->{organisation}->{latitude} * 1,
|
||||
longitude => $_->{organisation}->{longitude} * 1,
|
||||
|
|
|
@ -100,11 +100,11 @@ function initMap() {
|
|||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label for="local" class="col-md-4 col-form-label">Part of LIS</label>
|
||||
<label for="lis" class="col-md-4 col-form-label">Part of LIS</label>
|
||||
<div class="col-md-8">
|
||||
<select id="local" class="form-control" name="is_local">
|
||||
<option value="0"<%= !$associations->lis ? '' : ' selected' %>>In Story</option>
|
||||
<option value="1"<%= $associations->lis ? ' selected' : '' %>>Not in Story</option>
|
||||
<select id="lis" class="form-control" name="is_lis">
|
||||
<option value="0"<%= !$associations->{lis} ? '' : ' selected' %>>Not In Story</option>
|
||||
<option value="1"<%= $associations->{lis} ? ' selected' : '' %>>In Story</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Reference in a new issue