Remove last occurences of address_type

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2019-01-14 18:12:52 +01:00
parent 289ba03960
commit 3230381be4
No known key found for this signature in database
GPG Key ID: A061B9DDE0CA0773
4 changed files with 117 additions and 125 deletions

View File

@ -8,14 +8,8 @@
</v-toolbar>
<v-card-text>
<v-form>
<v-text-field
label="Title"
v-model="event.title"
:counter="100"
required
></v-text-field>
<v-date-picker v-model="event.begins_on">
</v-date-picker>
<v-text-field label="Title" v-model="event.title" :counter="100" required></v-text-field>
<v-date-picker v-model="event.begins_on"></v-date-picker>
<v-radio-group v-model="event.location_type" row>
<v-radio label="Address" value="physical" off-icon="place"></v-radio>
<v-radio label="Online" value="online" off-icon="link"></v-radio>
@ -33,7 +27,7 @@
types="geocode"
v-on:placechanged="getAddressData"
>
</vuetify-google-autocomplete> -->
</vuetify-google-autocomplete>-->
<v-text-field
v-if="event.location_type === 'online'"
label="Meeting adress"
@ -54,8 +48,7 @@
item-text="title"
item-value="id"
label="Categories"
>
</v-autocomplete>
></v-autocomplete>
<v-btn color="primary" @click="create">Create event</v-btn>
</v-form>
</v-card-text>
@ -66,125 +59,135 @@
</template>
<script lang="ts">
// import Location from '@/components/Location';
import VueMarkdown from 'vue-markdown';
import { CREATE_EVENT, EDIT_EVENT } from '@/graphql/event';
import { FETCH_CATEGORIES } from '@/graphql/category';
import { AUTH_USER_ACTOR } from '@/constants';
import { Component, Prop, Vue } from 'vue-property-decorator';
// import Location from '@/components/Location';
import VueMarkdown from "vue-markdown";
import { CREATE_EVENT, EDIT_EVENT } from "@/graphql/event";
import { FETCH_CATEGORIES } from "@/graphql/category";
import { AUTH_USER_ACTOR } from "@/constants";
import { Component, Prop, Vue } from "vue-property-decorator";
@Component({
components: {
VueMarkdown
},
apollo: {
categories: {
query: FETCH_CATEGORIES,
},
@Component({
components: {
VueMarkdown
},
apollo: {
categories: {
query: FETCH_CATEGORIES
}
})
export default class CreateEvent extends Vue {
@Prop({required: false, type: String}) uuid!: string
}
})
export default class CreateEvent extends Vue {
@Prop({ required: false, type: String }) uuid!: string;
e1 = 0
event = {
title: null,
organizer_actor_id: null,
description: '',
begins_on: (new Date()).toISOString().substr(0, 10),
ends_on: new Date(),
seats: null,
physical_address: null,
location_type: 'physical',
online_address: null,
tel_num: null,
price: null,
category: null,
category_id: null,
tags: [],
participants: [],
} as any // FIXME: correctly type an event
categories = []
tags = []
tagsToSend = []
tagsFetched = []
loading = false
e1 = 0;
event = {
title: null,
organizer_actor_id: null,
description: "",
begins_on: new Date().toISOString().substr(0, 10),
ends_on: new Date(),
seats: null,
physical_address: null,
location_type: "physical",
online_address: null,
tel_num: null,
price: null,
category: null,
category_id: null,
tags: [],
participants: []
} as any; // FIXME: correctly type an event
categories = [];
tags = [];
tagsToSend = [];
tagsFetched = [];
loading = false;
// created() {
// if (this.uuid) {
// this.fetchEvent();
// }
// }
// created() {
// if (this.uuid) {
// this.fetchEvent();
// }
// }
create () {
// this.event.seats = parseInt(this.event.seats, 10);
// this.tagsToSend.forEach((tag) => {
// this.event.tags.push({
// title: tag,
// // '@type': 'Tag',
// });
// });
// FIXME: correctly parse actor JSON
const actor = JSON.parse(localStorage.getItem(AUTH_USER_ACTOR) || '{}')
this.event.category_id = this.event.category
this.event.organizer_actor_id = actor.id
this.event.participants = [actor.id]
// this.event.price = parseFloat(this.event.price);
create() {
// this.event.seats = parseInt(this.event.seats, 10);
// this.tagsToSend.forEach((tag) => {
// this.event.tags.push({
// title: tag,
// // '@type': 'Tag',
// });
// });
// FIXME: correctly parse actor JSON
const actor = JSON.parse(localStorage.getItem(AUTH_USER_ACTOR) || "{}");
this.event.category_id = this.event.category;
this.event.organizer_actor_id = actor.id;
this.event.participants = [actor.id];
// this.event.price = parseFloat(this.event.price);
if (this.uuid === undefined) {
this.$apollo.mutate({
if (this.uuid === undefined) {
this.$apollo
.mutate({
mutation: CREATE_EVENT,
variables: {
title: this.event.title,
description: this.event.description,
organizerActorId: this.event.organizer_actor_id,
categoryId: this.event.category_id,
beginsOn: this.event.begins_on,
addressType: this.event.location_type,
beginsOn: this.event.begins_on
}
}).then((data) => {
this.loading = false
this.$router.push({name: 'Event', params: {uuid: data.data.uuid}})
}).catch((error) => {
console.log(error)
})
} else {
this.$apollo.mutate({
mutation: EDIT_EVENT,
}).then((data) => {
this.loading = false
this.$router.push({name: 'Event', params: {uuid: data.data.uuid}})
}).catch((error) => {
console.log(error)
.then(data => {
this.loading = false;
this.$router.push({
name: "Event",
params: { uuid: data.data.uuid }
});
})
}
this.event.tags = []
.catch(error => {
console.log(error);
});
} else {
this.$apollo
.mutate({
mutation: EDIT_EVENT
})
.then(data => {
this.loading = false;
this.$router.push({
name: "Event",
params: { uuid: data.data.uuid }
});
})
.catch(error => {
console.log(error);
});
}
this.event.tags = [];
}
getAddressData (addressData) {
if (addressData !== null) {
this.event.address = {
geom: {
data: {
latitude: addressData.latitude,
longitude: addressData.longitude,
},
type: 'point',
getAddressData(addressData) {
if (addressData !== null) {
this.event.address = {
geom: {
data: {
latitude: addressData.latitude,
longitude: addressData.longitude
},
addressCountry: addressData.country,
addressLocality: addressData.locality,
addressRegion: addressData.administrative_area_level_1,
postalCode: addressData.postal_code,
streetAddress: `${addressData.street_number} ${addressData.route}`,
}
}
type: "point"
},
addressCountry: addressData.country,
addressLocality: addressData.locality,
addressRegion: addressData.administrative_area_level_1,
postalCode: addressData.postal_code,
streetAddress: `${addressData.street_number} ${addressData.route}`
};
}
};
}
}
</script>
<style>
.markdown-render h1 {
font-size: 2em;
}
.markdown-render h1 {
font-size: 2em;
}
</style>

View File

@ -85,19 +85,13 @@ export const CREATE_EVENT = gql`
$organizerActorId: Int!,
$categoryId: Int!,
$beginsOn: DateTime!,
$addressType: AddressType!,
) {
createEvent(
title: $title,
description: $description,
beginsOn: $beginsOn,
organizerActorId: $organizerActorId,
categoryId: $categoryId,
addressType: $addressType) {
uuid,
title,
description,
}
categoryId: $categoryId
}
`;

View File

@ -2,9 +2,7 @@ defmodule Mobilizon.Repo.Migrations.AddAddressType do
use Ecto.Migration
def up do
Mobilizon.Events.AddressTypeEnum.create_type
alter table(:events) do
add :address_type, :address_type
add :online_address, :string
add :phone, :string
end
@ -17,11 +15,9 @@ defmodule Mobilizon.Repo.Migrations.AddAddressType do
def down do
alter table(:events) do
remove :address_type
remove :online_address
remove :phone
end
Mobilizon.Events.AddressTypeEnum.drop_type
drop constraint(:events, "events_physical_address_id_fkey")
rename table(:events), :physical_address_id, to: :address_id
alter table(:events) do

View File

@ -1,11 +1,10 @@
defmodule Mobilizon.Repo.Migrations.RemoveAddressType do
use Ecto.Migration
require Logger
def up do
alter table(:events) do
remove(:address_type)
end
execute "DROP TYPE address_type"
execute "DROP TYPE IF EXISTS address_type"
execute "ALTER TABLE \"events\" DROP COLUMN IF EXISTS address_type"
rename table(:events), :phone, to: :phone_address
end
end