Allow for ignoring of values in import and toggle showing of them
This commit is contained in:
parent
7df6fecfc4
commit
1015be7810
5 changed files with 48 additions and 18 deletions
|
@ -208,8 +208,7 @@ sub startup {
|
|||
$admin_routes->get('/import/:set_id/user')->to('admin-import#get_user');
|
||||
$admin_routes->get('/import/:set_id/org')->to('admin-import#get_org');
|
||||
|
||||
$admin_routes->get('/import/:set_id/:value_id')->to('admin-import#get_value');
|
||||
$admin_routes->post('/import/:set_id/:value_id')->to('admin-import#post_value');
|
||||
$admin_routes->get('/import/:set_id/ignore/:value_id')->to('admin-import#ignore_value');
|
||||
# my $user_routes = $r->under('/')->to('root#under');
|
||||
|
||||
# $user_routes->get('/home')->to('root#home');
|
||||
|
|
|
@ -27,10 +27,12 @@ sub list {
|
|||
my $c = shift;
|
||||
my $set_id = $c->param('set_id');
|
||||
|
||||
my $include_ignored = $c->param('ignored');
|
||||
|
||||
my $import_set = $c->result_set->find($set_id);
|
||||
my $import_value_rs = $c->result_set->get_values($set_id);
|
||||
my $import_users_rs = $c->result_set->get_users($set_id);
|
||||
my $import_org_rs = $c->result_set->get_orgs($set_id);
|
||||
my $import_value_rs = $c->result_set->get_values($set_id, $include_ignored);
|
||||
my $import_users_rs = $c->result_set->get_users($set_id, $include_ignored);
|
||||
my $import_org_rs = $c->result_set->get_orgs($set_id, $include_ignored);
|
||||
my $import_lookup_rs = $c->result_set->get_lookups($set_id);
|
||||
|
||||
$c->stash(
|
||||
|
@ -240,14 +242,32 @@ sub get_org {
|
|||
);
|
||||
}
|
||||
|
||||
sub get_value {
|
||||
sub ignore_value {
|
||||
my $c = shift;
|
||||
my $set_id = $c->param('set_id');
|
||||
my $value_id = $c->param('value_id');
|
||||
|
||||
my $set_result = $c->result_set->find($set_id);
|
||||
unless ( defined $set_result ) {
|
||||
$c->flash( error => "Set does not exist" );
|
||||
return $c->redirect_to( '/admin/import' );
|
||||
}
|
||||
|
||||
sub post_value {
|
||||
my $c = shift;
|
||||
my $set_id = $c->param('set_id');
|
||||
my $value_result = $set_result->values->find($value_id);
|
||||
unless ( defined $value_result ) {
|
||||
$c->flash( error => "Value does not exist" );
|
||||
return $c->redirect_to( '/admin/import/' . $set_id );
|
||||
}
|
||||
|
||||
$value_result->update({ ignore_value => $value_result->ignore_value ? 0 : 1 });
|
||||
|
||||
$c->flash( success => "Updated value" );
|
||||
my $referer = $c->req->headers->header('Referer');
|
||||
return $c->redirect_to(
|
||||
defined $referer
|
||||
? $c->url_for($referer)->path_query
|
||||
: '/admin/import/' . $set_id
|
||||
);
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -8,10 +8,11 @@ use base 'DBIx::Class::ResultSet';
|
|||
sub get_values {
|
||||
my $self = shift;
|
||||
my $id = shift;
|
||||
my $include_ignored = shift;
|
||||
|
||||
return $self->find($id)->search_related(
|
||||
'values',
|
||||
undef,
|
||||
( $include_ignored ? {} : { ignore_value => 0 } ),
|
||||
{
|
||||
order_by => { '-asc' => 'id' },
|
||||
},
|
||||
|
@ -21,8 +22,9 @@ sub get_values {
|
|||
sub get_users {
|
||||
my $self = shift;
|
||||
my $id = shift;
|
||||
my $include_ignored = shift;
|
||||
|
||||
return $self->get_values($id)->search({},
|
||||
return $self->get_values($id, $include_ignored)->search({},
|
||||
{
|
||||
group_by => 'user_name',
|
||||
},
|
||||
|
@ -32,8 +34,9 @@ sub get_users {
|
|||
sub get_orgs {
|
||||
my $self = shift;
|
||||
my $id = shift;
|
||||
my $include_ignored = shift;
|
||||
|
||||
return $self->get_values($id)->search({},
|
||||
return $self->get_values($id, $include_ignored)->search({},
|
||||
{
|
||||
group_by => 'org_name',
|
||||
},
|
||||
|
|
|
@ -78,6 +78,10 @@
|
|||
<div class="card">
|
||||
<h3 class="card-header">
|
||||
%= format_human_datetime $import_set->date;
|
||||
<a href="<%= url_for->query({ignored => $c->param('ignored') ? 0 : 1 }) %>"
|
||||
class="btn btn-primary float-right">
|
||||
Toggle show Ignored
|
||||
</a>
|
||||
</h3>
|
||||
<div class="card-body">
|
||||
Content listed in original order of import
|
||||
|
@ -99,7 +103,11 @@
|
|||
<%= $import_value->org_name %>
|
||||
</div>
|
||||
<div class="col-2">
|
||||
<a href="#" class="btn btn-danger">Ignore</a>
|
||||
% if ( $import_value->ignore_value ) {
|
||||
<a href="<%= url_for . '/ignore/' . $import_value->id %>" class="btn btn-success">Un Ignore</a>
|
||||
% } else {
|
||||
<a href="<%= url_for . '/ignore/' . $import_value->id %>" class="btn btn-danger">Ignore</a>
|
||||
% }
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -60,13 +60,13 @@
|
|||
</div>
|
||||
</nav>
|
||||
<div class="container">
|
||||
% if ( my $error = flash 'error' ) {
|
||||
% if ( my $f_error = flash 'error' ) {
|
||||
<div class="alert alert-danger" role="alert">
|
||||
<strong>Error!</strong> <%= $error %>
|
||||
<strong>Error!</strong> <%= $f_error %>
|
||||
</div>
|
||||
% } elsif ( my $error = stash 'error' ) {
|
||||
% } elsif ( my $s_error = stash 'error' ) {
|
||||
<div class="alert alert-danger" role="alert">
|
||||
<strong>Error!</strong> <%= $error %>
|
||||
<strong>Error!</strong> <%= $s_error %>
|
||||
</div>
|
||||
% } elsif ( my $success = flash 'success' ) {
|
||||
<div class="alert alert-success" role="alert">
|
||||
|
|
Reference in a new issue