2 lines
17 KiB
JavaScript
2 lines
17 KiB
JavaScript
import{a as J,b as K,c as W,d as X,e as Z,f as tt,g as nt,h as et,i as ot,j as it,k as at}from"./chunk-CAFW6QNR.js";import{a as lt}from"./chunk-5WBSN65X.js";import{c as ct,g as rt}from"./chunk-YWCH6MM5.js";import"./chunk-66PBOFKL.js";import{a as Y}from"./chunk-B4CGVF35.js";import{b as U}from"./chunk-NIBVQDYD.js";import"./chunk-LLJSP5R2.js";import"./chunk-HMKN2VB2.js";import"./chunk-M5XZ5N2D.js";import{b as G,g as Q}from"./chunk-TAS7XC6E.js";import{a as F}from"./chunk-GMUETU5N.js";import"./chunk-3GOV5KJM.js";import"./chunk-TPLZKWZ7.js";import"./chunk-EGL4ZKWQ.js";import"./chunk-GPI43RSU.js";import{a as D,b as k,c as $,f as z,i as I}from"./chunk-6NRCTHHS.js";import"./chunk-RC3JXGN6.js";import{a as N,b as B}from"./chunk-N6VRXIQE.js";import"./chunk-GWD5A44H.js";import"./chunk-52JZ5I3Y.js";import{Aa as q,C as L,j as T,ua as R,w as A,wa as V,ya as H,za as j}from"./chunk-COFYR5MX.js";import{Db as s,Eb as p,Jb as x,Kb as e,Lb as o,Mb as u,Qb as d,Rb as g,Tb as h,U as y,Xb as M,Za as c,Zb as _,da as f,i as v,ia as O,ic as w,ja as P,lc as a,mc as C,nc as E,ob as S,ub as l}from"./chunk-2MUIW2M6.js";function dt(t,n){t&1&&(e(0,"div",3),u(1,"mat-spinner",5),e(2,"p"),a(3,"Loading categories..."),o()())}function gt(t,n){if(t&1){let i=h();e(0,"div",4)(1,"mat-icon",6),a(2,"error_outline"),o(),e(3,"h2"),a(4,"Failed to load categories"),o(),e(5,"p"),a(6),o(),e(7,"button",2),M("click",function(){O(i);let m=_();return P(m.retry())}),e(8,"mat-icon"),a(9,"refresh"),o(),a(10," Try Again "),o()()}if(t&2){let i=_();c(6),C(i.error())}}function _t(t,n){if(t&1){let i=h();e(0,"div",7)(1,"mat-icon",9),a(2,"folder_open"),o(),e(3,"h2"),a(4,"No Categories Yet"),o(),e(5,"p"),a(6,"Create your first category to get started."),o(),e(7,"button",2),M("click",function(){O(i);let m=_(2);return P(m.createCategory())}),e(8,"mat-icon"),a(9,"add"),o(),a(10," Create Category "),o()()}}function Ct(t,n){t&1&&(e(0,"th",22),a(1,"Icon"),o())}function st(t,n){if(t&1&&(e(0,"td",23)(1,"div",24)(2,"mat-icon"),a(3),o()()()),t&2){let i=n.$implicit;c(),w("background-color",i.color||"#2196F3"),c(2),C(i.icon||"category")}}function pt(t,n){t&1&&(e(0,"th",22),a(1,"Name"),o())}function Mt(t,n){if(t&1&&(e(0,"td",23)(1,"div",25)(2,"strong"),a(3),o(),e(4,"span",26),a(5),o()()()),t&2){let i=n.$implicit;c(3),C(i.name),c(2),C(i.description)}}function Ot(t,n){t&1&&(e(0,"th",22),a(1,"Slug"),o())}function Pt(t,n){if(t&1&&(e(0,"td",23)(1,"code"),a(2),o()()),t&2){let i=n.$implicit;c(2),C(i.slug)}}function yt(t,n){t&1&&(e(0,"th",22),a(1,"Questions"),o())}function ft(t,n){if(t&1&&(e(0,"td",23)(1,"mat-chip"),a(2),o()()),t&2){let i=n.$implicit;c(2),C(i.questionCount||0)}}function xt(t,n){t&1&&(e(0,"th",22),a(1,"Access"),o())}function ut(t,n){t&1&&(e(0,"mat-chip",27)(1,"mat-icon"),a(2,"public"),o(),a(3," Guest "),o())}function ht(t,n){t&1&&(e(0,"mat-chip",28)(1,"mat-icon"),a(2,"lock"),o(),a(3," Auth "),o())}function bt(t,n){if(t&1&&(e(0,"td",23),s(1,ut,4,0,"mat-chip",27)(2,ht,4,0,"mat-chip",28),o()),t&2){let i=n.$implicit;c(),p(i.guestAccessible?1:2)}}function vt(t,n){t&1&&(e(0,"th",22),a(1,"Order"),o())}function St(t,n){if(t&1&&(e(0,"td",23),a(1),o()),t&2){let i=n.$implicit;c(),E(" ",i.displayOrder??"-"," ")}}function wt(t,n){t&1&&(e(0,"th",22),a(1,"Actions"),o())}function Et(t,n){if(t&1){let i=h();e(0,"td",23)(1,"div",29)(2,"button",30),M("click",function(){let m=O(i).$implicit,b=_(3);return P(b.editCategory(m))}),e(3,"mat-icon"),a(4,"edit"),o()(),e(5,"button",31),M("click",function(){let m=O(i).$implicit,b=_(3);return P(b.deleteCategory(m))}),e(6,"mat-icon"),a(7,"delete"),o()()()()}}function Tt(t,n){t&1&&u(0,"tr",32)}function At(t,n){t&1&&u(0,"tr",33)}function Lt(t,n){if(t&1&&(e(0,"div",8)(1,"table",10),d(2,11),l(3,Ct,2,0,"th",12)(4,st,4,3,"td",13),g(),d(5,14),l(6,pt,2,0,"th",12)(7,Mt,6,2,"td",13),g(),d(8,15),l(9,Ot,2,0,"th",12)(10,Pt,3,1,"td",13),g(),d(11,16),l(12,yt,2,0,"th",12)(13,ft,3,1,"td",13),g(),d(14,17),l(15,xt,2,0,"th",12)(16,bt,3,1,"td",13),g(),d(17,18),l(18,vt,2,0,"th",12)(19,St,2,1,"td",13),g(),d(20,19),l(21,wt,2,0,"th",12)(22,Et,8,0,"td",13),g(),l(23,Tt,1,0,"tr",20)(24,At,1,0,"tr",21),o()()),t&2){let i=_(2);c(),x("dataSource",i.categories()),c(22),x("matHeaderRowDef",i.displayedColumns),c(),x("matRowDefColumns",i.displayedColumns)}}function Dt(t,n){if(t&1&&s(0,_t,11,0,"div",7)(1,Lt,25,3,"div",8),t&2){let i=_();p(i.categories().length===0?0:1)}}var mt=class t{categoryService=f(F);router=f(A);dialog=f(ct);destroy$=new v;categories=this.categoryService.categories;isLoading=this.categoryService.isLoading;error=this.categoryService.error;displayedColumns=["icon","name","slug","questionCount","guestAccessible","displayOrder","actions"];ngOnInit(){this.loadCategories()}loadCategories(){this.categoryService.getCategories(!0).pipe(y(this.destroy$)).subscribe()}createCategory(){this.router.navigate(["/admin/categories/new"])}editCategory(n){this.router.navigate(["/admin/categories/edit",n.id])}deleteCategory(n){this.dialog.open(lt,{width:"450px",data:{title:"Delete Category",message:`Are you sure you want to delete "${n.name}"?`,warning:n.questionCount>0?`This category has ${n.questionCount} question(s). Deleting it may affect existing quizzes.`:null,confirmText:"Delete",cancelText:"Cancel",confirmColor:"warn"}}).afterClosed().pipe(y(this.destroy$)).subscribe(r=>{r&&this.performDelete(n)})}performDelete(n){this.categoryService.deleteCategory(n.id).pipe(y(this.destroy$)).subscribe({next:()=>{},error:()=>{}})}retry(){this.loadCategories()}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete()}static \u0275fac=function(i){return new(i||t)};static \u0275cmp=S({type:t,selectors:[["app-admin-category-list"]],decls:15,vars:3,consts:[[1,"admin-category-list-container"],[1,"header-title"],["mat-raised-button","","color","primary",3,"click"],[1,"loading-container"],[1,"error-container"],["diameter","60"],[1,"error-icon"],[1,"empty-container"],[1,"table-container"],[1,"empty-icon"],["mat-table","",1,"categories-table",3,"dataSource"],["matColumnDef","icon"],["mat-header-cell","",4,"matHeaderCellDef"],["mat-cell","",4,"matCellDef"],["matColumnDef","name"],["matColumnDef","slug"],["matColumnDef","questionCount"],["matColumnDef","guestAccessible"],["matColumnDef","displayOrder"],["matColumnDef","actions"],["mat-header-row","",4,"matHeaderRowDef"],["mat-row","",4,"matRowDef","matRowDefColumns"],["mat-header-cell",""],["mat-cell",""],[1,"category-icon-cell"],[1,"category-name"],[1,"category-description"],[1,"access-chip","guest"],[1,"access-chip","auth"],[1,"action-buttons"],["mat-icon-button","","color","primary","matTooltip","Edit category","aria-label","Edit category",3,"click"],["mat-icon-button","","color","warn","matTooltip","Delete category","aria-label","Delete category",3,"click"],["mat-header-row",""],["mat-row",""]],template:function(i,r){i&1&&(e(0,"div",0)(1,"mat-card")(2,"mat-card-header")(3,"mat-card-title")(4,"div",1)(5,"h1"),a(6,"Manage Categories"),o(),e(7,"button",2),M("click",function(){return r.createCategory()}),e(8,"mat-icon"),a(9,"add"),o(),a(10," Create Category "),o()()()(),e(11,"mat-card-content"),s(12,dt,4,0,"div",3),s(13,gt,11,1,"div",4),s(14,Dt,2,1),o()()()),i&2&&(c(12),p(r.isLoading()?12:-1),c(),p(r.error()&&!r.isLoading()?13:-1),c(),p(!r.isLoading()&&!r.error()?14:-1))},dependencies:[T,L,I,D,$,z,k,H,V,R,q,j,at,J,W,nt,X,K,et,Z,tt,ot,it,Q,G,B,N,rt,Y,U],styles:[".admin-category-list-container[_ngcontent-%COMP%]{max-width:1400px;margin:24px auto;padding:0 16px}.admin-category-list-container[_ngcontent-%COMP%] mat-card[_ngcontent-%COMP%] mat-card-header[_ngcontent-%COMP%]{margin-bottom:24px}.admin-category-list-container[_ngcontent-%COMP%] mat-card[_ngcontent-%COMP%] mat-card-header[_ngcontent-%COMP%] .header-title[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;width:100%;flex-wrap:wrap;gap:16px}.admin-category-list-container[_ngcontent-%COMP%] mat-card[_ngcontent-%COMP%] mat-card-header[_ngcontent-%COMP%] .header-title[_ngcontent-%COMP%] h1[_ngcontent-%COMP%]{margin:0;font-size:28px;font-weight:500}@media (max-width: 600px){.admin-category-list-container[_ngcontent-%COMP%] mat-card[_ngcontent-%COMP%] mat-card-header[_ngcontent-%COMP%] .header-title[_ngcontent-%COMP%] h1[_ngcontent-%COMP%]{font-size:24px}}.admin-category-list-container[_ngcontent-%COMP%] mat-card[_ngcontent-%COMP%] mat-card-content[_ngcontent-%COMP%] .loading-container[_ngcontent-%COMP%]{display:flex;flex-direction:column;align-items:center;justify-content:center;min-height:300px;gap:20px}.admin-category-list-container[_ngcontent-%COMP%] mat-card[_ngcontent-%COMP%] mat-card-content[_ngcontent-%COMP%] .loading-container[_ngcontent-%COMP%] p[_ngcontent-%COMP%]{font-size:16px;color:#0009}.admin-category-list-container[_ngcontent-%COMP%] mat-card[_ngcontent-%COMP%] mat-card-content[_ngcontent-%COMP%] .error-container[_ngcontent-%COMP%]{display:flex;flex-direction:column;align-items:center;justify-content:center;min-height:300px;gap:16px;text-align:center}.admin-category-list-container[_ngcontent-%COMP%] mat-card[_ngcontent-%COMP%] mat-card-content[_ngcontent-%COMP%] .error-container[_ngcontent-%COMP%] .error-icon[_ngcontent-%COMP%]{font-size:64px;width:64px;height:64px;color:#f44336}.admin-category-list-container[_ngcontent-%COMP%] mat-card[_ngcontent-%COMP%] mat-card-content[_ngcontent-%COMP%] .error-container[_ngcontent-%COMP%] h2[_ngcontent-%COMP%]{margin:0;font-size:24px}.admin-category-list-container[_ngcontent-%COMP%] mat-card[_ngcontent-%COMP%] mat-card-content[_ngcontent-%COMP%] .error-container[_ngcontent-%COMP%] p[_ngcontent-%COMP%]{margin:0;color:#0009}.admin-category-list-container[_ngcontent-%COMP%] mat-card[_ngcontent-%COMP%] mat-card-content[_ngcontent-%COMP%] .empty-container[_ngcontent-%COMP%]{display:flex;flex-direction:column;align-items:center;justify-content:center;min-height:300px;gap:16px;text-align:center}.admin-category-list-container[_ngcontent-%COMP%] mat-card[_ngcontent-%COMP%] mat-card-content[_ngcontent-%COMP%] .empty-container[_ngcontent-%COMP%] .empty-icon[_ngcontent-%COMP%]{font-size:64px;width:64px;height:64px;color:#0000004d}.admin-category-list-container[_ngcontent-%COMP%] mat-card[_ngcontent-%COMP%] mat-card-content[_ngcontent-%COMP%] .empty-container[_ngcontent-%COMP%] h2[_ngcontent-%COMP%]{margin:0;font-size:24px}.admin-category-list-container[_ngcontent-%COMP%] mat-card[_ngcontent-%COMP%] mat-card-content[_ngcontent-%COMP%] .empty-container[_ngcontent-%COMP%] p[_ngcontent-%COMP%]{margin:0;color:#0009}.admin-category-list-container[_ngcontent-%COMP%] mat-card[_ngcontent-%COMP%] mat-card-content[_ngcontent-%COMP%] .table-container[_ngcontent-%COMP%]{overflow-x:auto}.admin-category-list-container[_ngcontent-%COMP%] mat-card[_ngcontent-%COMP%] mat-card-content[_ngcontent-%COMP%] .table-container[_ngcontent-%COMP%] .categories-table[_ngcontent-%COMP%]{width:100%}.admin-category-list-container[_ngcontent-%COMP%] mat-card[_ngcontent-%COMP%] mat-card-content[_ngcontent-%COMP%] .table-container[_ngcontent-%COMP%] .categories-table[_ngcontent-%COMP%] th[_ngcontent-%COMP%]{font-weight:600;font-size:14px;text-transform:uppercase;letter-spacing:.5px}.admin-category-list-container[_ngcontent-%COMP%] mat-card[_ngcontent-%COMP%] mat-card-content[_ngcontent-%COMP%] .table-container[_ngcontent-%COMP%] .categories-table[_ngcontent-%COMP%] td[_ngcontent-%COMP%], .admin-category-list-container[_ngcontent-%COMP%] mat-card[_ngcontent-%COMP%] mat-card-content[_ngcontent-%COMP%] .table-container[_ngcontent-%COMP%] .categories-table[_ngcontent-%COMP%] th[_ngcontent-%COMP%]{padding:16px 12px}.admin-category-list-container[_ngcontent-%COMP%] mat-card[_ngcontent-%COMP%] mat-card-content[_ngcontent-%COMP%] .table-container[_ngcontent-%COMP%] .categories-table[_ngcontent-%COMP%] .category-icon-cell[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:center;width:40px;height:40px;border-radius:8px}.admin-category-list-container[_ngcontent-%COMP%] mat-card[_ngcontent-%COMP%] mat-card-content[_ngcontent-%COMP%] .table-container[_ngcontent-%COMP%] .categories-table[_ngcontent-%COMP%] .category-icon-cell[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{color:#fff;font-size:24px;width:24px;height:24px}.admin-category-list-container[_ngcontent-%COMP%] mat-card[_ngcontent-%COMP%] mat-card-content[_ngcontent-%COMP%] .table-container[_ngcontent-%COMP%] .categories-table[_ngcontent-%COMP%] .category-name[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:4px}.admin-category-list-container[_ngcontent-%COMP%] mat-card[_ngcontent-%COMP%] mat-card-content[_ngcontent-%COMP%] .table-container[_ngcontent-%COMP%] .categories-table[_ngcontent-%COMP%] .category-name[_ngcontent-%COMP%] strong[_ngcontent-%COMP%]{font-size:16px}.admin-category-list-container[_ngcontent-%COMP%] mat-card[_ngcontent-%COMP%] mat-card-content[_ngcontent-%COMP%] .table-container[_ngcontent-%COMP%] .categories-table[_ngcontent-%COMP%] .category-name[_ngcontent-%COMP%] .category-description[_ngcontent-%COMP%]{font-size:13px;color:#0009;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.admin-category-list-container[_ngcontent-%COMP%] mat-card[_ngcontent-%COMP%] mat-card-content[_ngcontent-%COMP%] .table-container[_ngcontent-%COMP%] .categories-table[_ngcontent-%COMP%] code[_ngcontent-%COMP%]{padding:4px 8px;background-color:#0000000d;border-radius:4px;font-family:Courier New,monospace;font-size:13px}.admin-category-list-container[_ngcontent-%COMP%] mat-card[_ngcontent-%COMP%] mat-card-content[_ngcontent-%COMP%] .table-container[_ngcontent-%COMP%] .categories-table[_ngcontent-%COMP%] mat-chip.access-chip[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:4px}.admin-category-list-container[_ngcontent-%COMP%] mat-card[_ngcontent-%COMP%] mat-card-content[_ngcontent-%COMP%] .table-container[_ngcontent-%COMP%] .categories-table[_ngcontent-%COMP%] mat-chip.access-chip[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:16px;width:16px;height:16px}.admin-category-list-container[_ngcontent-%COMP%] mat-card[_ngcontent-%COMP%] mat-card-content[_ngcontent-%COMP%] .table-container[_ngcontent-%COMP%] .categories-table[_ngcontent-%COMP%] mat-chip.access-chip.guest[_ngcontent-%COMP%]{background-color:#4caf501a!important;color:#4caf50!important}.admin-category-list-container[_ngcontent-%COMP%] mat-card[_ngcontent-%COMP%] mat-card-content[_ngcontent-%COMP%] .table-container[_ngcontent-%COMP%] .categories-table[_ngcontent-%COMP%] mat-chip.access-chip.auth[_ngcontent-%COMP%]{background-color:#ff98001a!important;color:#ff9800!important}.admin-category-list-container[_ngcontent-%COMP%] mat-card[_ngcontent-%COMP%] mat-card-content[_ngcontent-%COMP%] .table-container[_ngcontent-%COMP%] .categories-table[_ngcontent-%COMP%] .action-buttons[_ngcontent-%COMP%]{display:flex;gap:4px}@media (max-width: 960px){.admin-category-list-container[_ngcontent-%COMP%] mat-card[_ngcontent-%COMP%] mat-card-content[_ngcontent-%COMP%] .table-container[_ngcontent-%COMP%] .categories-table[_ngcontent-%COMP%] th[_ngcontent-%COMP%]:nth-child(3), .admin-category-list-container[_ngcontent-%COMP%] mat-card[_ngcontent-%COMP%] mat-card-content[_ngcontent-%COMP%] .table-container[_ngcontent-%COMP%] .categories-table[_ngcontent-%COMP%] td[_ngcontent-%COMP%]:nth-child(3), .admin-category-list-container[_ngcontent-%COMP%] mat-card[_ngcontent-%COMP%] mat-card-content[_ngcontent-%COMP%] .table-container[_ngcontent-%COMP%] .categories-table[_ngcontent-%COMP%] th[_ngcontent-%COMP%]:nth-child(6), .admin-category-list-container[_ngcontent-%COMP%] mat-card[_ngcontent-%COMP%] mat-card-content[_ngcontent-%COMP%] .table-container[_ngcontent-%COMP%] .categories-table[_ngcontent-%COMP%] td[_ngcontent-%COMP%]:nth-child(6){display:none}}@media (max-width: 600px){.admin-category-list-container[_ngcontent-%COMP%] mat-card[_ngcontent-%COMP%] mat-card-content[_ngcontent-%COMP%] .table-container[_ngcontent-%COMP%] .categories-table[_ngcontent-%COMP%] th[_ngcontent-%COMP%]:nth-child(4), .admin-category-list-container[_ngcontent-%COMP%] mat-card[_ngcontent-%COMP%] mat-card-content[_ngcontent-%COMP%] .table-container[_ngcontent-%COMP%] .categories-table[_ngcontent-%COMP%] td[_ngcontent-%COMP%]:nth-child(4){display:none}}@media (prefers-color-scheme: dark){.admin-category-list-container[_ngcontent-%COMP%] .loading-container[_ngcontent-%COMP%] p[_ngcontent-%COMP%], .admin-category-list-container[_ngcontent-%COMP%] .error-container[_ngcontent-%COMP%] p[_ngcontent-%COMP%], .admin-category-list-container[_ngcontent-%COMP%] .empty-container[_ngcontent-%COMP%] p[_ngcontent-%COMP%], .admin-category-list-container[_ngcontent-%COMP%] .categories-table[_ngcontent-%COMP%] .category-name[_ngcontent-%COMP%] .category-description[_ngcontent-%COMP%]{color:#ffffffb3}.admin-category-list-container[_ngcontent-%COMP%] .categories-table[_ngcontent-%COMP%] code[_ngcontent-%COMP%]{background-color:#ffffff1a}}"]})};export{mt as AdminCategoryListComponent};
|