edf0196cba5fb10cb602b098d910c08cb8794361356da3df6c9fcf61fbe5897d.json 12 KB

1
  1. {"ast":null,"code":"import { Validators } from '@angular/forms';\nimport * as i0 from \"@angular/core\";\nimport * as i1 from \"@angular/forms\";\nimport * as i2 from \"./../../../../services/email.service\";\nfunction EmailFormComponent_mat_radio_button_7_Template(rf, ctx) {\n if (rf & 1) {\n i0.ɵɵelementStart(0, \"mat-radio-button\", 19);\n i0.ɵɵtext(1);\n i0.ɵɵelementEnd();\n }\n if (rf & 2) {\n const option_r6 = ctx.$implicit;\n i0.ɵɵpropertyInterpolate(\"value\", option_r6.value);\n i0.ɵɵproperty(\"checked\", option_r6.checked);\n i0.ɵɵadvance(1);\n i0.ɵɵtextInterpolate1(\" \", option_r6.label, \" \");\n }\n}\nfunction EmailFormComponent_div_8_mat_error_6_Template(rf, ctx) {\n if (rf & 1) {\n i0.ɵɵelementStart(0, \"mat-error\", 24);\n i0.ɵɵtext(1, \" Adresse email Invalide \");\n i0.ɵɵelementEnd();\n }\n if (rf & 2) {\n i0.ɵɵnextContext();\n const _r7 = i0.ɵɵreference(5);\n i0.ɵɵproperty(\"hidden\", !(_r7.errors == null ? null : _r7.errors.pattern));\n }\n}\nfunction EmailFormComponent_div_8_Template(rf, ctx) {\n if (rf & 1) {\n const _r10 = i0.ɵɵgetCurrentView();\n i0.ɵɵelementStart(0, \"div\", 20)(1, \"p\", 8);\n i0.ɵɵtext(2, \"Adresse email :\");\n i0.ɵɵelementEnd();\n i0.ɵɵelementStart(3, \"mat-form-field\", 9)(4, \"input\", 21, 22);\n i0.ɵɵlistener(\"ngModelChange\", function EmailFormComponent_div_8_Template_input_ngModelChange_4_listener($event) {\n i0.ɵɵrestoreView(_r10);\n const ctx_r9 = i0.ɵɵnextContext();\n return i0.ɵɵresetView(ctx_r9.adressemail = $event);\n });\n i0.ɵɵelementEnd();\n i0.ɵɵtemplate(6, EmailFormComponent_div_8_mat_error_6_Template, 2, 1, \"mat-error\", 23);\n i0.ɵɵelementEnd()();\n }\n if (rf & 2) {\n const _r7 = i0.ɵɵreference(5);\n const ctx_r1 = i0.ɵɵnextContext();\n i0.ɵɵadvance(4);\n i0.ɵɵproperty(\"ngModel\", ctx_r1.adressemail);\n i0.ɵɵadvance(2);\n i0.ɵɵproperty(\"ngIf\", _r7.errors && (_r7.touched || _r7.dirty));\n }\n}\nfunction EmailFormComponent_mat_error_15_Template(rf, ctx) {\n if (rf & 1) {\n i0.ɵɵelementStart(0, \"mat-error\");\n i0.ɵɵtext(1);\n i0.ɵɵelementEnd();\n }\n if (rf & 2) {\n const ctx_r2 = i0.ɵɵnextContext();\n i0.ɵɵadvance(1);\n i0.ɵɵtextInterpolate1(\" \", ctx_r2.getErrorTitle(), \" \");\n }\n}\nfunction EmailFormComponent_mat_error_21_Template(rf, ctx) {\n if (rf & 1) {\n i0.ɵɵelementStart(0, \"mat-error\");\n i0.ɵɵtext(1);\n i0.ɵɵelementEnd();\n }\n if (rf & 2) {\n const ctx_r3 = i0.ɵɵnextContext();\n i0.ɵɵadvance(1);\n i0.ɵɵtextInterpolate1(\" \", ctx_r3.getErrorDescription(), \" \");\n }\n}\nfunction EmailFormComponent_mat_error_27_Template(rf, ctx) {\n if (rf & 1) {\n i0.ɵɵelementStart(0, \"mat-error\");\n i0.ɵɵtext(1);\n i0.ɵɵelementEnd();\n }\n if (rf & 2) {\n const ctx_r4 = i0.ɵɵnextContext();\n i0.ɵɵadvance(1);\n i0.ɵɵtextInterpolate1(\" \", ctx_r4.getErrorObject(), \" \");\n }\n}\nfunction EmailFormComponent_mat_error_33_Template(rf, ctx) {\n if (rf & 1) {\n i0.ɵɵelementStart(0, \"mat-error\");\n i0.ɵɵtext(1);\n i0.ɵɵelementEnd();\n }\n if (rf & 2) {\n const ctx_r5 = i0.ɵɵnextContext();\n i0.ɵɵadvance(1);\n i0.ɵɵtextInterpolate1(\" \", ctx_r5.getErrorMessage(), \" \");\n }\n}\nexport let EmailFormComponent = /*#__PURE__*/(() => {\n class EmailFormComponent {\n constructor(formBuilder, emailService) {\n this.formBuilder = formBuilder;\n this.emailService = emailService;\n //radio button\n this.userOptions = [{\n label: 'Tout les clients',\n value: '0',\n checked: true\n }, {\n label: 'Clients gagnant',\n value: '1',\n checked: false\n }, {\n label: 'Clients non gagnant',\n value: '2',\n checked: false\n }, {\n label: 'Clients compte actives',\n value: '3',\n checked: false\n }, {\n label: 'Clients bloqués',\n value: '4',\n checked: false\n }, {\n label: 'Adresse email',\n value: '5',\n checked: false\n }];\n }\n ngOnInit() {\n this.createForm();\n }\n //select radio button\n selectValue($event) {\n this.selectedRadio = $event.source.value;\n }\n createForm() {\n let caracereregex = /^[a-zA-ZàáâäãåąčćęèéêëėįìíîïłńòóôöõøùúûüųūÿýżźñçčšžÀÁÂÄÃÅĄĆČĖĘÈÉÊËÌÍÎÏĮŁŃÒÓÔÖÕØÙÚÛÜŲŪŸÝŻŹÑßÇŒÆČŠŽ∂ð ,.'-]+$/;\n this.formGroup = this.formBuilder.group({\n title: [null, [Validators.required, Validators.pattern(caracereregex)]],\n description: [null, [Validators.required, Validators.pattern(caracereregex)]],\n subject: [null, [Validators.required, Validators.pattern(caracereregex)]],\n text: [null, [Validators.required, Validators.pattern(caracereregex)]]\n });\n }\n getErrorTitle() {\n return this.formGroup.get('title').hasError('required') ? 'Titre requis' : this.formGroup.get('title').hasError('pattern') ? 'Titre non valide' : 'Titre non valide';\n }\n getErrorDescription() {\n return this.formGroup.get('description').hasError('required') ? 'Description requise' : this.formGroup.get('description').hasError('pattern') ? 'Description non valide' : 'Description non valide';\n }\n getErrorObject() {\n return this.formGroup.get('subject').hasError('required') ? 'Objet requis' : this.formGroup.get('subject').hasError('pattern') ? 'Objet non valide' : 'Objet non valide';\n }\n getErrorMessage() {\n return this.formGroup.get('text').hasError('required') ? 'Message requis' : this.formGroup.get('text').hasError('pattern') ? 'Message non valide' : 'Message non valide';\n }\n get f() {\n return this.formGroup.controls;\n }\n // rest form\n resetForm() {\n this.formGroup.reset();\n }\n // send email\n sendEmail() {\n if (this.formGroup.invalid) {\n return;\n }\n let email = '';\n let isgain = '';\n let isactive = '';\n if (this.selectedRadio == 5) {\n email = this.adressemail;\n }\n if (this.selectedRadio == 1) {\n isgain = true;\n }\n if (this.selectedRadio == 2) {\n isgain = false;\n }\n if (this.selectedRadio == 3) {\n isactive = true;\n }\n if (this.selectedRadio == 4) {\n isactive = false;\n }\n this.emailService.sendEmail(this.formGroup.value, email, isgain, isactive).subscribe(res => res);\n }\n static #_ = this.ɵfac = function EmailFormComponent_Factory(t) {\n return new (t || EmailFormComponent)(i0.ɵɵdirectiveInject(i1.FormBuilder), i0.ɵɵdirectiveInject(i2.EmailService));\n };\n static #_2 = this.ɵcmp = /*@__PURE__*/i0.ɵɵdefineComponent({\n type: EmailFormComponent,\n selectors: [[\"app-email-form\"]],\n decls: 39,\n vars: 7,\n consts: [[1, \"\"], [1, \"row\", \"justify-content-center\", \"mb-4\"], [1, \"row\", \"justify-content-center\", \"mb-3\"], [\"aria-label\", \"Select an option\", 3, \"change\"], [3, \"checked\", \"value\", 4, \"ngFor\", \"ngForOf\"], [\"class\", \"row mb-4\", 4, \"ngIf\"], [3, \"formGroup\", \"ngSubmit\"], [1, \"row\"], [1, \"col-5\", \"col-md-4\", \"font-weight-bold\", \"text-lg-right\", \"parag\"], [\"appearance\", \"outline\", 1, \"col-7\", \"col-md-5\"], [\"matInput\", \"\", \"placeholder\", \"\", \"formControlName\", \"title\", \"required\", \"\"], [4, \"ngIf\"], [\"matInput\", \"\", \"placeholder\", \"\", \"formControlName\", \"description\", \"required\", \"\"], [\"matInput\", \"\", \"placeholder\", \"\", \"formControlName\", \"subject\", \"required\", \"\"], [\"appearance\", \"outline\", 1, \"col-7\", \"col-md-5\", 2, \"width\", \"500px\"], [\"matInput\", \"\", \"rows\", \"13\", \"formControlName\", \"text\"], [1, \"row\", \"justify-content-center\", \"my-3\"], [\"mat-raised-button\", \"\", \"color\", \"primary\", \"type\", \"submit\", 1, \"mr-4\"], [\"mat-raised-button\", \"\", \"color\", \"primary\", 1, \"\", 3, \"click\"], [3, \"checked\", \"value\"], [1, \"row\", \"mb-4\"], [\"matInput\", \"\", \"type\", \"text\", \"pattern\", \"[a-z0-9._%+-]+@[a-z0-9.-]+\\\\.[a-z]{2,3}$\", \"id\", \"email\", \"name\", \"email\", \"required\", \"\", 3, \"ngModel\", \"ngModelChange\"], [\"emailref\", \"ngModel\"], [3, \"hidden\", 4, \"ngIf\"], [3, \"hidden\"]],\n template: function EmailFormComponent_Template(rf, ctx) {\n if (rf & 1) {\n i0.ɵɵelementStart(0, \"mat-card\", 0)(1, \"mat-card-content\")(2, \"h1\", 1)(3, \"b\");\n i0.ɵɵtext(4, \"Emailing\");\n i0.ɵɵelementEnd()();\n i0.ɵɵelementStart(5, \"div\", 2)(6, \"mat-radio-group\", 3);\n i0.ɵɵlistener(\"change\", function EmailFormComponent_Template_mat_radio_group_change_6_listener($event) {\n return ctx.selectValue($event);\n });\n i0.ɵɵtemplate(7, EmailFormComponent_mat_radio_button_7_Template, 2, 3, \"mat-radio-button\", 4);\n i0.ɵɵelementEnd()();\n i0.ɵɵtemplate(8, EmailFormComponent_div_8_Template, 7, 2, \"div\", 5);\n i0.ɵɵelementStart(9, \"form\", 6);\n i0.ɵɵlistener(\"ngSubmit\", function EmailFormComponent_Template_form_ngSubmit_9_listener() {\n return ctx.sendEmail();\n });\n i0.ɵɵelementStart(10, \"div\", 7)(11, \"p\", 8);\n i0.ɵɵtext(12, \"Titre :\");\n i0.ɵɵelementEnd();\n i0.ɵɵelementStart(13, \"mat-form-field\", 9);\n i0.ɵɵelement(14, \"input\", 10);\n i0.ɵɵtemplate(15, EmailFormComponent_mat_error_15_Template, 2, 1, \"mat-error\", 11);\n i0.ɵɵelementEnd()();\n i0.ɵɵelementStart(16, \"div\", 7)(17, \"p\", 8);\n i0.ɵɵtext(18, \"Description :\");\n i0.ɵɵelementEnd();\n i0.ɵɵelementStart(19, \"mat-form-field\", 9);\n i0.ɵɵelement(20, \"input\", 12);\n i0.ɵɵtemplate(21, EmailFormComponent_mat_error_21_Template, 2, 1, \"mat-error\", 11);\n i0.ɵɵelementEnd()();\n i0.ɵɵelementStart(22, \"div\", 7)(23, \"p\", 8);\n i0.ɵɵtext(24, \"Objet :\");\n i0.ɵɵelementEnd();\n i0.ɵɵelementStart(25, \"mat-form-field\", 9);\n i0.ɵɵelement(26, \"input\", 13);\n i0.ɵɵtemplate(27, EmailFormComponent_mat_error_27_Template, 2, 1, \"mat-error\", 11);\n i0.ɵɵelementEnd()();\n i0.ɵɵelementStart(28, \"div\", 7)(29, \"p\", 8);\n i0.ɵɵtext(30, \"Message :\");\n i0.ɵɵelementEnd();\n i0.ɵɵelementStart(31, \"mat-form-field\", 14);\n i0.ɵɵelement(32, \"textarea\", 15);\n i0.ɵɵtemplate(33, EmailFormComponent_mat_error_33_Template, 2, 1, \"mat-error\", 11);\n i0.ɵɵelementEnd()();\n i0.ɵɵelementStart(34, \"div\", 16)(35, \"button\", 17);\n i0.ɵɵtext(36, \"Envoyer\");\n i0.ɵɵelementEnd();\n i0.ɵɵelementStart(37, \"button\", 18);\n i0.ɵɵlistener(\"click\", function EmailFormComponent_Template_button_click_37_listener() {\n return ctx.resetForm();\n });\n i0.ɵɵtext(38, \"Effacer\");\n i0.ɵɵelementEnd()()()()();\n }\n if (rf & 2) {\n i0.ɵɵadvance(7);\n i0.ɵɵproperty(\"ngForOf\", ctx.userOptions);\n i0.ɵɵadvance(1);\n i0.ɵɵproperty(\"ngIf\", ctx.selectedRadio == 5);\n i0.ɵɵadvance(1);\n i0.ɵɵproperty(\"formGroup\", ctx.formGroup);\n i0.ɵɵadvance(6);\n i0.ɵɵproperty(\"ngIf\", !ctx.formGroup.controls[\"title\"].valid || ctx.formGroup.controls[\"title\"].touched);\n i0.ɵɵadvance(6);\n i0.ɵɵproperty(\"ngIf\", !ctx.formGroup.controls[\"description\"].valid || ctx.formGroup.controls[\"description\"].touched);\n i0.ɵɵadvance(6);\n i0.ɵɵproperty(\"ngIf\", !ctx.formGroup.controls[\"subject\"].valid || ctx.formGroup.controls[\"subject\"].touched);\n i0.ɵɵadvance(6);\n i0.ɵɵproperty(\"ngIf\", !ctx.formGroup.controls[\"text\"].valid || ctx.formGroup.controls[\"text\"].touched);\n }\n },\n styles: [\".parag[_ngcontent-%COMP%]{margin-top:1em}.mat-radio-button[_ngcontent-%COMP%] ~ .mat-radio-button[_ngcontent-%COMP%]{margin-left:16px}\"]\n });\n }\n return EmailFormComponent;\n})();","map":null,"metadata":{},"sourceType":"module","externalDependencies":[]}