Skip to content

Commit

Permalink
enh: use NcDateTimePickerNative
Browse files Browse the repository at this point in the history
Signed-off-by: Cleopatra Enjeck M <patrathewhiz@gmail.com>
  • Loading branch information
enjeck committed Feb 11, 2024
1 parent af22340 commit e1238ee
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 24 deletions.
4 changes: 2 additions & 2 deletions cypress/e2e/column-datetime.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('Test column ' + columnTitle, () => {

// insert row with int value
cy.get('button').contains('Create row').click()
cy.get('.modal__content input').first().clear().type('2023-12-24 05:15')
cy.get('.modal__content input').first().clear().type('2023-12-24T05:15')
cy.get('[data-cy="createRowAddMoreSwitch"]').click().click()
cy.get('button').contains('Save').click()
cy.get('.custom-table table tr td div').contains('24').should('be.visible')
Expand All @@ -49,7 +49,7 @@ describe('Test column ' + columnTitle, () => {
cy.createDatetimeColumn(columnTitle, true, true)

cy.get('button').contains('Create row').click()
cy.get('.modal__content input').first().should('contain.value', '2023-12-24 07:21')
cy.get('.modal__content input').first().should('contain.value', '2023-12-24T07:21')
cy.get('[data-cy="createRowAddMoreSwitch"]').click().click()
cy.get('button').contains('Save').click()
cy.get('.custom-table table tr td div').contains('7:').should('be.visible')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
<template>
<RowFormWrapper :title="column.title" :mandatory="column.mandatory" :description="column.description" :width="2">
<NcDateTimePicker v-model="localValue"
type="date"
format="YYYY-MM-DD"
:clearable="false"
:show-week-number="true" />
<NcDateTimePickerNative id="datetime-date-picker" v-model="localValue"
type="date" />
<div v-if="canBeCleared" class="icon-close make-empty" @click="emptyValue" />
</RowFormWrapper>
</template>

<script>
import { NcDateTimePicker } from '@nextcloud/vue'
import { NcDateTimePickerNative } from '@nextcloud/vue'
import Moment from '@nextcloud/moment'
import RowFormWrapper from './RowFormWrapper.vue'
export default {
components: {
NcDateTimePicker,
NcDateTimePickerNative,
RowFormWrapper,
},
props: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
<template>
<RowFormWrapper :title="column.title" :mandatory="column.mandatory" :description="column.description" :width="2">
<NcDateTimePicker v-model="localValue"
type="datetime"
format="YYYY-MM-DD HH:mm"
:clearable="false"
:show-week-number="true" />
<NcDateTimePickerNative id="datetime-picker" v-model="localValue"
type="datetime-local"/>
<div v-if="canBeCleared" class="icon-close make-empty" @click="emptyValue" />
</RowFormWrapper>
</template>

<script>
import { NcDateTimePicker } from '@nextcloud/vue'
import { NcDateTimePickerNative } from '@nextcloud/vue'
import Moment from '@nextcloud/moment'
import RowFormWrapper from './RowFormWrapper.vue'
export default {
components: {
NcDateTimePicker,
NcDateTimePickerNative,
RowFormWrapper,
},
props: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
<template>
<RowFormWrapper :title="column.title" :mandatory="column.mandatory" :description="column.description" :width="2">
<NcDateTimePicker v-model="localValue"
type="time"
format="HH:mm"
:clearable="false"
:show-week-number="true" />
<NcDateTimePickerNative id="datetime-time-picker" v-model="localValue" :label="t('tables', 'Please select a new time')"
type="time"/>
<div v-if="canBeCleared" class="icon-close make-empty" @click="emptyValue" />
</RowFormWrapper>
</template>

<script>
import { NcDateTimePicker } from '@nextcloud/vue'
import { NcDateTimePickerNative } from '@nextcloud/vue'
import Moment from '@nextcloud/moment'
import RowFormWrapper from './RowFormWrapper.vue'
export default {
components: {
NcDateTimePicker,
NcDateTimePickerNative,
RowFormWrapper,
},
props: {
Expand All @@ -39,14 +36,15 @@ export default {
},
localValue: {
get() {
console.log(this.value)
if (this.value !== null && this.value !== 'none') {
return Moment(this.value, 'HH:mm').toDate()
} else if (this.value === null && this.column.datetimeDefault === 'now') {
const dt = Moment()
this.$emit('update:value', dt.format('HH:mm'))
return dt.toDate()
} else {
return null
return new Date()
}
},
set(v) {
Expand Down

0 comments on commit e1238ee

Please sign in to comment.