Allow to display media

This commit is contained in:
Thomas 2019-08-09 17:11:59 +02:00
parent 3f0028cecc
commit d48f75890f
3 changed files with 64 additions and 10 deletions

View file

@ -11,6 +11,7 @@ namespace App\Form;
use App\SocialEntity\Compose;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
@ -44,6 +45,7 @@ class ComposeType extends AbstractType {
'status.visibility.direct' => 'direct',
]
]);
$builder->add('sensitive', CheckboxType::class);
$builder->add('scheduled_at', \Symfony\Component\Form\Extension\Core\Type\DateTimeType::class,[
'widget' => 'single_text',
]);

View file

@ -27,6 +27,8 @@ class Compose
private $sent_at;
private $sensitive;
private $social_account;
private $in_reply_to_id;
@ -91,6 +93,24 @@ class Compose
return $this;
}
/**
* @return boolean
*/
public function getSensitive()
{
return $this->sensitive;
}
/**
* @param mixed $sensitive
*/
public function setSensitive(bool $sensitive): void
{
$this->sensitive = $sensitive;
}
/**
* @return Collection|Media[]
*/

View file

@ -48,6 +48,7 @@
</div>
</div>
</div>
<div class="row">
<div class=" col-md-3">
<div class="form-group has-feedback">
@ -65,7 +66,21 @@
</div>
<div class="row">
<div class=" col-md-3">
<div class="form-group has-feedback">
{{ form_label(form.sensitive) }}
{{ form_widget(form.sensitive) }}
{% if not form.sensitive.vars.errors is empty %}
<span class="label label-danger">
{% for errorItem in form.sensitive.vars.errors %}
{{ errorItem.message }}
{% endfor %}
</span>
{% endif %}
</div>
</div>
</div>
<div class="row">
<div class=" col-md-4">
@ -85,21 +100,17 @@
</div>
</div>
<div class="container" style="margin-bottom: 30px;" id="media_container"></div>
<div class="container">
<!-- The file upload form used as target for the file upload widget -->
<form
id="fileupload"
action="https://jquery-file-upload.appspot.com/"
action="https://{{ instance }}/api/v1/media"
method="POST"
enctype="multipart/form-data"
>
<!-- Redirect browsers with JavaScript disabled to the origin page -->
<noscript
><input
type="hidden"
name="redirect"
value="https://blueimp.github.io/jQuery-File-Upload/"
/></noscript>
<!-- The fileupload-buttonbar contains buttons to add/delete files and start/cancel the upload -->
<div class="row fileupload-buttonbar">
<div class="col-lg-7">
@ -107,7 +118,7 @@
<span class="btn btn-success fileinput-button">
<i class="glyphicon glyphicon-plus"></i>
<span>Add files...</span>
<input type="file" name="files[]" multiple />
<input type="file" name="file" />
</span>
<button type="submit" class="btn btn-primary start">
<i class="glyphicon glyphicon-upload"></i>
@ -141,6 +152,7 @@
</form>
</div>
</div>
{% endblock %}
@ -319,6 +331,25 @@
},
success: function (data) {
var content;
content = ' <div class="row" id="media_container_'+data.id+'">\n' +
' <div class="col-md-4">\n' +
' <img src="'+data.preview_url+'" style="width:100%;max-width:400px;" id="media_preview_'+data.id+'"/>\n' +
' </div>\n' +
' <div class="col-md-6">\n' +
' <textarea name="media_description_'+data.id+'" class="form-control"></textarea>\n' +
' </div>\n' +
' <input type="hidden" name="media_id_'+data.id+'"/>\n' +
' <div class="col-md-2">\n' +
' <button class="btn btn-danger" class="delete_media" data-id="'+data.id+'">\n' +
' <i class="glyphicon glyphicon-trash"></i>\n' +
' <span>Delete</span>\n' +
' </button>\n' +
' </div>\n' +
' </div>'
$('#media_container').html($('#media_container').html() + content);
},
url: 'https://{{ instance }}/api/v1/media'
});
@ -351,6 +382,7 @@
});
var setHeader = function (xhr) {
xhr.setRequestHeader('Authorization', '{{ token }}');
xhr.setRequestHeader('Accept', 'application/json, text/plain, */*');
};
</script>