Skip to content
Snippets Groups Projects
Commit 5d7e8ecb authored by Remco Tukker's avatar Remco Tukker
Browse files

textual change and only show 1 toast on save

parent 94171df7
No related branches found
No related tags found
1 merge request!58add toast messages and fix some verification button bugs
......@@ -169,4 +169,4 @@ to {
> * {
pointer-events: auto;
}
`,er=({reverseOrder:e,position:n="top-center",toastOptions:r,gutter:o,children:i,containerStyle:s,containerClassName:a})=>{let{toasts:l,handlers:u}=(e=>{let{toasts:n,pausedAt:r}=((e={})=>{let[n,r]=(0,t.useState)(En);(0,t.useEffect)((()=>(Vn.push(r),()=>{let e=Vn.indexOf(r);e>-1&&Vn.splice(e,1)})),[n]);let o=n.toasts.map((t=>{var n,r;return{...e,...e[t.type],...t,duration:t.duration||(null==(n=e[t.type])?void 0:n.duration)||(null==e?void 0:e.duration)||_n[t.type],style:{...e.style,...null==(r=e[t.type])?void 0:r.style,...t.style}}}));return{...n,toasts:o}})(e);(0,t.useEffect)((()=>{if(r)return;let e=Date.now(),t=n.map((t=>{if(t.duration===1/0)return;let n=(t.duration||0)+t.pauseDuration-(e-t.createdAt);if(!(n<0))return setTimeout((()=>In.dismiss(t.id)),n);t.visible&&In.dismiss(t.id)}));return()=>{t.forEach((e=>e&&clearTimeout(e)))}}),[n,r]);let o=(0,t.useCallback)((()=>{r&&On({type:6,time:Date.now()})}),[r]),i=(0,t.useCallback)(((e,t)=>{let{reverseOrder:r=!1,gutter:o=8,defaultPosition:i}=t||{},s=n.filter((t=>(t.position||i)===(e.position||i)&&t.height)),a=s.findIndex((t=>t.id===e.id)),l=s.filter(((e,t)=>t<a&&e.visible)).length;return s.filter((e=>e.visible)).slice(...r?[l+1]:[0,l]).reduce(((e,t)=>e+(t.height||0)+o),0)}),[n]);return{toasts:n,handlers:{updateHeight:Rn,startPause:Dn,endPause:o,calculateOffset:i}}})(r);return t.createElement("div",{style:{position:"fixed",zIndex:9999,top:16,left:16,right:16,bottom:16,pointerEvents:"none",...s},className:a,onMouseEnter:u.startPause,onMouseLeave:u.endPause},l.map((r=>{let s=r.position||n,a=((e,t)=>{let n=e.includes("top"),r=n?{top:0}:{bottom:0},o=e.includes("center")?{justifyContent:"center"}:e.includes("right")?{justifyContent:"flex-end"}:{};return{left:0,right:0,display:"flex",position:"absolute",transition:wn()?void 0:"all 230ms cubic-bezier(.21,1.02,.73,1)",transform:`translateY(${t*(n?1:-1)}px)`,...r,...o}})(s,u.calculateOffset(r,{reverseOrder:e,gutter:o,defaultPosition:n}));return t.createElement(Xn,{id:r.id,key:r.id,onHeightUpdate:u.updateHeight,className:r.visible?Yn:"",style:a},"custom"===r.type?bn(r.message,r):i?i(r):t.createElement(Zn,{toast:r,position:s}))})))},tr=In,nr=n(535),rr=n(352),or=function(e){return e.New="new",e.Answered="answered",e.Unverified="unverified",e.Verified="verified",e.Edited="edited",e}({});const ir=function(e){var n=e.surveyModel,r=e.verificationStatus;function o(e,t){var n;r.current.set(e.name,t);var i=document.createElement("button");i.type="button",i.className="sv-action-bar-item verification",i.innerHTML=t,t==or.Unverified?(i.innerHTML="No change from previous year",i.className+=" verification-required",i.onclick=function(){e.validate(),o(e,or.Verified)}):(i.innerHTML="Answer confirmed",i.className+=" verification-ok");var s='[data-name="'+e.name+'"]',a=null===(n=document.querySelector(s))||void 0===n?void 0:n.querySelector("h5"),l=null==a?void 0:a.querySelector(".verification");l?l.replaceWith(i):null==a||a.appendChild(i)}return n.css={question:{title:"sv-title sv-question__title sv-header-flex",titleOnError:"sv-question__title--error sv-error-color-fix"}},nr.FunctionFactory.Instance.register("validateWebsiteUrl",(function(e){var t=e[0];if(void 0===t||null==t||""==t)return!0;try{var n=new URL(t);return"http:"===n.protocol||"https:"===n.protocol}catch(e){return!1}})),n.onAfterRenderQuestion.add((function(e,t){var n=r.current.get(t.question.name);n&&o(t.question,n)})),n.onValueChanged.add((function(e,t){var n=r.current.get(t.question.name);n==or.New?o(t.question,or.Answered):n==or.Unverified&&o(t.question,or.Edited)})),n.onUpdateQuestionCssClasses.add((function(e,t){t.question.hideCheckboxLabels&&(t.cssClasses.root+=" hidden-checkbox-labels")})),n.onMatrixAfterCellRender.add((function(e,t){if(0==t.column.indexValue&&"item"in t.row){var n,r=t.row.item;void 0!==r.customDescription&&(null===(n=t.htmlElement.parentElement)||void 0===n||n.children[0].setAttribute("title",r.customDescription))}})),t.createElement(rr.Survey,{model:n})},sr=t.forwardRef(((e,t)=>{const[{className:n,...r},{as:o="div",bsPrefix:i,spans:s}]=function({as:e,bsPrefix:t,className:n,...r}){t=je(t,"col");const o=Me(),i=qe(),s=[],a=[];return o.forEach((e=>{const n=r[e];let o,l,u;delete r[e],"object"==typeof n&&null!=n?({span:o,offset:l,order:u}=n):o=n;const c=e!==i?`-${e}`:"";o&&s.push(!0===o?`${t}${c}`:`${t}${c}-${o}`),null!=u&&a.push(`order${c}-${u}`),null!=l&&a.push(`offset${c}-${l}`)})),[{...r,className:Se()(n,...s,...a)},{as:e,bsPrefix:t,spans:s}]}(e);return(0,Te.jsx)(o,{...r,ref:t,className:Se()(n,!s.length&&i)})}));sr.displayName="Col";const ar=sr;function lr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function ur(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?lr(Object(n),!0).forEach((function(t){Ft(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):lr(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const cr=function(e){var n=e.surveyModel,r=e.pageNoSetter,o=ve((0,t.useState)([]),2),i=o[0],s=o[1],a=function(e){return null!==e.value&&void 0!==e.value};(0,t.useEffect)((function(){var e=function(e){if(e&&e.pages){var t=[];e.pages.forEach((function(n){var r=n.questions.filter((function(e){return e.startWithNewLine})),o=r.length,i=r.filter(a).length,s=o-i,l=i/o;t.push({completionPercentage:100*l,unansweredPercentage:s/o*100,totalPages:e.pages.length,pageTitle:n.title})})),s(t)}};n.onValueChanged.add((function(t){e(t)})),e(n)}),[n]);var l={height:"0.5rem",transition:"width 0.3s ease"};return t.createElement(zt,{className:"survey-progress"},t.createElement(Ut,null,i.map((function(e,o){return t.createElement(ar,{xs:12,md:!0,key:o,onClick:function(){return r(o)},style:{cursor:"pointer",margin:"0.5rem"}},t.createElement("div",null,t.createElement("span",{style:{whiteSpace:"nowrap",fontSize:"1.5rem",marginRight:"0.25rem",fontWeight:"bold",color:"#2db394"}},o+1),t.createElement("span",{style:ur({whiteSpace:"nowrap"},n.currentPageNo==o&&{fontWeight:"bold"})},e.pageTitle),t.createElement("div",{style:{display:"flex",flexWrap:"wrap"}},t.createElement("div",{style:ur(ur({},l),{},{width:"".concat(e.completionPercentage,"%"),backgroundColor:"#262261"})}),t.createElement("div",{style:ur(ur({},l),{},{width:"".concat(e.unansweredPercentage,"%"),backgroundColor:"#cdcdcd"})}))))}))))},pr=function(e){var n=e.surveyModel,r=e.endSurvey,o=e.saveSurvey,i=(e.validatePage,e.children),s=e.readonly,a=ve((0,t.useState)(0),2),l=a[0],u=a[1];(0,t.useEffect)((function(){u(n.currentPageNo)}),[n]);var c=function(e,n){return t.createElement("button",{className:"sv-btn sv-btn--navigation",onClick:n},e)},p=function(){return s?t.createElement(t.Fragment,null):t.createElement("div",{className:"navigation-block"},t.createElement("div",{className:"navigation-progress-container"},t.createElement("div",{className:"navigation-buttons-container"},l===n.visiblePages.length-1&&c("Complete Survey",r),c("Save progress",o))))};return t.createElement(zt,null,t.createElement(Ut,null,p()),t.createElement(Ut,null,t.createElement(cr,{surveyModel:n,pageNoSetter:function(e){u(e),n.currentPageNo=e}}),i),t.createElement(Ut,null,p()))};nr.Serializer.addProperty("itemvalue","customDescription:text"),nr.Serializer.addProperty("question","hideCheckboxLabels:boolean");const dr=function(e){var n=e.loadFrom,r=e.saveTo,o=void 0===r?"":r,i=e.readonly,s=void 0!==i&&i,a=ve((0,t.useState)(),2),l=a[0],u=a[1],c=(0,t.useRef)(new Map),p=function(){let{matches:e}=t.useContext(Q),n=e[e.length-1];return n?n.params:{}}(),d=p.year,h=p.nren,f=ve((0,t.useState)("loading survey..."),2),g=f[0],m=f[1];if((0,t.useEffect)((function(){function e(){return(e=Ce(xe().mark((function e(){var t,r,o,i;return xe().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch(n+d+(h?"/"+h:""));case 2:return t=e.sent,e.next=5,t.json();case 5:if(r=e.sent,t.ok){e.next=12;break}if(!("message"in r)){e.next=11;break}throw new Error(r.message);case 11:throw new Error("Request failed with status ".concat(t.status));case 12:for(o in r.verification_status)c.current.set(o,r.verification_status[o]);(i=new nr.Model(r.model)).setVariable("surveyyear",d),i.setVariable("previousyear",parseInt(d)-1),i.data=r.data,i.clearIncorrectValues(!0),i.currentPageNo=r.page,i.showNavigationButtons=!1,i.showTOC=!1,s&&(i.mode="display"),u(i);case 23:case"end":return e.stop()}}),e)})))).apply(this,arguments)}(function(){return e.apply(this,arguments)})().catch((function(e){return m("Error when loading survey: "+e.message)}))}),[]),!l)return g;function y(e,t,n){if(""!=o){var r=new XMLHttpRequest;r.open("POST",o+d+"/"+h),r.setRequestHeader("Content-Type","application/json; charset=utf-8"),r.onload=r.onerror=function(){200==r.status&&t?t():200!=r.status&&n&&n()};var i={data:e.data,page:e.currentPageNo,verification_status:Object.fromEntries(c.current)};r.send(JSON.stringify(i))}}return t.createElement(zt,{className:"survey-container"},t.createElement(er,null),t.createElement(Ut,{className:"survey-content"},t.createElement("h2",null,t.createElement("span",{className:"survey-title"},d," Compendium Survey"),t.createElement("span",{className:"survey-title-nren"},h)),t.createElement("span",{className:"survey-description"},"How to complete this survey - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo tempus pulvinar. Aenean interdum lectus nec diam porttitor interdum. Sed efficitur, magna ut dignissim consequat, purus lacus aliquam tortor, ut dignissim orci ligula ac ligula.")),t.createElement(Ut,null,t.createElement(pr,{surveyModel:l,endSurvey:function(){var e="",t=function(t,n){c.current.get(n.name)==or.Unverified&&(""==e&&(e=n.name),n.error="Please verify that last years data is correct by editing the value or pressing the verification button!")};l.onValidateQuestion.add(t);var n=l.validate();l.onValidateQuestion.remove(t),n?(tr("Completing survey..."),y(l,(function(){return tr("Survey completed!")}),(function(){return tr("Failed completing survey!")}))):l.focusQuestion(e)},saveSurvey:function(){tr("Saving survey..."),y(l,(function(){return tr("Survey saved!")}),(function(){return tr("Failed saving survey!")}))},validatePage:function(){var e="",t=function(t,n){c.current.get(n.name)==or.Unverified&&(""==e&&(e=n.name),n.error="Please verify that last years data is correct by editing the value or pressing the verification button!")};l.onValidateQuestion.add(t);var n=l.validateCurrentPage();l.onValidateQuestion.remove(t),n||l.focusQuestion(e)},readonly:s},t.createElement(ir,{surveyModel:l,verificationStatus:c}))))},hr=n.p+"9ab20ac1d835b50b2e01.svg",fr=function(){return t.createElement("div",{className:"external-page-nav-bar"},t.createElement(zt,null,t.createElement(Ut,null,t.createElement(ar,{xs:10},t.createElement("div",{className:"nav-wrapper"},t.createElement("nav",{className:"header-nav"},t.createElement("a",{href:"https://geant.org/"},t.createElement("img",{src:hr})),t.createElement("ul",null,t.createElement("li",null,t.createElement("a",{className:"nav-link-entry",href:"https://network.geant.org/"},"NETWORK")),t.createElement("li",null,t.createElement("a",{className:"nav-link-entry",href:"https://geant.org/services/"},"SERVICES")),t.createElement("li",null,t.createElement("a",{className:"nav-link-entry",href:"https://community.geant.org/"},"COMMUNITY")),t.createElement("li",null,t.createElement("a",{className:"nav-link-entry",href:"https://tnc23.geant.org/"},"TNC")),t.createElement("li",null,t.createElement("a",{className:"nav-link-entry",href:"https://geant.org/projects/"},"PROJECTS")),t.createElement("li",null,t.createElement("a",{className:"nav-link-entry",href:"https://connect.geant.org/"},"CONNECT")),t.createElement("li",null,t.createElement("a",{className:"nav-link-entry",href:"https://impact.geant.org/"},"IMPACT")),t.createElement("li",null,t.createElement("a",{className:"nav-link-entry",href:"https://careers.geant.org/"},"CAREERS")),t.createElement("li",null,t.createElement("a",{className:"nav-link-entry",href:"https://about.geant.org/"},"ABOUT")),t.createElement("li",null,t.createElement("a",{className:"nav-link-entry",href:"https://connect.geant.org/community-news"},"NEWS")),t.createElement("li",null,t.createElement("a",{className:"nav-link-entry",href:"https://resources.geant.org/"},"RESOURCES")))))))))},gr=function(){var e,n=(0,t.useContext)($t).user,r=J(),o=!!n.id,i=!!o&&!!n.nrens.length,s=i?n.nrens[0]:"",a=!!o&&n.permissions.admin;return t.createElement(zt,{className:"py-5 grey-container"},t.createElement(Ut,null,t.createElement("div",{className:"center-text"},t.createElement("h1",{className:"geant-header"},"THE GÉANT COMPENDIUM OF NRENS SURVEY"),t.createElement("div",{className:"wordwrap pt-4",style:{maxWidth:"75rem"}},t.createElement("p",{style:{textAlign:"left"}},"Hello, Welcome to the GÉANT Compendium Survey. NREN Compendium administrators can login ",t.createElement("a",{href:"/login"},"here")," to complete their registration to fill in the 2023 Compendium survey. Once your registration has been confirmed you will receive an email from the Compendium administration team.",t.createElement("br",null),"If you are not sure whether you are a Compendium Administrator for your NREN, please contact your GÉANT Partner Relations relationship manager.",t.createElement("br",null),"Thank you."),t.createElement("span",null,"Current registration status:"),t.createElement("br",null),t.createElement("br",null),a?t.createElement("ul",null,t.createElement("li",null,t.createElement("span",null,"You are logged in as a Compendium Administrator")),t.createElement("li",null,t.createElement("span",null,"Click ",t.createElement(he,{to:"/survey/admin/surveys"},"here")," to access the survey management page.")),t.createElement("li",null,t.createElement("span",null,"Click ",t.createElement(he,{to:"/survey/admin/users"},"here")," to access the user management page."))):t.createElement("ul",null,!a&&i&&(e=(new Date).getFullYear(),r("/survey/respond/".concat(e,"/").concat(s)),t.createElement(t.Fragment,null)),o?t.createElement("li",null,t.createElement("span",null,"You are logged in")):t.createElement("li",null,t.createElement("span",null,"You are not logged in")),o&&!i&&t.createElement("li",null,t.createElement("span",null,"Your access to the survey has not been approved")),o&&!i&&t.createElement("li",null,t.createElement("span",null,"Once you have been approved, you will immediately be directed to the relevant survey upon visiting this page")))))))},mr=function(){return t.createElement("div",{className:"app"},t.createElement(ce,null,t.createElement(Gt,null,t.createElement(fr,null),t.createElement(se,null,t.createElement(oe,{path:"survey/admin/surveys",element:t.createElement(At,null)}),t.createElement(oe,{path:"survey/admin/users",element:t.createElement(tn,null)}),t.createElement(oe,{path:"survey/admin/inspect/:year",element:t.createElement(dr,{loadFrom:"/api/survey/inspect/"})}),t.createElement(oe,{path:"survey/admin/try/:year",element:t.createElement(dr,{loadFrom:"/api/survey/try/"})}),t.createElement(oe,{path:"survey/respond/:year/:nren",element:t.createElement(dr,{loadFrom:"/api/survey/load/",saveTo:"/api/survey/save/"})}),t.createElement(oe,{path:"survey/show/:year/:nren",element:t.createElement(dr,{loadFrom:"/api/survey/load/",readonly:!0})}),t.createElement(oe,{path:"*",element:t.createElement(gr,null)})))))};var yr=document.getElementById("root");(0,r.s)(yr).render(t.createElement(t.StrictMode,null,t.createElement(mr,null)))})()})();
\ No newline at end of file
`,er=({reverseOrder:e,position:n="top-center",toastOptions:r,gutter:o,children:i,containerStyle:s,containerClassName:a})=>{let{toasts:l,handlers:u}=(e=>{let{toasts:n,pausedAt:r}=((e={})=>{let[n,r]=(0,t.useState)(En);(0,t.useEffect)((()=>(Vn.push(r),()=>{let e=Vn.indexOf(r);e>-1&&Vn.splice(e,1)})),[n]);let o=n.toasts.map((t=>{var n,r;return{...e,...e[t.type],...t,duration:t.duration||(null==(n=e[t.type])?void 0:n.duration)||(null==e?void 0:e.duration)||_n[t.type],style:{...e.style,...null==(r=e[t.type])?void 0:r.style,...t.style}}}));return{...n,toasts:o}})(e);(0,t.useEffect)((()=>{if(r)return;let e=Date.now(),t=n.map((t=>{if(t.duration===1/0)return;let n=(t.duration||0)+t.pauseDuration-(e-t.createdAt);if(!(n<0))return setTimeout((()=>In.dismiss(t.id)),n);t.visible&&In.dismiss(t.id)}));return()=>{t.forEach((e=>e&&clearTimeout(e)))}}),[n,r]);let o=(0,t.useCallback)((()=>{r&&On({type:6,time:Date.now()})}),[r]),i=(0,t.useCallback)(((e,t)=>{let{reverseOrder:r=!1,gutter:o=8,defaultPosition:i}=t||{},s=n.filter((t=>(t.position||i)===(e.position||i)&&t.height)),a=s.findIndex((t=>t.id===e.id)),l=s.filter(((e,t)=>t<a&&e.visible)).length;return s.filter((e=>e.visible)).slice(...r?[l+1]:[0,l]).reduce(((e,t)=>e+(t.height||0)+o),0)}),[n]);return{toasts:n,handlers:{updateHeight:Rn,startPause:Dn,endPause:o,calculateOffset:i}}})(r);return t.createElement("div",{style:{position:"fixed",zIndex:9999,top:16,left:16,right:16,bottom:16,pointerEvents:"none",...s},className:a,onMouseEnter:u.startPause,onMouseLeave:u.endPause},l.map((r=>{let s=r.position||n,a=((e,t)=>{let n=e.includes("top"),r=n?{top:0}:{bottom:0},o=e.includes("center")?{justifyContent:"center"}:e.includes("right")?{justifyContent:"flex-end"}:{};return{left:0,right:0,display:"flex",position:"absolute",transition:wn()?void 0:"all 230ms cubic-bezier(.21,1.02,.73,1)",transform:`translateY(${t*(n?1:-1)}px)`,...r,...o}})(s,u.calculateOffset(r,{reverseOrder:e,gutter:o,defaultPosition:n}));return t.createElement(Xn,{id:r.id,key:r.id,onHeightUpdate:u.updateHeight,className:r.visible?Yn:"",style:a},"custom"===r.type?bn(r.message,r):i?i(r):t.createElement(Zn,{toast:r,position:s}))})))},tr=In,nr=n(535),rr=n(352),or=function(e){return e.New="new",e.Answered="answered",e.Unverified="unverified",e.Verified="verified",e.Edited="edited",e}({});const ir=function(e){var n=e.surveyModel,r=e.verificationStatus;function o(e,t){var n;r.current.set(e.name,t);var i=document.createElement("button");i.type="button",i.className="sv-action-bar-item verification",i.innerHTML=t,t==or.Unverified?(i.innerHTML="No change from previous year",i.className+=" verification-required",i.onclick=function(){e.validate(),o(e,or.Verified)}):(i.innerHTML="Answer updated",i.className+=" verification-ok");var s='[data-name="'+e.name+'"]',a=null===(n=document.querySelector(s))||void 0===n?void 0:n.querySelector("h5"),l=null==a?void 0:a.querySelector(".verification");l?l.replaceWith(i):null==a||a.appendChild(i)}return n.css={question:{title:"sv-title sv-question__title sv-header-flex",titleOnError:"sv-question__title--error sv-error-color-fix"}},nr.FunctionFactory.Instance.register("validateWebsiteUrl",(function(e){var t=e[0];if(void 0===t||null==t||""==t)return!0;try{var n=new URL(t);return"http:"===n.protocol||"https:"===n.protocol}catch(e){return!1}})),n.onAfterRenderQuestion.add((function(e,t){var n=r.current.get(t.question.name);n&&o(t.question,n)})),n.onValueChanged.add((function(e,t){var n=r.current.get(t.question.name);n==or.New?o(t.question,or.Answered):n==or.Unverified&&o(t.question,or.Edited)})),n.onUpdateQuestionCssClasses.add((function(e,t){t.question.hideCheckboxLabels&&(t.cssClasses.root+=" hidden-checkbox-labels")})),n.onMatrixAfterCellRender.add((function(e,t){if(0==t.column.indexValue&&"item"in t.row){var n,r=t.row.item;void 0!==r.customDescription&&(null===(n=t.htmlElement.parentElement)||void 0===n||n.children[0].setAttribute("title",r.customDescription))}})),t.createElement(rr.Survey,{model:n})},sr=t.forwardRef(((e,t)=>{const[{className:n,...r},{as:o="div",bsPrefix:i,spans:s}]=function({as:e,bsPrefix:t,className:n,...r}){t=je(t,"col");const o=Me(),i=qe(),s=[],a=[];return o.forEach((e=>{const n=r[e];let o,l,u;delete r[e],"object"==typeof n&&null!=n?({span:o,offset:l,order:u}=n):o=n;const c=e!==i?`-${e}`:"";o&&s.push(!0===o?`${t}${c}`:`${t}${c}-${o}`),null!=u&&a.push(`order${c}-${u}`),null!=l&&a.push(`offset${c}-${l}`)})),[{...r,className:Se()(n,...s,...a)},{as:e,bsPrefix:t,spans:s}]}(e);return(0,Te.jsx)(o,{...r,ref:t,className:Se()(n,!s.length&&i)})}));sr.displayName="Col";const ar=sr;function lr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function ur(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?lr(Object(n),!0).forEach((function(t){Ft(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):lr(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const cr=function(e){var n=e.surveyModel,r=e.pageNoSetter,o=ve((0,t.useState)([]),2),i=o[0],s=o[1],a=function(e){return null!==e.value&&void 0!==e.value};(0,t.useEffect)((function(){var e=function(e){if(e&&e.pages){var t=[];e.pages.forEach((function(n){var r=n.questions.filter((function(e){return e.startWithNewLine})),o=r.length,i=r.filter(a).length,s=o-i,l=i/o;t.push({completionPercentage:100*l,unansweredPercentage:s/o*100,totalPages:e.pages.length,pageTitle:n.title})})),s(t)}};n.onValueChanged.add((function(t){e(t)})),e(n)}),[n]);var l={height:"0.5rem",transition:"width 0.3s ease"};return t.createElement(zt,{className:"survey-progress"},t.createElement(Ut,null,i.map((function(e,o){return t.createElement(ar,{xs:12,md:!0,key:o,onClick:function(){return r(o)},style:{cursor:"pointer",margin:"0.5rem"}},t.createElement("div",null,t.createElement("span",{style:{whiteSpace:"nowrap",fontSize:"1.5rem",marginRight:"0.25rem",fontWeight:"bold",color:"#2db394"}},o+1),t.createElement("span",{style:ur({whiteSpace:"nowrap"},n.currentPageNo==o&&{fontWeight:"bold"})},e.pageTitle),t.createElement("div",{style:{display:"flex",flexWrap:"wrap"}},t.createElement("div",{style:ur(ur({},l),{},{width:"".concat(e.completionPercentage,"%"),backgroundColor:"#262261"})}),t.createElement("div",{style:ur(ur({},l),{},{width:"".concat(e.unansweredPercentage,"%"),backgroundColor:"#cdcdcd"})}))))}))))},pr=function(e){var n=e.surveyModel,r=e.endSurvey,o=e.saveSurvey,i=(e.validatePage,e.children),s=e.readonly,a=ve((0,t.useState)(0),2),l=a[0],u=a[1];(0,t.useEffect)((function(){u(n.currentPageNo)}),[n]);var c=function(e,n){return t.createElement("button",{className:"sv-btn sv-btn--navigation",onClick:n},e)},p=function(){return s?t.createElement(t.Fragment,null):t.createElement("div",{className:"navigation-block"},t.createElement("div",{className:"navigation-progress-container"},t.createElement("div",{className:"navigation-buttons-container"},l===n.visiblePages.length-1&&c("Complete Survey",r),c("Save progress",o))))};return t.createElement(zt,null,t.createElement(Ut,null,p()),t.createElement(Ut,null,t.createElement(cr,{surveyModel:n,pageNoSetter:function(e){u(e),n.currentPageNo=e}}),i),t.createElement(Ut,null,p()))};nr.Serializer.addProperty("itemvalue","customDescription:text"),nr.Serializer.addProperty("question","hideCheckboxLabels:boolean");const dr=function(e){var n=e.loadFrom,r=e.saveTo,o=void 0===r?"":r,i=e.readonly,s=void 0!==i&&i,a=ve((0,t.useState)(),2),l=a[0],u=a[1],c=(0,t.useRef)(new Map),p=function(){let{matches:e}=t.useContext(Q),n=e[e.length-1];return n?n.params:{}}(),d=p.year,h=p.nren,f=ve((0,t.useState)("loading survey..."),2),g=f[0],m=f[1];if((0,t.useEffect)((function(){function e(){return(e=Ce(xe().mark((function e(){var t,r,o,i;return xe().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch(n+d+(h?"/"+h:""));case 2:return t=e.sent,e.next=5,t.json();case 5:if(r=e.sent,t.ok){e.next=12;break}if(!("message"in r)){e.next=11;break}throw new Error(r.message);case 11:throw new Error("Request failed with status ".concat(t.status));case 12:for(o in r.verification_status)c.current.set(o,r.verification_status[o]);(i=new nr.Model(r.model)).setVariable("surveyyear",d),i.setVariable("previousyear",parseInt(d)-1),i.data=r.data,i.clearIncorrectValues(!0),i.currentPageNo=r.page,i.showNavigationButtons=!1,i.showTOC=!1,s&&(i.mode="display"),u(i);case 23:case"end":return e.stop()}}),e)})))).apply(this,arguments)}(function(){return e.apply(this,arguments)})().catch((function(e){return m("Error when loading survey: "+e.message)}))}),[]),!l)return g;function y(e,t,n){if(""!=o){var r=new XMLHttpRequest;r.open("POST",o+d+"/"+h),r.setRequestHeader("Content-Type","application/json; charset=utf-8"),r.onload=r.onerror=function(){200==r.status&&t?t():200!=r.status&&n&&n()};var i={data:e.data,page:e.currentPageNo,verification_status:Object.fromEntries(c.current)};r.send(JSON.stringify(i))}}return t.createElement(zt,{className:"survey-container"},t.createElement(er,null),t.createElement(Ut,{className:"survey-content"},t.createElement("h2",null,t.createElement("span",{className:"survey-title"},d," Compendium Survey"),t.createElement("span",{className:"survey-title-nren"},h)),t.createElement("span",{className:"survey-description"},"How to complete this survey - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo tempus pulvinar. Aenean interdum lectus nec diam porttitor interdum. Sed efficitur, magna ut dignissim consequat, purus lacus aliquam tortor, ut dignissim orci ligula ac ligula.")),t.createElement(Ut,null,t.createElement(pr,{surveyModel:l,endSurvey:function(){var e="",t=function(t,n){c.current.get(n.name)==or.Unverified&&(""==e&&(e=n.name),n.error='Please verify that last years data is correct by editing the answer or pressing the "No change from previous year" button!')};l.onValidateQuestion.add(t);var n=l.validate();l.onValidateQuestion.remove(t),n?y(l,(function(){return tr("Survey completed!")}),(function(){return tr("Failed completing survey!")})):l.focusQuestion(e)},saveSurvey:function(){y(l,(function(){return tr("Survey saved!")}),(function(){return tr("Failed saving survey!")}))},validatePage:function(){var e="",t=function(t,n){c.current.get(n.name)==or.Unverified&&(""==e&&(e=n.name),n.error="Please verify that last years data is correct by editing the value or pressing the verification button!")};l.onValidateQuestion.add(t);var n=l.validateCurrentPage();l.onValidateQuestion.remove(t),n||l.focusQuestion(e)},readonly:s},t.createElement(ir,{surveyModel:l,verificationStatus:c}))))},hr=n.p+"9ab20ac1d835b50b2e01.svg",fr=function(){return t.createElement("div",{className:"external-page-nav-bar"},t.createElement(zt,null,t.createElement(Ut,null,t.createElement(ar,{xs:10},t.createElement("div",{className:"nav-wrapper"},t.createElement("nav",{className:"header-nav"},t.createElement("a",{href:"https://geant.org/"},t.createElement("img",{src:hr})),t.createElement("ul",null,t.createElement("li",null,t.createElement("a",{className:"nav-link-entry",href:"https://network.geant.org/"},"NETWORK")),t.createElement("li",null,t.createElement("a",{className:"nav-link-entry",href:"https://geant.org/services/"},"SERVICES")),t.createElement("li",null,t.createElement("a",{className:"nav-link-entry",href:"https://community.geant.org/"},"COMMUNITY")),t.createElement("li",null,t.createElement("a",{className:"nav-link-entry",href:"https://tnc23.geant.org/"},"TNC")),t.createElement("li",null,t.createElement("a",{className:"nav-link-entry",href:"https://geant.org/projects/"},"PROJECTS")),t.createElement("li",null,t.createElement("a",{className:"nav-link-entry",href:"https://connect.geant.org/"},"CONNECT")),t.createElement("li",null,t.createElement("a",{className:"nav-link-entry",href:"https://impact.geant.org/"},"IMPACT")),t.createElement("li",null,t.createElement("a",{className:"nav-link-entry",href:"https://careers.geant.org/"},"CAREERS")),t.createElement("li",null,t.createElement("a",{className:"nav-link-entry",href:"https://about.geant.org/"},"ABOUT")),t.createElement("li",null,t.createElement("a",{className:"nav-link-entry",href:"https://connect.geant.org/community-news"},"NEWS")),t.createElement("li",null,t.createElement("a",{className:"nav-link-entry",href:"https://resources.geant.org/"},"RESOURCES")))))))))},gr=function(){var e,n=(0,t.useContext)($t).user,r=J(),o=!!n.id,i=!!o&&!!n.nrens.length,s=i?n.nrens[0]:"",a=!!o&&n.permissions.admin;return t.createElement(zt,{className:"py-5 grey-container"},t.createElement(Ut,null,t.createElement("div",{className:"center-text"},t.createElement("h1",{className:"geant-header"},"THE GÉANT COMPENDIUM OF NRENS SURVEY"),t.createElement("div",{className:"wordwrap pt-4",style:{maxWidth:"75rem"}},t.createElement("p",{style:{textAlign:"left"}},"Hello, Welcome to the GÉANT Compendium Survey. NREN Compendium administrators can login ",t.createElement("a",{href:"/login"},"here")," to complete their registration to fill in the 2023 Compendium survey. Once your registration has been confirmed you will receive an email from the Compendium administration team.",t.createElement("br",null),"If you are not sure whether you are a Compendium Administrator for your NREN, please contact your GÉANT Partner Relations relationship manager.",t.createElement("br",null),"Thank you."),t.createElement("span",null,"Current registration status:"),t.createElement("br",null),t.createElement("br",null),a?t.createElement("ul",null,t.createElement("li",null,t.createElement("span",null,"You are logged in as a Compendium Administrator")),t.createElement("li",null,t.createElement("span",null,"Click ",t.createElement(he,{to:"/survey/admin/surveys"},"here")," to access the survey management page.")),t.createElement("li",null,t.createElement("span",null,"Click ",t.createElement(he,{to:"/survey/admin/users"},"here")," to access the user management page."))):t.createElement("ul",null,!a&&i&&(e=(new Date).getFullYear(),r("/survey/respond/".concat(e,"/").concat(s)),t.createElement(t.Fragment,null)),o?t.createElement("li",null,t.createElement("span",null,"You are logged in")):t.createElement("li",null,t.createElement("span",null,"You are not logged in")),o&&!i&&t.createElement("li",null,t.createElement("span",null,"Your access to the survey has not been approved")),o&&!i&&t.createElement("li",null,t.createElement("span",null,"Once you have been approved, you will immediately be directed to the relevant survey upon visiting this page")))))))},mr=function(){return t.createElement("div",{className:"app"},t.createElement(ce,null,t.createElement(Gt,null,t.createElement(fr,null),t.createElement(se,null,t.createElement(oe,{path:"survey/admin/surveys",element:t.createElement(At,null)}),t.createElement(oe,{path:"survey/admin/users",element:t.createElement(tn,null)}),t.createElement(oe,{path:"survey/admin/inspect/:year",element:t.createElement(dr,{loadFrom:"/api/survey/inspect/"})}),t.createElement(oe,{path:"survey/admin/try/:year",element:t.createElement(dr,{loadFrom:"/api/survey/try/"})}),t.createElement(oe,{path:"survey/respond/:year/:nren",element:t.createElement(dr,{loadFrom:"/api/survey/load/",saveTo:"/api/survey/save/"})}),t.createElement(oe,{path:"survey/show/:year/:nren",element:t.createElement(dr,{loadFrom:"/api/survey/load/",readonly:!0})}),t.createElement(oe,{path:"*",element:t.createElement(gr,null)})))))};var yr=document.getElementById("root");(0,r.s)(yr).render(t.createElement(t.StrictMode,null,t.createElement(mr,null)))})()})();
\ No newline at end of file
......@@ -42,7 +42,7 @@ function SurveyComponent({ surveyModel, verificationStatus }) {
setVerifyButton(question, VerificationStatus.Verified);
}
} else {
btn.innerHTML = "Answer confirmed"
btn.innerHTML = "Answer updated"
btn.className += " verification-ok";
}
......
......@@ -85,7 +85,6 @@ function SurveyContainerComponent({ loadFrom, saveTo = '', readonly = false }) {
}
const saveSurvey = () => {
toast("Saving survey...");
saveSurveyData(surveyModel, () => toast("Survey saved!"), () => toast("Failed saving survey!"));
};
......@@ -97,14 +96,13 @@ function SurveyContainerComponent({ loadFrom, saveTo = '', readonly = false }) {
if (firstValidationError == '') {
firstValidationError = options.name;
}
options.error = 'Please verify that last years data is correct by editing the value or pressing the verification button!';
options.error = 'Please verify that last years data is correct by editing the answer or pressing the "No change from previous year" button!';
}
};
surveyModel.onValidateQuestion.add(verificationValidator);
const validSurvey = surveyModel.validate();
surveyModel.onValidateQuestion.remove(verificationValidator);
if (validSurvey) {
toast("Completing survey...");
saveSurveyData(surveyModel, () => toast("Survey completed!"), () => toast("Failed completing survey!"));
} else {
surveyModel.focusQuestion(firstValidationError);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment