Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display and updated in process documents in PDF document data metabox #782

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
d420c49
Move PDF document data markup to separate file in the views directory…
MohamadNateqi Apr 29, 2024
a4b723e
Update and improvements for `output_number_date_edit_fields()` method
MohamadNateqi Apr 29, 2024
be12ee7
Add Ajax fetch document data
MohamadNateqi Apr 29, 2024
ca206a2
Improvements and WPCS
MohamadNateqi Apr 29, 2024
69cfaf2
WPCS
MohamadNateqi Apr 29, 2024
344768f
Generate minified JS and CSS files
MohamadNateqi Apr 29, 2024
5fa229d
Update version
MohamadNateqi Apr 29, 2024
24096b4
Merge branch 'refs/heads/main' into 756-pdf-document-data-in-process
MohamadNateqi May 16, 2024
8d35403
Merge branch 'refs/heads/main' into 756-pdf-document-data-in-process
MohamadNateqi May 31, 2024
2497c7c
Merge branch 'refs/heads/main' into 756-pdf-document-data-in-process
MohamadNateqi Jun 5, 2024
342a8dd
Merge branch 'refs/heads/main' into 756-pdf-document-data-in-process
MohamadNateqi Jul 8, 2024
b0f24e6
Merge branch 'refs/heads/main' into 756-pdf-document-data-in-process
MohamadNateqi Jul 9, 2024
e8495aa
WPCS
alexmigf Jul 9, 2024
8411c79
WPCS
alexmigf Jul 9, 2024
4dfa736
Tweaks
alexmigf Jul 9, 2024
767c2e1
WPCS
MohamadNateqi Jul 9, 2024
21a8662
Improvements
MohamadNateqi Jul 9, 2024
925a127
Add a comment
MohamadNateqi Jul 9, 2024
6cd4c67
Fix translation of labels
MohamadNateqi Jul 9, 2024
6849117
Fix translation of labels
MohamadNateqi Jul 9, 2024
7029ecf
Improvements
MohamadNateqi Jul 10, 2024
9bf76b5
Merge branch 'refs/heads/main' into 756-pdf-document-data-in-process
MohamadNateqi Sep 2, 2024
f034d2b
Merge branch 'refs/heads/main' into 756-pdf-document-data-in-process
MohamadNateqi Oct 9, 2024
7e210fb
Fix path
MohamadNateqi Oct 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions assets/css/order-styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@

#wpo_wcpdf-data-input-box .form-field input {
width: auto;
min-width: 5em;
}

.wcpdf-data-fields {
Expand Down
2 changes: 1 addition & 1 deletion assets/css/order-styles.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 48 additions & 0 deletions assets/js/order-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,52 @@ jQuery( function( $ ) {
}
} );

function get_pending_documents() {
let pending_documents = [];
$( '.wcpdf-data-fields' ).each( function () {
if ( 'yes' === $( this ).attr( 'data-is_pending' ) ) {
pending_documents.push( $( this ).data( 'document' ) );
}
} );

return pending_documents;
}

// Fetch data for pending documents if documents were pending and now are generated.
const pending_documents = get_pending_documents();
let ajax_count = 0;
const ajax_max_count = 3;
const ajax_interval = 2000;
const ajax_timer = function() {
if ( pending_documents.length <= 0 ) {
return;
}

$.ajax( {
url: wpo_wcpdf_ajax.ajaxurl,
type: 'POST',
data: {
action: 'wpo_fetch_document_data',
security: wpo_wcpdf_ajax.nonce,
document_types: pending_documents,
order_id: woocommerce_admin_meta_boxes.post_id,
},
success: function ( response ) {
$.each( response.data, function ( key, value ) {
$( '.wcpdf-data-fields[data-document="' + key + '"]' ).replaceWith( value );
} );
},
error: function ( response ) {
console.log( response.message );
}
} );

ajax_count++;
if ( ajax_count < ajax_max_count ) {
setTimeout( ajax_timer, ajax_interval );
}
}

setTimeout( ajax_timer, ajax_interval );

} );
2 changes: 1 addition & 1 deletion assets/js/order-script.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading