refactor: compile data in handles

Introduce a handle for requests.
This commit is contained in:
jamesgeorge007
2024-02-07 11:36:33 +05:30
parent ab7df212c2
commit 89bcc58de6
10 changed files with 1616 additions and 666 deletions

View File

@@ -75,7 +75,7 @@ import {
import { useVModel } from "@vueuse/core"
import { useService } from "dioc/vue"
import { clone } from "lodash-es"
import { ref, watch } from "vue"
import { ref, toRefs, watch } from "vue"
import { HoppInheritedProperty } from "~/helpers/types/HoppInheritedProperties"
import { PersistenceService } from "~/services/persistence"
@@ -100,11 +100,15 @@ const props = withDefaults(
editingProperties: EditingProperties | null
source: "REST" | "GraphQL"
modelValue: string
// TODO: Purpose of this prop is to maintain backwards compatibility
// To be removed after porting all usages of this component
emitWithFullCollection: boolean
}>(),
{
show: false,
loadingState: false,
editingProperties: null,
emitWithFullCollection: true,
}
)
@@ -178,15 +182,24 @@ watch(
const saveEditedCollection = () => {
if (!props.editingProperties) return
const finalCollection = clone(editableCollection.value)
delete finalCollection.body
const { path } = toRefs(props.editingProperties)
const collection = {
path: props.editingProperties.path,
path: path.value,
collection: {
...props.editingProperties.collection,
...finalCollection,
},
isRootCollection: props.editingProperties.isRootCollection,
}
emit("set-collection-properties", collection as EditingProperties)
const data = props.emitWithFullCollection
? collection
: { ...finalCollection, collIndexPath: path.value }
emit("set-collection-properties", data as EditingProperties)
persistenceService.removeLocalConfig("unsaved_collection_properties")
}