-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathblocks.js
More file actions
1 lines (1 loc) · 4.29 KB
/
blocks.js
File metadata and controls
1 lines (1 loc) · 4.29 KB
1
(()=>{"use strict";const e=window.wp.blocks,l=window.React,a=window.wp.blockEditor,t=JSON.parse('{"name":"prefill-gravity-forms/personal-data-table","title":"Profielpagina","category":"embed","icon":"list-view","description":"Maak een profielpagina met persoonsgegevens van de ingelogde gebruiker."}'),{name:n,description:r,title:o,category:i,icon:s,attributes:c}=t;(0,e.registerBlockType)(n,{title:o,description:r,attributes:c,edit:()=>(0,l.createElement)("div",{...(0,a.useBlockProps)()},(0,l.createElement)("div",{className:"container px-0"},(0,l.createElement)(a.InnerBlocks,{allowedBlocks:["prefill-gravity-forms/personal-data-row"],template:[["prefill-gravity-forms/personal-data-row"]],renderAppender:()=>(0,l.createElement)(a.InnerBlocks.ButtonBlockAppender,null)}))),save:()=>(0,l.createElement)("div",{...a.useBlockProps.save()},(0,l.createElement)("table",{className:"table"},(0,l.createElement)(a.InnerBlocks.Content,null))),icon:s,category:i}),window.wp.i18n;const u=window.wp.components,d=window.wp.data,v=window.wp.element,b=[{value:"",label:"Selecteer persoonsgegevens",disabled:!0},{label:"Burgerservicenummer (BSN)",value:"burgerservicenummer"},{label:"Geslacht",value:"geslachtsaanduiding"},{label:"Leeftijd",value:"leeftijd"},{label:"Achternaam",value:"naam.geslachtsnaam"},{label:"Voorvoegsel (tussenvoegsel)",value:"naam.voorvoegsel"},{label:"Voorletters",value:"naam.voorletters"},{label:"Voornaam",value:"naam.voornaam"},{label:"Voornamen",value:"naam.voornamen"},{label:"Geboortedatum",value:"geboorte.datum.datum"},{label:"Straat",value:"verblijfplaats.straat"},{label:"Huisnummer",value:"verblijfplaats.huisnummer"},{label:"Huisletter",value:"verblijfplaats.huisletter"},{label:"Postcode",value:"verblijfplaats.postcode"},{label:"Woonplaats",value:"verblijfplaats.woonplaats"}],p=[{value:"",label:"Selecteer een leverancier",disabled:!0},{label:"EnableU",value:"EnableU"},{label:"OpenZaak",value:"OpenZaak"},{label:"PinkRoccade",value:"PinkRoccade"},{label:"VrijBRP",value:"VrijBRP"},{label:"WeAreFrank",value:"WeAreFrank"}],m=JSON.parse('{"name":"prefill-gravity-forms/personal-data-row","title":"Persoonsgegevens","category":"embed","icon":"id","description":"Toon persoonsgegevens van de ingelogde gebruiker.","attributes":{"selectedSupplier":{"type":"object","default":{"value":"","label":""}},"selectedOption":{"type":"object","default":{"value":"","label":""}},"isChildOfTable":{"type":"boolean","default":false},"htmlElement":{"type":"string","default":"p"}}}'),{name:g,description:f,title:w,category:E,icon:k,attributes:h}=m;(0,e.registerBlockType)(g,{title:w,description:f,attributes:h,edit:function({attributes:e,setAttributes:t,clientId:n}){const{selectedSupplier:r,selectedOption:o,htmlElement:i,isChildOfTable:s}=e,{blockParents:c}=(0,d.useSelect)((e=>({blockParents:e("core/block-editor").getBlockNamesByClientId(e("core/block-editor").getBlockParents(n))})));(0,v.useEffect)((()=>{c.length>0&&"prefill-gravity-forms/personal-data-table"===c[c.length-1]&&t({isChildOfTable:!0})}),[c,t]);const m=(0,l.createElement)(u.SelectControl,{help:"Selecteer de juiste leverancier die ingesteld is in de algemene instellingen.",label:"Leverancier",value:r.value,options:p,onChange:e=>{const l={value:e,label:p.find((l=>l.value===e)).label};t({selectedSupplier:l})}}),g=(0,l.createElement)(u.SelectControl,{label:"Automatisch invullen",value:o.value,options:b,onChange:e=>{const l={value:e,label:b.find((l=>l.value===e)).label};t({selectedOption:l})}}),f=(0,l.createElement)(u.SelectControl,{label:"HTML Element",value:i,options:[{label:"<div>",value:"div"},{label:"<p>",value:"p"},{label:"<span>",value:"span"}],onChange:e=>{t({htmlElement:e})}});return(0,l.createElement)("div",{...(0,a.useBlockProps)()},(0,l.createElement)(a.InspectorControls,null,(0,l.createElement)(u.TabPanel,{activeClass:"active-tab",tabs:[{name:"settings",title:"Settings"}]},(e=>(0,l.createElement)(u.PanelBody,{initialOpen:!0},"settings"===e.name&&(0,l.createElement)(l.Fragment,null,m,g,!s&&f))))),void 0===o.value||""===o.value?(0,l.createElement)("p",null,g):(0,l.createElement)(l.Fragment,null,(0,l.createElement)("div",{className:"row"},s&&(0,l.createElement)("div",{className:"col-6 font-weight-bold"},(0,l.createElement)("p",null,o.label)),(0,l.createElement)("div",{className:"col-6"},"[",(w=o.label)?w.charAt(0).toLowerCase()+w.slice(1):w,"]"))));var w},icon:k,category:E})})();