kf save almost good

This commit is contained in:
STEINNI
2025-10-26 20:03:19 +00:00
parent 4e1f6886f2
commit f349ff38f4
5 changed files with 58 additions and 18 deletions
+15 -4
View File
@@ -31,6 +31,9 @@ class KeyframeView extends WindozDomContent {
this.agentTypes = types
this.currentAgentType = null
//TODO from browser
this.currentKeyframe = { }
this.outputs.agentsSelector.fillOptions( this.agentTypes.map(item => {
return({ markup: `<i class="icon-${item.atp_hascode ? 'bug' : 'atom1'}"></i>${item.atp_name}`, value: item.atp_id})
}))
@@ -48,7 +51,7 @@ class KeyframeView extends WindozDomContent {
this.outputs.btnAddAgent.disabled = true
this.outputs.btnRemoveAgent.disabled = true
this.outputs.btnSaveKF.disabled = true
this.outputs.kfName.addEventListener('keyup', this.updateKfButtons.bind(this))
this.currentlySelectedAid = null
}
@@ -93,7 +96,8 @@ class KeyframeView extends WindozDomContent {
}
updateKfButtons(){
if(Object.keys(this.kfArena.agents).length > 0) this.outputs.btnSaveKF.disabled = false
if((Object.keys(this.kfArena.agents).length > 0) && (this.outputs.kfName.value.length > 5)) { this.outputs.btnSaveKF.disabled = false }
else { this.outputs.btnSaveKF.disabled = true }
}
fillAgentProperties(aid, agentProps, agentValues = {}){
@@ -140,8 +144,15 @@ class KeyframeView extends WindozDomContent {
}
async onSaveKF(evt){
console.log('SAVE:',this.kfArena.agents)
await this.models.keyframe.save(this.kfArena.agents)
if(!this.currentKeyframe.kfId){ // Create first (and get new kfId)
this.currentKeyframe.kfName = this.outputs.kfName.value
const result = await this.models.keyframes.create(this.currentKeyframe)
this.currentKeyframe.kfId = result.payload.kfId
} else if(this.currentKeyframe.kfName != this.outputs.kfName.value){ //rename
this.currentKeyframe.kfName = this.outputs.kfName.value
const result = await this.models.keyframes.rename(this.currentKeyframe)
}
await this.models.keyframes.save(this.currentKeyframe.kfId, this.kfArena.agents)
}
}