From e3584c7e5b1bf1f10968f703367801331ba0d791 Mon Sep 17 00:00:00 2001 From: Antoine M Date: Tue, 23 Apr 2024 09:30:51 +0200 Subject: [PATCH] refining custom orderPaper form --- Makefile_prod | 62 ------ includes/forms.php | 3 +- ...rPaper.php => field-OrderBrochureList.php} | 15 +- includes/forms/field-OrderDocumentsList.php | 178 ++++++++++++++++++ .../forms/template-field-order-brochures.php | 47 +++++ .../forms/template-field-order-documents.php | 55 ++++++ includes/forms/template-form-order-paper.php | 37 ---- resources/css/admin-style.css | 64 +++++++ resources/css/components/forms.css | 27 ++- 9 files changed, 376 insertions(+), 112 deletions(-) delete mode 100644 Makefile_prod rename includes/forms/{form-OrderPaper.php => field-OrderBrochureList.php} (90%) create mode 100644 includes/forms/field-OrderDocumentsList.php create mode 100644 includes/forms/template-field-order-brochures.php create mode 100644 includes/forms/template-field-order-documents.php delete mode 100644 includes/forms/template-form-order-paper.php diff --git a/Makefile_prod b/Makefile_prod deleted file mode 100644 index 4397fa0..0000000 --- a/Makefile_prod +++ /dev/null @@ -1,62 +0,0 @@ -########################## -# SCRIPT DE DÉPLOIEMENT -########################## - -include .env_prod -# include .env_dev - -RED=\033[0;31m -GREEN=\033[0;32m -YELLOW=\033[0;33m -NC=\033[0m # No Color - -deploy: pull-media deploy-theme deploy-plugin - -deploy-theme: - @echo "$(GREEN)####Synchronisation des Themes $(NC)" - @rsync -avhp -e 'ssh' ./ $(HOST):$(THEMES_PATH)/$(THEME_FOLDER_NAME) --delete --exclude 'node_modules' --exclude 'Makefile' --exclude 'Makefile_dev' --exclude '.env' --exclude '.env_prod' --exclude '.env_dev' --exclude '.git' - -deploy-plugin: - @echo "$(GREEN)####Synchronisation du plugin $(NC)" - @rsync -avhp -e 'ssh' ../../plugins/$(PLUGIN_FOLDER_NAME) $(HOST):$(PLUGINS_PATH) --delete --exclude 'node_modules' --exclude 'Makefile' --exclude 'Makefile_dev' --exclude '.env' --exclude '.env_prod' --exclude '.env_dev' --exclude '.git' - -deploy-full-content: - @echo "$(GREEN)####Synchronisation de tout le wp-content$(NC)" - @rsync -avhp -e 'ssh' ../../ $(HOST):$(CONTENT_PATH) --delete --exclude 'node_modules' --exclude 'Makefile' --exclude 'Makefile_dev' --exclude '.env' --exclude '.env_prod' --exclude '.env_dev' --exclude '.git' - -pull-media: - @echo "$(GREEN)####Pull des médias $(NC)" - @rsync -avhp -e 'ssh' $(HOST):$(UPLOADS_PATH) ../../uploads --delete - -pull-plugins: - @echo "$(GREEN)####Pull des Plugins $(NC)" - @rsync -avhp -e 'ssh' $(HOST):$(PLUGINS_PATH) ../../plugins --delete - -bundle: - @echo "$(GREEN)####BUNDLE $(NC)" - @rsync -avh ./* ../$(THEME_DIST_NAME) --delete \ - --exclude '.env' \ - --exclude '.env_dev' \ - --exclude '.env_prod' \ - --exclude 'node_modules' \ - --exclude 'Makefile' \ - --exclude 'Makefile_dev' \ - --exclude '.git' \ - --exclude '.gitignore' \ - --exclude 'composer.json' \ - -maintenance-on: - @echo "$(YELLOW)####MISE EN MAINTENANCE $(NC)" - @ssh -p $(PORT) $(HOST) "cd $(CONTENT_PATH); cd ..; echo '> .maintenance " - -maintenance-off: - @echo "$(GREEN)####MISE EN LIGNE / SUPPRESSION DU MAINTENANCE $(NC)" - @ssh -p $(PORT) $(HOST) "cd $(CONTENT_PATH); cd ..; rm .maintenance " - -test-connect: - @echo "$(GREEN)####SIMULATION — TEST DE CONNEXION $(NC)" - @ssh -p $(PORT) $(HOST) "cd $(CONTENT_PATH); pwd" - -test-deploy: - @echo "$(RED)####SIMULATION — Synchronisation RSYNC DES FICHIERS $(NC)" - @rsync -avhpn -e 'ssh' ./ $(HOST):$(THEMES_PATH)/$(THEME_FOLDER_NAME)/test --delete --exclude 'node_modules' --exclude 'Makefile' --exclude 'Makefile_dev' --exclude '.git' --exclude '.env' --exclude '.env_prod' --exclude '.env_dev' \ No newline at end of file diff --git a/includes/forms.php b/includes/forms.php index dfbb79a..78a234b 100644 --- a/includes/forms.php +++ b/includes/forms.php @@ -2,4 +2,5 @@ -require_once(__DIR__ . '/forms/form-OrderPaper.php'); +require_once(__DIR__ . '/forms/field-OrderBrochureList.php'); +require_once(__DIR__ . '/forms/field-OrderDocumentsList.php'); diff --git a/includes/forms/form-OrderPaper.php b/includes/forms/field-OrderBrochureList.php similarity index 90% rename from includes/forms/form-OrderPaper.php rename to includes/forms/field-OrderBrochureList.php index 9756f45..0ed4253 100644 --- a/includes/forms/form-OrderPaper.php +++ b/includes/forms/field-OrderBrochureList.php @@ -1,9 +1,9 @@ posts as $key => $post) { array_push($choices, ['text' => $post->post_title, 'slug' => $post->post_name, 'ID' => $post->ID]); } @@ -40,7 +35,7 @@ if (class_exists('GF_Field')) { public function get_form_editor_field_title() { - return esc_attr__('Commande de publications papier', 'txtdomain'); + return esc_attr__('Listes des brochures commandable', 'txtdomain'); } public function get_form_editor_button() { @@ -84,7 +79,7 @@ if (class_exists('GF_Field')) { $id = $this->id; ob_start(); - include 'template-form-order-paper.php'; + include 'template-field-order-brochures.php'; $table = ob_get_clean(); @@ -168,5 +163,5 @@ if (class_exists('GF_Field')) { return $this->PrettyListBrochureOrder($value); } } - GF_Fields::register(new OrderPaperPublications()); + GF_Fields::register(new OrderBrochureList()); } diff --git a/includes/forms/field-OrderDocumentsList.php b/includes/forms/field-OrderDocumentsList.php new file mode 100644 index 0000000..61e511a --- /dev/null +++ b/includes/forms/field-OrderDocumentsList.php @@ -0,0 +1,178 @@ + 'Synthèse des primes'], + ['text' => 'Publication 2'], + ['text' => 'Publication 3'], + ]; + + // public $choices = [ + // [ + // 'text' => 'Synthèse des primes', + // 'slug' => "the post name", + // 'ID' => 24 + // ], + // [ + // 'text' => 'Document 2', + // 'slug' => "the post name", + // 'ID' => 24 + // ], + + // ]; + + private function buildChoices() + { + + $choices = [ + [ + 'text' => 'La synthèse des primes', + 'description' => __("Ce document informe sur les incitants financiers à l’achat et à la rénovation des logements en Région de Bruxelles-Capitale, dont les primes RENOLUTION, le crédit ECORENO, la subvention petit patrimoine, la prime gaz, les certificats verts...", "homegrade-theme__texte-fonctionnel"), + 'slug' => "the post name", + 'ID' => 24 + ], + [ + 'text' => 'Document 2', + 'slug' => "the post name", + 'ID' => 24 + ], + + ]; + + + $this->choices = $choices; + } + + public function get_form_editor_field_title() + { + return esc_attr__('Listes des documents commandables', 'txtdomain'); + } + public function get_form_editor_button() + { + return [ + 'group' => 'advanced_fields', + 'text' => $this->get_form_editor_field_title(), + ]; + } + public function get_form_editor_field_icon() + { + return 'gform-icon--multi-select'; + } + public function get_form_editor_field_settings() + { + return [ + 'label_setting', + 'choices_setting', + 'description_setting', + 'rules_setting', + 'error_message_setting', + 'css_class_setting', + 'conditional_logic_field_setting' + ]; + } + + + public function is_value_submission_array() + { + return true; + } + + public function get_field_input($form, $value = '', $entry = null) + { + + // $this->buildChoices(); + $form_id = $form['id']; + $id = $this->id; + + ob_start(); + include 'template-field-order-documents.php'; + $table = ob_get_clean(); + + return $table; + } + + private function translateValueArray($value) + { + $this->buildChoices(); + + $table_value = []; + $counter = 0; + + foreach ($this->choices as $document) { + $table_value[$document['text']]['quantity_fr'] = $value[$counter] ?? 0; + $table_value[$document['text']]['quantity_nl'] = $value[$counter + 1] ?? 0; + $counter += 2; + } + return $table_value; + } + + public function get_value_save_entry($value, $form, $input_name, $lead_id, $lead) + { + + if (empty($value)) { + $value = ''; + } else { + $table_value = $this->translateValueArray($value); + + $value = serialize($table_value); + } + + return $value; + } + + + private function PrettyListBrochureOrder($value) + { + $brochureOrderPreviewHtml = ''; + return $brochureOrderPreviewHtml; + } + + + public function get_value_entry_list($value, $entry, $field_id, $columns, $form) + { + return __('Enter details to see delivery details', 'txtdomain'); + } + + public function get_value_entry_detail($value, $currency = '', $use_text = false, $format = 'html', $media = 'screen') + { + $value = maybe_unserialize($value); + if (empty($value)) { + return; + } + $str = $this->PrettyListBrochureOrder($value); + + return $str; + } + + public function get_value_merge_tag($value, $input_id, $entry, $form, $modifier, $raw_value, $url_encode, $esc_html, $format, $nl2br) + { + return $this->PrettyListBrochureOrder($value); + } + } + GF_Fields::register(new OrderDocumentList()); +} diff --git a/includes/forms/template-field-order-brochures.php b/includes/forms/template-field-order-brochures.php new file mode 100644 index 0000000..c344826 --- /dev/null +++ b/includes/forms/template-field-order-brochures.php @@ -0,0 +1,47 @@ + + +
+ + choices as $index => $brochurePost) : ?> + term_id); + + ?> + +
+
+ + + +

+ name ?> +

+
+ + +
+
+ + +
+
+ + +
+ +
+
+ + +
+ + + +
+ +
\ No newline at end of file diff --git a/includes/forms/template-field-order-documents.php b/includes/forms/template-field-order-documents.php new file mode 100644 index 0000000..4aa02b0 --- /dev/null +++ b/includes/forms/template-field-order-documents.php @@ -0,0 +1,55 @@ + + +
+ + choices as $index => $document) : ?> + + + +
+
+ + + +

+ + +

+
+ + +
+
+ + +
+
+ + +
+ +
+ + +

+ + + +
+ + +
+ + +
+ +
\ No newline at end of file diff --git a/includes/forms/template-form-order-paper.php b/includes/forms/template-form-order-paper.php deleted file mode 100644 index 8093f74..0000000 --- a/includes/forms/template-form-order-paper.php +++ /dev/null @@ -1,37 +0,0 @@ - - -
- - choices as $index => $brochurePost) : ?> - term_id); - - ?> - -
-
- - - -

- name ?> -

-
- - voir la brochure -
- - -
-
- - -
-
- -
\ No newline at end of file diff --git a/resources/css/admin-style.css b/resources/css/admin-style.css index d285c92..8d41c2c 100644 --- a/resources/css/admin-style.css +++ b/resources/css/admin-style.css @@ -112,3 +112,67 @@ .block-editor-link-control__search-item-top { word-break: break-all; } + +.field-order-paper-publications { + @apply !grid gap-x-12 gap-y-2; + + .brochure-order-field { + @apply grid justify-end gap-3 items-center; + grid-template-columns: auto 1fr 1fr auto; + .thematique-tag, + legend { + @apply mt-6; + } + .thematique-tag { + @apply !py-1 !px-4 !rounded-lg mr-4 flex items-center shrink-0; + line-height: 1.7; + } + .thematique-icon { + @apply w-8 mr-3 my-2; + } + legend { + @apply block ml-0 !mr-auto !font-normal; + font-weight: revert !important; + } + .preview-brochure { + @apply !text-neutral-700 flex justify-center items-center w-fit mx-auto; + &:after { + content: ' '; + @apply w-4 h-4 block ml-3 bg-no-repeat bg-center bg-contain; + background-image: url('../resources/img/graphic-assets/icone-external-link.svg'); + } + } + .inputs-container { + @apply flex gap-4; + } + + .publications-amount-fr, + .publications-amount-nl { + label { + @apply block mx-auto; + } + input[type='number'] { + @apply h-2 !w-16 !py-5; + } + #publications-amount__label-nl, + #publications-amount__label-fr { + @apply !text-neutral-600 uppercase !text-sm text-center; + } + } + } +} + +#gform_wrapper_18 { + @apply max-w-screen-lg; + + input[type='submit'] { + @apply !mx-auto mt-6; + } + .gsection_description { + @apply pt-2; + } + .gfield--type-section { + border-bottom: 1px solid !important; + @apply !border-neutral-400; + } +} diff --git a/resources/css/components/forms.css b/resources/css/components/forms.css index 0de3811..4a01ac3 100644 --- a/resources/css/components/forms.css +++ b/resources/css/components/forms.css @@ -185,7 +185,8 @@ form:not(.metabox-location-side):not(.metabox-location-normal):not( @apply !grid gap-x-12 gap-y-2; .brochure-order-field { - @apply flex justify-end gap-3 items-center max-w-screen-md; + @apply grid justify-end gap-3 items-center; + grid-template-columns: auto 1fr 1fr auto; .thematique-tag, legend { @apply mt-6; @@ -202,13 +203,16 @@ form:not(.metabox-location-side):not(.metabox-location-normal):not( font-weight: revert !important; } .preview-brochure { - @apply !text-neutral-700 flex justify-center items-center; + @apply !text-neutral-700 flex justify-center items-center w-fit mx-auto; &:after { content: ' '; @apply w-4 h-4 block ml-3 bg-no-repeat bg-center bg-contain; background-image: url('../resources/img/graphic-assets/icone-external-link.svg'); } } + .inputs-container { + @apply flex gap-4; + } .publications-amount-fr, .publications-amount-nl { @@ -223,5 +227,24 @@ form:not(.metabox-location-side):not(.metabox-location-normal):not( @apply !text-neutral-600 uppercase !text-sm text-center; } } + .legend { + @apply col-start-2 col-span-2 text-neutral-500; + line-height: 1.5; + } + } +} + +#gform_wrapper_18 { + @apply max-w-screen-lg; + + input[type='submit'] { + @apply !mx-auto mt-6; + } + .gsection_description { + @apply pt-2; + } + .gfield--type-section { + border-bottom: 1px solid !important; + @apply !border-neutral-300 pb-4; } }