Skip to content

Commit d35cb6b

Browse files
committed
integrated drive link and custom popup views
1 parent 44f3e58 commit d35cb6b

22 files changed

+1058
-718
lines changed

CHANGES

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,63 @@
1+
0.13.0 2024-03-25 11:23:07 +0100 Tobias Oetiker <[email protected]>
2+
3+
-
4+
5+
0.13.0 2024-03-25 11:20:12 +0100 Tobias Oetiker <[email protected]>
6+
7+
- add okt event filter to okt view
8+
9+
0.13.0 2024-01-09 10:03:09 +0100 Tobias Oetiker <[email protected]>
10+
11+
- openlink features
12+
- general dependency update
13+
14+
0.12.0 2023-10-25 16:50:42 +0200 Tobias Oetiker <[email protected]>
15+
16+
-
17+
18+
0.12.0 2023-10-24 11:26:22 +0200 Tobias Oetiker <[email protected]>
19+
20+
-
21+
22+
0.12.0 2023-10-24 11:17:42 +0200 Tobias Oetiker <[email protected]>
23+
24+
-
25+
26+
0.12.0 2023-10-24 11:08:59 +0200 Tobias Oetiker <[email protected]>
27+
28+
-
29+
30+
0.12.0 2023-10-24 10:56:59 +0200 Tobias Oetiker <[email protected]>
31+
32+
-
33+
34+
0.12.0 2023-10-24 10:53:27 +0200 Tobias Oetiker <[email protected]>
35+
36+
-
37+
38+
0.12.0 2023-10-23 22:12:52 +0200 Tobias Oetiker <[email protected]>
39+
40+
-
41+
42+
0.12.0 2023-10-22 13:35:54 +0200 Tobias Oetiker <[email protected]>
43+
44+
-
45+
46+
0.12.0 2023-10-19 16:56:29 +0200 Tobias Oetiker <[email protected]>
47+
48+
-
49+
50+
0.12.0 2023-10-19 13:59:23 +0200 Tobias Oetiker <[email protected]>
51+
52+
-
53+
54+
0.12.0 2023-10-18 23:03:36 +0200 Tobias Oetiker <[email protected]>
55+
56+
57+
0.12.0 2023-10-18 08:37:40 +0200 Tobias Oetiker <[email protected]>
58+
59+
- try with better validation
60+
161
0.12.0 2023-10-16 11:47:09 +0200 Tobias Oetiker <[email protected]>
262

363
-

COPYRIGHT

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
OktDB
22
a cool web app with Mojolicious backend
33

4-
Copyright (c) 2023 Tobias Oetiker and the other people listed in the
4+
Copyright (c) 2024 Tobias Oetiker and the other people listed in the
55
AUTHORS file.
66

77
All rights reserved.

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.12.0
1+
0.13.0

bin/oktdb-source-mode.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/sh
22
export MOJO_MODE=development
33
export MOJO_LOG_LEVEL=debug
4-
exec `dirname $0`/oktdb.pl prefork --listen 'http://*:3323'
4+
exec `dirname $0`/oktdb.pl prefork --listen 'http://*:3323' --pid-file /run/shm/oktdb.$$.pid

cpanfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
requires 'CallBackery', '>= 0.47.3';
2-
requires 'Mojolicious', '>= 9.33';
1+
requires 'CallBackery', '>= 0.49.0';
2+
requires 'Mojolicious', '>= 9.35';
33
requires 'Mojo::SQLite';
44
requires 'Mojolicious::Plugin::OpenAPI';
55
requires 'Crypt::ScryptKDF';

lib/OktDB.pm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,3 +420,7 @@ INSERT INTO cbright (cbright_key,cbright_label)
420420
421421
--sql
422422
ALTER TABLE oktevent ADD oktevent_expense_note TEXT;
423+
424+
-- 10 up
425+
--sql
426+
ALTER TABLE oktevent ADD oktevent_drive_url TEXT;

lib/OktDB/GuiPlugin/ArtPers.pm

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,27 @@ has actionCfg => sub {
271271
}
272272
}
273273
},
274+
{
275+
label => trm('Show OktEvents'),
276+
action => 'popup',
277+
key => 'events',
278+
defaultAction => false,
279+
addToContextMenu => true,
280+
popupTitle => trm('OktEvents'),
281+
buttonSet => {
282+
enabled => false
283+
},
284+
set => {
285+
height => 750,
286+
width => 1200
287+
},
288+
backend => {
289+
plugin => 'OktEvent',
290+
config => {
291+
mode => 'filtered'
292+
}
293+
}
294+
},
274295
{
275296
label => trm('Add Production'),
276297
action => 'popup',
@@ -436,6 +457,9 @@ SQL_END
436457
report => {
437458
enabled => true,
438459
},
460+
events => {
461+
enabled => true,
462+
},
439463
};
440464
}
441465
return $data;

lib/OktDB/GuiPlugin/ArtPersMember.pm

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,6 @@ has grammar => sub ($self) {
259259
};
260260
1;
261261

262-
1;
263-
264262
__END__
265263
266264
=head1 COPYRIGHT

lib/OktDB/GuiPlugin/Okt.pm

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,30 @@ has actionCfg => sub {
141141
};
142142
}
143143
},
144-
$self->makeExportAction(
145-
filename => localtime->strftime('okt-%Y-%m-%d-%H-%M-%S.xlsx')
146-
),
144+
{
145+
label => trm('Show OktEvents'),
146+
action => 'popup',
147+
key => 'events',
148+
defaultAction => false,
149+
addToContextMenu => true,
150+
popupTitle => trm('OktEvents'),
151+
buttonSet => {
152+
enabled => false
153+
},
154+
set => {
155+
height => 750,
156+
width => 1200
157+
},
158+
backend => {
159+
plugin => 'OktEvent',
160+
config => {
161+
mode => 'filtered-okt'
162+
}
163+
}
164+
},
165+
$self->makeExportAction(
166+
filename => localtime->strftime('okt-%Y-%m-%d-%H-%M-%S.xlsx')
167+
),
147168
];
148169
};
149170

@@ -187,6 +208,9 @@ SQL_END
187208
delete => {
188209
enabled => true,
189210
},
211+
events => {
212+
enabled => true,
213+
},
190214
};
191215
$row->{okt_end_ts} = localtime($row->{okt_end_ts})->strftime("%d.%m.%Y") if $row->{okt_end_ts};
192216
$row->{okt_start_ts} = localtime($row->{okt_start_ts})->strftime("%d.%m.%Y") if $row->{okt_start_ts};

lib/OktDB/GuiPlugin/OktEvent.pm

Lines changed: 64 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ All the methods of L<CallBackery::GuiPlugin::AbstractTable> plus:
3030

3131
has formCfg => sub {
3232
my $self = shift;
33+
return [] if $self->config->{mode} =~ /filtered/;
3334
return [
3435
{
3536
key => 'search',
@@ -44,6 +45,21 @@ has formCfg => sub {
4445
];
4546
};
4647

48+
has grammar => sub ($self) {
49+
$self->mergeGrammar(
50+
$self->SUPER::grammar,
51+
{
52+
_vars => [ qw(mode) ],
53+
type => {
54+
_doc => 'filtered or full',
55+
_re => '(filtered|full)',
56+
_default => 'full'
57+
}
58+
},
59+
);
60+
};
61+
1;
62+
4763
=head2 tableCfg
4864
4965
@@ -60,27 +76,29 @@ has tableCfg => sub {
6076
sortable => true,
6177
primary => true
6278
},
63-
{
79+
($self->config->{mode} ne 'filtered-okt' ?
80+
({
6481
label => trm('OKT'),
6582
type => 'string',
6683
width => '6*',
6784
key => 'okt_edition',
6885
sortable => true,
69-
},
86+
}):()),
7087
{
7188
label => trm('Production'),
7289
type => 'string',
7390
width => '6*',
7491
key => 'production_title',
7592
sortable => true,
7693
},
77-
{
94+
($self->config->{mode} ne 'filtered' ?
95+
({
7896
label => trm('ArtPers'),
7997
type => 'string',
8098
width => '6*',
8199
key => 'artpers_name',
82100
sortable => true,
83-
},
101+
}) : ()),
84102
{
85103
label => trm('Type'),
86104
type => 'string',
@@ -218,7 +236,32 @@ has actionCfg => sub {
218236
}
219237
}
220238
} if not $self->user or $self->user->may('finance');
221-
239+
240+
push @actions,{
241+
label => trm('Open Drive'),
242+
action => 'submit',
243+
addToContextMenu => true,
244+
key => 'drive',
245+
buttonSet => {
246+
enabled => false
247+
},
248+
actionHandler => sub {
249+
my $self = shift;
250+
my $args = shift;
251+
my $url = $args->{selection}{oktevent_drive_url};
252+
if ($url) {
253+
return {
254+
action => 'openLink',
255+
url => $url,
256+
target => '_blank',
257+
features => 'noopener,noreferrer'
258+
}
259+
}
260+
else {
261+
die mkerror(4994,"No Drive URL found for this event");
262+
}
263+
}
264+
};
222265

223266
push @actions,{
224267
label => trm('Report'),
@@ -268,6 +311,14 @@ sub WHERE {
268311
my $self = shift;
269312
my $args = shift;
270313
my $where = {};
314+
if ($self->config->{mode} eq 'filtered') {
315+
$where->{production_artpers} = $args->{parentFormData}{selection}{artpers_id};
316+
return $where;
317+
}if ($self->config->{mode} eq 'filtered-okt') {
318+
$where->{oktevent_okt} = $args->{parentFormData}{selection}{okt_id};
319+
return $where;
320+
}
321+
271322
if (my $str = $args->{formData}{search}) {
272323
chomp($str);
273324
for my $search (quotewords('\s+', 0, $str)){
@@ -299,6 +350,7 @@ my $SUB_SELECT = <<SELECT_END;
299350
300351
SELECT
301352
oktevent_id,
353+
oktevent_okt,
302354
okt_edition,
303355
production_title,
304356
artpers_name,
@@ -307,7 +359,9 @@ my $SUB_SELECT = <<SELECT_END;
307359
location_name,
308360
oktevent_start_ts,
309361
oktevent_duration_s,
310-
oktevent_note
362+
oktevent_note,
363+
oktevent_drive_url,
364+
production_artpers
311365
FROM oktevent
312366
JOIN okt ON oktevent_okt = okt_id
313367
LEFT JOIN location ON oktevent_location = location_id
@@ -324,8 +378,7 @@ sub getTableRowCount {
324378
my $db = $self->db;
325379
my ($where,@where_bind) = $sql->where($WHERE);
326380
return $db->query(<<"SQL_END",@where_bind)->hash->{count};
327-
SELECT COUNT(*) AS count FROM ( $SUB_SELECT )
328-
$where
381+
SELECT COUNT(*) AS count FROM ( $SUB_SELECT ) $where
329382
SQL_END
330383
}
331384

@@ -369,6 +422,9 @@ SQL_END
369422
):(),
370423
report => {
371424
enabled => true,
425+
},
426+
drive => {
427+
enabled => $row->{oktevent_drive_url} ? true : false,
372428
}
373429
};
374430
$row->{oktevent_start_ts} = localtime($row->{oktevent_start_ts})->strftime("%d.%m.%Y %H:%M") if $row->{oktevent_start_ts};

lib/OktDB/GuiPlugin/OktEventForm.pm

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,20 @@ SQL_END
131131
)->hashes->to_array}]
132132
}
133133
},
134+
{
135+
key => 'oktevent_drive_url',
136+
label => trm('Drive URL'),
137+
widget => 'text',
138+
set => {
139+
%readOnly,
140+
},
141+
validator => sub ($value,$fieldName,$form) {
142+
if ($value and $value !~ m{^https://drive.google.com/\S+$}) {
143+
return trm("Expected a google drive url");
144+
}
145+
return "";
146+
}
147+
},
134148
{
135149
key => 'oktevent_honorarium',
136150
label => trm('Honorarium CHF'),
@@ -228,7 +242,7 @@ has actionCfg => sub {
228242
my %metaInfo;
229243
my $fieldMap = { map {
230244
"oktevent_".$_ => $args->{"oktevent_".$_}
231-
} qw(okt production type location expense expense_note honorarium start_ts duration_s note)
245+
} qw(okt drive_url production type location expense expense_note honorarium start_ts duration_s note)
232246
};
233247
if ($self->user->may('oktadmin')) {
234248
if ($type eq 'add') {

0 commit comments

Comments
 (0)