Hide some fields and fix datetime issue

Closes #168

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2019-10-09 12:54:09 +02:00
parent f756c1bc37
commit c47546bb1a
No known key found for this signature in database
GPG Key ID: A061B9DDE0CA0773
2 changed files with 55 additions and 44 deletions

View File

@ -40,8 +40,12 @@ export default class DateTimePicker extends Vue {
date: Date = this.value; date: Date = this.value;
time: string = '00:00'; time: string = '00:00';
created() { mounted() {
let minutes = this.value.getHours() * 60 + this.value.getMinutes(); this.convertTime();
}
convertTime() {
let minutes = this.date.getHours() * 60 + this.date.getMinutes();
minutes = Math.ceil(minutes / this.step) * this.step; minutes = Math.ceil(minutes / this.step) * this.step;
this.time = [Math.floor(minutes / 60), minutes % 60].map((v) => { return v < 10 ? `0${v}` : v; }).join(':'); this.time = [Math.floor(minutes / 60), minutes % 60].map((v) => { return v < 10 ? `0${v}` : v; }).join(':');
@ -57,15 +61,22 @@ export default class DateTimePicker extends Vue {
@Watch('date') @Watch('date')
updateDate() { updateDate() {
this.updateDateTime(); this.updateTime(this.time);
}
@Watch('value')
updateValue() {
this.date = this.value;
this.convertTime();
} }
updateDateTime() { updateDateTime() {
/** /**
* Returns the updated date * Returns the updated date
* *
* @type {DateTime} * @type {Date}
*/ */
console.log('updated this.date with', this.date);
this.$emit('input', this.date); this.$emit('input', this.date);
} }
} }

View File

@ -67,13 +67,13 @@ import {ParticipantRole} from "@/types/event.model";
{{ $t('Only accessible through link and search (private)') }} {{ $t('Only accessible through link and search (private)') }}
</b-radio> </b-radio>
</div> </div>
<div class="field"> <!-- <div class="field">
<b-radio v-model="event.visibility" <b-radio v-model="event.visibility"
name="eventVisibility" name="eventVisibility"
:native-value="EventVisibility.PRIVATE"> :native-value="EventVisibility.PRIVATE">
{{ $t('Page limited to my group (asks for auth)') }} {{ $t('Page limited to my group (asks for auth)') }}
</b-radio> </b-radio>
</div> </div> -->
<div class="field"> <div class="field">
<label class="label">{{ $t('Participation approval') }}</label> <label class="label">{{ $t('Participation approval') }}</label>
@ -83,16 +83,17 @@ import {ParticipantRole} from "@/types/event.model";
</div> </div>
<div class="field"> <div class="field">
<label class="label">{{ $t('Number of places') }}</label>
<b-switch v-model="limitedPlaces"> <b-switch v-model="limitedPlaces">
{{ $t('Limited places') }} {{ $t('Limited number of places') }}
</b-switch> </b-switch>
</div> </div>
<div class="box" v-if="limitedPlaces"> <div class="box" v-if="limitedPlaces">
<b-field :label="$t('Number of places')"> <b-field :label="$t('Number of places')">
<b-numberinput v-model="event.options.maximumAttendeeCapacity"></b-numberinput> <b-numberinput controls-position="compact" min="0" v-model="event.options.maximumAttendeeCapacity"></b-numberinput>
</b-field> </b-field>
<!--
<b-field> <b-field>
<b-switch v-model="event.options.showRemainingAttendeeCapacity"> <b-switch v-model="event.options.showRemainingAttendeeCapacity">
{{ $t('Show remaining number of places') }} {{ $t('Show remaining number of places') }}
@ -103,10 +104,10 @@ import {ParticipantRole} from "@/types/event.model";
<b-switch v-model="event.options.showParticipationPrice"> <b-switch v-model="event.options.showParticipationPrice">
{{ $t('Display participation price') }} {{ $t('Display participation price') }}
</b-switch> </b-switch>
</b-field> </b-field> -->
</div> </div>
<h2 class="subtitle"> <!-- <h2 class="subtitle">
{{ $t('Public comment moderation') }} {{ $t('Public comment moderation') }}
</h2> </h2>
@ -134,7 +135,7 @@ import {ParticipantRole} from "@/types/event.model";
:native-value="CommentModeration.CLOSED"> :native-value="CommentModeration.CLOSED">
{{ $t('Close comments for all (except for admins)') }} {{ $t('Close comments for all (except for admins)') }}
</b-radio> </b-radio>
</div> </div> -->
<h2 class="subtitle"> <h2 class="subtitle">
{{ $t('Status') }} {{ $t('Status') }}
@ -361,21 +362,22 @@ export default class EditEvent extends Vue {
} }
async createEvent() { async createEvent() {
try { console.log(this.buildVariables());
const { data } = await this.$apollo.mutate({ // try {
mutation: CREATE_EVENT, // const { data } = await this.$apollo.mutate({
variables: this.buildVariables(), // mutation: CREATE_EVENT,
update: (store, { data: { createEvent } }) => this.postCreateOrUpdate(store, createEvent), // variables: this.buildVariables(),
refetchQueries: ({ data: { createEvent } }) => this.postRefetchQueries(createEvent), // update: (store, { data: { createEvent } }) => this.postCreateOrUpdate(store, createEvent),
}); // refetchQueries: ({ data: { createEvent } }) => this.postRefetchQueries(createEvent),
// });
await this.$router.push({ // await this.$router.push({
name: 'Event', // name: 'Event',
params: { uuid: data.createEvent.uuid }, // params: { uuid: data.createEvent.uuid },
}); // });
} catch (err) { // } catch (err) {
console.error(err); // console.error(err);
} // }
} }
async updateEvent() { async updateEvent() {
@ -526,24 +528,22 @@ export default class EditEvent extends Vue {
return JSON.stringify(this.event.toEditJSON()) !== JSON.stringify(this.unmodifiedEvent); return JSON.stringify(this.event.toEditJSON()) !== JSON.stringify(this.unmodifiedEvent);
} }
// getAddressData(addressData) { get beginsOn() { return this.event.beginsOn; }
// if (addressData !== null) {
// this.event.address = { @Watch('beginsOn')
// geom: { onBeginsOnChanged(beginsOn) {
// data: { console.log('beginsOnWatcher', beginsOn);
// latitude: addressData.latitude, if (!this.event.endsOn) return;
// longitude: addressData.longitude const dateBeginsOn = new Date(beginsOn);
// }, const dateEndsOn = new Date(this.event.endsOn);
// type: "point" if (dateEndsOn < dateBeginsOn) {
// }, this.event.endsOn = dateBeginsOn;
// addressCountry: addressData.country, this.event.endsOn.setUTCHours(dateEndsOn.getUTCHours());
// addressLocality: addressData.locality, }
// addressRegion: addressData.administrative_area_level_1, if (dateEndsOn === dateBeginsOn) {
// postalCode: addressData.postal_code, this.event.endsOn.setUTCHours(dateEndsOn.getUTCHours() + 1);
// streetAddress: `${addressData.street_number} ${addressData.route}` }
// }; }
// }
// }
} }
</script> </script>