Front end deps upgrades and fixes

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2019-07-23 17:14:03 +02:00
parent 93984eb53a
commit 1cd511f440
No known key found for this signature in database
GPG key ID: A061B9DDE0CA0773
4 changed files with 516 additions and 432 deletions

View file

@ -143,8 +143,7 @@ export const CREATE_EVENT = gql`
$organizerActorId: ID!,
$category: String!,
$beginsOn: DateTime!,
$picture_file: Upload,
$picture_name: String,
$picture: PictureInput!
) {
createEvent(
title: $title,
@ -152,12 +151,7 @@ export const CREATE_EVENT = gql`
beginsOn: $beginsOn,
organizerActorId: $organizerActorId,
category: $category,
picture: {
picture: {
file: $picture_file,
name: $picture_name,
}
}
picture: $picture
) {
id,
uuid,

View file

@ -28,7 +28,7 @@
</b-select>
</b-field>
<picture-upload @change="handlePictureUploadChange" />
<picture-upload v-model="pictureFile" />
<button class="button is-primary">
<translate>Create my event</translate>
@ -50,7 +50,6 @@ import {
import { LOGGED_PERSON } from '@/graphql/actor';
import { IPerson, Person } from '@/types/actor';
import PictureUpload from '@/components/PictureUpload.vue';
import { IPictureUpload } from '@/types/picture.model';
import Editor from '@/components/Editor.vue';
import DateTimePicker from '@/components/Event/DateTimePicker.vue';
@ -68,8 +67,7 @@ export default class CreateEvent extends Vue {
loggedPerson: IPerson = new Person();
categories: string[] = Object.keys(Category);
event: IEvent = new EventModel();
pictureFile?: File;
pictureName?: String;
pictureFile: File | null = null;
created() {
const now = new Date();
@ -81,23 +79,14 @@ export default class CreateEvent extends Vue {
createEvent(e: Event) {
e.preventDefault();
this.event.organizerActor = this.loggedPerson;
this.event.attributedTo = this.loggedPerson;
if (this.event.uuid === '') {
console.log('event', this.event);
this.$apollo
.mutate({
mutation: CREATE_EVENT,
variables: {
title: this.event.title,
description: this.event.description,
beginsOn: this.event.beginsOn.toISOString(),
category: this.event.category,
organizerActorId: this.event.organizerActor.id,
picture_file: this.pictureFile,
picture_name: this.pictureName,
},
variables: this.buildVariables(),
})
.then(data => {
console.log('event created', data);
@ -126,10 +115,35 @@ export default class CreateEvent extends Vue {
}
}
handlePictureUploadChange(picture: IPictureUpload) {
console.log('picture upload change', picture);
this.pictureFile = picture.file;
this.pictureName = picture.name;
/**
* Build variables for Event GraphQL creation query
*/
private buildVariables() {
/**
* Transform general variables
*/
let pictureObj = {};
let obj = {
organizerActorId: this.loggedPerson.id,
beginsOn: this.event.beginsOn.toISOString(),
};
let res = Object.assign({}, this.event, obj);
/**
* Transform picture files
*/
if (this.pictureFile) {
pictureObj = {
picture: {
picture: {
name: this.pictureFile.name,
file: this.pictureFile,
},
},
};
}
return Object.assign({}, res, pictureObj);
}
// getAddressData(addressData) {

File diff suppressed because it is too large Load diff

View file

@ -91,10 +91,12 @@ defmodule MobilizonWeb.Upload do
def remove(url, opts \\ []) do
with opts <- get_opts(opts),
%URI{path: "/media/" <> path, host: host} <- URI.parse(url),
true <- host == MobilizonWeb.Endpoint.host() do
{:same_host, true} <- {:same_host, host == MobilizonWeb.Endpoint.host()} do
MobilizonWeb.Uploaders.Uploader.remove_file(opts.uploader, path)
else
%URI{} = _uri -> {:error, "URL doesn't match pattern"}
{:same_host, _} ->
Logger.error("Media can't be deleted because its URL doesn't match current host")
end
end