Skip to content

Commit

Permalink
RED-95 - mensagem para campos obrigatórios
Browse files Browse the repository at this point in the history
  • Loading branch information
sombriks committed Jul 21, 2024
1 parent f8e0602 commit af7d0e1
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion web-app-vue/src/pages/categoria/detalhe-categoria.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<v-card v-if="edit" elevation="24" min-width="300px" class="ma-2">
<v-form v-model="valid" @submit.prevent.stop="doEdit">
<v-color-picker v-model="catEdit.cor"></v-color-picker>
<v-text-field :rules="[requiredRule]" v-model="catEdit.descricao" label="Nome"></v-text-field>
<v-text-field :rules="[requiredRule('Descrição obrigatória')]" v-model="catEdit.descricao" label="Nome"></v-text-field>
<v-container>
<v-row align="center">
<v-btn
Expand Down
6 changes: 3 additions & 3 deletions web-app-vue/src/pages/configuracao/card-configuracoes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<p class="item">Veja o <a href="dados.csv">arquivo de exemplo</a></p>
<v-file-input
v-model="csvFile"
:rules="[requiredRule, lengthRule(1)]"
:rules="[requiredRule('Arquivo obrigatório'), lengthRule(1)]"
accept="text/plain, text/csv"
class="item"
label="Selecionar CSV"
Expand Down Expand Up @@ -61,7 +61,7 @@
>
<!-- account -->
<div class="item row">
<conta-autocomplete v-model="exporta.conta_id" :rules="[requiredRule]" />
<conta-autocomplete v-model="exporta.conta_id" :rules="[requiredRule('Conta obrigatória')]" />
</div>
<div class="item row">
<chip-periodo
Expand Down Expand Up @@ -111,7 +111,7 @@
>
<v-text-field
v-model="pwd"
:rules="[requiredRule]"
:rules="[requiredRule('Senha obrigatória')]"
label="Confirme sua senha"
type="password"
/>
Expand Down
2 changes: 1 addition & 1 deletion web-app-vue/src/pages/conta/detalhe-conta.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
>
</v-select>
<v-text-field
:rules="[requiredRule]"
:rules="[requiredRule('Descrição obrigatória')]"
v-model="contaEdit.descricao"
label="Descrição"
></v-text-field>
Expand Down
8 changes: 4 additions & 4 deletions web-app-vue/src/pages/movimentacao/editar-movimentacao.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<!-- valor -->
<v-text-field
class="item"
:rules="[requiredRule, numberRule]"
:rules="[requiredRule('Valor obrigatório'), numberRule]"
type="number"
v-model="movForm.valor"
label="Valor"
Expand All @@ -29,14 +29,14 @@
<categoria-autocomplete
class="item"
v-model="movForm.categoria_id"
:rules="[requiredRule]"
:rules="[requiredRule('Categoria obrigatória')]"
/>
<!-- movEdit.conta_id-->
<conta-autocomplete class="item" v-model="movForm.conta_id" :rules="[requiredRule]" />
<conta-autocomplete class="item" v-model="movForm.conta_id" :rules="[requiredRule('Conta obrigatória')]" />
<!-- movEdit.descricao-->
<v-text-field
class="item"
:rules="[requiredRule]"
:rules="[requiredRule('Descrição obrigatória')]"
v-model="movForm.descricao"
label="Descrição"
/>
Expand Down
6 changes: 3 additions & 3 deletions web-app-vue/src/pages/pagamento/pagamento-form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
class="item"
label="Categoria da transferência"
v-model="formPagamento.categoria"
:rules="[requiredRule]"
:rules="[requiredRule('Categoria obrigatória')]"
/>
<conta-autocomplete
class="item"
label="Conta de origem"
v-model="formPagamento.contaOrigem"
:rules="[requiredRule]"
:rules="[requiredRule('Conta origem obrigatória')]"
/>
<conta-autocomplete
class="item"
label="Conta de destino"
v-model="formPagamento.contaDestino"
:rules="[requiredRule]"
:rules="[requiredRule('Conta destino obrigatória')]"
/>
<chip-date class="item" label="Data pagamento" v-model="formPagamento.vencimento" />
<chip-periodo
Expand Down
8 changes: 4 additions & 4 deletions web-app-vue/src/pages/pagamento/transferencia-form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@
class="item"
label="Categoria da transferência"
v-model="formTransferencia.categoria"
:rules="[requiredRule]"
:rules="[requiredRule('Categoria obrigatória')]"
/>
<conta-autocomplete
class="item"
label="Conta de origem"
v-model="formTransferencia.contaOrigem"
:rules="[requiredRule]"
:rules="[requiredRule('Conta origem obrigatória')]"
/>
<conta-autocomplete
class="item"
label="Conta de destino"
v-model="formTransferencia.contaDestino"
:rules="[requiredRule]"
:rules="[requiredRule('Conta destino obrigatória')]"
/>
<v-text-field
class="item"
:rules="[requiredRule, numberRule]"
:rules="[requiredRule('Valor obrigatório'), numberRule]"
type="number"
v-model="formTransferencia.valor"
label="Valor"
Expand Down
4 changes: 2 additions & 2 deletions web-app-vue/src/pages/planejamento/detalhe-planejamento.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@
</v-row>
<v-row align="center">
<v-text-field
:rules="[requiredRule]"
:rules="[requiredRule('Descrição obrigatória')]"
v-model="plan.descricao"
label="Descrição"
></v-text-field>
</v-row>
<v-row align="center">
<v-text-field
class="item"
:rules="[requiredRule, numberRule]"
:rules="[requiredRule('Valor obrigatório'), numberRule]"
type="number"
v-model="plan.limite"
label="Valor"
Expand Down
6 changes: 3 additions & 3 deletions web-app-vue/src/pages/recorrencia/detalhe-recorrencia.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@
</v-radio-group>
</v-row>
<v-text-field
:rules="[requiredRule]"
:rules="[requiredRule('Descrição obrigatória')]"
v-model="rec.descricao"
label="Descrição"
></v-text-field>
<categoria-autocomplete v-model="rec.categoria_id" />
<conta-autocomplete :rules="[requiredRule]" v-model="rec.conta_id" />
<conta-autocomplete :rules="[requiredRule('Conta obrigatória')]" v-model="rec.conta_id" />
<v-select
v-model="rec.tipo_recorrencia_id"
:items="recorrenciaStore.store.tiposRecorrencia"
Expand All @@ -71,7 +71,7 @@
></chip-periodo>
<v-text-field
class="item"
:rules="[requiredRule, minValueRule(1)]"
:rules="[requiredRule('Valor obrigatório'), minValueRule(1)]"
type="number"
v-model="rec.valorParcela"
label="Valor parcela"
Expand Down
10 changes: 5 additions & 5 deletions web-app-vue/src/pages/usuario/card-login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,28 @@
<v-card :title="createMode ? 'Criar conta' : 'Login'" elevation="24">
<v-form v-model="valid" @submit.prevent.stop="doLogin" class="auth-form">
<v-text-field
:rules="[requiredRule]"
:rules="[requiredRule('Nome obrigatório')]"
v-if="createMode"
v-model="nome"
label="Nome"
required
></v-text-field>
<v-text-field
:rules="[requiredRule]"
:rules="[requiredRule('Email obrigatório')]"
v-model="email"
label="Email"
required
type="email"
></v-text-field>
<v-text-field
:rules="[requiredRule]"
:rules="[requiredRule('Senha obrigatória'), minSizeRule(6)]"
v-model="senha"
label="Senha"
required
type="password"
></v-text-field>
<v-text-field
:rules="[requiredRule]"
:rules="[requiredRule()]"
v-if="createMode"
v-model="invite"
label="Convite"
Expand Down Expand Up @@ -52,7 +52,7 @@
<script setup>
import { ref } from 'vue'
import { useUserStore } from '@/stores/userStore'
import { requiredRule } from '@/services/basic-rules'
import { minSizeRule, requiredRule } from '@/services/basic-rules'
const nome = ref('')
const email = ref('')
Expand Down
8 changes: 4 additions & 4 deletions web-app-vue/src/pages/usuario/user-details.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@
<v-card title="Editar dados pessoais" elevation="24">
<v-form v-model="valid" @submit.prevent.stop="save" class="auth-form">
<v-text-field
:rules="[requiredRule]"
:rules="[requiredRule('Nome obrigatório')]"
v-model="userUpdate.nome"
label="Nome"
required
></v-text-field>
<v-text-field
:rules="[requiredRule]"
:rules="[requiredRule('Email obrigatório')]"
v-model="userUpdate.email"
label="Email"
required
type="email"
></v-text-field>
<v-text-field
:rules="[requiredRule, minSizeRule(6)]"
:rules="[requiredRule('Senha obrigatória'), minSizeRule(6)]"
v-model="userUpdate.senha"
label="Senha"
required
type="password"
></v-text-field>
<v-text-field
:rules="[requiredRule, minSizeRule(6)]"
:rules="[requiredRule('Confirmação de senha obrigatória'), minSizeRule(6)]"
v-model="userUpdate.repetirSenha"
label=" Confirma Senha"
required
Expand Down
4 changes: 2 additions & 2 deletions web-app-vue/src/services/basic-rules.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const requiredRule = (value) => {
return !!value || 'Required field'
export const requiredRule = (message = 'Required field') => (value) => {
return !!value || message
}

export const lengthRule = (n, msg = `Minimum ${n} required`) => (value) => {
Expand Down

0 comments on commit af7d0e1

Please sign in to comment.