Skip to content

Commit

Permalink
integrated drive link and custom popup views
Browse files Browse the repository at this point in the history
  • Loading branch information
oetiker committed Mar 25, 2024
1 parent 44f3e58 commit d35cb6b
Show file tree
Hide file tree
Showing 22 changed files with 1,058 additions and 718 deletions.
60 changes: 60 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,63 @@
0.13.0 2024-03-25 11:23:07 +0100 Tobias Oetiker <[email protected]>

-

0.13.0 2024-03-25 11:20:12 +0100 Tobias Oetiker <[email protected]>

- add okt event filter to okt view

0.13.0 2024-01-09 10:03:09 +0100 Tobias Oetiker <[email protected]>

- openlink features
- general dependency update

0.12.0 2023-10-25 16:50:42 +0200 Tobias Oetiker <[email protected]>

-

0.12.0 2023-10-24 11:26:22 +0200 Tobias Oetiker <[email protected]>

-

0.12.0 2023-10-24 11:17:42 +0200 Tobias Oetiker <[email protected]>

-

0.12.0 2023-10-24 11:08:59 +0200 Tobias Oetiker <[email protected]>

-

0.12.0 2023-10-24 10:56:59 +0200 Tobias Oetiker <[email protected]>

-

0.12.0 2023-10-24 10:53:27 +0200 Tobias Oetiker <[email protected]>

-

0.12.0 2023-10-23 22:12:52 +0200 Tobias Oetiker <[email protected]>

-

0.12.0 2023-10-22 13:35:54 +0200 Tobias Oetiker <[email protected]>

-

0.12.0 2023-10-19 16:56:29 +0200 Tobias Oetiker <[email protected]>

-

0.12.0 2023-10-19 13:59:23 +0200 Tobias Oetiker <[email protected]>

-

0.12.0 2023-10-18 23:03:36 +0200 Tobias Oetiker <[email protected]>


0.12.0 2023-10-18 08:37:40 +0200 Tobias Oetiker <[email protected]>

- try with better validation

0.12.0 2023-10-16 11:47:09 +0200 Tobias Oetiker <[email protected]>

-
Expand Down
2 changes: 1 addition & 1 deletion COPYRIGHT
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
OktDB
a cool web app with Mojolicious backend

Copyright (c) 2023 Tobias Oetiker and the other people listed in the
Copyright (c) 2024 Tobias Oetiker and the other people listed in the
AUTHORS file.

All rights reserved.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.12.0
0.13.0
2 changes: 1 addition & 1 deletion bin/oktdb-source-mode.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
export MOJO_MODE=development
export MOJO_LOG_LEVEL=debug
exec `dirname $0`/oktdb.pl prefork --listen 'http://*:3323'
exec `dirname $0`/oktdb.pl prefork --listen 'http://*:3323' --pid-file /run/shm/oktdb.$$.pid
4 changes: 2 additions & 2 deletions cpanfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
requires 'CallBackery', '>= 0.47.3';
requires 'Mojolicious', '>= 9.33';
requires 'CallBackery', '>= 0.49.0';
requires 'Mojolicious', '>= 9.35';
requires 'Mojo::SQLite';
requires 'Mojolicious::Plugin::OpenAPI';
requires 'Crypt::ScryptKDF';
Expand Down
4 changes: 4 additions & 0 deletions lib/OktDB.pm
Original file line number Diff line number Diff line change
Expand Up @@ -420,3 +420,7 @@ INSERT INTO cbright (cbright_key,cbright_label)
--sql
ALTER TABLE oktevent ADD oktevent_expense_note TEXT;
-- 10 up
--sql
ALTER TABLE oktevent ADD oktevent_drive_url TEXT;
24 changes: 24 additions & 0 deletions lib/OktDB/GuiPlugin/ArtPers.pm
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,27 @@ has actionCfg => sub {
}
}
},
{
label => trm('Show OktEvents'),
action => 'popup',
key => 'events',
defaultAction => false,
addToContextMenu => true,
popupTitle => trm('OktEvents'),
buttonSet => {
enabled => false
},
set => {
height => 750,
width => 1200
},
backend => {
plugin => 'OktEvent',
config => {
mode => 'filtered'
}
}
},
{
label => trm('Add Production'),
action => 'popup',
Expand Down Expand Up @@ -436,6 +457,9 @@ SQL_END
report => {
enabled => true,
},
events => {
enabled => true,
},
};
}
return $data;
Expand Down
2 changes: 0 additions & 2 deletions lib/OktDB/GuiPlugin/ArtPersMember.pm
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,6 @@ has grammar => sub ($self) {
};
1;

1;

__END__
=head1 COPYRIGHT
Expand Down
30 changes: 27 additions & 3 deletions lib/OktDB/GuiPlugin/Okt.pm
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,30 @@ has actionCfg => sub {
};
}
},
$self->makeExportAction(
filename => localtime->strftime('okt-%Y-%m-%d-%H-%M-%S.xlsx')
),
{
label => trm('Show OktEvents'),
action => 'popup',
key => 'events',
defaultAction => false,
addToContextMenu => true,
popupTitle => trm('OktEvents'),
buttonSet => {
enabled => false
},
set => {
height => 750,
width => 1200
},
backend => {
plugin => 'OktEvent',
config => {
mode => 'filtered-okt'
}
}
},
$self->makeExportAction(
filename => localtime->strftime('okt-%Y-%m-%d-%H-%M-%S.xlsx')
),
];
};

Expand Down Expand Up @@ -187,6 +208,9 @@ SQL_END
delete => {
enabled => true,
},
events => {
enabled => true,
},
};
$row->{okt_end_ts} = localtime($row->{okt_end_ts})->strftime("%d.%m.%Y") if $row->{okt_end_ts};
$row->{okt_start_ts} = localtime($row->{okt_start_ts})->strftime("%d.%m.%Y") if $row->{okt_start_ts};
Expand Down
72 changes: 64 additions & 8 deletions lib/OktDB/GuiPlugin/OktEvent.pm
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ All the methods of L<CallBackery::GuiPlugin::AbstractTable> plus:

has formCfg => sub {
my $self = shift;
return [] if $self->config->{mode} =~ /filtered/;
return [
{
key => 'search',
Expand All @@ -44,6 +45,21 @@ has formCfg => sub {
];
};

has grammar => sub ($self) {
$self->mergeGrammar(
$self->SUPER::grammar,
{
_vars => [ qw(mode) ],
type => {
_doc => 'filtered or full',
_re => '(filtered|full)',
_default => 'full'
}
},
);
};
1;

=head2 tableCfg
Expand All @@ -60,27 +76,29 @@ has tableCfg => sub {
sortable => true,
primary => true
},
{
($self->config->{mode} ne 'filtered-okt' ?
({
label => trm('OKT'),
type => 'string',
width => '6*',
key => 'okt_edition',
sortable => true,
},
}):()),
{
label => trm('Production'),
type => 'string',
width => '6*',
key => 'production_title',
sortable => true,
},
{
($self->config->{mode} ne 'filtered' ?
({
label => trm('ArtPers'),
type => 'string',
width => '6*',
key => 'artpers_name',
sortable => true,
},
}) : ()),
{
label => trm('Type'),
type => 'string',
Expand Down Expand Up @@ -218,7 +236,32 @@ has actionCfg => sub {
}
}
} if not $self->user or $self->user->may('finance');


push @actions,{
label => trm('Open Drive'),
action => 'submit',
addToContextMenu => true,
key => 'drive',
buttonSet => {
enabled => false
},
actionHandler => sub {
my $self = shift;
my $args = shift;
my $url = $args->{selection}{oktevent_drive_url};
if ($url) {
return {
action => 'openLink',
url => $url,
target => '_blank',
features => 'noopener,noreferrer'
}
}
else {
die mkerror(4994,"No Drive URL found for this event");
}
}
};

push @actions,{
label => trm('Report'),
Expand Down Expand Up @@ -268,6 +311,14 @@ sub WHERE {
my $self = shift;
my $args = shift;
my $where = {};
if ($self->config->{mode} eq 'filtered') {
$where->{production_artpers} = $args->{parentFormData}{selection}{artpers_id};
return $where;
}if ($self->config->{mode} eq 'filtered-okt') {
$where->{oktevent_okt} = $args->{parentFormData}{selection}{okt_id};
return $where;
}

if (my $str = $args->{formData}{search}) {
chomp($str);
for my $search (quotewords('\s+', 0, $str)){
Expand Down Expand Up @@ -299,6 +350,7 @@ my $SUB_SELECT = <<SELECT_END;
SELECT
oktevent_id,
oktevent_okt,
okt_edition,
production_title,
artpers_name,
Expand All @@ -307,7 +359,9 @@ my $SUB_SELECT = <<SELECT_END;
location_name,
oktevent_start_ts,
oktevent_duration_s,
oktevent_note
oktevent_note,
oktevent_drive_url,
production_artpers
FROM oktevent
JOIN okt ON oktevent_okt = okt_id
LEFT JOIN location ON oktevent_location = location_id
Expand All @@ -324,8 +378,7 @@ sub getTableRowCount {
my $db = $self->db;
my ($where,@where_bind) = $sql->where($WHERE);
return $db->query(<<"SQL_END",@where_bind)->hash->{count};
SELECT COUNT(*) AS count FROM ( $SUB_SELECT )
$where
SELECT COUNT(*) AS count FROM ( $SUB_SELECT ) $where
SQL_END
}

Expand Down Expand Up @@ -369,6 +422,9 @@ SQL_END
):(),
report => {
enabled => true,
},
drive => {
enabled => $row->{oktevent_drive_url} ? true : false,
}
};
$row->{oktevent_start_ts} = localtime($row->{oktevent_start_ts})->strftime("%d.%m.%Y %H:%M") if $row->{oktevent_start_ts};
Expand Down
16 changes: 15 additions & 1 deletion lib/OktDB/GuiPlugin/OktEventForm.pm
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,20 @@ SQL_END
)->hashes->to_array}]
}
},
{
key => 'oktevent_drive_url',
label => trm('Drive URL'),
widget => 'text',
set => {
%readOnly,
},
validator => sub ($value,$fieldName,$form) {
if ($value and $value !~ m{^https://drive.google.com/\S+$}) {
return trm("Expected a google drive url");
}
return "";
}
},
{
key => 'oktevent_honorarium',
label => trm('Honorarium CHF'),
Expand Down Expand Up @@ -228,7 +242,7 @@ has actionCfg => sub {
my %metaInfo;
my $fieldMap = { map {
"oktevent_".$_ => $args->{"oktevent_".$_}
} qw(okt production type location expense expense_note honorarium start_ts duration_s note)
} qw(okt drive_url production type location expense expense_note honorarium start_ts duration_s note)
};
if ($self->user->may('oktadmin')) {
if ($type eq 'add') {
Expand Down
Loading

0 comments on commit d35cb6b

Please sign in to comment.