PageSourceSearch

https://avallainmagnet.com/assets/index-CBV6jP94.js

js avallainmagnet.com collected 2026-10-05 03:23:52 UTC 12,254 bytes, 1 lines download raw bytes

1import{e as B,X as H,j as e,at as ae,i as U,M as T,K as re,c as oe,c0 as ne,a_ as Q,b8 as le,C as ie,G as ce,av as X,ck as he,a6 as Y}from"./index-C0lny_Xs.js";import{v as A,r,P as n,u as de,cd as ee,ce as c,T as I,H as J,E as V,Q as pe,U as ue,ch as me,a2 as ge,cf as fe,cz as xe,cg as be}from"./[email protected]";import{u as je,a as ke}from"./useGetSchemesOfWork-ChWg22NK.js";import{l as ye}from"./vendor_lodash-CTmRrDuj.js";import{S as we}from"./index-BBL2boO_.js";import{F as Ce}from"./index-DDuLLC3h.js";import{E as se}from"./index-ZysFpGCa.js";import{S as z}from"./schemeOfWork-BCg8rGvC.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor_froala-editor-CINOzXuQ.js";import"./vendor_dexie-BfOzdcb7.js";import"./vendor_sendbird-g5x2IwfQ.js";import"./vendor_json-api-normalizer-BiAerEzu.js";import"./vendor_tincanjs-BV0rgLwS.js";import"./vendor_date-fns-C2_VU7J2.js";import"./vendor_final-form-B8E5KH4E.js";import"./vendor_frontend-lrs-Bt2ksvpn.js";import"./vendor_echarts-for-react-DmExc8Jt.js";import"./vendor_echarts-Cbt4a95V.js";import"./helpers-DHNCQbr6.js";import"./index-EFT2lXEh.js";import"./index-Ckqmyq2s.js";const Se=A(({spacing:s})=>({root:{display:"flex",flexDirection:"column",gap:s(2)},body:{display:"flex",flexDirection:"column",gap:s(2)}})),ve=A(({spacing:s,palette:t})=>({root:{display:"flex",flexDirection:"column",gap:s(3)},search:{width:"100%",justifyContent:"left",backgroundColor:t.background.paper,borderRadius:16,boxShadow:"0 0 5px #11111126"},searchWrapper:{width:"100%"},buttonContainer:{display:"flex",justifyContent:"flex-end"},createSchemaButton:{height:36,maxWidth:180,marginLeft:"auto",gap:s(.5)},actions:{display:"flex",justifyContent:"space-between",width:"100%"}})),_e=[{key:"-updated_at",name:"Last Updated"},{key:"name",name:"Name"},{key:"-created_at",name:"Newest"}],G=({meta:s,sort:t,onSort:m,onSearch:h,onFilters:j})=>{const a=ve(),{t:g}=B(),o=H(),k=r.useMemo(()=>{var x,C;const d=(s==null?void 0:s.filterOptions)||{},w=[];return(x=d.states)!=null&&x.length&&w.push({name:"state",label:"Status",options:d.states.map(p=>({id:p,title:p.charAt(0).toUpperCase()+p.slice(1)}))}),(C=d.subjects)!=null&&C.length&&w.push({name:"subject",label:"Subject",options:d.subjects.map(p=>({id:p,title:p}))}),w},[s]),f=r.useCallback(()=>{o.push("/scheme-of-work/new")},[o]),v=r.useCallback(d=>{m(d)},[m]),y=r.useCallback(d=>{h(d)},[h]),_=ye.debounce(y,500);return e.jsxs("div",{className:a.root,children:[e.jsx(ae,{placeholder:g("schemes-of-work-page.search"),className:a.search,wrapperClassName:a.searchWrapper,onEnter:y,onChange:_}),e.jsx("div",{className:a.buttonContainer,children:e.jsxs(U.primary,{onClick:f,className:a.createSchemaButton,children:[e.jsx(T,{glyph:"addIcon"}),g("schemes-of-work-page.new_scheme")]})}),e.jsxs("div",{className:a.actions,children:[e.jsx(we,{variant:"short",value:t,items:_e,onChange:v}),e.jsx(Ce,{items:k,filters:{},onChange:j})]})]})};G.propTypes={schemesOfWork:n.array.isRequired,meta:n.object,sort:n.string.isRequired,onSort:n.func.isRequired,onSearch:n.func.isRequired,onFilters:n.func.isRequired};G.defaultProps={meta:{}};const Ie=A(({palette:s,spacing:t})=>({table:{"& .MuiTableCell-root":{borderBottom:`1px solid ${s.divider}`}},tableHead:{"& th":{fontSize:12,fontWeight:500,height:36,paddingInline:t(2),paddingBlock:0},backgroundColor:s.grey[200]},tableBody:{"& td":{fontSize:14,fontWeight:500}}})),Te=A(({palette:s,spacing:t,shape:m})=>({tableRow:{"&:last-child td, &:last-child th":{border:0}},groupsChip:{cursor:"pointer",paddingInline:t(1),paddingBlock:2},dropdownIcon:{display:"flex",alignItems:"center"},singleGroup:{display:"flex",alignItems:"center",justifyContent:"center",gap:t(.5),maxWidth:180,"& .MuiTypography-root":{display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",whiteSpace:"normal"}},menuPaper:{borderRadius:4,minWidth:200,boxShadow:"0px 0px 5px 0px #11111126",gap:1,padding:t(.5)},menuItem:{paddingBlock:t(1.5),paddingInline:t(1),borderBottom:`1px solid ${s.divider}`,"&:first-child":{paddingTop:0},"&:last-child":{borderBottom:"none",paddingBottom:0}},menuItemIcon:{minWidth:"unset",marginLeft:t(2)}
1,groupsPopoverPaper:{borderRadius:12,minWidth:140,minHeight:112,maxHeight:300,maxWidth:260,boxShadow:"0 4px 20px rgba(0, 0, 0, 0.1)",overflowY:"auto"},userCell:{display:"flex",alignItems:"center",gap:t(1)},blackText:{color:s.common.black},groupItem:{display:"flex",alignItems:"center",gap:t(1.5),borderBottom:`1px solid ${s.divider}`},groupIcon:{flexShrink:0,"& svg":{borderRadius:m.borderRadius}}})),Z={DRAFT:"Draft",PUBLISHED:"Published"},te=({item:s})=>{var R,O;const{t}=B(),m=H(),h=re.useSnackbar(),[j,a]=r.useState(null),[g,o]=r.useState(null),[k,f]=r.useState(!1),[v,y]=r.useState(!1),[_,d]=r.useState(!1),w=oe(ne)==="teacher_admin",x=s.status===Z.DRAFT,C=s.status===Z.PUBLISHED,p=je(),{palette:S}=de(),u=Te(),F=!!j,q=!!g,L=[{label:t("schemes-of-work-page.scheme_item.menu_options.preview"),action:"preview"},{label:t("schemes-of-work-page.scheme_item.menu_options.edit"),action:"edit"},...x?[{label:t("schemes-of-work-page.publish"),action:"publish"}]:[{label:t("schemes-of-work-page.scheme_item.menu_options.link_to_groups"),action:"link"}],{label:t("schemes-of-work-page.scheme_item.menu_options.duplicate"),action:"duplicate"},...w?[{label:t("schemes-of-work-page.scheme_item.menu_options.delete"),action:"delete",glyph:"delete"}]:[]],N=i=>{a(i.currentTarget)},P=()=>{a(null)},E=r.useCallback(async i=>{switch(a(null),i){case"preview":m.push(`/scheme-of-work/${s.id}/review`);break;case"edit":m.push(`/scheme-of-work/${s.id}/edit`);break;case"publish":try{await z.publishSchemeOfWork(s.id),p()}catch($){h.showMessage(t("schemes-of-work-page.errors.publish_failed")),console.error("Failed to publish:",$)}break;case"duplicate":if(_)break;d(!0);try{await z.duplicateSchemeOfWork(s.id),p()}catch($){h.showMessage(t("schemes-of-work-page.errors.duplication_failed")),console.error($)}finally{d(!1)}break;case"link":m.push(`/scheme-of-work/${s.id}/link`);break;case"delete":f(!0);break}},[m,s.id,_,p,h,t]),M=i=>{o(i.currentTarget)},W=()=>{o(null)},b=x?{hexColor:S.grey[200]}:C?{hexColor:S.status.informationSoft}:{hexColor:S.status.successSoft},D=r.useCallback(async()=>{y(!0);try{await z.deleteSchemeOfWork(s.id),p(),f(!1)}catch(i){h.showMessage(t("schemes-of-work-page.errors.delete_failed")),console.error(i)}finally{y(!1)}},[s.id,p,h,t]);return e.jsxs(e.Fragment,{children:[e.jsxs(ee,{className:u.tableRow,children:[e.jsx(c,{align:"left",children:e.jsx(I,{variant:"subtitle1",children:s.name})}),e.jsx(c,{align:"left",children:e.jsx(I,{variant:"caption",children:s.base_curriculum})}),e.jsx(c,{align:"center",children:e.jsx(I,{variant:"caption",children:s.year})}),e.jsxs(c,{align:"center",children:[e.jsx(Q,{label:t("schemes-of-work-page.scheme_item.groups_chip",{count:((R=s.groups)==null?void 0:R.length)||0}),hexColor:((O=s.groups)==null?void 0:O.length)>5?S.grey[300]:S.grey[200],className:u.groupsChip,onClick:M,endIcon:e.jsx(T,{glyph:"dropDownExpand",size:16,className:u.dropdownIcon})}),e.jsx(J,{open:q,anchorEl:g,onClose:W,anchorOrigin:{vertical:"bottom",horizontal:"center"},transformOrigin:{vertical:"top",horizontal:"center"}
1,getContentAnchorEl:null,classes:{paper:u.groupsPopoverPaper},children:(s.groups||[]).map(i=>e.jsxs(V,{className:u.groupItem,children:[e.jsx(T,{glyph:"groupAvatar",size:32,className:u.groupIcon}),e.jsx(I,{variant:"caption",className:u.blackText,noWrap:!0,children:i.name})]},i.id))})]}),e.jsx(c,{align:"center",children:e.jsx(Q,{label:s.status,hexColor:b.hexColor})}),e.jsx(c,{align:"left",children:e.jsx("div",{className:u.userCell,children:e.jsx(I,{variant:"caption",className:u.blackText,children:s.created_by})})}),e.jsx(c,{align:"left",children:e.jsx(I,{variant:"caption",children:s.last_updated})}),e.jsxs(c,{align:"left",children:[e.jsx(le,{onClick:N,children:e.jsx(T,{glyph:"contextualMenu"})}),e.jsx(J,{anchorEl:j,open:F,onClose:P,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},getContentAnchorEl:null,classes:{paper:u.menuPaper},children:L.map(i=>e.jsxs(V,{onClick:()=>E(i.action),className:u.menuItem,children:[e.jsx(pe,{primary:i.label}),i.glyph&&e.jsx(ue,{className:u.menuItemIcon,children:e.jsx(T,{glyph:i.glyph})})]},i.action))})]})]},s.id),e.jsx(ie,{open:k,title:t("schemes-of-work-page.delete_dialog.title"),description:t("schemes-of-work-page.delete_dialog.description",{name:s.name}),onOk:D,onCancel:()=>f(!1),shouldDisableActionsOnConfirm:v})]})};te.propTypes={item:n.shape({id:n.string.isRequired,name:n.string.isRequired,base_curriculum:n.string.isRequired,subject:n.string.isRequired,year:n.string.isRequired,status:n.string.isRequired,created_by:n.string.isRequired,last_updated:n.string.isRequired}).isRequired};const K=({schemesOfWork:s,isLoading:t,error:m,isFetchingNextPage:h,hasActiveFilters:j,onRetry:a})=>{const g=Ie(),{t:o}=B();return!t&&m?e.jsxs("div",{className:g.errorContainer,children:[e.jsx(ce,{variant:"h3",children:o("schemes-of-work-page.errors.load_failed")}),a&&e.jsx(U.primary,{variant:"contained",onClick:a,children:o("schemes-of-work-page.errors.retry")})]}):t&&!s.length?e.jsx(X,{}):j&&s.length===0?e.jsx(se,{className:g.root,headerText:o("schemes-of-work-page.empty_list"),glyph:"emptyBox"}):e.jsxs(me,{component:ge,children:[e.jsxs(fe,{"aria-label":o("schemes-of-work-page.table_title"),className:g.table,children:[e.jsx(xe,{className:g.tableHead,children:e.jsxs(ee,{children:[e.jsx(c,{align:"left",children:o("schemes-of-work-page.list.name")}),e.jsx(c,{align:"left",children:o("schemes-of-work-page.list.base_curriculum")}),e.jsx(c,{align:"center",children:o("schemes-of-work-page.list.year")}),e.jsx(c,{align:"center",children:o("schemes-of-work-page.list.subject")}),e.jsx(c,{align:"center",children:o("schemes-of-work-page.list.status")}),e.jsx(c,{align:"left",children:o("schemes-of-work-page.list.created_by")}),e.jsx(c,{align:"left",children:o("schemes-of-work-page.list.last_updated")}),e.jsx(c,{align:"left",children:o("schemes-of-work-page.list.actions")})]})}),e.jsx(be,{className:g.tableBody,children:s.map(k=>e.jsx(te,{item:k},k.id))})]}),h&&e.jsx(X,{})]})};K.propTypes={schemesOfWork:n.array.isRequired,isLoading:n.bool,error:n.object,isFetchingNextPage:n.bool,hasActiveFilters:n.bool,onRetry:n.func};K.defaultProps={isLoading:!1,error:null,isFetchingNextPage:!1,hasActiveFilters:!1,onRetry:null};const Ne=({createSoW:s})=>{const{t}=B();return e.jsx(se,{headerText:t("schemes-of-work-page.empty_list"),action:e.jsx(U.primary,{disableElevation:!0,onClick:s,startIcon:e.jsx(T,{glyph:"addIcon"}),children:t("schemes-of-work-page.new_scheme")})})},Ve=()=>{var P,E,M,W;const s=Se(),[t,m]=r.useState(""),[h,j]=r.useState("-updated_at"),[a,g]=r.useState({}),o=H(),k=r.useMemo(()=>{var b,D,R,O;const l={sort:h};return t&&(l.search=t),((b=a.state)!=null&&b.length||(D=a.subject)!=null&&D.length)&&(l.filter={},(R=a.state)!=null&&R.length&&(l.filter.state=a.state.length===1?a.state[0]:a.state),(O=a.subject)!=null&&O.length&&(l.filter.subject=a.subject.length===1?a.subject[0]:a.subject)),l},[t,h,a]),{data:f,isLoading:v,error:y,refetch:_,fetchNextPage:d,hasNextPage:w,isFetchingNextPage:x}=ke({queryParams:k}),C=r.useMemo(()=>{var l;return((l=f==null?void 0:f.pages)==null?void 0:l.flatMap(b=>b.items))||[]},[f]),p=((E=(P=f==null?void 0:f.pages)==null?void 0:P[0])==null?void 0:E.meta)||{},S=r.useCallback(()=>{w&&!x&&d()},[d,w,x]);he(S,document.documentElement,[S]);const u=r.useCallback(l=>{m(l||"")},[]),F=r.useCallback(l=>{j(l)},[]),q=r.useCallback(l=>{g(l)},[]),L=r.useCallback(()=>{o.push("/scheme-of-work/new")},[o]),N=r.useMemo(()=>{var l,b;return!!t||!!((l=a.state)!=null&&l.length)||!!((b=a.subject)!=null&&b.length)},[(M=a.state)==null?void 0:M.length,(W=a.subject)==null?void 0:W.length,t]);return!v&&!y&&!N&&C.length===0?e.jsxs(Y,{registerAsMain:!0,className:s.root,children:[e.jsx(Ne,{createSoW:L}),";"]}):e.jsxs(Y,{registerAsMain:!0,className:s.root,children:[e.jsx(G,{schemesOfWork:C,isLoading:v,hasActiveFilters:N,meta:p,sort:h,onSort:F,onSearch:u,onFilters:q}),e.jsx("div",{className:s.body,children:e.jsx(K,{schemesOfWork:C,isLoading:v,isFetchingNextPage:x,error:y,hasActiveFilters:N,onRetry:_})})]})};export{Ve as default};

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.