Skip to content

Commit

Permalink
refactor(components): improve form title generation in Form using com…
Browse files Browse the repository at this point in the history
…puted values
  • Loading branch information
mthsps committed Aug 20, 2024
1 parent 95a9924 commit c1ccd1c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions components/Form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -158,16 +158,20 @@ onBeforeUnmount(() => {
const urlList = ROUTES.list + labelSlug.value;
const urlCreate = ROUTES.create + labelSlug.value;
const isCreate = !props.formStore.getId();
const isAuxiliary = props.formStore.getIsAuxiliary();
const isCreate = computed(() => {
return !props.formStore.getId();
});
const isAuxiliary = computed(() => {
return props.formStore.getIsAuxiliary();
});
const isAdd = computed(() => {
return isAuxiliary && isCreate;
return isAuxiliary.value && isCreate.value;
});
const formTitle = computed(() => {
return (
(isAdd.value ? 'Adicionar' : isCreate ? 'Criar' : 'Editar') +
(isAdd.value ? 'Adicionar' : isCreate.value ? 'Criar' : 'Editar') +
' ' +
uncapitalize(label.value)
);
Expand All @@ -180,7 +184,7 @@ const buttonLabel = computed(() => {
async function submit() {
const id = await props.formStore.save();
if (id && !isAuxiliary) {
if (id && !isAuxiliary.value) {
confirmSave();
if (import.meta.client) {
Expand Down

0 comments on commit c1ccd1c

Please sign in to comment.