Fixed organisaiton listing and editing in backend
This commit is contained in:
parent
2594d826ef
commit
2ef5193e41
4 changed files with 64 additions and 17 deletions
|
@ -6,8 +6,8 @@ use Try::Tiny;
|
|||
sub list {
|
||||
my $c = shift;
|
||||
|
||||
my $valid_orgs_rs = $c->schema->resultset('Organisation');
|
||||
my $pending_orgs_rs = $c->schema->resultset('PendingOrganisation');
|
||||
my $valid_orgs_rs = $c->schema->resultset('Organisation')->search({ pending => 0 });
|
||||
my $pending_orgs_rs = $c->schema->resultset('Organisation')->search({ pending => 1 });
|
||||
|
||||
$c->stash(
|
||||
valid_orgs_rs => $valid_orgs_rs,
|
||||
|
@ -85,6 +85,7 @@ sub valid_edit {
|
|||
$validation->required('town');
|
||||
$validation->optional('sector');
|
||||
$validation->required('postcode')->postcode;
|
||||
$validation->optional('pending');
|
||||
|
||||
if ( $validation->has_error ) {
|
||||
$c->flash( error => 'The validation has failed' );
|
||||
|
@ -101,6 +102,7 @@ sub valid_edit {
|
|||
town => $validation->param('town'),
|
||||
sector => $validation->param('sector'),
|
||||
postcode => $validation->param('postcode'),
|
||||
pending => defined $validation->param('pending') ? 0 : 1,
|
||||
});
|
||||
} );
|
||||
} finally {
|
||||
|
|
|
@ -51,4 +51,16 @@ __PACKAGE__->has_many(
|
|||
{ cascade_copy => 0, cascade_delete => 0 },
|
||||
);
|
||||
|
||||
sub name {
|
||||
my $self = shift;
|
||||
|
||||
if ( $self->type eq 'customer' ) {
|
||||
return $self->customer->display_name;
|
||||
} elsif ( $self->type eq 'organisation' ) {
|
||||
return $self->organisation->name;
|
||||
} else {
|
||||
return "Unknown Name";
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
</h3>
|
||||
<div class="list-group list-group-flush">
|
||||
% for my $valid_org ($valid_orgs_rs->all) {
|
||||
<a href="<%= url_for . '/valid/' . $valid_org->id %>" class="list-group-item list-group-item-action">
|
||||
<a href="<%= url_for . '/' . $valid_org->id %>" class="list-group-item list-group-item-action">
|
||||
<div>
|
||||
%= $valid_org->name
|
||||
</div>
|
||||
|
@ -41,7 +41,7 @@
|
|||
</div>
|
||||
% } else {
|
||||
% for my $pending_org ($pending_orgs_rs->all) {
|
||||
<a href="<%= url_for . '/pending/' . $pending_org->id %>" class="list-group-item list-group-item-action">
|
||||
<a href="<%= url_for . '/' . $pending_org->id %>" class="list-group-item list-group-item-action">
|
||||
<div>
|
||||
%= $pending_org->name
|
||||
</div>
|
||||
|
|
|
@ -15,20 +15,53 @@
|
|||
<h3 class="card-header">
|
||||
%= $valid_org->name
|
||||
</h3>
|
||||
<ul class="list-group list-group-flush">
|
||||
<form action="<%= url_for . '/edit' %>" method="post">
|
||||
<li class="list-group-item"><input id="name" type="text" class="form-control" placeholder="Organisation Name" name="name" value="<%= $valid_org->name %>"></li>
|
||||
<li class="list-group-item"><input id="street_name" type="text" class="form-control" placeholder="Street Name" name="street_name" value="<%= $valid_org->street_name %>"></li>
|
||||
<li class="list-group-item"><input id="town" type="text" class="form-control" placeholder="Town" name="town" value="<%= $valid_org->town %>"></li>
|
||||
<li class="list-group-item">
|
||||
<select class="form-control" name="sector">
|
||||
%= include 'partials/sector_options', selected_sector => $valid_org->sector || '';
|
||||
</select>
|
||||
</li>
|
||||
<li class="list-group-item"><input id="postcode" type="text" class="form-control" placeholder="Postcode" name="postcode" value="<%= $valid_org->postcode %>"></li>
|
||||
<li class="list-group-item"><button class="btn btn-success" type="submit">Edit Organisation</button></li>
|
||||
<div class="card-block">
|
||||
<form action="<%= url_for %>" method="post">
|
||||
<div class="form-group row">
|
||||
<label for="name" class="col-sm-2 col-form-label">Organisation Name</label>
|
||||
<div class="col-sm-10">
|
||||
<input id="name" type="text" class="form-control" placeholder="Organisation Name" name="name" value="<%= $valid_org->name %>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label for="name" class="col-sm-2 col-form-label">Street Name</label>
|
||||
<div class="col-sm-10">
|
||||
<input id="street_name" type="text" class="form-control" placeholder="Street Name" name="street_name" value="<%= $valid_org->street_name %>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label for="name" class="col-sm-2 col-form-label">Town/City</label>
|
||||
<div class="col-sm-10">
|
||||
<input id="town" type="text" class="form-control" placeholder="Town" name="town" value="<%= $valid_org->town %>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label for="name" class="col-sm-2 col-form-label">Sector</label>
|
||||
<div class="col-sm-10">
|
||||
<select class="form-control" name="sector">
|
||||
%= include 'partials/sector_options', selected_sector => $valid_org->sector || '';
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label for="name" class="col-sm-2 col-form-label">Postcode</label>
|
||||
<div class="col-sm-10">
|
||||
<input id="postcode" type="text" class="form-control" placeholder="Postcode" name="postcode" value="<%= $valid_org->postcode %>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label for="name" class="col-sm-2 col-form-label">Validated</label>
|
||||
<div class="col-sm-10">
|
||||
<input id="pending" type="checkbox" name="pending" value="0"<%= $valid_org->pending ? '' : ' checked' %>>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<div class="ml-auto col-sm-10">
|
||||
<button class="btn btn-success" type="submit">Save Changes To Organisation</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card mb-3">
|
||||
<h3 class="card-header">
|
||||
|
|
Reference in a new issue