Skip to content

Commit

Permalink
Undid accidental merge
Browse files Browse the repository at this point in the history
  • Loading branch information
droberts-ctrlo committed Oct 24, 2023
1 parent 9bdf958 commit 3349c6c
Show file tree
Hide file tree
Showing 30 changed files with 33 additions and 13,514 deletions.
5 changes: 2 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,9 @@ module.exports = {
'strict': 0,
'object-shorthand': 0,
'dot-notation': 0,
'prettier/prettier': 0,
'prettier/prettier': 'error',
'jsdoc/require-param-description': 0,
'jsdoc/require-returns-description': 0,
'no-unused-vars': 0,
'no-undef': 0,
},
};

190 changes: 12 additions & 178 deletions lib/GADS.pm
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ use Tie::Cache;
use URI;
use URI::Escape qw/uri_escape_utf8 uri_unescape/;

use Log::Log4perl; #qw(:easy); # Just for WWW::Mechanize::Chrome
use Log::Log4perl qw(:easy); # Just for WWW::Mechanize::Chrome
use WWW::Mechanize::Chrome;

use Dancer2; # Last to stop Moo generating conflicting namespace
Expand Down Expand Up @@ -778,7 +778,7 @@ any ['get', 'post'] => '/myaccount/?' => require_login sub {
$update{$field->{name}} = param($field->{name}) || undef;
}

if (process( sub { $user->update_user(current_user => logged_in_user, edit_own_user => 1, %update) }))
if (process( sub { $user->update_user(current_user => logged_in_user, %update) }))
{
return forwardHome(
{ success => "The account details have been updated" }, 'myaccount' );
Expand Down Expand Up @@ -1577,6 +1577,16 @@ any ['get', 'post'] => '/user/:id' => require_any_role [qw/useradmin superadmin/
return forwardHome(
{ success => "User has been updated successfully" }, 'user_overview/' );
}

# In case of failure, pass back to form
my $view_limits_with_blank = [ map {
+{
view_id => $_
}
} body_parameters->get_all('view_limits') ];

$values{view_limits_with_blank} = $view_limits_with_blank;
$editUser = \%values;
}
elsif (my $delete_id = param('delete'))
{
Expand Down Expand Up @@ -2752,182 +2762,6 @@ prefix '/:layout_name' => sub {
template 'data' => $params;
};

prefix '/report' => sub {

#view the report
get '' => require_login sub {
my $user = logged_in_user;
my $layout = var('layout') or pass;

if ( app->has_hook('plugin.linkspace.data_before_request') ) {
app->execute_hook( 'plugin.linkspace.data_before_request',
user => $user );
}

my %params = (
user => $user,
layout => $layout,
schema => schema,
);

my $records = GADS::Records->new(%params);

my $alert = GADS::Alert->new(
user => $user,
layout => $layout,
schema => schema,
);

my $base_url = request->base;

my $params;

$params->{alerts} = $alert->all;
$params->{header_type} = 'table_tabs';

$params->{layout_obj} = $layout;
$params->{layout} = $layout;

$params->{header_back_url} = "${base_url}table";
$params->{breadcrumbs} = [
Crumb( $base_url . "table/", "Tables" ),
Crumb( "", "Table: " . $layout->name )
];

my $reports = schema->resultset('Report')->search(
{
instance_id => $layout->instance_id,
}
);

my $report;
my @result;

while ( $report = $reports->next ) {
push(
@result,
{
id => $report->id,
name => $report->name
}
);
}

$params->{viewtype} = 'table';
$params->{reports} = \@result;

template 'report' => $params;
};

post '/add' => require_login sub {
print STDOUT Dumper params;

redirect '/report';
};

#add a report
get '/add' => require_login sub {

my $user = logged_in_user;
my $layout = var('layout') or pass;

if ( app->has_hook('plugin.linkspace.data_before_request') ) {
app->execute_hook( 'plugin.linkspace.data_before_request',
user => $user );
}

my %params = (
user => $user,
layout => $layout,
schema => schema,
);

my $records = GADS::Records->new(%params);

my @columns = @{$records->columns_render};

my $fields = [ map $_->presentation(
group => $records->is_group,
group_col_ids => $records->group_col_ids,
sort => $records->sort_first,
query_parameters => query_parameters,
), @columns ];

my $alert = GADS::Alert->new(
user => $user,
layout => $layout,
schema => schema,
);

my $base_url = request->base;

my $params;

$params->{alerts} = $alert->all;
$params->{header_type} = 'table_tabs';

$params->{layout_obj} = $layout;
$params->{layout} = $layout;

$params->{header_back_url} = "${base_url}table";
$params->{breadcrumbs} = [
Crumb( $base_url . "table/", "Tables" ),
Crumb( "", "Table: " . $layout->name )
];

$params->{viewtype} = 'add';
$params->{fields} = $fields;

template 'report' => $params;
};

any ['get','post'] => '/edit:id' => require_login sub {

#todo: We be working on this after add!
my $user = logged_in_user;
my $layout = var('layout') or pass;

if ( app->has_hook('plugin.linkspace.data_before_request') ) {
app->execute_hook( 'plugin.linkspace.data_before_request',
user => $user );
}

my %params = (
user => $user,
layout => $layout,
schema => schema,
);

my $records = GADS::Records->new(%params);

my $alert = GADS::Alert->new(
user => $user,
layout => $layout,
schema => schema,
);

my $base_url = request->base;

my $params;

$params->{alerts} = $alert->all;
$params->{header_type} = 'table_tabs';

$params->{layout_obj} = $layout;
$params->{layout} = $layout;

$params->{header_back_url} = "${base_url}table";
$params->{breadcrumbs} = [
Crumb( $base_url . "table/", "Tables" ),
Crumb( "", "Table: " . $layout->name )
];

$params->{viewtype} = 'edit';

template 'report' => $params;
};
};

# any ['get', 'post'] => qr{/tree[0-9]*/([0-9]*)/?} => require_login sub {
any ['get', 'post'] => '/tree:any?/:layout_id/?' => require_login sub {
# Random number can be used after "tree" to prevent caching
Expand Down
2 changes: 1 addition & 1 deletion lib/GADS/Schema.pm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use base 'DBIx::Class::Schema';

__PACKAGE__->load_namespaces;

our $VERSION = 101;
our $VERSION = 100;

our $IGNORE_PERMISSIONS;
our $IGNORE_PERMISSIONS_SEARCH;
Expand Down
15 changes: 0 additions & 15 deletions lib/GADS/Schema/Result/Layout.pm
Original file line number Diff line number Diff line change
Expand Up @@ -865,19 +865,4 @@ __PACKAGE__->has_many(
{ cascade_copy => 0, cascade_delete => 0 },
);

=head2 report_layouts
Type: has_many
Related object: L<GADS::Schema::Result::ReportLayout>
=cut

__PACKAGE__->has_many(
"report_layouts",
"GADS::Schema::Result::ReportLayout",
{ "foreign.report_id" => "self.id" },
{ cascade_copy => 0, cascade_delete => 0 },
);

1;
Loading

0 comments on commit 3349c6c

Please sign in to comment.