Skip to content

Commit

Permalink
Usa Datepicker no combo box
Browse files Browse the repository at this point in the history
  • Loading branch information
lubien committed Jun 27, 2019
1 parent ffff35e commit 494399d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 47 deletions.
6 changes: 6 additions & 0 deletions components/datepicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
:day-names="['D', 'S', 'T', 'Q', 'Q', 'S', 'S']"
:first-day-of-week="0"
:disabled="disabled"
:max-date="maxDate"
@input="onInput"
/>
</template>
Expand All @@ -33,6 +34,11 @@ export default {
default: '01/01/1970'
},
maxDate: {
type: Date,
required: false
},
disabled: {
type: Boolean,
default: false
Expand Down
54 changes: 7 additions & 47 deletions components/studentComboBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,13 @@
<strong>{{ defenseDateStatus }}</strong
><br />
<b-field>
<b-datepicker
v-model="defenseDate"
<Datepicker
v-model="studentData.defenseDate"
:max-date="
defenseDateStatus === 'Defendeu em' ? new Date() : undefined
"
:date-formatter="dateFormatter"
:disabled="!canEdit"
:month-names="[
'Janeiro',
'Fevereiro',
'Março',
'Abril',
'Maio',
'Junho',
'Julho',
'Agosto',
'Setembro',
'Outubro',
'Novembro',
'Dezembro'
]"
:day-names="['D', 'S', 'T', 'Q', 'Q', 'S', 'S']"
:first-day-of-week="0"
></b-datepicker>
/>
</b-field>
<strong>E-mail</strong>:
<b-input v-model="studentData.email" :disabled="!canEdit"></b-input>
Expand Down Expand Up @@ -198,6 +181,7 @@

<script>
import DocumentRow from '@/components/studentComboBox/documentRow'
import Datepicker from '@/components/datepicker'
import { errorsHandler } from './mixins/errors'
import { studentStatus } from './mixins/studentStatus'
Expand All @@ -206,7 +190,7 @@ const { ATA, LAUDA, LISTA_PRESCRICAO } = documents
export default {
name: 'StudentComboBox',
components: { DocumentRow },
components: { DocumentRow, Datepicker },
mixins: [errorsHandler, studentStatus],
documents,
props: {
Expand All @@ -230,8 +214,7 @@ export default {
totalSubjects: [],
studentSubjects: [],
studentData: Object.assign({}, this.student),
isLoading: false,
defenseDate: new Date()
isLoading: false
}
},
computed: {
Expand Down Expand Up @@ -262,17 +245,6 @@ export default {
created() {
this.getStudentsDocument()
this.defenseDate = this.studentData.defenseDate
? new Date(
Date.parse(
this.studentData.defenseDate
.split('/')
.reverse()
.join('/')
)
)
: null
const endpoint = `/api/students/${this.student.id}/pendencies`
this.$axios
.get(endpoint)
Expand All @@ -298,26 +270,14 @@ export default {
putStudents() {
this.isLoading = true
const defenseDate =
this.defenseDate && this.dateFormatter(this.defenseDate)
const endpoint = `/api/students/${this.studentData.id}`
const payload = { ...this.studentData, defenseDate }
const payload = this.studentData
this.$axios
.$put(endpoint, payload)
.then(data => {
this.isLoading = false
this.studentData = data
this.defenseDate = this.studentData.defenseDate
? new Date(
Date.parse(
this.studentData.defenseDate
.split('/')
.reverse()
.join('/')
)
)
: null
this.canEdit = false
this.$toast.open({
message: 'Aluno atualizado com sucesso.',
Expand Down

0 comments on commit 494399d

Please sign in to comment.