refactor(sync) : remove restrictedMode and add sync service + confirmation modal
This commit is contained in:
@@ -20,7 +20,6 @@ export type EditorProduct = {
|
||||
interface Deps {
|
||||
props: {
|
||||
modelValue?: PieceModelStructure | null
|
||||
restrictedMode?: boolean
|
||||
}
|
||||
emit: (event: 'update:modelValue', value: PieceModelStructure) => void
|
||||
}
|
||||
@@ -202,8 +201,6 @@ export function usePieceStructureEditorLogic(deps: Deps) {
|
||||
const products = ref<EditorProduct[]>(hydrateProducts(props.modelValue))
|
||||
const restState = ref<Record<string, unknown>>(extractRest(props.modelValue))
|
||||
|
||||
const initialFieldUids = ref<Set<string>>(new Set(fields.value.map(f => f.uid)))
|
||||
const initialProductUids = ref<Set<string>>(new Set(products.value.map(p => p.uid)))
|
||||
|
||||
// --- Product types ---
|
||||
|
||||
@@ -250,18 +247,6 @@ export function usePieceStructureEditorLogic(deps: Deps) {
|
||||
}
|
||||
}
|
||||
|
||||
// --- Locked state ---
|
||||
|
||||
const isFieldLocked = (field: EditorField): boolean => {
|
||||
return props.restrictedMode === true && initialFieldUids.value.has(field.uid)
|
||||
}
|
||||
|
||||
const isProductLocked = (product: EditorProduct): boolean => {
|
||||
return props.restrictedMode === true && initialProductUids.value.has(product.uid)
|
||||
}
|
||||
|
||||
const restrictedMode = computed(() => props.restrictedMode === true)
|
||||
|
||||
// --- CRUD ---
|
||||
|
||||
const createEmptyProduct = (): EditorProduct => ({
|
||||
@@ -407,8 +392,6 @@ export function usePieceStructureEditorLogic(deps: Deps) {
|
||||
products.value = hydrateProducts(value)
|
||||
products.value.forEach(product => updateProductTypeMetadata(product))
|
||||
lastEmitted = incomingSerialized
|
||||
initialFieldUids.value = new Set(fields.value.map(f => f.uid))
|
||||
initialProductUids.value = new Set(products.value.map(p => p.uid))
|
||||
},
|
||||
{ deep: true },
|
||||
)
|
||||
@@ -426,9 +409,6 @@ export function usePieceStructureEditorLogic(deps: Deps) {
|
||||
fields,
|
||||
products,
|
||||
productTypeOptions,
|
||||
restrictedMode,
|
||||
isFieldLocked,
|
||||
isProductLocked,
|
||||
formatProductTypeOption,
|
||||
handleProductTypeSelect,
|
||||
addProduct,
|
||||
|
||||
Reference in New Issue
Block a user