{"version":3,"sources":["webpack:///./src/components/Forms/Form.vue?f8f5","webpack:///./src/views/BuyerEnquiry.vue?deb7","webpack:///./src/views/BuyerEnquiry.vue","webpack:///./src/views/BuyerEnquiry.vue?3988","webpack:///./src/views/BuyerEnquiry.vue?e9c5","webpack:///./src/components/Forms/Form.vue?4717","webpack:///./src/components/Forms/Form.vue","webpack:///./src/components/Forms/Form.vue?d965","webpack:///./src/components/Forms/Form.vue?4d45"],"names":["render","_vm","this","_h","$createElement","_c","_self","attrs","staticRenderFns","components","Form","component","staticClass","style","fieldBg","loading","on","loadAutosave","_v","_s","autosaveDate","_e","domProps","definition","Options","SubmittedText","_l","section","key","SectionId","ref","refInFor","errors","ctx","type","handleFieldInput","class","submitButtonClass","submitButtonColour","submitButtonBackgroundColour","submitForm","SubmitButtonText","context","errored","submitted","autosaveManager","Require","FormAutosave","hasAutosave","submitPercent","recaptchaService","ReCaptcha","progress","total","Math","round","console","log","Items","ClientWebsiteId","Website","Id","undefined","Forms","GetForm","then","def","enableAutosave","state","GetState","catch","Sections","forEach","sectionComponent","$refs","setData","fieldDef","filter","err","Key","collectData","data","normalisedData","normaliseData","SubmitForm","result","Valid","Submitted","$emit","resetRecaptcha","ValidationState","Errors","newValues","entry","Value","Array","length","push","i","includeRecaptcha","Promise","resolve","reject","getRecaptchaResponse","recaptchaResponse","Log","Debug","Reset","GetResponse","default","Section","Loader"],"mappings":"yIAAA,W,yCCAA,IAAIA,EAAS,WAAa,IAAIC,EAAIC,KAASC,EAAGF,EAAIG,eAAmBC,EAAGJ,EAAIK,MAAMD,IAAIF,EAAG,OAAOE,EAAG,OAAO,CAACA,EAAG,eAAe,CAACE,MAAM,CAAC,KAAO,OAAO,MAAQ,mBAAmBF,EAAG,aAAa,CAACA,EAAG,mBAAmB,CAACA,EAAG,OAAO,CAACE,MAAM,CAAC,KAAO,kEAAkE,IAAI,IAAI,IACrTC,EAAkB,G,oCCoBtB,IAAqB,EAArB,cAA0C,SAArB,EAAY,gBALhC,e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B,GAElEoD,EAAKgB,QAAQxB,EAAiBO,iBAI5BmB,EACFjG,KAAKqG,uBAAuBtC,KAAMuC,IAChC,OAAOC,IAAI,OAASC,MAAO,SAAU,0BAErCzB,EAAKgB,KAAK,CACRlB,IAAK,aACLe,MAAOU,IAGTH,EAAQpB,KACPX,MAAMgC,GAMXD,EAAQpB,KAIJ,iBACN/E,KAAKgD,iBAAiByD,QAGhB,uBACN,OAAOzG,KAAKgD,iBAAiB0D,gBA1N/B,gBADC,eAAK,CAAEC,QAAS,KAAM,CAAGnD,MAAO,Q,8BAIjC,gBADC,kB,2BAID,gBADC,kB,yCAID,gBADC,kB,mDAID,gBADC,kB,wCAID,gBADC,kB,wCAID,gBADC,kB,qCAID,gBADC,eAAK,CAAEmD,QAAS,0B,8BAIjB,gBADC,eAAK,CAAEA,QAAS,8B,kCAIjB,gBADC,eAAK,CAAEA,QAAS,8B,kCAIjB,gBADC,eAAK,CAAEA,QAAS,qC,mCAIjB,gBADC,eAAK,CAAEA,QAAS,kC,qCAIjB,gBADC,eAAK,CAAEA,QAAS,sC,yCArCE,EAAI,kBANxB,eAAU,CACTpG,WAAY,CACVqG,UAAA,KACAC,SAAA,SAGiB,WCtE4X,I,wBCQ7YpG,EAAY,eACd,EACAX,EACAQ,GACA,EACA,KACA,WACA,MAIa,OAAAG,E","file":"js/chunk-118c9f42.4d87eabb.js","sourcesContent":["export * from \"-!../../../node_modules/mini-css-extract-plugin/dist/loader.js??ref--6-oneOf-1-0!../../../node_modules/css-loader/dist/cjs.js??ref--6-oneOf-1-1!../../../node_modules/vue-loader/lib/loaders/stylePostLoader.js!../../../node_modules/postcss-loader/src/index.js??ref--6-oneOf-1-2!../../../node_modules/cache-loader/dist/cjs.js??ref--0-0!../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./Form.vue?vue&type=style&index=0&id=726d98f2&scoped=true&lang=css&\"","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('Page',[_c('SiteMasthead',{attrs:{\"mini\":\"true\",\"title\":\"Buyer Enquiry\"}}),_c('ContentRow',[_c('ContentContainer',[_c('Form',{attrs:{\"type\":\"Variations.TSPropertyGroup.AlexieAristides.BuyerEnquiryForm\"}})],1)],1)],1)}\nvar staticRenderFns = []\n\nexport { render, staticRenderFns }","\n\n\n\n\n\n\n\n\n\n\n\nimport { Component, Vue } from 'vue-property-decorator';\n\nimport Form from '../components/Forms/Form.vue';\n\n@Component({\n components: {\n Form,\n },\n})\nexport default class BuyerEnquiry extends Vue {\n\n}\n","import mod from \"-!../../node_modules/cache-loader/dist/cjs.js??ref--14-0!../../node_modules/thread-loader/dist/cjs.js!../../node_modules/babel-loader/lib/index.js!../../node_modules/ts-loader/index.js??ref--14-3!../../node_modules/cache-loader/dist/cjs.js??ref--0-0!../../node_modules/vue-loader/lib/index.js??vue-loader-options!./BuyerEnquiry.vue?vue&type=script&lang=ts&\"; export default mod; export * from \"-!../../node_modules/cache-loader/dist/cjs.js??ref--14-0!../../node_modules/thread-loader/dist/cjs.js!../../node_modules/babel-loader/lib/index.js!../../node_modules/ts-loader/index.js??ref--14-3!../../node_modules/cache-loader/dist/cjs.js??ref--0-0!../../node_modules/vue-loader/lib/index.js??vue-loader-options!./BuyerEnquiry.vue?vue&type=script&lang=ts&\"","import { render, staticRenderFns } from \"./BuyerEnquiry.vue?vue&type=template&id=4aa44ae4&scoped=true&\"\nimport script from \"./BuyerEnquiry.vue?vue&type=script&lang=ts&\"\nexport * from \"./BuyerEnquiry.vue?vue&type=script&lang=ts&\"\n\n\n/* normalize component */\nimport normalizer from \"!../../node_modules/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n script,\n render,\n staticRenderFns,\n false,\n null,\n \"4aa44ae4\",\n null\n \n)\n\nexport default component.exports","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('form',{staticClass:\"form\",style:({'--field-bg': _vm.fieldBg})},[_c('Loader',{attrs:{\"loading\":_vm.loading}}),(_vm.hasAutosave)?_c('div',{staticClass:\"form__panel form__panel--autosaved\",on:{\"click\":_vm.loadAutosave}},[_c('p',[_vm._v(\" This form was autosaved at \"+_vm._s(_vm.autosaveDate)+\". Click here to load the autosave. \")])]):_vm._e(),(_vm.errored)?_c('div',{staticClass:\"form__panel form__panel--errored\"},[_c('p',[_vm._v(\" An error occurred. Please try again later. \")])]):_vm._e(),(_vm.definition)?[(_vm.submitted)?_c('div',{staticClass:\"form__panel form__panel--success\"},[_c('p',{domProps:{\"innerHTML\":_vm._s(_vm.definition.Options.SubmittedText)}})]):[_vm._l((_vm.definition.Sections),function(section){return _c('Section',{key:section.SectionId,ref:section.SectionId,refInFor:true,attrs:{\"def\":section,\"errors\":_vm.errors,\"form-context\":_vm.ctx,\"form-type\":_vm.type},on:{\"field_input\":_vm.handleFieldInput}})}),_c('div',{staticClass:\"center-text\"},[_c('Button',{staticClass:\"form__submit-btn\",class:_vm.submitButtonClass,attrs:{\"loading\":_vm.loading,\"colour\":_vm.submitButtonColour,\"background-colour\":_vm.submitButtonBackgroundColour},on:{\"click\":_vm.submitForm}},[_vm._v(_vm._s(_vm.definition.Options.SubmitButtonText))])],1)]]:_vm._e()],2)}\nvar staticRenderFns = []\n\nexport { render, staticRenderFns }","\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nimport { Component, Vue, Prop } from 'vue-property-decorator';\nimport { FormDefinition, FormSubmissionValidationError, FormField, FormValue } from 'client-website-ts-library/types/Forms';\nimport {\n AutosaveManager,\n ServiceManager,\n ServiceType,\n API,\n Config,\n Logger,\n LogLevel,\n ReCaptchaService,\n} from 'client-website-ts-library/services';\nimport { Context } from 'client-website-ts-library/types';\nimport { PDFFieldData } from 'client-website-ts-library/types/Forms/FieldTypes';\nimport { IRequestProgressDelegate } from 'client-website-ts-library/services/API/IRequestProgressDelegate';\n\nimport Section from './Section.vue';\nimport Loader from '../UI/Loader.vue';\n\n@Component({\n components: {\n Section,\n Loader,\n },\n})\nexport default class Form extends Vue implements IRequestProgressDelegate {\n @Prop({ default: () => ({ Items: [] }) })\n private readonly context!: Context;\n\n @Prop()\n private readonly type!: string;\n\n @Prop()\n private readonly submitButtonColour!: string;\n\n @Prop()\n private readonly submitButtonBackgroundColour!: string;\n\n @Prop()\n private readonly submitButtonClass!: string;\n\n @Prop()\n private readonly autosaveNamespace!: string;\n\n @Prop()\n private readonly enableAutosave!: boolean;\n\n @Prop({ default: 'var(--form-field-bg)' })\n private readonly fieldBg!: string;\n\n @Prop({ default: 'var(--form-field-colour)' })\n private readonly fieldColour!: string;\n\n @Prop({ default: 'var(--form-label-colour)' })\n private readonly labelColour!: string;\n\n @Prop({ default: 'var(--form-field-border-colour)' })\n private readonly borderColour!: string;\n\n @Prop({ default: 'var(--form-label-focused-bg)' })\n private readonly labelFocusedBg!: string;\n\n @Prop({ default: 'var(--form-label-focused-colour)' })\n private readonly labelFocusedColour!: string;\n\n private ctx: Context = this.context;\n\n private errored = false;\n\n private submitted = false;\n\n private errors: FormSubmissionValidationError[] = [];\n\n private loading = true;\n\n private definition: FormDefinition | null = null;\n\n private autosaveManager: AutosaveManager = ServiceManager.Require(ServiceType.FormAutosave);\n\n private hasAutosave = false;\n\n private autosaveDate: string | null = null;\n\n private submitPercent = 0;\n\n private recaptchaService = ServiceManager.Require(ServiceType.ReCaptcha) as ReCaptchaService;\n\n onProgress(progress: number, total: number) {\n this.submitPercent = Math.round((progress / total) * 100);\n\n console.log(this.submitPercent);\n }\n\n mounted() {\n if (this.ctx === null) {\n this.ctx = {\n Items: [],\n ClientWebsiteId: Config.Website.Id,\n };\n }\n\n if (this.ctx.ClientWebsiteId === undefined) {\n this.ctx.ClientWebsiteId = Config.Website.Id;\n }\n\n API.Forms.GetForm(this.type, this.context).then((def) => {\n this.loading = false;\n this.definition = def;\n\n if (this.enableAutosave) {\n const state = this.autosaveManager.GetState(this.type);\n\n if (state !== null) {\n this.hasAutosave = true;\n }\n }\n }).catch(() => {\n this.errored = true;\n });\n }\n\n loadAutosave(): void {\n if (!this.hasAutosave) return;\n\n const state = this.autosaveManager.GetState(this.type);\n\n if (state === null) return;\n\n this.definition!.Sections.forEach((section) => {\n const sectionComponent = (this.$refs[section.SectionId] as Vue[])[0] as Section;\n\n sectionComponent.setData(state);\n });\n }\n\n private handleFieldInput(fieldDef: FormField): void {\n this.errors = this.errors.filter((err) => err.Key !== fieldDef.Key);\n }\n\n submitForm(): void {\n if (this.loading) return;\n\n this.loading = true;\n\n this.errors = [];\n\n this.collectData(true).then((data) => {\n const normalisedData = Form.normaliseData(data);\n\n console.log(normalisedData);\n\n this.loading = false;\n\n // this.context.ClientWebsiteId = Config.Website.Id;\n\n // if (this.enableAutosave) this.autosaveManager.SetState(this.type, data);\n\n API.Forms.SubmitForm(this.type, this.context, normalisedData).then((result) => {\n this.loading = false;\n\n if (!result.Valid) {\n // Reset ReCaptcha\n this.resetRecaptcha();\n\n // Update errors\n this.errors = result.ValidationState.Errors;\n } else if (result.Submitted) {\n // Inform the user that the form was submitted\n this.submitted = true;\n\n this.$emit('submitted');\n }\n }).catch(() => {\n // Reset ReCaptcha\n this.resetRecaptcha();\n\n // Inform the user that there was an error\n this.errored = true;\n });\n });\n }\n\n private static normaliseData(data: FormValue[]): FormValue[] {\n const newValues: FormValue[] = [];\n\n data.forEach((entry) => {\n if (entry.Value instanceof Array) {\n if (entry.Value.length) {\n newValues.push({\n Key: `${entry.Key}_length`,\n Value: entry.Value.length,\n });\n\n for (let i = 0; i < entry.Value.length; i += 1) {\n newValues.push({\n Key: `${entry.Key}_${i}`,\n Value: entry.Value[i],\n });\n }\n }\n } else {\n newValues.push(entry);\n }\n });\n\n return newValues;\n }\n\n private collectData(includeRecaptcha: boolean): Promise {\n return new Promise((resolve, reject) => {\n const data: FormValue[] = [];\n\n // Loop through each form secction and collect the data from it\n this.definition!.Sections.forEach((section) => {\n const sectionComponent = (this.$refs[section.SectionId] as Vue[])[0] as Section;\n\n data.push(...sectionComponent.collectData());\n });\n\n // If we also need to submit the ReCaptcha response, make sure we call getResponse on the ReCaptcha component\n if (includeRecaptcha) {\n this.getRecaptchaResponse().then((recaptchaResponse: string) => {\n Logger.Log(LogLevel.Debug, '[Form]', 'Got ReCaptcha response');\n\n data.push({\n Key: '_recaptcha',\n Value: recaptchaResponse,\n });\n\n resolve(data);\n }).catch(reject);\n\n return;\n }\n\n // If we don't need ReCaptcha, resolve straight away\n resolve(data);\n });\n }\n\n private resetRecaptcha(): void {\n this.recaptchaService.Reset();\n }\n\n private getRecaptchaResponse(): Promise {\n return this.recaptchaService.GetResponse();\n }\n}\n","import mod from \"-!../../../node_modules/cache-loader/dist/cjs.js??ref--14-0!../../../node_modules/thread-loader/dist/cjs.js!../../../node_modules/babel-loader/lib/index.js!../../../node_modules/ts-loader/index.js??ref--14-3!../../../node_modules/cache-loader/dist/cjs.js??ref--0-0!../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./Form.vue?vue&type=script&lang=ts&\"; export default mod; export * from \"-!../../../node_modules/cache-loader/dist/cjs.js??ref--14-0!../../../node_modules/thread-loader/dist/cjs.js!../../../node_modules/babel-loader/lib/index.js!../../../node_modules/ts-loader/index.js??ref--14-3!../../../node_modules/cache-loader/dist/cjs.js??ref--0-0!../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./Form.vue?vue&type=script&lang=ts&\"","import { render, staticRenderFns } from \"./Form.vue?vue&type=template&id=726d98f2&scoped=true&\"\nimport script from \"./Form.vue?vue&type=script&lang=ts&\"\nexport * from \"./Form.vue?vue&type=script&lang=ts&\"\nimport style0 from \"./Form.vue?vue&type=style&index=0&id=726d98f2&scoped=true&lang=css&\"\n\n\n/* normalize component */\nimport normalizer from \"!../../../node_modules/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n script,\n render,\n staticRenderFns,\n false,\n null,\n \"726d98f2\",\n null\n \n)\n\nexport default component.exports"],"sourceRoot":""}