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 a1c4293cf4
commit d80b12b608
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>
@ -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>
@ -67,11 +60,11 @@
<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 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: {
@ -79,36 +72,36 @@
},
apollo: {
categories: {
query: FETCH_CATEGORIES,
},
query: FETCH_CATEGORIES
}
}
})
export default class CreateEvent extends Vue {
@Prop({required: false, type: String}) uuid!: string
@Prop({ required: false, type: String }) uuid!: string;
e1 = 0
e1 = 0;
event = {
title: null,
organizer_actor_id: null,
description: '',
begins_on: (new Date()).toISOString().substr(0, 10),
description: "",
begins_on: new Date().toISOString().substr(0, 10),
ends_on: new Date(),
seats: null,
physical_address: null,
location_type: 'physical',
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
participants: []
} as any; // FIXME: correctly type an event
categories = [];
tags = [];
tagsToSend = [];
tagsFetched = [];
loading = false;
// created() {
// if (this.uuid) {
@ -125,40 +118,51 @@
// });
// });
// 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]
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({
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)
})
.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)
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 = []
this.event.tags = [];
}
getAddressData(addressData) {
@ -167,20 +171,19 @@
geom: {
data: {
latitude: addressData.latitude,
longitude: addressData.longitude,
longitude: addressData.longitude
},
type: 'point',
type: "point"
},
addressCountry: addressData.country,
addressLocality: addressData.locality,
addressRegion: addressData.administrative_area_level_1,
postalCode: addressData.postal_code,
streetAddress: `${addressData.street_number} ${addressData.route}`,
}
}
}
streetAddress: `${addressData.street_number} ${addressData.route}`
};
}
}
}
</script>
<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