1
0
mirror of https://github.com/lana-k/sqliteviz.git synced 2025-12-07 02:28:54 +08:00

duplicate feature

This commit is contained in:
lana-k
2020-10-13 20:05:18 +02:00
parent 805f2861aa
commit f25a4d5c07

View File

@@ -37,7 +37,7 @@
<div class="date-container">{{ query.createdAt | date }}</div>
<div class="icons-container">
<rename-icon @click="showRenameDialog(index)" />
<copy-icon />
<copy-icon @click="duplicateQuery(index)"/>
<export-icon />
<delete-icon />
</div>
@@ -151,6 +151,14 @@ export default {
this.$store.commit('updateTabName', { index: tabIndex, newName: this.newName })
}
},
duplicateQuery (index) {
const newQuery = JSON.parse(JSON.stringify(this.queries[index]))
newQuery.name = newQuery.name + ' Copy'
newQuery.id = Number(new Date())
newQuery.createdAt = new Date()
this.queries.push(newQuery)
this.saveQueriesInLocalStorage()
},
saveQueriesInLocalStorage () {
localStorage.setItem('myQueries', JSON.stringify(this.queries))
}