UNPKG

manifest

Version:

The backend for AI code editors

1 lines 14.7 kB
"use strict";(self.webpackChunkadmin=self.webpackChunkadmin||[]).push([[45],{4045:(ut,d,s)=>{s.r(d),s.d(d,{CrudCollectionModule:()=>mt});var C=s(4493),p=s(183),u=s(1424),G=s(992),f=s(7431),m=s(5442),T=s(4782),$=s(9e3),t=s(8284),F=s(6119),h=s(2283),k=s(9879),y=s(818),c=s(2943),x=s(6631),R=s(8785);function b(e,o){if(1&e&&(t.j41(0,"span"),t.EFF(1),t.k0s()),2&e){const n=t.XpG();t.R7$(),t.Lme(" Page ",n.paginator.currentPage," of ",n.paginator.lastPage," \u2022 ")}}function j(e,o){1&e&&t.EFF(0,"No result")}function M(e,o){1&e&&t.EFF(0,"1 result")}function I(e,o){if(1&e&&t.EFF(0),2&e){const n=t.XpG();t.SpI(" ",n.paginator.total," results ")}}function L(e,o){1&e&&(t.j41(0,"span"),t.EFF(1,"in total"),t.k0s())}let P=(()=>{class e{static{this.\u0275fac=function(i){return new(i||e)}}static{this.\u0275cmp=t.VBU({type:e,selectors:[["app-list-meta"]],inputs:{paginator:"paginator"},decls:8,vars:3,consts:[[1,"mb-2"],[4,"ngIf"],[3,"ngPlural"],["ngPluralCase","0"],["ngPluralCase","1"],["ngPluralCase","other"]],template:function(i,a){1&i&&(t.j41(0,"p",0),t.DNE(1,b,2,2,"span",1),t.j41(2,"span"),t.qex(3,2),t.DNE(4,j,1,0,"ng-template",3)(5,M,1,0,"ng-template",4)(6,I,1,1,"ng-template",5),t.bVm(),t.DNE(7,L,2,0,"span",1),t.k0s()()),2&i&&(t.R7$(),t.Y8G("ngIf",a.paginator.lastPage>1),t.R7$(2),t.Y8G("ngPlural",a.paginator.total),t.R7$(4),t.Y8G("ngIf",a.paginator.lastPage>1))},dependencies:[c.bT,c.IJ,c.WO]})}}return e})();const E=e=>({"is-current":e});function S(e,o){1&e&&(t.j41(0,"li")(1,"span",5),t.EFF(2,"\u2026"),t.k0s()())}function Y(e,o){if(1&e){const n=t.RV6();t.j41(0,"li")(1,"a",6),t.bIt("click",function(){const a=t.eBV(n).$implicit,r=t.XpG(2);return t.Njj(r.goToPage(a))}),t.EFF(2),t.k0s()()}if(2&e){const n=o.$implicit,i=t.XpG(2);t.R7$(),t.Y8G("ngClass",t.eq3(2,E,i.paginator.currentPage==n)),t.R7$(),t.JRh(n)}}function D(e,o){1&e&&(t.j41(0,"li")(1,"span",5),t.EFF(2,"\u2026"),t.k0s()())}function X(e,o){if(1&e&&(t.j41(0,"nav",1)(1,"ul",2),t.DNE(2,S,3,0,"li",3)(3,Y,3,4,"li",4)(4,D,3,0,"li",3),t.k0s()()),2&e){const n=t.XpG();t.R7$(2),t.Y8G("ngIf",n.pageArray[0]>1),t.R7$(),t.Y8G("ngForOf",n.pageArray),t.R7$(),t.Y8G("ngIf",n.pageArray[n.pageArray.length-1]<n.paginator.lastPage)}}let N=(()=>{class e{constructor(){this.pageChanged=new t.bkB}ngOnChanges(){this.pageArray=this.createPageArray(this.paginator.currentPage,this.paginator.lastPage)}goToPage(n){this.pageChanged.emit(n),this.pageArray=this.createPageArray(n,this.paginator.lastPage)}createPageArray(n,i){let a,r;i<=5?(a=1,r=i):n<=3?(a=1,r=5):n+2>=i?(a=i-4,r=i):(a=n-2,r=n+2);const l=[];for(let g=a;g<=r;g+=1)l.push(g);return l}scrollTop(){window.scrollTo({top:0,behavior:"smooth"})}static{this.\u0275fac=function(i){return new(i||e)}}static{this.\u0275cmp=t.VBU({type:e,selectors:[["app-pagination"]],inputs:{paginator:"paginator"},outputs:{pageChanged:"pageChanged"},features:[t.OA$],decls:1,vars:1,consts:[["class","pagination is-centered my-5 is-rounded","role","navigation","aria-label","pagination",4,"ngIf"],["role","navigation","aria-label","pagination",1,"pagination","is-centered","my-5","is-rounded"],[1,"pagination-list"],[4,"ngIf"],[4,"ngFor","ngForOf"],[1,"pagination-ellipsis"],["duration","400",1,"pagination-link",3,"click","ngClass"]],template:function(i,a){1&i&&t.DNE(0,X,5,3,"nav",0),2&i&&t.Y8G("ngIf",a.paginator.lastPage>1)},dependencies:[c.YU,c.Sq,c.bT]})}}return e})();const v=e=>["/collections",e,"create"],V=e=>({"mb-0":e}),O=e=>({"has-text-right":e}),A=(e,o)=>["/","collections",e,o],B=(e,o)=>["/collections",e,o,"edit"],U=(e,o)=>({"has-text-right":e,"has-detail-link":o});function w(e,o){if(1&e&&t.nrm(0,"app-list-meta",17),2&e){const n=t.XpG(2);t.Y8G("paginator",n.paginator)}}function K(e,o){1&e&&(t.j41(0,"div",18),t.nrm(1,"span",19),t.k0s())}function q(e,o){if(1&e&&(t.j41(0,"th",20),t.EFF(1),t.k0s()),2&e){const n=o.$implicit,i=t.XpG(2);t.Y8G("ngClass",t.eq3(2,O,n.type===i.PropType.Money||n.type===i.PropType.Number||n.type===i.PropType.Date)),t.R7$(),t.SpI(" ",n.name," ")}}function J(e,o){if(1&e&&(t.j41(0,"th"),t.EFF(1),t.k0s()),2&e){const n=t.XpG().$implicit;t.R7$(),t.SpI(" ",n.name," ")}}function z(e,o){if(1&e&&(t.qex(0),t.DNE(1,J,2,1,"th",0),t.bVm()),2&e){const n=o.$implicit;t.R7$(),t.Y8G("ngIf","many-to-one"===n.type||"many-to-many"===n.type&&n.owningSide)}}function H(e,o){if(1&e){const n=t.RV6();t.j41(0,"td",30),t.bIt("click",function(){const a=t.eBV(n).$implicit,r=t.XpG().$implicit,l=t.XpG(3);return t.Njj(a.name===l.entityManifest.mainProp?l.goToDetailPage(r.id):null)}),t.nrm(1,"app-yield",31),t.k0s()}if(2&e){const n=o.$implicit,i=t.XpG().$implicit,a=t.XpG(3);t.Y8G("ngClass",t.l_i(4,U,n.type===a.PropType.Money||n.type===a.PropType.Number||n.type===a.PropType.Date,n.name===a.entityManifest.mainProp)),t.R7$(),t.Y8G("prop",n)("value",i[n.name])("compact",!0)}}function W(e,o){if(1&e&&t.nrm(0,"app-relation-yield",33),2&e){const n=t.XpG(2).$implicit,i=t.XpG().$implicit;t.Y8G("item",i[n.name])("relationship",n)}}function Q(e,o){1&e&&(t.qex(0),t.EFF(1,", "),t.bVm())}function Z(e,o){if(1&e&&(t.qex(0),t.nrm(1,"app-relation-yield",33),t.DNE(2,Q,2,0,"ng-container",0),t.bVm()),2&e){const n=o.$implicit,i=o.last,a=t.XpG(3).$implicit;t.R7$(),t.Y8G("item",n)("relationship",a),t.R7$(),t.Y8G("ngIf",!i)}}function tt(e,o){if(1&e&&(t.qex(0),t.DNE(1,Z,3,3,"ng-container",15),t.bVm()),2&e){const n=t.XpG(2).$implicit,i=t.XpG().$implicit;t.R7$(),t.Y8G("ngForOf",i[n.name])}}function nt(e,o){if(1&e&&(t.qex(0),t.DNE(1,W,1,2,"app-relation-yield",32)(2,tt,2,1,"ng-container",0),t.bVm()),2&e){const n=t.XpG().$implicit;t.R7$(),t.Y8G("ngIf","many-to-one"===n.type),t.R7$(),t.Y8G("ngIf","many-to-many"===n.type)}}function et(e,o){if(1&e&&(t.j41(0,"td"),t.DNE(1,nt,3,2,"ng-container",0),t.k0s()),2&e){const n=o.$implicit;t.R7$(),t.Y8G("ngIf","many-to-one"===n.type||"many-to-many"===n.type&&n.owningSide)}}function it(e,o){if(1&e){const n=t.RV6();t.j41(0,"tr"),t.DNE(1,H,2,7,"td",21)(2,et,2,1,"td",15),t.j41(3,"td",22)(4,"div",23)(5,"a",24),t.nrm(6,"i",25),t.k0s(),t.j41(7,"a",26),t.nrm(8,"i",27),t.k0s(),t.j41(9,"a",28),t.bIt("click",function(){const a=t.eBV(n).$implicit,r=t.XpG(3);return t.Njj(r.toggleDeleteModal(a))}),t.nrm(10,"i",29),t.k0s()()()()}if(2&e){const n=o.$implicit,i=t.XpG(3);t.R7$(),t.Y8G("ngForOf",i.properties),t.R7$(),t.Y8G("ngForOf",i.entityManifest.relationships),t.R7$(3),t.Y8G("routerLink",t.l_i(4,A,i.entityManifest.slug,n.id)),t.R7$(2),t.Y8G("routerLink",t.l_i(7,B,i.entityManifest.slug,n.id))}}function at(e,o){if(1&e&&(t.j41(0,"tbody"),t.DNE(1,it,11,10,"tr",15),t.k0s()),2&e){const n=t.XpG(2);t.R7$(),t.Y8G("ngForOf",n.paginator.data)}}function ot(e,o){if(1&e&&(t.j41(0,"tbody")(1,"tr")(2,"td"),t.EFF(3),t.k0s()()()),2&e){const n=t.XpG(2);t.R7$(2),t.BMQ("colspan",n.properties.length),t.R7$(),t.SpI(" There is no ",n.entityManifest.nameSingular,". ")}}function st(e,o){1&e&&(t.j41(0,"div",18),t.nrm(1,"div")(2,"div")(3,"div")(4,"div")(5,"div")(6,"div")(7,"div")(8,"div",34)(9,"div",34)(10,"div",34)(11,"div",34)(12,"div",34)(13,"div",34)(14,"div",34),t.k0s())}function rt(e,o){if(1&e){const n=t.RV6();t.j41(0,"app-pagination",35),t.bIt("pageChanged",function(a){t.eBV(n);const r=t.XpG(2);return t.Njj(r.filter("page",a))}),t.k0s()}if(2&e){const n=t.XpG(2);t.Y8G("paginator",n.paginator)}}function lt(e,o){if(1&e&&(t.qex(0),t.j41(1,"div",2)(2,"div",3)(3,"h1",4),t.EFF(4),t.k0s()(),t.j41(5,"div",5)(6,"a",6),t.EFF(7),t.k0s(),t.j41(8,"a",7),t.nrm(9,"i",8),t.k0s()()(),t.DNE(10,w,1,1,"app-list-meta",9)(11,K,2,0,"div",10),t.j41(12,"div",11)(13,"div",12)(14,"table",13)(15,"thead")(16,"tr"),t.DNE(17,q,2,4,"th",14)(18,z,2,1,"ng-container",15),t.nrm(19,"th"),t.k0s()(),t.DNE(20,at,2,1,"tbody",0)(21,ot,4,2,"tbody",0),t.k0s()(),t.DNE(22,st,15,0,"div",10),t.k0s(),t.DNE(23,rt,1,1,"app-pagination",16),t.bVm()),2&e){const n=t.XpG();t.R7$(4),t.SpI(" List of ",n.entityManifest.namePlural," "),t.R7$(2),t.Y8G("routerLink",t.eq3(13,v,n.entityManifest.slug)),t.R7$(),t.SpI("Create a new ",n.entityManifest.nameSingular,""),t.R7$(),t.Y8G("routerLink",t.eq3(15,v,n.entityManifest.slug)),t.R7$(2),t.Y8G("ngIf",n.paginator),t.R7$(),t.Y8G("ngIf",n.loadingPaginator),t.R7$(2),t.Y8G("ngClass",t.eq3(17,V,n.loadingPaginator)),t.R7$(4),t.Y8G("ngForOf",n.properties),t.R7$(),t.Y8G("ngForOf",n.entityManifest.relationships),t.R7$(2),t.Y8G("ngIf",null==n.paginator||null==n.paginator.data?null:n.paginator.data.length),t.R7$(),t.Y8G("ngIf",0===(null==n.paginator||null==n.paginator.data?null:n.paginator.data.length)),t.R7$(),t.Y8G("ngIf",n.loadingPaginator),t.R7$(),t.Y8G("ngIf",n.paginator)}}function ct(e,o){if(1&e){const n=t.RV6();t.j41(0,"div",36)(1,"div",37),t.bIt("click",function(){t.eBV(n);const a=t.XpG();return t.Njj(a.toggleDeleteModal())}),t.k0s(),t.j41(2,"div",38)(3,"div",39)(4,"p"),t.EFF(5," Do you really want to delete "),t.j41(6,"strong"),t.EFF(7),t.k0s(),t.EFF(8),t.k0s(),t.j41(9,"p"),t.EFF(10),t.k0s(),t.j41(11,"div",40)(12,"button",41),t.bIt("click",function(){t.eBV(n);const a=t.XpG();return t.Njj(a.toggleDeleteModal())}),t.EFF(13," Cancel "),t.k0s(),t.j41(14,"button",42),t.bIt("click",function(){t.eBV(n);const a=t.XpG();return t.Njj(a.delete(a.itemToDelete.id))}),t.EFF(15," Delete "),t.k0s()(),t.j41(16,"button",43),t.bIt("click",function(){t.eBV(n);const a=t.XpG();return t.Njj(a.toggleDeleteModal())}),t.k0s()()()()}if(2&e){const n=t.XpG();t.R7$(7),t.JRh(n.itemToDelete[n.entityManifest.mainProp]),t.R7$(),t.SpI(" ",n.entityManifest.nameSingular," ? This action cannot be undone. "),t.R7$(2),t.SpI(" If ",n.itemToDelete[n.entityManifest.mainProp]," has related items, you should delete them first. ")}}let pt=(()=>{class e{constructor(n,i,a,r,l,g,dt){this.crudService=n,this.manifestService=i,this.router=a,this.activatedRoute=r,this.metaService=l,this.flashMessageService=g,this.renderer=dt,this.paginator=null,this.PropType=m.Kk}ngOnInit(){var n=this;(0,T.z)([this.activatedRoute.queryParams,this.activatedRoute.params]).subscribe(function(){var i=(0,f.A)(function*([a,r]){delete n.paginator,n.queryParams=a,n.entityManifest=yield n.manifestService.getEntityManifest({slug:r.entitySlug}),n.entityManifest?(n.properties=n.entityManifest.properties.filter(l=>l.type!==m.Kk.Password&&l.type!==m.Kk.RichText),n.metaService.setTitle((new $.X).transform(n.entityManifest.namePlural)),n.loadingPaginator=!0,n.paginator=yield n.crudService.list(n.entityManifest.slug,{filters:n.queryParams,relations:n.entityManifest.relationships?.filter(l=>"one-to-many"!==l.type).filter(l=>"many-to-many"!==l.type||l.owningSide).map(l=>l.name)}).catch(()=>(n.loadingPaginator=!1,null)),n.loadingPaginator=!1):n.router.navigate(["/404"])});return function(a){return i.apply(this,arguments)}}())}filter(n,i){const a={[n]:i};"page"!==n&&(a.page=1),this.router.navigate(["."],{relativeTo:this.activatedRoute,queryParams:a,queryParamsHandling:"merge"})}delete(n){this.crudService.delete(this.entityManifest.slug,n).then(()=>{this.itemToDelete=null,this.renderer.removeClass(document.querySelector("html"),"is-clipped"),this.flashMessageService.success(`The ${this.entityManifest.nameSingular} has been deleted.`),this.paginator.data=this.paginator.data.filter(i=>i.id!==n)}).catch(i=>{this.flashMessageService.error(i.error.message)})}goToDetailPage(n){this.router.navigate(["/collections",this.entityManifest.slug,n])}toggleDeleteModal(n){this.itemToDelete?(this.itemToDelete=null,this.renderer.removeClass(document.querySelector("html"),"is-clipped")):(this.itemToDelete=n,this.renderer.addClass(document.querySelector("html"),"is-clipped"))}static{this.\u0275fac=function(i){return new(i||e)(t.rXU(F.m),t.rXU(h.x),t.rXU(p.Ix),t.rXU(p.nX),t.rXU(k.R),t.rXU(y.L),t.rXU(t.sFG))}}static{this.\u0275cmp=t.VBU({type:e,selectors:[["app-list"]],decls:2,vars:2,consts:[[4,"ngIf"],["class","modal is-active",4,"ngIf"],[1,"is-flex","flex-mobile","is-justify-content-space-between","is-align-items-center","mb-2"],[1,"left-part"],[1,"title","is-2","has-text-weight-light"],[1,"right-part","is-flex"],[1,"button","is-dark","ml-5","is-hidden-touch",3,"routerLink"],[1,"button","is-circle","is-link","ml-5","is-hidden-desktop",3,"routerLink"],[1,"icon","icon-plus"],[3,"paginator",4,"ngIf"],["class","is-loading",4,"ngIf"],[1,"card","p-0","mb-6","is-shadowless"],[1,"table-container",3,"ngClass"],[1,"table","is-fullwidth","is-hoverable"],[3,"ngClass",4,"ngFor","ngForOf"],[4,"ngFor","ngForOf"],[3,"paginator","pageChanged",4,"ngIf"],[3,"paginator"],[1,"is-loading"],[1,"list-meta"],[3,"ngClass"],[3,"ngClass","click",4,"ngFor","ngForOf"],[1,"has-text-right","is-nowrap"],[1,"is-flex","is-justify-content-flex-end"],[1,"button","is-light","is-small","is-circle",3,"routerLink"],[1,"icon","icon-eye"],[1,"button","is-light","is-small","is-circle","mx-2",3,"routerLink"],[1,"icon","icon-edit"],[1,"button","is-light","is-small","is-circle",3,"click"],[1,"icon","icon-trash-2"],[3,"click","ngClass"],[3,"prop","value","compact"],[3,"item","relationship",4,"ngIf"],[3,"item","relationship"],[1,"is-hidden-touch"],[3,"pageChanged","paginator"],[1,"modal","is-active"],[1,"modal-background",3,"click"],[1,"modal-card"],[1,"modal-card-body","content","is-normal"],[1,"is-flex","is-align-items-center","is-justify-content-space-between","mt-6"],[1,"button","is-white",3,"click"],[1,"button","is-danger",3,"click"],["aria-label","close",1,"modal-close","is-large",3,"click"]],template:function(i,a){1&i&&t.DNE(0,lt,24,19,"ng-container",0)(1,ct,17,3,"div",1),2&i&&(t.Y8G("ngIf",a.entityManifest),t.R7$(),t.Y8G("ngIf",a.itemToDelete&&a.entityManifest))},dependencies:[c.YU,c.Sq,c.bT,p.Wk,x.L,R.x,P,N]})}}return e})(),_=(()=>{class e{constructor(n,i,a){this.manifestService=n,this.flashMessageService=i,this.router=a}canActivate(n){var i=this;return(0,f.A)(function*(){return!(yield i.manifestService.getEntityManifest({slug:n.params.entitySlug})).single||(i.flashMessageService.error("Error: This entity is not a collection"),i.router.navigate(["/"]),!1)})()}static{this.\u0275fac=function(i){return new(i||e)(t.KVO(h.x),t.KVO(y.L),t.KVO(p.Ix))}}static{this.\u0275prov=t.jDH({token:e,factory:e.\u0275fac,providedIn:"root"})}}return e})();const gt=[{path:":entitySlug",component:pt,canActivate:[_]},{path:":entitySlug/create",component:u.O,canActivate:[_],data:{edit:!1}},{path:":entitySlug/:id",component:G.R,canActivate:[_]},{path:":entitySlug/:id/edit",component:u.O,canActivate:[_],data:{edit:!0}}];let _t=(()=>{class e{static{this.\u0275fac=function(i){return new(i||e)}}static{this.\u0275mod=t.$C({type:e})}static{this.\u0275inj=t.G2t({imports:[p.iI.forChild(gt),p.iI]})}}return e})(),mt=(()=>{class e{static{this.\u0275fac=function(i){return new(i||e)}}static{this.\u0275mod=t.$C({type:e})}static{this.\u0275inj=t.G2t({imports:[C.B,_t,c.MD]})}}return e})()}}]);