From 9cf895e5ed869083d87c876f2ed244509f56699f Mon Sep 17 00:00:00 2001 From: wbudic Date: Sat, 14 Aug 2021 14:40:19 +1000 Subject: [PATCH] Impl. the buffered rtf document storing & loading. --- .gitignore | 2 + Current Development Check List.md | 5 +++ htdocs/cgi-bin/main.cgi | 39 ++++++++++------ htdocs/cgi-bin/wsrc/main.css | 7 ++- htdocs/cgi-bin/wsrc/main.js | 74 ++++++++++++++++++++----------- 5 files changed, 85 insertions(+), 42 deletions(-) diff --git a/.gitignore b/.gitignore index 8f15f5f..d0bfbb6 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,8 @@ *.pid *.log *.osz +*.swm +*.swn cgisess_* .DS_Store .idea diff --git a/Current Development Check List.md b/Current Development Check List.md index aa9a4af..3546613 100644 --- a/Current Development Check List.md +++ b/Current Development Check List.md @@ -6,10 +6,15 @@ ### New Development +* ✔ RTF load of the zero document if present. When RTF attaching to a new log, you can save the rtf, + it is called a zero document (not assigned), as the log hasn't been saved yet. This reload can be useful, as it is always stored... * ✔ Implement backup/restore on Pg based data. Restore only partially works from older backup. * ✔ Bug 35. SQL migration, version update, not working for PG based databases. * ✔ JS - Event, on expense sum in log numbers found at beginning of lines. * ✔ Update to CNF v.2.2, branch to $RELEASE_VER = 2.3, Earth Stage initial. + +#### Not Urgent New Development ( In Planning + * Plugins * Perl files enabled by being including them in main.cnf file under the <>> list, and placed in the plugins directory. * This plugin perl file is then be executed, to provide auto installation and checks. diff --git a/htdocs/cgi-bin/main.cgi b/htdocs/cgi-bin/main.cgi index c085461..6edf73a 100755 --- a/htdocs/cgi-bin/main.cgi +++ b/htdocs/cgi-bin/main.cgi @@ -83,7 +83,7 @@ my $BGCOL = Settings::bgcol(); #Set to 1 to get debug help. Switch off with 0. my $DEBUG = Settings::debug(); #END OF SETTINGS - +my $rtf_buffer = 0; my $BUFFER; sub toBuf { $BUFFER .= shift; @@ -751,7 +751,7 @@ $log_output .= <<_TXT; Show All hidden ➔ - +   @@ -765,7 +765,6 @@ $log_output .= <<_TXT;   - _TXT @@ -785,9 +784,11 @@ $log_output .= qq(
- + + @@ -797,9 +798,7 @@ $log_output .= qq(
* LOG ENTRY FORM * - $sp1 - $sp2 +
* LOG ENTRY FORM * + $sp1 + $sp2
Date:
Now   - Enter log... -    Category:  @@ -817,7 +816,8 @@ $log_output .= qq(
- + +
 Amount:
Amount:   Marks as: @@ -826,12 +826,19 @@ $log_output .= qq(Income  - RTF Attach - Sticky + + + RTF Attach + + Sticky + + @@ -845,6 +852,7 @@ $log_output .= qq(
  - + + +
+ $tags ); @@ -1079,6 +1087,7 @@ sub processSubmit { my $sticky = $cgi->param('sticky'); my $stm; my $SQLID = 'rowid'; + my @gzero; if($rtf eq 'on'){$rtf = 1} else {$rtf = 0} if($sticky eq 'on'){$sticky = 1} else {$sticky = 0} @@ -1200,6 +1209,8 @@ try { } Settings::renumerate($db) if ( $dtCur > $dt ); } + if(!@gzero){$st = traceDBExe('SELECT DOC FROM NOTES WHERE LID = 0;');@gzero = $st->fetchrow_array()} + $rtf_buffer = 1 if $gzero[0]; } catch { @@ -1444,7 +1455,9 @@ return qq(
- + + +
)} diff --git a/htdocs/cgi-bin/wsrc/main.css b/htdocs/cgi-bin/wsrc/main.css index f960317..bb3d495 100644 --- a/htdocs/cgi-bin/wsrc/main.css +++ b/htdocs/cgi-bin/wsrc/main.css @@ -283,18 +283,17 @@ img { .midnight{ color:midnightblue; } - - a:link { color:#5b06fa; } a:visited { - color: #065bfa; + color: #2d7081; } a:hover { color: #2d7081; - font-style: oblique; + font-style:normal; + font-size: x-large; } #sss_status{ diff --git a/htdocs/cgi-bin/wsrc/main.js b/htdocs/cgi-bin/wsrc/main.js index d61ac3c..d1f69f1 100644 --- a/htdocs/cgi-bin/wsrc/main.js +++ b/htdocs/cgi-bin/wsrc/main.js @@ -15,6 +15,7 @@ var DEF_BACKGROUND = 'white'; var RTF_DOC_RESIZED = false; var RTF_DOC_ORIG; +var RTF_DOC_CUR_ID; var TIME_STAMP; var LOCALE; var TIMEZONE; @@ -23,6 +24,8 @@ var DBI_LVAR_SZ; function onBodyLoadGeneric() { $("input[type=submit], input[type=reset], .ui-widget-content, button, .a_").button(); $("#btn_save_doc").button(); + $("#btn_zero_doc").button(); if($("rtf_buffer").val()==0){$("#btn_zero_doc").hide()}; + $("#btn_load_doc").button(); $("#btn_load_doc").hide(); if(!LOCALE || LOCALE==="English"){ LOCALE = "en-US"; } @@ -387,7 +390,6 @@ function onBodyLoad(toggle, locale, tz, today, expires, rs_cur, log_limit) { source: AUTOWORDS }); }); - display("Log page is ready!"); } @@ -570,8 +572,12 @@ function edit(row) { if(isRTF){ display("Loading RTF: "+ ed_v.val() ); + RTF_DOC_CUR_ID = row; loadRTF(false, row); - }else{display("Editing: "+ ed_v.val(),3);} + }else{ + display("Editing: "+ ed_v.val(),3); + RTF_DOC_CUR_ID = 0; + } //Select category var ec_lb = $("#c" + row).text(); @@ -685,11 +691,10 @@ function resizeDoc() { } function resetDoc(){ - if (RTF_SET) { - QUILL.setText(""); - } + if (RTF_SET) { QUILL.setText(""); } $("#submit_is_edit").val("0"); toggleDoc(true); + $('#btn_load_doc').hide(); } @@ -1050,7 +1055,7 @@ var RTF_SUBMIT = false; function saveRTF(id, action) { // alert(JSON.stringify(QUILL.getContents())); - //Strip ammount to show plain number. + //Strip amount to show plain number. var am = $("#am").val().trim(); am = am.replace(/[^\d\.]/g,""); $("#am").val(am); @@ -1064,28 +1069,40 @@ function saveRTF(id, action) { } RTF_SUBMIT = true; var bg = $("#fldBG").val(); - $.post('json.cgi', {action:'store', id:id, bg:bg, doc: JSON.stringify(QUILL.getContents())},saveRTFResult).fail( - function(response) {dialogModal("Server Error: "+response.status,response.responseText);}); - if(is_submit){ - //we must wait before submitting actual form! + $.post('json.cgi', {action:'store', id:id, bg:bg, doc: JSON.stringify( + QUILL.getContents())},saveRTFResult).fail( + function(response) {dialogModal("Server Error: "+response.status,response.responseText);} + ); + if(is_submit){ $("#idx_cat").value = "SAVING DOCUMENT..."; $("#idx_cat").show(); + //we must wait before submitting actual form! setTimeout(delayedSubmit, 200); } return false; } function saveRTFResult(result) { - console.log("Result->" + result); - var obj = JSON.parse(result); - //alert(obj.response); + //console.log("Result->" + result); + var json = JSON.parse(result); $("html, body").animate({ scrollTop: 0 }, "fast"); - display(obj.response); - if(obj.log_id>0){ + + let msg = json.response; + if(json.log_id==0){ + console.log(msg = "Saved to Buffer"); + + }else{ + console.log(msg = "Saved document by lid -> "+json.log_id); + } + display(msg, 5); + + if(json.log_id>0){ //update under log display - if($("#q-rtf"+obj.log_id).is(":visible")){ - loadRTF(true, obj.log_id); + if($("#q-rtf"+json.log_id).is(":visible")){ + loadRTF(true, json.log_id); } + }else{ + $('#btn_zero_doc').show(); } RTF_SUBMIT = false; } @@ -1104,13 +1121,10 @@ function loadRTF(under, id){ //show under log entry the document if(under){ - if($("#q-rtf"+id).is(":visible")){ $("#q-rtf"+id).hide(); return false; } - - QUILL_PNL = new Quill('#q-container'+id, { scrollingContainer: '#q-scroll'+id, placeholder: 'Loading Document...', @@ -1123,8 +1137,10 @@ function loadRTF(under, id){ return false; } - //var json = "[{'insert': 'Loading Document...', 'attributes': { 'bold': true }}, {'insert': '\n'}]"; - //console.log("Query json.cgi action -> load, id:" + id); + if(id==-1){ + id = RTF_DOC_CUR_ID; // btn_load_rtf clicked + } + QUILL.setText('Loading Document...\n'); $.post('json.cgi', {action:'load', id:id}, loadRTFResult).fail( function(response) {dialogModal("Server Error: "+response.status,response.responseText);} @@ -1142,7 +1158,7 @@ function loadRTFPnlResult(content, result, prms) { } function loadRTFResult(content, result, prms, quill) { - //console.log("Result->" + content); + var json = JSON.parse(content); if(!quill)quill=QUILL; @@ -1157,8 +1173,16 @@ function loadRTFResult(content, result, prms, quill) { var css = $("#q-scroll"+id).prop('style'); if(css){css.backgroundColor = json.content.bg;} } - display(json.response, 5); - //alert(obj.response); + + let msg = json.response; + if(json.log_id==0){ + console.log(msg = "Loaded in Buffer"); + $('#btn_zero_doc').show(); + }else{ + console.log(msg = "Loaded in document by lid -> "+json.log_id); + $('#btn_load_doc').show(); + } + display(msg, 5); } -- 2.34.1