On save, update page editor route

main
Garrett Mills 2 years ago
parent 399407b15a
commit 241486fc4f

@ -103,6 +103,7 @@ const openEditFunctionModal = () => {
editFunctionModalOpen.value = true editFunctionModalOpen.value = true
} }
const chartBoxKey = ref(uuidv4())
const updateStatements = () => { const updateStatements = () => {
statements.value = math.value.getStatements(); statements.value = math.value.getStatements();
try { try {
@ -153,18 +154,21 @@ const saveNewVariable = (stmt: MathStatement) => {
math.value.addStatement(stmt) math.value.addStatement(stmt)
newVariableModalOpen.value = false newVariableModalOpen.value = false
updateStatements() updateStatements()
chartBoxKey.value = uuidv4()
}; };
const saveNewExpression = (stmt: MathStatement) => { const saveNewExpression = (stmt: MathStatement) => {
math.value.addStatement(stmt) math.value.addStatement(stmt)
newExpressionModalOpen.value = false newExpressionModalOpen.value = false
updateStatements() updateStatements()
chartBoxKey.value = uuidv4()
}; };
const saveNewFunction = (stmt: MathStatement) => { const saveNewFunction = (stmt: MathStatement) => {
math.value.addStatement(stmt) math.value.addStatement(stmt)
newFunctionModalOpen.value = false newFunctionModalOpen.value = false
updateStatements() updateStatements()
chartBoxKey.value = uuidv4()
} }
const editStatement = (stmt: MathStatement) => { const editStatement = (stmt: MathStatement) => {
@ -182,6 +186,7 @@ const editStatement = (stmt: MathStatement) => {
const removeStatement = (stmt: MathStatement) => { const removeStatement = (stmt: MathStatement) => {
math.value.removeStatement(stmt.id) math.value.removeStatement(stmt.id)
updateStatements() updateStatements()
chartBoxKey.value = uuidv4()
} }
const finishEditStatement = () => { const finishEditStatement = () => {
@ -189,6 +194,7 @@ const finishEditStatement = () => {
editVarDeclModalOpen.value = false editVarDeclModalOpen.value = false
editFunctionModalOpen.value = false editFunctionModalOpen.value = false
updateStatements() updateStatements()
chartBoxKey.value = uuidv4()
} }
/* /*
@ -202,7 +208,6 @@ const makeNewRichTextBox = () => {
richEditModal.value = true; richEditModal.value = true;
}; };
const chartBoxKey = ref(uuidv4())
const chartBoxes = ref<ChartBox[]>([]) const chartBoxes = ref<ChartBox[]>([])
const newChartModalOpen = ref(false) const newChartModalOpen = ref(false)
@ -213,6 +218,7 @@ const openNewChartModal = () => {
const saveNewChartBox = (chartBox: ChartBox) => { const saveNewChartBox = (chartBox: ChartBox) => {
chartBoxes.value.push(chartBox) chartBoxes.value.push(chartBox)
newChartModalOpen.value = false newChartModalOpen.value = false
chartBoxKey.value = uuidv4()
} }
const editingChartBox = ref<ChartBox | undefined>() const editingChartBox = ref<ChartBox | undefined>()
@ -362,9 +368,12 @@ const saveEditorPage = async (close = false) => {
return alert('Failed to save page: ' + result.message) return alert('Failed to save page: ' + result.message)
} }
const justCreated = !editorPageId.value
editorPageId.value = result.data.pageId editorPageId.value = result.data.pageId
if ( close ) { if ( close ) {
await router.push('/Listings') await router.push('/Listings')
} else if ( justCreated ) {
await router.push(`/Editor/${editorPageId.value}`)
} }
} }

Loading…
Cancel
Save