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>
|
||||
</th>
|
||||
<!-- Status -->
|
||||
<th>
|
||||
<div class="th-wrap">{{ $i18n.get('label_status') }}</div>
|
||||
</th>
|
||||
<!--<th>-->
|
||||
<!--<div class="th-wrap">{{ $i18n.get('label_status') }}</div>-->
|
||||
<!--</th>-->
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -39,31 +39,31 @@
|
|||
<p v-html="event.by" />
|
||||
</td>
|
||||
<!-- Status -->
|
||||
<td
|
||||
@click="goToEventPage(event.id)"
|
||||
class="status-cell"
|
||||
:label="$i18n.get('label_status')"
|
||||
:aria-label="$i18n.get('label_status') + ': ' + event.status">
|
||||
<p>
|
||||
<a
|
||||
v-if="event.status === 'pending'"
|
||||
id="button-approve"
|
||||
:aria-label="$i18n.get('approve_item')"
|
||||
@click.prevent.stop="approveEvent(event.id)">
|
||||
<b-icon
|
||||
icon="check" />
|
||||
</a>
|
||||
<!--<td-->
|
||||
<!--@click="goToEventPage(event.id)"-->
|
||||
<!--class="status-cell" -->
|
||||
<!--:label="$i18n.get('label_status')" -->
|
||||
<!--:aria-label="$i18n.get('label_status') + ': ' + event.status">-->
|
||||
<!--<p>-->
|
||||
<!--<a-->
|
||||
<!--v-if="event.status === 'pending'"-->
|
||||
<!--id="button-approve"-->
|
||||
<!--:aria-label="$i18n.get('approve_item')"-->
|
||||
<!--@click.prevent.stop="approveEvent(event.id)">-->
|
||||
<!--<b-icon-->
|
||||
<!--icon="check" />-->
|
||||
<!--</a>-->
|
||||
|
||||
<a
|
||||
v-if="event.status === 'pending'"
|
||||
id="button-not-approve"
|
||||
class="delete"
|
||||
:aria-label="$i18n.get('not_approve_item')"
|
||||
@click.prevent.stop="notApproveEvent(event.id)" />
|
||||
<!--<a-->
|
||||
<!--v-if="event.status === 'pending'"-->
|
||||
<!--id="button-not-approve"-->
|
||||
<!--class="delete"-->
|
||||
<!--:aria-label="$i18n.get('not_approve_item')"-->
|
||||
<!--@click.prevent.stop="notApproveEvent(event.id)" />-->
|
||||
|
||||
<small v-if="event.status !== 'pending'">{{ $i18n.get('label_approved') }}</small>
|
||||
</p>
|
||||
</td>
|
||||
<!--<small v-if="event.status !== 'pending'">{{ $i18n.get('label_approved') }}</small>-->
|
||||
<!--</p>-->
|
||||
<!--</td>-->
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
@ -157,7 +157,7 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import { mapActions } from 'vuex'
|
||||
// import { mapActions } from 'vuex'
|
||||
|
||||
export default {
|
||||
name: 'EventsList',
|
||||
|
@ -174,16 +174,16 @@
|
|||
events: Array
|
||||
},
|
||||
methods: {
|
||||
...mapActions('event', [
|
||||
'approve',
|
||||
'notApprove'
|
||||
]),
|
||||
approveEvent(eventId){
|
||||
this.approve(eventId);
|
||||
},
|
||||
notApproveEvent(eventId){
|
||||
this.notApprove(eventId);
|
||||
},
|
||||
// ...mapActions('event', [
|
||||
// 'approve',
|
||||
// 'notApprove'
|
||||
// ]),
|
||||
// approveEvent(eventId){
|
||||
// this.approve(eventId);
|
||||
// },
|
||||
// notApproveEvent(eventId){
|
||||
// this.notApprove(eventId);
|
||||
// },
|
||||
goToEventPage(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_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') {
|
||||
$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();
|
||||
}
|
||||
|
|
|
@ -139,9 +139,13 @@ class Entity {
|
|||
*/
|
||||
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>
|
||||
import { dateInter } from "../../../admin/js/mixins";
|
||||
import moment from 'moment';
|
||||
|
||||
export default {
|
||||
mixins: [ dateInter ],
|
||||
|
@ -65,10 +66,13 @@
|
|||
onInput($event) {
|
||||
let dateISO = '';
|
||||
|
||||
let localeData = moment.localeData();
|
||||
let format = localeData.longDateFormat('L');
|
||||
|
||||
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) {
|
||||
dateISO = new Date($event.target.value).toISOString().split('T')[0];
|
||||
dateISO = moment($event.target.value, format).toISOString().split('T')[0];
|
||||
}
|
||||
|
||||
this.$emit('input', dateISO);
|
||||
|
|
Loading…
Reference in New Issue