1import{a as tt}from"./chunk-KSUTOOR2.js";import"./chunk-PDAABYZR.js";import{Q as z,U as G,V as K,Z as q,_ as J,b as M,i as O,j as R,k as V,l as j,m as D,o as U,q as W,u as $}from"./chunk-KMXQE4KL.js";import{a as Y,e as Z}from"./chunk-R5WJRIHB.js";import{a as X}from"./chunk-NFYWOYC5.js";import"./chunk-ITMFNP22.js";import{d as Q}from"./chunk-LFRTPRFK.js";import"./chunk-GUZO7ZNK.js";import{Aa as f,Db as F,Ga as E,Ha as u,Ia as T,Ib as H,J as d,N as y,O as _,Pa as C,Pb as B,Rb as L,Ua as c,Va as g,Vc as A,Wa as I,aa as o,ab as k,bb as S,cb as N,fa as x,ka as v,qa as w,sa as b,vb as P,xa as p,ya as r,za as a}from"./chunk-3RYB6SVN.js";import"./chunk-QYJGY2IR.js";import"./chunk-YGHZJLBQ.js";import"./chunk-G35TH3HO.js";import"./chunk-QUJFQN2Y.js";import"./chunk-TQCPDUT3.js";import"./chunk-USX6FYMP.js";import"./chunk-LPZTKJWE.js";import"./chunk-PW6GA5NL.js";import"./chunk-S5XOBH6Y.js";import"./chunk-MKFP4TZ3.js";import"./chunk-JQVI6FS2.js";import"./chunk-BCFU56ZB.js";import"./chunk-PT3YUHTI.js";import"./chunk-MTEZNQW4.js";import"./chunk-PTASOGFN.js";import"./chunk-4K53T7NJ.js";import"./chunk-MTHZ7MWU.js";import"./chunk-WI5MSH4N.js";import"./chunk-N2ITJEWR.js";import"./chunk-CKP3SGE2.js";import"./chunk-RFGOEN6H.js";import"./chunk-Y7EQJLOB.js";import"./chunk-4EXU7QX3.js";import"./chunk-YG5PFMJ7.js";import"./chunk-NER57BGA.js";import"./chunk-DSHYVPZD.js";import"./chunk-PD2PSGYJ.js";import"./chunk-YGDXWWXH.js";import"./chunk-JNMFIV4M.js";import"./chunk-DXRS3GW7.js";import"./chunk-ZDL7X67C.js";import"./chunk-CLVRMGG4.js";import{g as h}from"./chunk-NMDLJX5Q.js";function at(i,l){i&1&&(r(0,"div",6),f(1,"ion-spinner",11),a())}function nt(i,l){i&1&&(r(0,"p",5),c(1," Rich formatting is disabled for this template because email sends plain text only. "),a())}function ot(i,l){if(i&1){let s=E();v(0,nt,2,0,"p",12),f(1,"app-rich-text-editor",13),r(2,"div",14)(3,"app-rich-text-editor",15,0),N("valueChange",function(t){y(s);let e=T();return S(e.templateText,t)||(e.templateText=t),_(t)}),a()(),r(5,"div",16)(6,"ion-button",17),u("click",function(){y(s);let t=C(4);return _(t.openEditor(!0))}),c(7," Edit Text "),a()()}if(i&2){let s=T();p("ngIf",s.fieldName==="instruct_email"),o(),p("value",s.templateText)("disabled",!0)("preserveHtml",!0)("placeholder","No template text set yet."),o(2),k("value",s.templateText),p("preserveHtml",!0)("plainTextMode",s.fieldName==="instruct_email")("placeholder",s.placeholder)("maxLength",2e4)}}function rt(i,l){i&1&&f(0,"ion-spinner",18)}var wt=(()=>{let l=class l{constructor(){this.http=d(H),this.route=d(B),this.router=d(L),this.global=d(X),this.alertCtrl=d(q),this.loadingCtrl=d(J),this.title="Edit Template",this.cardTitle="Template",this.description="",this.placeholder="Enter template text...",this.fieldName="template",this.templateText="",this.isSaving=!1,this.isLoading=!0,this.facultyId=null,this.userId=null,this.editorConfig={instruct_email:{title:"Edit Email Instruction",cardTitle:"Email Instruction",description:"This text is used for faculty email instructions (plain text only).",placeholder:"Enter email instruction content...",fieldName:"instruct_email"},booking_note:{title:"Edit Booking Note Template",cardTitle:"Booking Note Template",description:"This rich text is used as the faculty booking note template.",placeholder:"Enter booking note template content...",fieldName:"booking_note"},assessor_note:{title:"Edit Assessor Note Template",cardTitle:"Assessor Note Template",description:"This rich text is used as the faculty assessor note template.",placeholder:"Enter assessor note template content...",fieldName:"assessor_note"},template:{title:"Edit Site Report Template",cardTitle:"Site Report Template",description:"This rich text is used as the faculty site report template.",placeholder:"Enter site report template content...",fieldName:"template"}},Y({arrowBack:Z})}ngOnInit(){return h(this,null,function*(){try{let n=this.route.snapshot.paramMap.get("key")||"",t=this.editorConfig[n];if(!t){yield this.showAlert("Error","Unknown template type."),this.router.navigate(["/hod-faculty-settings"]);return}this.title=t.title,this.cardTitle=t.cardTitle,this.description=t.description,this.placeholder=t.placeholder,this.fieldName=t.fieldName;let e=this.global.getCurrentUser();if(!e?.faculty){yield this.showAlert("Error","No faculty found for your account."),this.router.navigate(["/hod-faculty-settings"]);return}this.facultyId=Number(e.faculty),this.userId=Number(e.user_id),this.global.setListByFaculty([]);let{Preferences:m}=yield import("./chunk-GPBI3ZNO.js");this.userId&&(yield m.remove({key:`listByFaculty_${this.userId}`}));let et=(yield this.global.loadFacultyList())?.find(it=>String(it?.list_id)===String(this.facultyId));this.templateText=String(et?.[this.fieldName]||"")}catch{yield this.showAlert("Error","Failed to load faculty template."),this.router.navigate(["/hod-faculty-settings"]);return}finally{this.isLoading=!1}})}save(){return h(this,null,function*(){if(this.facultyId===null){yield this.showAlert("Error","Faculty ID not found.");return}this.isSaving=!0;let n=yield this.loadingCtrl.create({message:"Saving..."});yield n.present();try{let t={faculty_id:this.facultyId,field:this.fieldName,value:this.templateText};t[this.fieldName]=this.templateText;let e=yield this.http.post(`${this.global.getApiBaseUrl()}
1update_faculty_popup.php`,t).toPromise();if(yield n.dismiss(),e?.success||e?.error===!1){this.global.setListByFaculty([]);let{Preferences:m}=yield import("./chunk-GPBI3ZNO.js");this.userId&&(yield m.remove({key:`listByFaculty_${this.userId}`})),yield this.showAlert("Saved",`${this.cardTitle} updated successfully.`),this.router.navigate(["/hod-faculty-settings"])}else yield this.showAlert("Error",e?.message||"Failed to save. Please try again.")}catch(t){yield n.dismiss(),yield this.showAlert("Error",t?.error?.message||"Network error. Please try again.")}finally{this.isSaving=!1}})}goBack(){this.router.navigate(["/hod-faculty-settings"])}showAlert(n,t){return h(this,null,function*(){yield(yield this.alertCtrl.create({header:n,message:t,buttons:["OK"]})).present()})}};l.\u0275fac=function(t){return new(t||l)},l.\u0275cmp=x({type:l,selectors:[["app-hod-faculty-template-editor"]],decls:22,vars:8,consts:[["editorLauncher",""],["color","primary"],["slot","start"],["defaultHref","/hod-faculty-settings",3,"click"],[1,"ion-padding"],[1,"hint"],[1,"loading-wrap"],[1,"button-group"],["expand","block","color","primary",3,"click","disabled"],["name","crescent","slot","start",4,"ngIf"],["expand","block","color","light",3,"click","disabled"],["name","crescent"],["class","hint",4,"ngIf"],[3,"value","disabled","preserveHtml","placeholder"],["aria-hidden","true",1,"hidden-editor-launcher"],[3,"valueChange","value","preserveHtml","plainTextMode","placeholder","maxLength"],[1,"preview-actions"],["fill","outline","color","primary",3,"click"],["name","crescent","slot","start"]],template:function(t,e){t&1&&(r(0,"ion-header")(1,"ion-toolbar",1)(2,"ion-buttons",2)(3,"ion-back-button",3),u("click",function(){return e.goBack()}),a()(),r(4,"ion-title"),c(5),a()()(),r(6,"ion-content",4)(7,"ion-card")(8,"ion-card-header")(9,"ion-card-title"),c(10),a()(),r(11,"ion-card-content")(12,"p",5),c(13),a(),w(14,at,2,0,"div",6)(15,ot,8,10),a()(),r(16,"div",7)(17,"ion-button",8),u("click",function(){return e.save()}),v(18,rt,1,0,"ion-spinner",9),c(19),a(),r(20,"ion-button",10),u("click",function(){return e.goBack()}),c(21," Cancel "),a()()()),t&2&&(o(5),g(e.title),o(5),g(e.cardTitle),o(3),g(e.description),o(),b(e.isLoading?14:15),o(3),p("disabled",e.isSaving||e.isLoading),o(),p("ngIf",e.isSaving),o(),I(" ",e.isSaving?"Saving...":"Save"," "),o(),p("disabled",e.isSaving))},dependencies:[F,P,A,Q,$,K,R,M,G,W,V,j,D,U,O,z,tt],styles:[".hint[_ngcontent-%COMP%]{font-size:.85em;color:var(--ion-color-medium);margin-bottom:16px}.loading-wrap[_ngcontent-%COMP%]{display:flex;justify-content:center;padding:24px 0}.button-group[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:8px;margin-top:16px}.preview-actions[_ngcontent-%COMP%]{display:flex;justify-content:flex-start;margin-top:16px;margin-bottom:12px}.hidden-editor-launcher[_ngcontent-%COMP%]{position:absolute;width:0;height:0;overflow:hidden;opacity:0;pointer-events:none}"]});let i=l;return i})();export{wt as HodFacultyTemplateEditorPage};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.