Commit ec0e0434 authored by Guillaume Perréal's avatar Guillaume Perréal
Browse files

Ajout de la description éditable des fichiers.

Showing with 49 additions and 4 deletions
+49 -4
...@@ -80,6 +80,11 @@ class UploadedFile implements UploadedFileInterface ...@@ -80,6 +80,11 @@ class UploadedFile implements UploadedFileInterface
* @var array * @var array
*/ */
private $metadata; private $metadata;
/**
* @ORM\Column(type="string", length=256, nullable=true)
* @var string
*/
private $description = null;
/** /**
* @var Filesystem * @var Filesystem
...@@ -541,6 +546,25 @@ class UploadedFile implements UploadedFileInterface ...@@ -541,6 +546,25 @@ class UploadedFile implements UploadedFileInterface
return true; return true;
} }
/**
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
*
* @param string $description
* @return UploadedFileInterface
*/
public function setDescription($description = null)
{
$this->description = $description;
return $this;
}
/** /**
* @return array * @return array
*/ */
...@@ -552,6 +576,7 @@ class UploadedFile implements UploadedFileInterface ...@@ -552,6 +576,7 @@ class UploadedFile implements UploadedFileInterface
'size' => $this->getSize(), 'size' => $this->getSize(),
'type' => $this->getMimeType(), 'type' => $this->getMimeType(),
'etat' => $this->getEtat(), 'etat' => $this->getEtat(),
'description' => $this->getDescription(),
'checksum' => $this->getChecksum(), 'checksum' => $this->getChecksum(),
'icon' => MimeTypeIcon::getMimeTypeIcon($this->getMimeType()) 'icon' => MimeTypeIcon::getMimeTypeIcon($this->getMimeType())
]; ];
......
...@@ -44,6 +44,17 @@ interface UploadedFileInterface ...@@ -44,6 +44,17 @@ interface UploadedFileInterface
*/ */
public function getDisplayName(); public function getDisplayName();
/**
* @param string $description
* @return UploadedFileInterface
*/
public function setDescription($description = null);
/**
* @return string
*/
public function getDescription();
/** /**
* Get path * Get path
* *
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
var $this = $(this), var $this = $(this),
$button = $this.find('.fileinput-button'), $button = $this.find('.fileinput-button'),
$entries = $this.find('.fileinput-entries'), $entries = $this.find('.fileinput-entries'),
nextIndex = $entries.find('.fileinput-entry').length,
createUrl = options.createUrl, createUrl = options.createUrl,
uploadPrototype = options.uploadPrototype, uploadPrototype = options.uploadPrototype,
downloadPrototype = options.downloadPrototype, downloadPrototype = options.downloadPrototype,
...@@ -104,7 +105,7 @@ ...@@ -104,7 +105,7 @@
downloadTemplate: function(data) { downloadTemplate: function(data) {
var rows = $(); var rows = $();
$.each(data.files, function (index, file) { $.each(data.files, function (index, file) {
var row = $(downloadPrototype); var row = $(downloadPrototype.replace(/__index__/g, nextIndex++));
row.find('.size').text(formatFileSize(file.size)); row.find('.size').text(formatFileSize(file.size));
if (file.error) { if (file.error) {
row.find('.name').text(file.name); row.find('.name').text(file.name);
...@@ -116,7 +117,7 @@ ...@@ -116,7 +117,7 @@
row.find('.delete') row.find('.delete')
.attr('data-type', file.delete_type) .attr('data-type', file.delete_type)
.attr('data-url', file.delete_url + csrfQuery); .attr('data-url', file.delete_url + csrfQuery);
row.find('input:hidden') row.find('input.id')
.val(file.id); .val(file.id);
if(file.icon && file.icon !== 'file') { if(file.icon && file.icon !== 'file') {
row.find('.icon') row.find('.icon')
......
...@@ -10,6 +10,13 @@ All rights reserved. ...@@ -10,6 +10,13 @@ All rights reserved.
.cancel, .delete { .cancel, .delete {
margin-left: 0.5em; margin-left: 0.5em;
} }
.description {
display: inline;
width: auto;
height: auto;
padding: @padding-xs-vertical @padding-xs-horizontal;
margin: 0;
}
.progress { .progress {
height: (@line-height-computed / 2); height: (@line-height-computed / 2);
margin: (@line-height-computed / 4) 0; margin: (@line-height-computed / 4) 0;
......
...@@ -16,13 +16,14 @@ ...@@ -16,13 +16,14 @@
{%- block file_upload_entry_prototype %} {%- block file_upload_entry_prototype %}
{%- set file = file|default([]) %} {%- set file = file|default([]) %}
<div class="template-download fileinput-entry"> <div class="template-download fileinput-entry">
<input type="hidden" name="{{ full_name }}{% if multiple %}[]{% endif %}" value="{{ file.id|default }}"/> <input class="id" type="hidden" name="{{ full_name }}{% if multiple %}[{{index|default('__index__')}}]{% endif %}[id]" value="{{ file.id|default }}"/>
<i class="fa fa-file{% if file.icon|default(false) %}-{{ file.icon }}{% endif %}-o icon"></i>&nbsp;<span class="name"> <i class="fa fa-file{% if file.icon|default(false) %}-{{ file.icon }}{% endif %}-o icon"></i>&nbsp;<span class="name">
<a{% if file %} href="{{ path('file_upload_get_content', {id: file.id, token: csrf_token}) }}"{% endif %}>{{ file.name|default }}</a> <a{% if file %} href="{{ path('file_upload_get_content', {id: file.id, token: csrf_token}) }}"{% endif %}>{{ file.name|default }}</a>
</span> </span>
(<span class="size"> (<span class="size">
{{- file.size|default -}} {{- file.size|default -}}
</span>) </span>)
<input class="form-control description" type="text" placeholder="{% trans %}form.file_upload.description.placeholder{% endtrans %}" name="{{ full_name }}{% if multiple %}[{{index|default('__index__')}}]{% endif %}[description]" value="{{ file.description|default }}"/>
<span class="error danger" style="display: none">ERROR</span> <span class="error danger" style="display: none">ERROR</span>
<a href="#" class="danger delete {%- if disabled or read_only %} disabled{% endif -%}" title="{% trans %}button.delete{% endtrans %}"> <a href="#" class="danger delete {%- if disabled or read_only %} disabled{% endif -%}" title="{% trans %}button.delete{% endtrans %}">
{{- irstea_icon('remove') -}} {{- irstea_icon('remove') -}}
...@@ -41,7 +42,7 @@ ...@@ -41,7 +42,7 @@
<div class="fileinput-entries"> <div class="fileinput-entries">
{%- if value is not empty %} {%- if value is not empty %}
{%- if multiple %} {%- if multiple %}
{% for file in value %} {% for index, file in value %}
{{ block('file_upload_entry_prototype') }} {{ block('file_upload_entry_prototype') }}
{% endfor %} {% endfor %}
{%- else %} {%- else %}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment