From 141c78b9ff849217e88bf34ef238342fd848a1a0 Mon Sep 17 00:00:00 2001 From: Jake Jackson Date: Wed, 21 Aug 2024 14:51:18 +1000 Subject: [PATCH] Add Preview PDF feature to Form PDF Settings --- src/Helper/Helper_Abstract_Options.php | 7 +- src/Helper/Helper_Data.php | 3 +- src/Helper/Helper_Options_Fields.php | 16 +- src/Model/Model_Form_Settings.php | 2 +- src/Model/Model_PDF.php | 138 +++-- .../Rest_Form_Settings.php} | 466 ++++++++------ src/Rest/Rest_Pdf_Preview.php | 136 +++++ src/View/html/FormSettings/add_edit.php | 16 +- src/assets/js/admin/helper/spinner.js | 6 +- .../common/setupDynamicTemplateFields.js | 14 +- src/assets/js/react/api/preview.js | 83 +++ .../js/react/bootstrap/templateBootstrap.js | 1 - src/assets/js/react/gfpdf-main.js | 27 +- .../{addEditButton.js => actionToolbar.js} | 28 +- .../utilities/PdfSettings/formSettings.js | 145 +++++ .../utilities/PdfSettings/previewButton.js | 60 ++ .../PdfSettings/unsavedChangesWarning.js | 29 + src/assets/js/react/utilities/download.js | 22 + src/assets/scss/Component/_submit.scss | 2 +- src/assets/scss/MediaQueries/_min-782.scss | 24 + src/assets/scss/Pages/_pdf-settings.scss | 13 +- src/assets/scss/gfpdf-styles.scss | 1 + src/bootstrap.php | 39 +- tests/e2e/advanced-checks/pdf-preview.test.js | 27 + .../page-model/helpers/advanced-check.js | 2 +- tests/e2e/utilities/page-model/helpers/pdf.js | 9 +- .../page-model/tabs/general-settings.js | 2 +- .../e2e/utilities/page-model/tabs/license.js | 2 +- tests/phpunit/bootstrap.php | 8 +- .../{unit-tests => data}/fonts/Chewy.ttf | Bin .../fonts/DejaVuSans-Bold.ttf | Bin .../{unit-tests => data}/fonts/DejaVuSans.ttf | Bin .../fonts/DejaVuSansCondensed.ttf | Bin .../fonts/DejaVuSerifCondensed.ttf | Bin .../fonts/chewy-LICENSE.txt | 0 .../json/all-form-euro-product-entry.json | 0 .../json/all-form-fields-entries.json | 0 .../json/all-form-fields.json | 0 .../json/form-settings-sample-input.json | 0 .../json/form-settings.json | 0 .../json/gravityform-1-entries.json | 0 .../json/gravityform-1.json | 0 .../json/gravityform-2.json | 0 .../json/latest-posts.json | 0 .../json/migration_v3_to_v4.json | 0 .../json/non-group-products-form-entries.json | 0 .../json/non-group-products-form.json | 0 .../json/number-fields.json | 0 .../json/options-settings.json | 0 .../json/repeater-consent-entry.json | 0 .../json/repeater-consent-form.json | 0 .../json/repeater-empty-entry.json | 0 .../json/repeater-empty-form.json | 0 .../json/shortcode-data.json | 0 .../Test_Controller_Custom_Fonts.php | 16 +- tests/phpunit/unit-tests/Rest/Test_Rest.php | 86 +++ .../Test_Rest_Form_Settings.php} | 571 +++++++++++------- .../unit-tests/Rest/Test_Rest_Pdf_Preview.php | 143 +++++ tests/phpunit/unit-tests/php/simple_config | 106 ---- tests/phpunit/unit-tests/test-ajax.php | 2 +- tests/phpunit/unit-tests/test-api.php | 6 +- tests/phpunit/unit-tests/test-form-data.php | 4 +- .../phpunit/unit-tests/test-form-settings.php | 2 +- tests/phpunit/unit-tests/test-options-api.php | 2 +- tests/phpunit/unit-tests/test-shortcodes.php | 4 +- .../unit-tests/test-slow-pdf-processes.php | 18 +- 66 files changed, 1620 insertions(+), 668 deletions(-) rename src/{Controller/Controller_Form_Settings_Rest_Api.php => Rest/Rest_Form_Settings.php} (71%) create mode 100644 src/Rest/Rest_Pdf_Preview.php create mode 100644 src/assets/js/react/api/preview.js rename src/assets/js/react/utilities/PdfSettings/{addEditButton.js => actionToolbar.js} (52%) create mode 100644 src/assets/js/react/utilities/PdfSettings/formSettings.js create mode 100644 src/assets/js/react/utilities/PdfSettings/previewButton.js create mode 100644 src/assets/js/react/utilities/PdfSettings/unsavedChangesWarning.js create mode 100644 src/assets/js/react/utilities/download.js create mode 100644 src/assets/scss/MediaQueries/_min-782.scss create mode 100644 tests/e2e/advanced-checks/pdf-preview.test.js rename tests/phpunit/{unit-tests => data}/fonts/Chewy.ttf (100%) rename tests/phpunit/{unit-tests => data}/fonts/DejaVuSans-Bold.ttf (100%) rename tests/phpunit/{unit-tests => data}/fonts/DejaVuSans.ttf (100%) rename tests/phpunit/{unit-tests => data}/fonts/DejaVuSansCondensed.ttf (100%) rename tests/phpunit/{unit-tests => data}/fonts/DejaVuSerifCondensed.ttf (100%) rename tests/phpunit/{unit-tests => data}/fonts/chewy-LICENSE.txt (100%) rename tests/phpunit/{unit-tests => data}/json/all-form-euro-product-entry.json (100%) rename tests/phpunit/{unit-tests => data}/json/all-form-fields-entries.json (100%) rename tests/phpunit/{unit-tests => data}/json/all-form-fields.json (100%) rename tests/phpunit/{unit-tests => data}/json/form-settings-sample-input.json (100%) rename tests/phpunit/{unit-tests => data}/json/form-settings.json (100%) rename tests/phpunit/{unit-tests => data}/json/gravityform-1-entries.json (100%) rename tests/phpunit/{unit-tests => data}/json/gravityform-1.json (100%) rename tests/phpunit/{unit-tests => data}/json/gravityform-2.json (100%) rename tests/phpunit/{unit-tests => data}/json/latest-posts.json (100%) rename tests/phpunit/{unit-tests => data}/json/migration_v3_to_v4.json (100%) rename tests/phpunit/{unit-tests => data}/json/non-group-products-form-entries.json (100%) rename tests/phpunit/{unit-tests => data}/json/non-group-products-form.json (100%) rename tests/phpunit/{unit-tests => data}/json/number-fields.json (100%) rename tests/phpunit/{unit-tests => data}/json/options-settings.json (100%) rename tests/phpunit/{unit-tests => data}/json/repeater-consent-entry.json (100%) rename tests/phpunit/{unit-tests => data}/json/repeater-consent-form.json (100%) rename tests/phpunit/{unit-tests => data}/json/repeater-empty-entry.json (100%) rename tests/phpunit/{unit-tests => data}/json/repeater-empty-form.json (100%) rename tests/phpunit/{unit-tests => data}/json/shortcode-data.json (100%) create mode 100644 tests/phpunit/unit-tests/Rest/Test_Rest.php rename tests/phpunit/unit-tests/{Controller/Test_Controller_Form_Settings_Rest_Api.php => Rest/Test_Rest_Form_Settings.php} (70%) create mode 100644 tests/phpunit/unit-tests/Rest/Test_Rest_Pdf_Preview.php delete mode 100644 tests/phpunit/unit-tests/php/simple_config diff --git a/src/Helper/Helper_Abstract_Options.php b/src/Helper/Helper_Abstract_Options.php index 06b5a71eb..84dad11c0 100644 --- a/src/Helper/Helper_Abstract_Options.php +++ b/src/Helper/Helper_Abstract_Options.php @@ -2272,7 +2272,12 @@ public function toggle_callback( $args ) {
- /> + />