-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: refactor user image view with custom component
- Loading branch information
Showing
3 changed files
with
584 additions
and
450 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<script setup lang="ts"> | ||
import { useForm } from "vee-validate"; | ||
import { useI18n } from "vue-i18n"; | ||
import * as yup from "yup"; | ||
import VeeIftaInputText from "@/components/vee-input/VeeIftaInputText.vue"; | ||
import Button from "primevue/button"; | ||
const { t } = useI18n(); | ||
const imageRenameFormSchema = yup.object({ | ||
displayName: yup | ||
.string() | ||
.trim() | ||
.test("at-least-one-field", t("myImageView.edit.dialog.form.verify.atLeastOneField"), function () { | ||
return !!(this.parent.displayName || this.parent.description); | ||
}), | ||
description: yup | ||
.string() | ||
.trim() | ||
.test("at-least-one-field", t("myImageView.edit.dialog.form.verify.atLeastOneField"), function () { | ||
return !!(this.parent.displayName || this.parent.description); | ||
}) | ||
}); | ||
const { handleSubmit } = useForm({ | ||
validationSchema: imageRenameFormSchema | ||
}); | ||
const { imagePageVO } = defineProps(["imagePageVO"]); | ||
const emits = defineEmits(["submit", "cancel"]); | ||
const onSubmit = handleSubmit((values, ctx) => { | ||
emits("submit", values, ctx); | ||
}); | ||
const onCancel = () => { | ||
emits("cancel"); | ||
}; | ||
</script> | ||
|
||
<template> | ||
<form @submit="onSubmit" class="flex flex-col gap-4 m-4 w-96"> | ||
<div class="flex flex-col gap-2.5 w-full"> | ||
<div class="flex flex-col gap-1"> | ||
<VeeIftaInputText | ||
id="editImageDisplayName" | ||
name="displayName" | ||
:placeholder="imagePageVO.displayName" | ||
:label="t('myImageView.edit.dialog.form.displayName')" | ||
/> | ||
</div> | ||
<div class="flex flex-col gap-1"> | ||
<VeeIftaInputText | ||
id="editImageDescription" | ||
name="description" | ||
:placeholder="imagePageVO.description" | ||
:label="t('myImageView.edit.dialog.form.description')" | ||
/> | ||
</div> | ||
</div> | ||
<div class="flex justify-end gap-2"> | ||
<Button | ||
type="button" | ||
:label="t('myImageView.edit.dialog.form.cancelButton')" | ||
severity="secondary" | ||
@click="onCancel" | ||
/> | ||
<Button type="submit" :label="t('myImageView.edit.dialog.form.submitButton')" /> | ||
</div> | ||
</form> | ||
</template> | ||
|
||
<style scoped></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.