mirror of
https://github.com/web3privacy/explorer-app.git
synced 2024-10-15 16:46:26 +02:00
fix: form init
This commit is contained in:
parent
5e37314daf
commit
1bcf0903ab
4 changed files with 10 additions and 4 deletions
|
@ -8,7 +8,6 @@ export const useProject = defineStore('project', () => {
|
||||||
const { getProjectById } = useData()
|
const { getProjectById } = useData()
|
||||||
|
|
||||||
function setProject(id: string) {
|
function setProject(id: string) {
|
||||||
clearProject()
|
|
||||||
project.value = getProjectById(id, { shallow: false }) as Project
|
project.value = getProjectById(id, { shallow: false }) as Project
|
||||||
delete project.value.ratings
|
delete project.value.ratings
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,6 @@ export const useProjectForm = defineStore('useProjectForm', () => {
|
||||||
|
|
||||||
const isEditingName = ref(false)
|
const isEditingName = ref(false)
|
||||||
const { value: name, errorMessage: nameError } = useField<string>('name', yup.string().required().notOneOf(['Untitled', 'Undefined', 'Create', 'create']))
|
const { value: name, errorMessage: nameError } = useField<string>('name', yup.string().required().notOneOf(['Untitled', 'Undefined', 'Create', 'create']))
|
||||||
name.value = project.value?.name || 'Untitled'
|
|
||||||
|
|
||||||
function toggleEditName() {
|
function toggleEditName() {
|
||||||
isEditingName.value = !isEditingName.value
|
isEditingName.value = !isEditingName.value
|
||||||
|
@ -87,6 +86,11 @@ export const useProjectForm = defineStore('useProjectForm', () => {
|
||||||
navigateTo(`/project/${project.value?.id || project.value?.name?.toLowerCase().replace(/\s+/g, '-')}`)
|
navigateTo(`/project/${project.value?.id || project.value?.name?.toLowerCase().replace(/\s+/g, '-')}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function initForm() {
|
||||||
|
selectedTab.value = 0
|
||||||
|
name.value = 'Untitled'
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
isEditingName,
|
isEditingName,
|
||||||
name,
|
name,
|
||||||
|
@ -100,5 +104,6 @@ export const useProjectForm = defineStore('useProjectForm', () => {
|
||||||
publish,
|
publish,
|
||||||
jumpTo,
|
jumpTo,
|
||||||
isPublishing,
|
isPublishing,
|
||||||
|
initForm,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -6,9 +6,11 @@ definePageMeta({
|
||||||
const { projects } = useData()
|
const { projects } = useData()
|
||||||
const { setProject, saveProjectImage } = useProject()
|
const { setProject, saveProjectImage } = useProject()
|
||||||
const { project } = storeToRefs(useProject())
|
const { project } = storeToRefs(useProject())
|
||||||
|
const { initForm } = useProjectForm()
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
await until(projects).toMatch(p => p?.length > 0)
|
await until(projects).toMatch(p => p?.length > 0)
|
||||||
|
initForm()
|
||||||
setProject(route.params.id as string)
|
setProject(route.params.id as string)
|
||||||
|
|
||||||
if (!project.value) {
|
if (!project.value) {
|
||||||
|
|
|
@ -24,7 +24,7 @@ onChange((files) => {
|
||||||
saveProjectImage(file)
|
saveProjectImage(file)
|
||||||
})
|
})
|
||||||
|
|
||||||
const { next, jumpTo, publish, toggleEditName } = useProjectForm()
|
const { next, jumpTo, publish, toggleEditName, initForm } = useProjectForm()
|
||||||
const { currentComponent, selectedTab, tabsArray, isEditingName, name, nameError, isPublishing } = storeToRefs(useProjectForm())
|
const { currentComponent, selectedTab, tabsArray, isEditingName, name, nameError, isPublishing } = storeToRefs(useProjectForm())
|
||||||
|
|
||||||
const projectNameInput = ref<HTMLInputElement | null>(null)
|
const projectNameInput = ref<HTMLInputElement | null>(null)
|
||||||
|
@ -40,7 +40,7 @@ const transitionDone = ref(false)
|
||||||
|
|
||||||
onBeforeMount(() => {
|
onBeforeMount(() => {
|
||||||
clearProject()
|
clearProject()
|
||||||
name.value = 'Untitled'
|
initForm()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue