adaptorex
Version:
Connect all your live interactive storytelling devices and software
2 lines (1 loc) • 4.74 kB
JavaScript
import{u as L,z as N,c as m,r as _,s as A,T as B,d as h,g as f,o as r,e,i as F,f as y,F as T,h as I,t as n,k as E,q as S,ao as j,l as c,m as d,_ as k}from"./index-BpVbOCok.js";const q={key:0,class:"has-background-purple-5 p-5 is-scroll-container"},z={class:"is-flex is-justify-content-space-between is-align-items-center mb-4"},U=e("p",{class:"title is-4 is-uppercase"},"Level Versions",-1),W={key:0,class:"table-container"},G={class:"table has-background-transparent is-bordered is-hoverable is-fullwidth"},H=e("thead",null,[e("tr",null,[e("th",null,"Revision ID"),e("th",null,"Name"),e("th",null,"Description"),e("th",null,"Created By"),e("th",null,"Created At"),e("th",null,"Actions")])],-1),J={class:"is-family-monospace"},K={class:"has-text-weight-semibold"},O={class:"content is-small"},P={class:"content is-small"},Q={class:"content is-small"},X={class:"is-flex"},Y=["onClick"],Z=["onClick"],ee={key:1,class:"has-text-centered py-6"},se=e("p",{class:"title is-5 has-text-grey"},"No revisions found",-1),te=e("p",{class:"subtitle is-6 has-text-grey-light"},"Create your first revision to get started",-1),ie=[se,te],oe=e("p",{class:"has-text-danger"},"This action cannot be undone.",-1),le={class:"content"},ne=e("p",{class:"has-text-warning-dark"},[e("strong",null," If other users are working on the level, their most recent changes may be overwritten by restoring the level. ")],-1),ae=e("p",null,"Are you sure you want to proceed?",-1),ue={__name:"LevelRevision",setup(re){const v=L(),R=N(),a=m(()=>v.state.level.selected),p=m(()=>v.state.level.revisions),u=m(()=>v.state.game.selected),C=m(()=>[...p.value].sort((t,s)=>s.revision.id-t.revision.id)),b=_({visible:!1}),l=_({visible:!1,revision:null}),o=_({visible:!1,revision:null});async function g(){if(u.value&&a.value)try{await v.dispatch("level/getLevelRevisions",{game:u.value,level:a.value})}catch(t){console.error("Failed to load revisions:",t)}}A(()=>{g()}),B([u,a],()=>{g()},{immediate:!0});function w(t){l.value.revision=t,l.value.visible=!0}function x(){const t=l.value.revision;v.dispatch("level/deleteLevelRevision",{game:u.value,level:a.value,revisionId:t.revision.id}).then(()=>{l.value.visible=!1,l.value.revision=null}).catch(s=>{console.error("Failed to delete revision:",s)})}function $(t){o.value.revision=t,o.value.visible=!0}function D(t){v.dispatch("level/restoreLevelRevision",{game:u.value,level:a.value,revisionId:t.revision.id}).then(()=>{R.push({name:"Editor",params:{game:u.value,level:a.value}})}).catch(s=>{console.error("Failed to restore revision:",s)})}function M(){const t=o.value.revision;o.value.visible=!1,o.value.revision=null,D(t)}return(t,s)=>a.value?(r(),h("div",q,[e("div",z,[U,e("button",{class:"button is-link",onClick:s[0]||(s[0]=i=>b.value.visible=!0)},"Mark as Version")]),p.value.length>0?(r(),h("div",W,[e("table",G,[H,e("tbody",null,[(r(!0),h(T,null,I(C.value,i=>(r(),h("tr",{key:i.revision.id},[e("td",J,n(i.revision.id),1),e("td",K,n(i.revision.name||"Unnamed"),1),e("td",O,n(i.revision.description||"-"),1),e("td",P,n(i.revision.created_by),1),e("td",Q,n(E(S)(i.revision.created_at)),1),e("td",null,[e("div",X,[e("button",{class:"button is-small is-success mr-2",title:"Restore this revision",onClick:V=>$(i)}," Restore ",8,Y),e("button",{class:"button is-small is-danger",title:"Delete this revision",onClick:V=>w(i)}," Delete ",8,Z)])])]))),128))])])])):(r(),h("div",ee,ie)),F(j,{visible:b.value.visible,onClose:s[1]||(s[1]=i=>b.value.visible=!1)},null,8,["visible"]),l.value.visible?(r(),y(k,{key:2,modal:l.value,"css-classes":["is-danger"],onCloseModal:s[3]||(s[3]=i=>l.value.visible=!1)},{header:c(()=>[d("Delete Revision")]),footer:c(()=>[e("button",{class:"button is-danger m-1",onClick:x},"Delete"),e("button",{class:"button m-1",onClick:s[2]||(s[2]=i=>l.value.visible=!1)},"Cancel")]),default:c(()=>[e("p",null,[d(" Are you sure you want to delete revision "),e("b",null,n(l.value.revision?.revision.name||l.value.revision?.revision.id),1),d(" ? ")]),oe]),_:1},8,["modal"])):f("",!0),o.value.visible?(r(),y(k,{key:3,modal:o.value,"css-classes":["is-warning"],onCloseModal:s[5]||(s[5]=i=>o.value.visible=!1)},{header:c(()=>[d(" Warning: Restore Version "+n(o.value.revision?.revision.name||o.value.revision?.revision.id),1)]),footer:c(()=>[e("button",{class:"button is-warning m-1",onClick:M},"Restore Anyway"),e("button",{class:"button m-1",onClick:s[4]||(s[4]=i=>o.value.visible=!1)},"Cancel")]),default:c(()=>[e("div",le,[e("p",null,[d(" The version "),e("strong",null,n(o.value.revision?.revision.name||o.value.revision?.revision.id),1),d(" will be restored. The current state of the level will be saved in a version before the restore. ")]),ne,ae])]),_:1},8,["modal"])):f("",!0)])):f("",!0)}};export{ue as default};