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

Feature/order export #2766

Draft
wants to merge 7 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
25 changes: 20 additions & 5 deletions assets/js/llms-admin-tables.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

var self = this;

self.$tables = $( '.llms-gb-table' );
self.$tables = $( '.llms-gb-table, body.post-type-llms_order .wp-list-table' );

if ( self.$tables.length ) {
self.bind();
Expand Down Expand Up @@ -52,6 +52,12 @@
self.export( $table, $( this ) );
} );

// The export button might be in the tablenav below the table.
$table.parent().find( '.tablenav button[name="llms-table-export"]' ).on( 'click', function( e ) {
e.preventDefault();
self.export( $table, $( this ) );
} );

$table.on( 'click', 'a.llms-sortable', function( e ) {
e.preventDefault();
self.change_order( $table, $( this ) );
Expand Down Expand Up @@ -141,20 +147,29 @@
this.export = function( $table, $btn, filename ) {

var self = this,
$msg = $table.find( '.llms-table-export .llms-table-export-msg' ),
$progress = $table.find( '.llms-table-export .llms-table-progress' );
$msg = $table.parent().find( '.llms-table-export .llms-table-export-msg' ),
$progress = $table.parent().find( '.llms-table-export .llms-table-progress' );

function activate_button() {
LLMS.Spinner.stop( $btn, 'small' );
$btn.removeAttr( 'disabled' );
}

// Figure out if the data-handler and args are on the table or button.
if ( ! $table.attr( 'data-handler' ) ) {
$data_handler = $btn.attr( 'data-handler' );
$data_args = $btn.attr( 'data-args' );
} else {
$data_handler = $table.attr( 'data-handler' );
$data_args = $table.attr( 'data-args' );
}

LLMS.Ajax.call( {
data: $.extend( {
action: 'export_admin_table',
handler: $table.attr( 'data-handler' ),
handler: $data_handler,
filename: filename,
}, JSON.parse( $table.attr( 'data-args' ) ) ),
}, JSON.parse( $data_args ) ),
beforeSend: function() {

if ( ! $btn.attr( 'disabled' ) ) {
Expand Down
2 changes: 1 addition & 1 deletion assets/js/llms-admin-tables.min.js

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

1 change: 1 addition & 0 deletions includes/admin/class.llms.admin.assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ public function admin_scripts() {
'course',
'lifterlms_page_llms-reporting',
'llms_membership',
'edit-llms_order',
)
);
if ( in_array( $screen->id, $tables, true ) ) {
Expand Down
Loading
Loading