Fossil SCM

Provide the ability to add custom header text on all ticket reports. The header and its mimetype are stored in the REPORTFMT.JX column.

drh 2022-11-18 18:50 json-meta-data
Commit c06a9980c36e0dcdc7c7a7313e510a399f54e0157a3a193269ed73202855e369
+1 -1
--- src/event.c
+++ src/event.c
@@ -552,11 +552,11 @@
552552
@ </td></tr>
553553
554554
@ <tr><th align="right" valign="top">\
555555
@ %z(href("%R/markup_help"))Markup Style</a>:</th>
556556
@ <td valign="top">
557
- mimetype_option_menu(zMimetype);
557
+ mimetype_option_menu(zMimetype, "mimetype");
558558
@ </td></tr>
559559
560560
@ <tr><th align="right" valign="top">Page&nbsp;Content:</th>
561561
@ <td valign="top">
562562
@ <textarea name="w" class="technoteedit" cols="80"
563563
--- src/event.c
+++ src/event.c
@@ -552,11 +552,11 @@
552 @ </td></tr>
553
554 @ <tr><th align="right" valign="top">\
555 @ %z(href("%R/markup_help"))Markup Style</a>:</th>
556 @ <td valign="top">
557 mimetype_option_menu(zMimetype);
558 @ </td></tr>
559
560 @ <tr><th align="right" valign="top">Page&nbsp;Content:</th>
561 @ <td valign="top">
562 @ <textarea name="w" class="technoteedit" cols="80"
563
--- src/event.c
+++ src/event.c
@@ -552,11 +552,11 @@
552 @ </td></tr>
553
554 @ <tr><th align="right" valign="top">\
555 @ %z(href("%R/markup_help"))Markup Style</a>:</th>
556 @ <td valign="top">
557 mimetype_option_menu(zMimetype, "mimetype");
558 @ </td></tr>
559
560 @ <tr><th align="right" valign="top">Page&nbsp;Content:</th>
561 @ <td valign="top">
562 @ <textarea name="w" class="technoteedit" cols="80"
563
+1 -1
--- src/forum.c
+++ src/forum.c
@@ -1059,11 +1059,11 @@
10591059
if( zTitle ){
10601060
@ Title: <input type="input" name="title" value="%h(zTitle)" size="50"
10611061
@ maxlength="125"><br>
10621062
}
10631063
@ %z(href("%R/markup_help"))Markup style</a>:
1064
- mimetype_option_menu(zMimetype);
1064
+ mimetype_option_menu(zMimetype, "mimetype");
10651065
@ <br><textarea aria-label="Content:" name="content" class="wikiedit" \
10661066
@ cols="80" rows="25" wrap="virtual">%h(zContent)</textarea><br>
10671067
}
10681068
10691069
/*
10701070
--- src/forum.c
+++ src/forum.c
@@ -1059,11 +1059,11 @@
1059 if( zTitle ){
1060 @ Title: <input type="input" name="title" value="%h(zTitle)" size="50"
1061 @ maxlength="125"><br>
1062 }
1063 @ %z(href("%R/markup_help"))Markup style</a>:
1064 mimetype_option_menu(zMimetype);
1065 @ <br><textarea aria-label="Content:" name="content" class="wikiedit" \
1066 @ cols="80" rows="25" wrap="virtual">%h(zContent)</textarea><br>
1067 }
1068
1069 /*
1070
--- src/forum.c
+++ src/forum.c
@@ -1059,11 +1059,11 @@
1059 if( zTitle ){
1060 @ Title: <input type="input" name="title" value="%h(zTitle)" size="50"
1061 @ maxlength="125"><br>
1062 }
1063 @ %z(href("%R/markup_help"))Markup style</a>:
1064 mimetype_option_menu(zMimetype, "mimetype");
1065 @ <br><textarea aria-label="Content:" name="content" class="wikiedit" \
1066 @ cols="80" rows="25" wrap="virtual">%h(zContent)</textarea><br>
1067 }
1068
1069 /*
1070
+74 -14
--- src/report.c
+++ src/report.c
@@ -401,19 +401,25 @@
401401
** rn=N Ticket report number. (required)
402402
** t=TITLE Title of the report format
403403
** w=USER Owner of the report format
404404
** s=SQL SQL text used to implement the report
405405
** k=KEY Color key
406
+** d=DESC Optional descriptive text
407
+** m=MIMETYPE Mimetype for DESC
408
+** x=TAG Symbolic name for the report
406409
*/
407410
void view_edit(void){
408411
int rn;
409
- const char *zTitle;
412
+ const char *zTitle; /* Title of the report */
410413
const char *z;
411
- const char *zOwner;
412
- const char *zClrKey;
413
- char *zSQL;
414
- char *zErr = 0;
414
+ const char *zOwner; /* Owner of the report */
415
+ const char *zClrKey; /* Color key - used to add colors to lines */
416
+ char *zSQL; /* The SQL text that gnerates the report */
417
+ char *zErr = 0; /* An error message */
418
+ const char *zDesc; /* Extra descriptive text about the report */
419
+ const char *zMimetype; /* Mimetype for zDesc */
420
+ const char *zTag; /* Symbolic name for this report */
415421
int dflt = P("dflt") ? 1 : 0;
416422
417423
login_check_credentials();
418424
if( !g.perm.TktFmt ){
419425
login_needed(g.anon.TktFmt);
@@ -425,10 +431,14 @@
425431
zTitle = P("t");
426432
zOwner = PD("w",g.zLogin);
427433
z = P("s");
428434
zSQL = z ? trim_string(z) : 0;
429435
zClrKey = trim_string(PD("k",""));
436
+ zDesc = trim_string(PD("d",""));
437
+ zMimetype = P("m");
438
+ zTag = P("x");
439
+ report_update_reportfmt_table();
430440
if( rn>0 && P("del2") ){
431441
login_verify_csrf_secret();
432442
db_multi_exec("DELETE FROM reportfmt WHERE rn=%d", rn);
433443
cgi_redirect("reportlist");
434444
return;
@@ -470,18 +480,26 @@
470480
){
471481
zErr = mprintf("There is already another report named \"%h\"", zTitle);
472482
}
473483
if( zErr==0 ){
474484
login_verify_csrf_secret();
485
+ if( zTag && zTag[0]==0 ) zTag = 0;
486
+ if( zDesc && zDesc[0]==0 ){ zDesc = 0; zMimetype = 0; }
487
+ if( zMimetype && zMimetype[0]==0 ){ zDesc = 0; zMimetype = 0; }
475488
if( rn>0 ){
476
- db_multi_exec("UPDATE reportfmt SET title=%Q, sqlcode=%Q,"
477
- " owner=%Q, cols=%Q, mtime=now() WHERE rn=%d",
478
- zTitle, zSQL, zOwner, zClrKey, rn);
489
+ db_multi_exec(
490
+ "UPDATE reportfmt SET title=%Q, sqlcode=%Q,"
491
+ " owner=%Q, cols=%Q, mtime=now(), "
492
+ " jx=json_patch(jx,json_object('desc',%Q,'descmt',%Q,'tag',%Q))"
493
+ " WHERE rn=%d",
494
+ zTitle, zSQL, zOwner, zClrKey, zDesc, zMimetype, zTag, rn);
479495
}else{
480
- db_multi_exec("INSERT INTO reportfmt(title,sqlcode,owner,cols,mtime) "
481
- "VALUES(%Q,%Q,%Q,%Q,now())",
482
- zTitle, zSQL, zOwner, zClrKey);
496
+ db_multi_exec(
497
+ "INSERT INTO reportfmt(title,sqlcode,owner,cols,mtime,jx) "
498
+ "VALUES(%Q,%Q,%Q,%Q,now(),"
499
+ "json_object('desc',%Q,'descmt',%Q,'tag',%Q))",
500
+ zTitle, zSQL, zOwner, zClrKey, zDesc, zMimetype, zTag);
483501
rn = db_last_insert_rowid();
484502
}
485503
if( dflt ){
486504
db_set("ticket-default-report", zTitle, 0);
487505
}else{
@@ -497,21 +515,36 @@
497515
zTitle = "";
498516
zSQL = ticket_report_template();
499517
zClrKey = ticket_key_template();
500518
}else{
501519
Stmt q;
502
- db_prepare(&q, "SELECT title, sqlcode, owner, cols "
520
+ int hasJx;
521
+ zDesc = 0;
522
+ zMimetype = 0;
523
+ zTag = 0;
524
+ db_prepare(&q, "SELECT title, sqlcode, owner, cols, json_valid(jx) "
503525
"FROM reportfmt WHERE rn=%d",rn);
504526
if( db_step(&q)==SQLITE_ROW ){
505527
char *defaultReport = db_get("ticket-default-report", 0);
506528
zTitle = db_column_malloc(&q, 0);
507529
zSQL = db_column_malloc(&q, 1);
508530
zOwner = db_column_malloc(&q, 2);
509531
zClrKey = db_column_malloc(&q, 3);
510532
dflt = fossil_strcmp(zTitle, defaultReport)==0;
533
+ hasJx = db_column_int(&q, 4);
511534
}
512535
db_finalize(&q);
536
+ if( hasJx ){
537
+ db_prepare(&q, "SELECT jx->>'desc', jx->>'descmt', jx->>'tag'"
538
+ " FROM reportfmt WHERE rn=%d", rn);
539
+ if( db_step(&q)==SQLITE_ROW ){
540
+ zDesc = db_column_malloc(&q, 0);
541
+ zMimetype = db_column_malloc(&q, 1);
542
+ zTag = db_column_malloc(&q, 2);
543
+ }
544
+ db_finalize(&q);
545
+ }
513546
if( P("copy") ){
514547
rn = 0;
515548
zTitle = mprintf("Copy Of %s", zTitle);
516549
zOwner = g.zLogin;
517550
}
@@ -535,19 +568,33 @@
535568
login_insert_csrf_secret();
536569
if( g.perm.Admin ){
537570
@ <p>Report owner:
538571
@ <input type="text" name="w" size="20" value="%h(zOwner)" />
539572
@ </p>
573
+ @ <p>Tag:
574
+ @ <input type="text" name="x" size="20" value="%h(zTag?zTag:"")" />
575
+ @ </p>
540576
} else {
541577
@ <input type="hidden" name="w" value="%h(zOwner)" />
578
+ if( zTag && zTag[0] ){
579
+ @ <input type="hidden" name="x" value="%h(zTag)" />
580
+ }
542581
}
543582
@ <p>Enter an optional color key in the following box. (If blank, no
544583
@ color key is displayed.) Each line contains the text for a single
545584
@ entry in the key. The first token of each line is the background
546585
@ color for that line.<br />
547586
@ <textarea name="k" rows="8" cols="50">%h(zClrKey)</textarea>
548587
@ </p>
588
+
589
+ @ <p>Optional human-readable description for this report<br />
590
+ @ %z(href("%R/markup_help"))Markup style</a>:
591
+ mimetype_option_menu(zMimetype, "m");
592
+ @ <br><textarea aria-label="Description:" name="d" class="wikiedit" \
593
+ @ cols="80" rows="15" wrap="virtual">%h(zDesc)</textarea>
594
+ @ </p>
595
+
549596
@ <p><label><input type="checkbox" name="dflt" %s(dflt?"checked":"")> \
550597
@ Make this the default report</label></p>
551598
if( !g.perm.Admin && fossil_strcmp(zOwner,g.zLogin)!=0 ){
552599
@ <p>This report format is owned by %h(zOwner). You are not allowed
553600
@ to change it.</p>
@@ -1039,29 +1086,33 @@
10391086
int rn, rc;
10401087
char *zSql;
10411088
char *zTitle;
10421089
char *zOwner;
10431090
char *zClrKey;
1091
+ char *zDesc;
1092
+ char *zMimetype;
10441093
int tabs;
10451094
Stmt q;
10461095
char *zErr1 = 0;
10471096
char *zErr2 = 0;
10481097
10491098
login_check_credentials();
10501099
if( !g.perm.RdTkt ){ login_needed(g.anon.RdTkt); return; }
10511100
tabs = P("tablist")!=0;
10521101
db_prepare(&q,
1053
- "SELECT title, sqlcode, owner, cols, rn FROM reportfmt WHERE rn=%d",
1102
+ "SELECT title, sqlcode, owner, cols, rn, jx->>'desc', jx->>'descmt'"
1103
+ " FROM reportfmt WHERE rn=%d",
10541104
atoi(PD("rn","0")));
10551105
rc = db_step(&q);
10561106
if( rc!=SQLITE_ROW ){
10571107
const char *titleSearch =
10581108
defaultTitleSearch==0 || trim_string(defaultTitleSearch)[0]==0 ?
10591109
P("title") : defaultTitleSearch;
10601110
db_finalize(&q);
10611111
db_prepare(&q,
1062
- "SELECT title, sqlcode, owner, cols, rn FROM reportfmt WHERE title GLOB %Q",
1112
+ "SELECT title, sqlcode, owner, cols, rn, jx->>'desc', jx->>'descmt'"
1113
+ " FROM reportfmt WHERE title GLOB %Q",
10631114
titleSearch);
10641115
rc = db_step(&q);
10651116
}
10661117
if( rc!=SQLITE_ROW ){
10671118
db_finalize(&q);
@@ -1073,10 +1124,12 @@
10731124
zTitle = db_column_malloc(&q, 0);
10741125
zSql = db_column_malloc(&q, 1);
10751126
zOwner = db_column_malloc(&q, 2);
10761127
zClrKey = db_column_malloc(&q, 3);
10771128
rn = db_column_int(&q,4);
1129
+ zDesc = db_column_malloc(&q, 5);
1130
+ zMimetype = db_column_malloc(&q, 6);
10781131
db_finalize(&q);
10791132
10801133
if( P("order_by") ){
10811134
/*
10821135
** If the user wants to do a column sort, wrap the query into a sub
@@ -1117,10 +1170,17 @@
11171170
}
11181171
if( g.perm.NewTkt ){
11191172
style_submenu_element("New Ticket", "%R/tktnew");
11201173
}
11211174
style_header("%s", zTitle);
1175
+ }
1176
+ if( zDesc && zMimetype ){
1177
+ Blob src;
1178
+ blob_init(&src, zDesc, -1);
1179
+ wiki_render_by_mimetype(&src, zMimetype);
1180
+ blob_reset(&src);
1181
+ @ <p>
11221182
}
11231183
output_color_key(zClrKey, 1,
11241184
"border=\"0\" cellpadding=\"3\" cellspacing=\"0\" class=\"report\"");
11251185
@ <table border="1" cellpadding="2" cellspacing="0" class="report sortable"
11261186
@ data-column-types='' data-init-sort='0'>
11271187
--- src/report.c
+++ src/report.c
@@ -401,19 +401,25 @@
401 ** rn=N Ticket report number. (required)
402 ** t=TITLE Title of the report format
403 ** w=USER Owner of the report format
404 ** s=SQL SQL text used to implement the report
405 ** k=KEY Color key
 
 
 
406 */
407 void view_edit(void){
408 int rn;
409 const char *zTitle;
410 const char *z;
411 const char *zOwner;
412 const char *zClrKey;
413 char *zSQL;
414 char *zErr = 0;
 
 
 
415 int dflt = P("dflt") ? 1 : 0;
416
417 login_check_credentials();
418 if( !g.perm.TktFmt ){
419 login_needed(g.anon.TktFmt);
@@ -425,10 +431,14 @@
425 zTitle = P("t");
426 zOwner = PD("w",g.zLogin);
427 z = P("s");
428 zSQL = z ? trim_string(z) : 0;
429 zClrKey = trim_string(PD("k",""));
 
 
 
 
430 if( rn>0 && P("del2") ){
431 login_verify_csrf_secret();
432 db_multi_exec("DELETE FROM reportfmt WHERE rn=%d", rn);
433 cgi_redirect("reportlist");
434 return;
@@ -470,18 +480,26 @@
470 ){
471 zErr = mprintf("There is already another report named \"%h\"", zTitle);
472 }
473 if( zErr==0 ){
474 login_verify_csrf_secret();
 
 
 
475 if( rn>0 ){
476 db_multi_exec("UPDATE reportfmt SET title=%Q, sqlcode=%Q,"
477 " owner=%Q, cols=%Q, mtime=now() WHERE rn=%d",
478 zTitle, zSQL, zOwner, zClrKey, rn);
 
 
 
479 }else{
480 db_multi_exec("INSERT INTO reportfmt(title,sqlcode,owner,cols,mtime) "
481 "VALUES(%Q,%Q,%Q,%Q,now())",
482 zTitle, zSQL, zOwner, zClrKey);
 
 
483 rn = db_last_insert_rowid();
484 }
485 if( dflt ){
486 db_set("ticket-default-report", zTitle, 0);
487 }else{
@@ -497,21 +515,36 @@
497 zTitle = "";
498 zSQL = ticket_report_template();
499 zClrKey = ticket_key_template();
500 }else{
501 Stmt q;
502 db_prepare(&q, "SELECT title, sqlcode, owner, cols "
 
 
 
 
503 "FROM reportfmt WHERE rn=%d",rn);
504 if( db_step(&q)==SQLITE_ROW ){
505 char *defaultReport = db_get("ticket-default-report", 0);
506 zTitle = db_column_malloc(&q, 0);
507 zSQL = db_column_malloc(&q, 1);
508 zOwner = db_column_malloc(&q, 2);
509 zClrKey = db_column_malloc(&q, 3);
510 dflt = fossil_strcmp(zTitle, defaultReport)==0;
 
511 }
512 db_finalize(&q);
 
 
 
 
 
 
 
 
 
 
513 if( P("copy") ){
514 rn = 0;
515 zTitle = mprintf("Copy Of %s", zTitle);
516 zOwner = g.zLogin;
517 }
@@ -535,19 +568,33 @@
535 login_insert_csrf_secret();
536 if( g.perm.Admin ){
537 @ <p>Report owner:
538 @ <input type="text" name="w" size="20" value="%h(zOwner)" />
539 @ </p>
 
 
 
540 } else {
541 @ <input type="hidden" name="w" value="%h(zOwner)" />
 
 
 
542 }
543 @ <p>Enter an optional color key in the following box. (If blank, no
544 @ color key is displayed.) Each line contains the text for a single
545 @ entry in the key. The first token of each line is the background
546 @ color for that line.<br />
547 @ <textarea name="k" rows="8" cols="50">%h(zClrKey)</textarea>
548 @ </p>
 
 
 
 
 
 
 
 
549 @ <p><label><input type="checkbox" name="dflt" %s(dflt?"checked":"")> \
550 @ Make this the default report</label></p>
551 if( !g.perm.Admin && fossil_strcmp(zOwner,g.zLogin)!=0 ){
552 @ <p>This report format is owned by %h(zOwner). You are not allowed
553 @ to change it.</p>
@@ -1039,29 +1086,33 @@
1039 int rn, rc;
1040 char *zSql;
1041 char *zTitle;
1042 char *zOwner;
1043 char *zClrKey;
 
 
1044 int tabs;
1045 Stmt q;
1046 char *zErr1 = 0;
1047 char *zErr2 = 0;
1048
1049 login_check_credentials();
1050 if( !g.perm.RdTkt ){ login_needed(g.anon.RdTkt); return; }
1051 tabs = P("tablist")!=0;
1052 db_prepare(&q,
1053 "SELECT title, sqlcode, owner, cols, rn FROM reportfmt WHERE rn=%d",
 
1054 atoi(PD("rn","0")));
1055 rc = db_step(&q);
1056 if( rc!=SQLITE_ROW ){
1057 const char *titleSearch =
1058 defaultTitleSearch==0 || trim_string(defaultTitleSearch)[0]==0 ?
1059 P("title") : defaultTitleSearch;
1060 db_finalize(&q);
1061 db_prepare(&q,
1062 "SELECT title, sqlcode, owner, cols, rn FROM reportfmt WHERE title GLOB %Q",
 
1063 titleSearch);
1064 rc = db_step(&q);
1065 }
1066 if( rc!=SQLITE_ROW ){
1067 db_finalize(&q);
@@ -1073,10 +1124,12 @@
1073 zTitle = db_column_malloc(&q, 0);
1074 zSql = db_column_malloc(&q, 1);
1075 zOwner = db_column_malloc(&q, 2);
1076 zClrKey = db_column_malloc(&q, 3);
1077 rn = db_column_int(&q,4);
 
 
1078 db_finalize(&q);
1079
1080 if( P("order_by") ){
1081 /*
1082 ** If the user wants to do a column sort, wrap the query into a sub
@@ -1117,10 +1170,17 @@
1117 }
1118 if( g.perm.NewTkt ){
1119 style_submenu_element("New Ticket", "%R/tktnew");
1120 }
1121 style_header("%s", zTitle);
 
 
 
 
 
 
 
1122 }
1123 output_color_key(zClrKey, 1,
1124 "border=\"0\" cellpadding=\"3\" cellspacing=\"0\" class=\"report\"");
1125 @ <table border="1" cellpadding="2" cellspacing="0" class="report sortable"
1126 @ data-column-types='' data-init-sort='0'>
1127
--- src/report.c
+++ src/report.c
@@ -401,19 +401,25 @@
401 ** rn=N Ticket report number. (required)
402 ** t=TITLE Title of the report format
403 ** w=USER Owner of the report format
404 ** s=SQL SQL text used to implement the report
405 ** k=KEY Color key
406 ** d=DESC Optional descriptive text
407 ** m=MIMETYPE Mimetype for DESC
408 ** x=TAG Symbolic name for the report
409 */
410 void view_edit(void){
411 int rn;
412 const char *zTitle; /* Title of the report */
413 const char *z;
414 const char *zOwner; /* Owner of the report */
415 const char *zClrKey; /* Color key - used to add colors to lines */
416 char *zSQL; /* The SQL text that gnerates the report */
417 char *zErr = 0; /* An error message */
418 const char *zDesc; /* Extra descriptive text about the report */
419 const char *zMimetype; /* Mimetype for zDesc */
420 const char *zTag; /* Symbolic name for this report */
421 int dflt = P("dflt") ? 1 : 0;
422
423 login_check_credentials();
424 if( !g.perm.TktFmt ){
425 login_needed(g.anon.TktFmt);
@@ -425,10 +431,14 @@
431 zTitle = P("t");
432 zOwner = PD("w",g.zLogin);
433 z = P("s");
434 zSQL = z ? trim_string(z) : 0;
435 zClrKey = trim_string(PD("k",""));
436 zDesc = trim_string(PD("d",""));
437 zMimetype = P("m");
438 zTag = P("x");
439 report_update_reportfmt_table();
440 if( rn>0 && P("del2") ){
441 login_verify_csrf_secret();
442 db_multi_exec("DELETE FROM reportfmt WHERE rn=%d", rn);
443 cgi_redirect("reportlist");
444 return;
@@ -470,18 +480,26 @@
480 ){
481 zErr = mprintf("There is already another report named \"%h\"", zTitle);
482 }
483 if( zErr==0 ){
484 login_verify_csrf_secret();
485 if( zTag && zTag[0]==0 ) zTag = 0;
486 if( zDesc && zDesc[0]==0 ){ zDesc = 0; zMimetype = 0; }
487 if( zMimetype && zMimetype[0]==0 ){ zDesc = 0; zMimetype = 0; }
488 if( rn>0 ){
489 db_multi_exec(
490 "UPDATE reportfmt SET title=%Q, sqlcode=%Q,"
491 " owner=%Q, cols=%Q, mtime=now(), "
492 " jx=json_patch(jx,json_object('desc',%Q,'descmt',%Q,'tag',%Q))"
493 " WHERE rn=%d",
494 zTitle, zSQL, zOwner, zClrKey, zDesc, zMimetype, zTag, rn);
495 }else{
496 db_multi_exec(
497 "INSERT INTO reportfmt(title,sqlcode,owner,cols,mtime,jx) "
498 "VALUES(%Q,%Q,%Q,%Q,now(),"
499 "json_object('desc',%Q,'descmt',%Q,'tag',%Q))",
500 zTitle, zSQL, zOwner, zClrKey, zDesc, zMimetype, zTag);
501 rn = db_last_insert_rowid();
502 }
503 if( dflt ){
504 db_set("ticket-default-report", zTitle, 0);
505 }else{
@@ -497,21 +515,36 @@
515 zTitle = "";
516 zSQL = ticket_report_template();
517 zClrKey = ticket_key_template();
518 }else{
519 Stmt q;
520 int hasJx;
521 zDesc = 0;
522 zMimetype = 0;
523 zTag = 0;
524 db_prepare(&q, "SELECT title, sqlcode, owner, cols, json_valid(jx) "
525 "FROM reportfmt WHERE rn=%d",rn);
526 if( db_step(&q)==SQLITE_ROW ){
527 char *defaultReport = db_get("ticket-default-report", 0);
528 zTitle = db_column_malloc(&q, 0);
529 zSQL = db_column_malloc(&q, 1);
530 zOwner = db_column_malloc(&q, 2);
531 zClrKey = db_column_malloc(&q, 3);
532 dflt = fossil_strcmp(zTitle, defaultReport)==0;
533 hasJx = db_column_int(&q, 4);
534 }
535 db_finalize(&q);
536 if( hasJx ){
537 db_prepare(&q, "SELECT jx->>'desc', jx->>'descmt', jx->>'tag'"
538 " FROM reportfmt WHERE rn=%d", rn);
539 if( db_step(&q)==SQLITE_ROW ){
540 zDesc = db_column_malloc(&q, 0);
541 zMimetype = db_column_malloc(&q, 1);
542 zTag = db_column_malloc(&q, 2);
543 }
544 db_finalize(&q);
545 }
546 if( P("copy") ){
547 rn = 0;
548 zTitle = mprintf("Copy Of %s", zTitle);
549 zOwner = g.zLogin;
550 }
@@ -535,19 +568,33 @@
568 login_insert_csrf_secret();
569 if( g.perm.Admin ){
570 @ <p>Report owner:
571 @ <input type="text" name="w" size="20" value="%h(zOwner)" />
572 @ </p>
573 @ <p>Tag:
574 @ <input type="text" name="x" size="20" value="%h(zTag?zTag:"")" />
575 @ </p>
576 } else {
577 @ <input type="hidden" name="w" value="%h(zOwner)" />
578 if( zTag && zTag[0] ){
579 @ <input type="hidden" name="x" value="%h(zTag)" />
580 }
581 }
582 @ <p>Enter an optional color key in the following box. (If blank, no
583 @ color key is displayed.) Each line contains the text for a single
584 @ entry in the key. The first token of each line is the background
585 @ color for that line.<br />
586 @ <textarea name="k" rows="8" cols="50">%h(zClrKey)</textarea>
587 @ </p>
588
589 @ <p>Optional human-readable description for this report<br />
590 @ %z(href("%R/markup_help"))Markup style</a>:
591 mimetype_option_menu(zMimetype, "m");
592 @ <br><textarea aria-label="Description:" name="d" class="wikiedit" \
593 @ cols="80" rows="15" wrap="virtual">%h(zDesc)</textarea>
594 @ </p>
595
596 @ <p><label><input type="checkbox" name="dflt" %s(dflt?"checked":"")> \
597 @ Make this the default report</label></p>
598 if( !g.perm.Admin && fossil_strcmp(zOwner,g.zLogin)!=0 ){
599 @ <p>This report format is owned by %h(zOwner). You are not allowed
600 @ to change it.</p>
@@ -1039,29 +1086,33 @@
1086 int rn, rc;
1087 char *zSql;
1088 char *zTitle;
1089 char *zOwner;
1090 char *zClrKey;
1091 char *zDesc;
1092 char *zMimetype;
1093 int tabs;
1094 Stmt q;
1095 char *zErr1 = 0;
1096 char *zErr2 = 0;
1097
1098 login_check_credentials();
1099 if( !g.perm.RdTkt ){ login_needed(g.anon.RdTkt); return; }
1100 tabs = P("tablist")!=0;
1101 db_prepare(&q,
1102 "SELECT title, sqlcode, owner, cols, rn, jx->>'desc', jx->>'descmt'"
1103 " FROM reportfmt WHERE rn=%d",
1104 atoi(PD("rn","0")));
1105 rc = db_step(&q);
1106 if( rc!=SQLITE_ROW ){
1107 const char *titleSearch =
1108 defaultTitleSearch==0 || trim_string(defaultTitleSearch)[0]==0 ?
1109 P("title") : defaultTitleSearch;
1110 db_finalize(&q);
1111 db_prepare(&q,
1112 "SELECT title, sqlcode, owner, cols, rn, jx->>'desc', jx->>'descmt'"
1113 " FROM reportfmt WHERE title GLOB %Q",
1114 titleSearch);
1115 rc = db_step(&q);
1116 }
1117 if( rc!=SQLITE_ROW ){
1118 db_finalize(&q);
@@ -1073,10 +1124,12 @@
1124 zTitle = db_column_malloc(&q, 0);
1125 zSql = db_column_malloc(&q, 1);
1126 zOwner = db_column_malloc(&q, 2);
1127 zClrKey = db_column_malloc(&q, 3);
1128 rn = db_column_int(&q,4);
1129 zDesc = db_column_malloc(&q, 5);
1130 zMimetype = db_column_malloc(&q, 6);
1131 db_finalize(&q);
1132
1133 if( P("order_by") ){
1134 /*
1135 ** If the user wants to do a column sort, wrap the query into a sub
@@ -1117,10 +1170,17 @@
1170 }
1171 if( g.perm.NewTkt ){
1172 style_submenu_element("New Ticket", "%R/tktnew");
1173 }
1174 style_header("%s", zTitle);
1175 }
1176 if( zDesc && zMimetype ){
1177 Blob src;
1178 blob_init(&src, zDesc, -1);
1179 wiki_render_by_mimetype(&src, zMimetype);
1180 blob_reset(&src);
1181 @ <p>
1182 }
1183 output_color_key(zClrKey, 1,
1184 "border=\"0\" cellpadding=\"3\" cellspacing=\"0\" class=\"report\"");
1185 @ <table border="1" cellpadding="2" cellspacing="0" class="report sortable"
1186 @ data-column-types='' data-init-sort='0'>
1187
+8 -5
--- src/wiki.c
+++ src/wiki.c
@@ -646,15 +646,18 @@
646646
return nrid;
647647
}
648648
649649
/*
650650
** Output a selection box from which the user can select the
651
-** wiki mimetype.
651
+** wiki mimetype. Arguments:
652
+**
653
+** zMimetype - The current value of the query parameter
654
+** zParam - The name of the query parameter
652655
*/
653
-void mimetype_option_menu(const char *zMimetype){
656
+void mimetype_option_menu(const char *zMimetype, const char *zParam){
654657
unsigned i;
655
- @ <select name="mimetype" size="1">
658
+ @ <select name="%s(zParam)" size="1">
656659
for(i=0; i<count(azStyles); i+=3){
657660
if( fossil_strcmp(zMimetype,azStyles[i])==0 ){
658661
@ <option value="%s(azStyles[i])" selected>%s(azStyles[i+1])</option>
659662
}else{
660663
@ <option value="%s(azStyles[i])">%s(azStyles[i+1])</option>
@@ -1334,11 +1337,11 @@
13341337
">");
13351338
CX("<div class='"
13361339
"wikiedit-options flex-container flex-row child-gap-small'>");
13371340
CX("<div class='input-with-label'>"
13381341
"<label>Mime type</label>");
1339
- mimetype_option_menu("text/x-markdown");
1342
+ mimetype_option_menu("text/x-markdown", "mimetype");
13401343
CX("</div>");
13411344
style_select_list_int("select-font-size",
13421345
"editor_font_size", "Editor font size",
13431346
NULL/*tooltip*/,
13441347
100,
@@ -1535,11 +1538,11 @@
15351538
well_formed_wiki_name_rules();
15361539
form_begin(0, "%R/wikinew");
15371540
@ <p>Name of new wiki page:
15381541
@ <input style="width: 35;" type="text" name="name" value="%h(zName)" /><br />
15391542
@ %z(href("%R/markup_help"))Markup style</a>:
1540
- mimetype_option_menu("text/x-markdown");
1543
+ mimetype_option_menu("text/x-markdown", "mimetype");
15411544
@ <br /><input type="submit" value="Create" />
15421545
@ </p></form>
15431546
if( zName[0] ){
15441547
@ <p><span class="wikiError">
15451548
@ "%h(zName)" is not a valid wiki page name!</span></p>
15461549
--- src/wiki.c
+++ src/wiki.c
@@ -646,15 +646,18 @@
646 return nrid;
647 }
648
649 /*
650 ** Output a selection box from which the user can select the
651 ** wiki mimetype.
 
 
 
652 */
653 void mimetype_option_menu(const char *zMimetype){
654 unsigned i;
655 @ <select name="mimetype" size="1">
656 for(i=0; i<count(azStyles); i+=3){
657 if( fossil_strcmp(zMimetype,azStyles[i])==0 ){
658 @ <option value="%s(azStyles[i])" selected>%s(azStyles[i+1])</option>
659 }else{
660 @ <option value="%s(azStyles[i])">%s(azStyles[i+1])</option>
@@ -1334,11 +1337,11 @@
1334 ">");
1335 CX("<div class='"
1336 "wikiedit-options flex-container flex-row child-gap-small'>");
1337 CX("<div class='input-with-label'>"
1338 "<label>Mime type</label>");
1339 mimetype_option_menu("text/x-markdown");
1340 CX("</div>");
1341 style_select_list_int("select-font-size",
1342 "editor_font_size", "Editor font size",
1343 NULL/*tooltip*/,
1344 100,
@@ -1535,11 +1538,11 @@
1535 well_formed_wiki_name_rules();
1536 form_begin(0, "%R/wikinew");
1537 @ <p>Name of new wiki page:
1538 @ <input style="width: 35;" type="text" name="name" value="%h(zName)" /><br />
1539 @ %z(href("%R/markup_help"))Markup style</a>:
1540 mimetype_option_menu("text/x-markdown");
1541 @ <br /><input type="submit" value="Create" />
1542 @ </p></form>
1543 if( zName[0] ){
1544 @ <p><span class="wikiError">
1545 @ "%h(zName)" is not a valid wiki page name!</span></p>
1546
--- src/wiki.c
+++ src/wiki.c
@@ -646,15 +646,18 @@
646 return nrid;
647 }
648
649 /*
650 ** Output a selection box from which the user can select the
651 ** wiki mimetype. Arguments:
652 **
653 ** zMimetype - The current value of the query parameter
654 ** zParam - The name of the query parameter
655 */
656 void mimetype_option_menu(const char *zMimetype, const char *zParam){
657 unsigned i;
658 @ <select name="%s(zParam)" size="1">
659 for(i=0; i<count(azStyles); i+=3){
660 if( fossil_strcmp(zMimetype,azStyles[i])==0 ){
661 @ <option value="%s(azStyles[i])" selected>%s(azStyles[i+1])</option>
662 }else{
663 @ <option value="%s(azStyles[i])">%s(azStyles[i+1])</option>
@@ -1334,11 +1337,11 @@
1337 ">");
1338 CX("<div class='"
1339 "wikiedit-options flex-container flex-row child-gap-small'>");
1340 CX("<div class='input-with-label'>"
1341 "<label>Mime type</label>");
1342 mimetype_option_menu("text/x-markdown", "mimetype");
1343 CX("</div>");
1344 style_select_list_int("select-font-size",
1345 "editor_font_size", "Editor font size",
1346 NULL/*tooltip*/,
1347 100,
@@ -1535,11 +1538,11 @@
1538 well_formed_wiki_name_rules();
1539 form_begin(0, "%R/wikinew");
1540 @ <p>Name of new wiki page:
1541 @ <input style="width: 35;" type="text" name="name" value="%h(zName)" /><br />
1542 @ %z(href("%R/markup_help"))Markup style</a>:
1543 mimetype_option_menu("text/x-markdown", "mimetype");
1544 @ <br /><input type="submit" value="Create" />
1545 @ </p></form>
1546 if( zName[0] ){
1547 @ <p><span class="wikiError">
1548 @ "%h(zName)" is not a valid wiki page name!</span></p>
1549

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button