Date input supports for different locales
This commit is contained in:
parent
67afcdbd24
commit
8af272ee2c
|
@ -13,9 +13,9 @@
|
||||||
<div class="th-wrap">{{ $i18n.get('label_who_when') }}</div>
|
<div class="th-wrap">{{ $i18n.get('label_who_when') }}</div>
|
||||||
</th>
|
</th>
|
||||||
<!-- Status -->
|
<!-- Status -->
|
||||||
<th>
|
<!--<th>-->
|
||||||
<div class="th-wrap">{{ $i18n.get('label_status') }}</div>
|
<!--<div class="th-wrap">{{ $i18n.get('label_status') }}</div>-->
|
||||||
</th>
|
<!--</th>-->
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
@ -39,31 +39,31 @@
|
||||||
<p v-html="event.by" />
|
<p v-html="event.by" />
|
||||||
</td>
|
</td>
|
||||||
<!-- Status -->
|
<!-- Status -->
|
||||||
<td
|
<!--<td-->
|
||||||
@click="goToEventPage(event.id)"
|
<!--@click="goToEventPage(event.id)"-->
|
||||||
class="status-cell"
|
<!--class="status-cell" -->
|
||||||
:label="$i18n.get('label_status')"
|
<!--:label="$i18n.get('label_status')" -->
|
||||||
:aria-label="$i18n.get('label_status') + ': ' + event.status">
|
<!--:aria-label="$i18n.get('label_status') + ': ' + event.status">-->
|
||||||
<p>
|
<!--<p>-->
|
||||||
<a
|
<!--<a-->
|
||||||
v-if="event.status === 'pending'"
|
<!--v-if="event.status === 'pending'"-->
|
||||||
id="button-approve"
|
<!--id="button-approve"-->
|
||||||
:aria-label="$i18n.get('approve_item')"
|
<!--:aria-label="$i18n.get('approve_item')"-->
|
||||||
@click.prevent.stop="approveEvent(event.id)">
|
<!--@click.prevent.stop="approveEvent(event.id)">-->
|
||||||
<b-icon
|
<!--<b-icon-->
|
||||||
icon="check" />
|
<!--icon="check" />-->
|
||||||
</a>
|
<!--</a>-->
|
||||||
|
|
||||||
<a
|
<!--<a-->
|
||||||
v-if="event.status === 'pending'"
|
<!--v-if="event.status === 'pending'"-->
|
||||||
id="button-not-approve"
|
<!--id="button-not-approve"-->
|
||||||
class="delete"
|
<!--class="delete"-->
|
||||||
:aria-label="$i18n.get('not_approve_item')"
|
<!--:aria-label="$i18n.get('not_approve_item')"-->
|
||||||
@click.prevent.stop="notApproveEvent(event.id)" />
|
<!--@click.prevent.stop="notApproveEvent(event.id)" />-->
|
||||||
|
|
||||||
<small v-if="event.status !== 'pending'">{{ $i18n.get('label_approved') }}</small>
|
<!--<small v-if="event.status !== 'pending'">{{ $i18n.get('label_approved') }}</small>-->
|
||||||
</p>
|
<!--</p>-->
|
||||||
</td>
|
<!--</td>-->
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
@ -157,7 +157,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapActions } from 'vuex'
|
// import { mapActions } from 'vuex'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'EventsList',
|
name: 'EventsList',
|
||||||
|
@ -174,16 +174,16 @@
|
||||||
events: Array
|
events: Array
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions('event', [
|
// ...mapActions('event', [
|
||||||
'approve',
|
// 'approve',
|
||||||
'notApprove'
|
// 'notApprove'
|
||||||
]),
|
// ]),
|
||||||
approveEvent(eventId){
|
// approveEvent(eventId){
|
||||||
this.approve(eventId);
|
// this.approve(eventId);
|
||||||
},
|
// },
|
||||||
notApproveEvent(eventId){
|
// notApproveEvent(eventId){
|
||||||
this.notApprove(eventId);
|
// this.notApprove(eventId);
|
||||||
},
|
// },
|
||||||
goToEventPage(eventId) {
|
goToEventPage(eventId) {
|
||||||
this.$router.push(this.$routerHelper.getEventPath(eventId));
|
this.$router.push(this.$routerHelper.getEventPath(eventId));
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,11 +105,12 @@ class REST_Items_Controller extends REST_Controller {
|
||||||
$item_metadata_array = $me->_toArray();
|
$item_metadata_array = $me->_toArray();
|
||||||
|
|
||||||
$item_array['metadata'][ $slug ]['name'] = $field->get_name();
|
$item_array['metadata'][ $slug ]['name'] = $field->get_name();
|
||||||
$item_array['metadata'][ $slug ]['value'] = $item_metadata_array['value'];
|
|
||||||
$item_array['metadata'][ $slug ]['value_as_html'] = $item_metadata_array['value_as_html'];
|
|
||||||
$item_array['metadata'][ $slug ]['value_as_string'] = $item_metadata_array['value_as_string'];
|
|
||||||
if($field->get_field_type_object()->get_primitive_type() === 'date') {
|
if($field->get_field_type_object()->get_primitive_type() === 'date') {
|
||||||
$item_array['metadata'][ $slug ]['date_i18n'] = $item_metadata_array['date_i18n'];
|
$item_array['metadata'][ $slug ]['date_i18n'] = $item_metadata_array['date_i18n'];
|
||||||
|
} else {
|
||||||
|
$item_array['metadata'][ $slug ]['value'] = $item_metadata_array['value'];
|
||||||
|
$item_array['metadata'][ $slug ]['value_as_html'] = $item_metadata_array['value_as_html'];
|
||||||
|
$item_array['metadata'][ $slug ]['value_as_string'] = $item_metadata_array['value_as_string'];
|
||||||
}
|
}
|
||||||
$item_array['metadata'][ $slug ]['multiple'] = $field->get_multiple();
|
$item_array['metadata'][ $slug ]['multiple'] = $field->get_multiple();
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,9 +139,13 @@ class Entity {
|
||||||
*/
|
*/
|
||||||
public function get_date_i18n($date){
|
public function get_date_i18n($date){
|
||||||
|
|
||||||
$unix_time_stamp = strtotime($date);
|
if($date) {
|
||||||
|
$unix_time_stamp = strtotime( $date );
|
||||||
|
|
||||||
return date_i18n(get_option('date_format'), $unix_time_stamp);
|
return date_i18n( get_option( 'date_format' ), $unix_time_stamp );
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { dateInter } from "../../../admin/js/mixins";
|
import { dateInter } from "../../../admin/js/mixins";
|
||||||
|
import moment from 'moment';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
mixins: [ dateInter ],
|
mixins: [ dateInter ],
|
||||||
|
@ -65,10 +66,13 @@
|
||||||
onInput($event) {
|
onInput($event) {
|
||||||
let dateISO = '';
|
let dateISO = '';
|
||||||
|
|
||||||
|
let localeData = moment.localeData();
|
||||||
|
let format = localeData.longDateFormat('L');
|
||||||
|
|
||||||
if($event && $event instanceof Date) {
|
if($event && $event instanceof Date) {
|
||||||
dateISO = this.dateValue.toISOString().split('T')[0]
|
dateISO = moment(this.dateValue, format).toISOString().split('T')[0];
|
||||||
} else if($event.target.value && $event.target.value.length === this.dateMask.length) {
|
} else if($event.target.value && $event.target.value.length === this.dateMask.length) {
|
||||||
dateISO = new Date($event.target.value).toISOString().split('T')[0];
|
dateISO = moment($event.target.value, format).toISOString().split('T')[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$emit('input', dateISO);
|
this.$emit('input', dateISO);
|
||||||
|
|
Loading…
Reference in New Issue