fix: drag and drop on collections
This commit is contained in:
@@ -67,24 +67,6 @@
|
|||||||
</div>
|
</div>
|
||||||
<div slot="body" class="flex flex-col">
|
<div slot="body" class="flex flex-col">
|
||||||
<div v-if="mode == 'import_export'" class="flex flex-col items-start p-2">
|
<div v-if="mode == 'import_export'" class="flex flex-col items-start p-2">
|
||||||
<span
|
|
||||||
v-tooltip="{
|
|
||||||
content: !fb.currentUser
|
|
||||||
? $t('login_first')
|
|
||||||
: $t('replace_current'),
|
|
||||||
}"
|
|
||||||
>
|
|
||||||
<!-- TODO: wtf -->
|
|
||||||
<button
|
|
||||||
v-if="collectionsType.type == 'my-collections'"
|
|
||||||
:disabled="!fb.currentUser"
|
|
||||||
class="icon"
|
|
||||||
@click="syncCollections"
|
|
||||||
>
|
|
||||||
<i class="material-icons">folder_shared</i>
|
|
||||||
<span>{{ $t("import_from_sync") }}</span>
|
|
||||||
</button>
|
|
||||||
</span>
|
|
||||||
<button
|
<button
|
||||||
v-tooltip="$t('replace_current')"
|
v-tooltip="$t('replace_current')"
|
||||||
class="icon"
|
class="icon"
|
||||||
@@ -214,6 +196,7 @@ export default {
|
|||||||
mode: "import_export",
|
mode: "import_export",
|
||||||
mySelectedCollectionID: undefined,
|
mySelectedCollectionID: undefined,
|
||||||
collectionJson: "",
|
collectionJson: "",
|
||||||
|
fb
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
subscriptions() {
|
subscriptions() {
|
||||||
@@ -267,7 +250,6 @@ export default {
|
|||||||
const collections = JSON.parse(Object.values(files)[0].content)
|
const collections = JSON.parse(Object.values(files)[0].content)
|
||||||
setRESTCollections(collections)
|
setRESTCollections(collections)
|
||||||
this.fileImported()
|
this.fileImported()
|
||||||
this.syncToFBCollections()
|
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.failedImport()
|
this.failedImport()
|
||||||
@@ -328,7 +310,6 @@ export default {
|
|||||||
} else {
|
} else {
|
||||||
setRESTCollections(collections)
|
setRESTCollections(collections)
|
||||||
this.fileImported()
|
this.fileImported()
|
||||||
this.syncToFBCollections()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
reader.readAsText(this.$refs.inputChooseFileToReplaceWith.files[0])
|
reader.readAsText(this.$refs.inputChooseFileToReplaceWith.files[0])
|
||||||
@@ -382,7 +363,6 @@ export default {
|
|||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
appendRESTCollections(collections)
|
appendRESTCollections(collections)
|
||||||
this.syncToFBCollections()
|
|
||||||
this.fileImported()
|
this.fileImported()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -411,7 +391,7 @@ export default {
|
|||||||
},
|
},
|
||||||
async getJSONCollection() {
|
async getJSONCollection() {
|
||||||
if (this.collectionsType.type === "my-collections") {
|
if (this.collectionsType.type === "my-collections") {
|
||||||
this.collectionJson = JSON.stringify(myCollections, null, 2)
|
this.collectionJson = JSON.stringify(this.myCollections, null, 2)
|
||||||
} else {
|
} else {
|
||||||
this.collectionJson = await teamUtils.exportAsJSON(
|
this.collectionJson = await teamUtils.exportAsJSON(
|
||||||
this.$apollo,
|
this.$apollo,
|
||||||
|
|||||||
@@ -163,8 +163,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { fb } from "~/helpers/fb"
|
import { moveRESTRequest } from "~/newstore/collections"
|
||||||
import { getSettingSubject } from "~/newstore/settings"
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
@@ -188,11 +187,6 @@ export default {
|
|||||||
pageNo: 0,
|
pageNo: 0,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
subscriptions() {
|
|
||||||
return {
|
|
||||||
SYNC_COLLECTIONS: getSettingSubject("syncCollections"),
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
computed: {
|
||||||
isSelected() {
|
isSelected() {
|
||||||
return (
|
return (
|
||||||
@@ -206,14 +200,6 @@ export default {
|
|||||||
editRequest(event) {
|
editRequest(event) {
|
||||||
this.$emit("edit-request", event)
|
this.$emit("edit-request", event)
|
||||||
},
|
},
|
||||||
syncCollections() {
|
|
||||||
if (fb.currentUser !== null && this.SYNC_COLLECTIONS) {
|
|
||||||
fb.writeCollections(
|
|
||||||
JSON.parse(JSON.stringify(this.$store.state.postwoman.collections)),
|
|
||||||
"collections"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
toggleShowChildren() {
|
toggleShowChildren() {
|
||||||
if (this.$props.saveRequest)
|
if (this.$props.saveRequest)
|
||||||
this.$emit("select", {
|
this.$emit("select", {
|
||||||
@@ -236,22 +222,9 @@ export default {
|
|||||||
},
|
},
|
||||||
dropEvent({ dataTransfer }) {
|
dropEvent({ dataTransfer }) {
|
||||||
this.dragging = !this.dragging
|
this.dragging = !this.dragging
|
||||||
const oldCollectionIndex = dataTransfer.getData("oldCollectionIndex")
|
const folderPath = dataTransfer.getData("folderPath")
|
||||||
const oldFolderIndex = dataTransfer.getData("oldFolderIndex")
|
|
||||||
const oldFolderName = dataTransfer.getData("oldFolderName")
|
|
||||||
const requestIndex = dataTransfer.getData("requestIndex")
|
const requestIndex = dataTransfer.getData("requestIndex")
|
||||||
const flag = "rest"
|
moveRESTRequest(folderPath, requestIndex, this.collectionIndex.toString())
|
||||||
this.$store.commit("postwoman/moveRequest", {
|
|
||||||
oldCollectionIndex,
|
|
||||||
newCollectionIndex: this.$props.collectionIndex,
|
|
||||||
newFolderIndex: -1,
|
|
||||||
newFolderName: this.$props.collection.name,
|
|
||||||
oldFolderIndex,
|
|
||||||
oldFolderName,
|
|
||||||
requestIndex,
|
|
||||||
flag,
|
|
||||||
})
|
|
||||||
this.syncCollections()
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,8 +104,8 @@
|
|||||||
:collection-index="collectionIndex"
|
:collection-index="collectionIndex"
|
||||||
:folder-index="folderIndex"
|
:folder-index="folderIndex"
|
||||||
:folder-name="folder.name"
|
:folder-name="folder.name"
|
||||||
:request-index="index"
|
|
||||||
:folder-path="folderPath"
|
:folder-path="folderPath"
|
||||||
|
:request-index="index"
|
||||||
:doc="doc"
|
:doc="doc"
|
||||||
:picked="picked"
|
:picked="picked"
|
||||||
:save-request="saveRequest"
|
:save-request="saveRequest"
|
||||||
@@ -142,8 +142,11 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { getSettingSubject } from "~/newstore/settings"
|
import {
|
||||||
import { removeRESTFolder, removeRESTRequest } from "~/newstore/collections"
|
removeRESTFolder,
|
||||||
|
removeRESTRequest,
|
||||||
|
moveRESTRequest,
|
||||||
|
} from "~/newstore/collections"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "Folder",
|
name: "Folder",
|
||||||
@@ -167,11 +170,6 @@ export default {
|
|||||||
cursor: "",
|
cursor: "",
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
subscriptions() {
|
|
||||||
return {
|
|
||||||
SYNC_COLLECTIONS: getSettingSubject("syncCollections"),
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
computed: {
|
||||||
isSelected() {
|
isSelected() {
|
||||||
return (
|
return (
|
||||||
@@ -203,25 +201,9 @@ export default {
|
|||||||
},
|
},
|
||||||
dropEvent({ dataTransfer }) {
|
dropEvent({ dataTransfer }) {
|
||||||
this.dragging = !this.dragging
|
this.dragging = !this.dragging
|
||||||
const oldCollectionIndex = dataTransfer.getData("oldCollectionIndex")
|
const folderPath = dataTransfer.getData("folderPath")
|
||||||
const oldFolderIndex = dataTransfer.getData("oldFolderIndex")
|
|
||||||
const oldFolderName = dataTransfer.getData("oldFolderName")
|
|
||||||
const requestIndex = dataTransfer.getData("requestIndex")
|
const requestIndex = dataTransfer.getData("requestIndex")
|
||||||
const flag = "rest"
|
moveRESTRequest(folderPath, requestIndex, this.folderPath)
|
||||||
|
|
||||||
// TODO: Implement for the new collection state system
|
|
||||||
|
|
||||||
this.$store.commit("postwoman/moveRequest", {
|
|
||||||
oldCollectionIndex,
|
|
||||||
newCollectionIndex: this.$props.collectionIndex,
|
|
||||||
newFolderIndex: this.$props.folderIndex,
|
|
||||||
newFolderName: this.$props.folder.name,
|
|
||||||
oldFolderIndex,
|
|
||||||
oldFolderName,
|
|
||||||
requestIndex,
|
|
||||||
flag,
|
|
||||||
})
|
|
||||||
this.syncCollections()
|
|
||||||
},
|
},
|
||||||
removeRequest({ requestIndex }) {
|
removeRequest({ requestIndex }) {
|
||||||
removeRESTRequest(this.folderPath, requestIndex)
|
removeRESTRequest(this.folderPath, requestIndex)
|
||||||
|
|||||||
@@ -124,10 +124,8 @@ export default {
|
|||||||
},
|
},
|
||||||
dragStart({ dataTransfer }) {
|
dragStart({ dataTransfer }) {
|
||||||
this.dragging = !this.dragging
|
this.dragging = !this.dragging
|
||||||
dataTransfer.setData("oldCollectionIndex", this.$props.collectionIndex)
|
dataTransfer.setData("folderPath", this.folderPath)
|
||||||
dataTransfer.setData("oldFolderIndex", this.$props.folderIndex)
|
dataTransfer.setData("requestIndex", this.requestIndex)
|
||||||
dataTransfer.setData("oldFolderName", this.$props.folderName)
|
|
||||||
dataTransfer.setData("requestIndex", this.$props.requestIndex)
|
|
||||||
},
|
},
|
||||||
removeRequest() {
|
removeRequest() {
|
||||||
this.$emit("remove-request", {
|
this.$emit("remove-request", {
|
||||||
|
|||||||
Reference in New Issue
Block a user