Merge remote-tracking branch 'origin/master' into feat/add-document-encrypter-service

This commit is contained in:
2022-04-26 09:37:30 +02:00
329 changed files with 5953 additions and 2055 deletions

View File

@@ -155,7 +155,7 @@ class DocumentAccompanyingCourseController extends AbstractController
$documents = $this->courseRepository
->findBy(
['course' => $course],
['date' => 'DESC'],
['date' => 'DESC', 'id' => 'DESC'],
$pagination->getItemsPerPage(),
$pagination->getCurrentPageFirstItemNumber()
);

View File

@@ -178,7 +178,7 @@ class DocumentPersonController extends AbstractController
$documents = $this->personDocumentACLAwareRepository->findByPerson(
$person,
[],
['date' => 'DESC', 'id' => 'DESC'],
$pagination->getItemsPerPage(),
$pagination->getCurrentPageFirstItemNumber()
);

View File

@@ -24,22 +24,15 @@ class PersonDocument extends Document implements HasCenterInterface, HasScopeInt
{
/**
* @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\Person")
*
* @var Person
*/
private $person;
private Person $person;
public function getCenter()
{
return $this->getPerson()->getCenter();
}
/**
* Get person.
*
* @return \Chill\MainBundle\Entity\Person
*/
public function getPerson()
public function getPerson(): Person
{
return $this->person;
}

View File

@@ -61,13 +61,13 @@ class StoredObject implements AsyncFileInterface, Document
/**
* @var int[]
* @ORM\Column(type="json", name="iv")
* @Serializer\Groups({"write"})
* @Serializer\Groups({"read", "write"})
*/
private array $iv = [];
/**
* @ORM\Column(type="json", name="key")
* @Serializer\Groups({"write"})
* @Serializer\Groups({"read", "write"})
*/
private array $keyInfos = [];

View File

@@ -64,7 +64,7 @@ class PersonDocumentACLAwareRepository implements PersonDocumentACLAwareReposito
$this->addACL($qb, $person);
foreach ($orderBy as [$field, $order]) {
foreach ($orderBy as $field => $order) {
$qb->addOrderBy($field, $order);
}

View File

@@ -73,6 +73,7 @@ var download = (button) => {
button.type = mimeType;
button.textContent = labelReady;
if (hasFilename) {
button.download = filename;
if (extension !== false) {
button.download = button.download + '.' + extension;
@@ -92,4 +93,4 @@ window.addEventListener('load', function(e) {
initializeButtons(e.target);
});
module.exports = initializeButtons;
export { initializeButtons, download };

View File

@@ -1,6 +1,6 @@
var algo = 'AES-CBC';
import Dropzone from 'dropzone';
var initializeDownload = require('./downloader.js');
import { initializeButtons } from './downloader.js';
/**
@@ -359,7 +359,7 @@ var insertDownloadButton = (zone, zoneData) => {
addBelowButton(newButton, zone, zoneData);
//zone.appendChild(newButton);
initializeDownload(zone);
initializeButtons(zone);
};
window.addEventListener('load', function(e) {

View File

@@ -1,5 +1,5 @@
<template>
<a class="btn btn-create" :title="$t(buttonTitle)" @click="openModal">
<a :class="btnClasses" :title="$t(buttonTitle)" @click="openModal">
<span>{{ $t(buttonTitle) }}</span>
</a>
<teleport to="body">
@@ -96,10 +96,27 @@ export default {
Modal
},
i18n,
props: [
'buttonTitle',
'options'
],
props: {
buttonTitle: {
type: String,
default: 'Ajouter un document',
},
options: {
type: Object,
default: {
maxFiles: 1,
maxPostSize: 262144000, // 250MB
required: false,
}
},
btnClasses: {
type: Object,
default: {
btn: true,
'btn-create': true
}
}
},
emits: ['addDocument'],
data() {
return {

View File

@@ -0,0 +1,45 @@
<template>
<a
class="btn btn-download"
:title="$t(buttonTitle)"
:data-key=JSON.stringify(storedObject.keyInfos)
:data-iv=JSON.stringify(storedObject.iv)
:data-mime-type=storedObject.type
:data-label-preparing="$t('dataLabelPreparing')"
:data-label-ready="$t('dataLabelReady')"
:data-temp-url-get-generator="url"
@click.once="downloadDocument">
</a>
</template>
<script>
import { download } from '../../module/async_upload/downloader';
const i18n = {
messages: {
fr: {
dataLabelPreparing: "Chargement...",
dataLabelReady: "",
}
}
};
export default {
name: "AddAsyncUploadDownloader",
i18n,
props: [
'buttonTitle',
'storedObject'
],
computed: {
url() {
return `/asyncupload/temp_url/generate/GET?object_name=${this.storedObject.filename}`;
}
},
methods: {
downloadDocument(e) {
download(e.target);
}
}
}
</script>

View File

@@ -23,14 +23,14 @@
{{ form_row(form.description) }}
{{ form_row(form.object, { 'label': 'Document', 'existing': document.object }) }}
<ul class="record_actions">
<ul class="record_actions sticky-form-buttons">
<li class="cancel">
<a href="{{ path('accompanying_course_document_index', {'course': accompanyingCourse.id}) }}" class="btn btn-cancel">
{{ 'Back to the list' | trans }}
</a>
</li>
<li class="create">
<button class="btn btn-create">{{ 'Create'|trans }}</button>
<button class="btn btn-save">{{ 'Save'|trans }}</button>
</li>
</ul>
{{ form_end(form) }}

View File

@@ -25,7 +25,7 @@
{% endblock %}
{% block layout_wvm_content %}
{% block admin_content %}<!-- block personcontent empty -->
{% block admin_content %}<!-- block content empty -->
<h1>{{ 'Documents configuration' |trans }}</h1>
{% endblock %}
{% endblock %}

View File

@@ -30,7 +30,7 @@
</dl>
{% endblock %}
{% block personcontent %}
{% block content %}
{{ include('@ChillMain/Util/confirmation_template.html.twig',
{
'title' : 'Delete document ?'|trans,

View File

@@ -20,7 +20,7 @@
{% set activeRouteKey = '' %}
{% block title %}{{ 'Editing document for %name%'|trans({ '%name%': person|chill_entity_render_string } ) }}{% endblock %}
{% block personcontent %}
{% block content %}
<h1>{{ 'Edit Document' | trans }}</h1>
{{ form_errors(form) }}

View File

@@ -39,7 +39,7 @@
{{ encore_entry_link_tags('mod_entity_workflow_pick') }}
{% endblock %}
{% block personcontent %}
{% block content %}
<div class="col-md-10 col-xxl">
<h1>{{ 'Documents for %name%'|trans({ '%name%': person|chill_entity_render_string } ) }}</h1>

View File

@@ -22,7 +22,7 @@
{{ 'New document for %name%'|trans({ '%name%': person|chill_entity_render_string } ) }}
{% endblock %}
{% block personcontent %}
{% block content %}
<h1>{{ 'New document for %name%'|trans({ '%name%': person|chill_entity_render_string } ) }}</h1>
{{ form_errors(form) }}
@@ -47,7 +47,7 @@
</a>
</li>
<li class="create">
<button class="btn btn-create">{{ 'Create'|trans }}</button>
<button class="btn btn-save">{{ 'Save'|trans }}</button>
</li>
</ul>
{{ form_end(form) }}

View File

@@ -27,7 +27,7 @@
{{ encore_entry_script_tags('mod_async_upload') }}
{% endblock %}
{% block personcontent %}
{% block content %}
<h1>{{ 'Document %title%' | trans({ '%title%': document.title }) }}</h1>
{{ mm.mimeIcon(document.object.type) }}

View File

@@ -16,10 +16,102 @@ use Chill\DocStoreBundle\Entity\StoredObject;
use Twig\Environment;
use Twig\Extension\RuntimeExtensionInterface;
use function array_key_exists;
use function in_array;
final class WopiEditTwigExtensionRuntime implements RuntimeExtensionInterface
{
public const SUPPORTED_MIMES = [
'image/svg+xml',
'application/vnd.ms-powerpoint',
'application/vnd.ms-excel',
'application/vnd.sun.xml.writer',
'application/vnd.oasis.opendocument.text',
'application/vnd.oasis.opendocument.text-flat-xml',
'application/vnd.sun.xml.calc',
'application/vnd.oasis.opendocument.spreadsheet',
'application/vnd.oasis.opendocument.spreadsheet-flat-xml',
'application/vnd.sun.xml.impress',
'application/vnd.oasis.opendocument.presentation',
'application/vnd.oasis.opendocument.presentation-flat-xml',
'application/vnd.sun.xml.draw',
'application/vnd.oasis.opendocument.graphics',
'application/vnd.oasis.opendocument.graphics-flat-xml',
'application/vnd.oasis.opendocument.chart',
'application/vnd.sun.xml.writer.global',
'application/vnd.oasis.opendocument.text-master',
'application/vnd.sun.xml.writer.template',
'application/vnd.oasis.opendocument.text-template',
'application/vnd.oasis.opendocument.text-master-template',
'application/vnd.sun.xml.calc.template',
'application/vnd.oasis.opendocument.spreadsheet-template',
'application/vnd.sun.xml.impress.template',
'application/vnd.oasis.opendocument.presentation-template',
'application/vnd.sun.xml.draw.template',
'application/vnd.oasis.opendocument.graphics-template',
'application/msword',
'application/msword',
'application/vnd.ms-excel',
'application/vnd.ms-powerpoint',
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'application/vnd.ms-word.document.macroEnabled.12',
'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
'application/vnd.ms-word.template.macroEnabled.12',
'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
'application/vnd.ms-excel.template.macroEnabled.12',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'application/vnd.ms-excel.sheet.binary.macroEnabled.12',
'application/vnd.ms-excel.sheet.macroEnabled.12',
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
'application/vnd.ms-powerpoint.presentation.macroEnabled.12',
'application/vnd.openxmlformats-officedocument.presentationml.template',
'application/vnd.ms-powerpoint.template.macroEnabled.12',
'application/vnd.wordperfect',
'application/x-aportisdoc',
'application/x-hwp',
'application/vnd.ms-works',
'application/x-mswrite',
'application/x-dif-document',
'text/spreadsheet',
'text/csv',
'application/x-dbase',
'application/vnd.lotus-1-2-3',
'image/cgm',
'image/vnd.dxf',
'image/x-emf',
'image/x-wmf',
'application/coreldraw',
'application/vnd.visio2013',
'application/vnd.visio',
'application/vnd.ms-visio.drawing',
'application/x-mspublisher',
'application/x-sony-bbeb',
'application/x-gnumeric',
'application/macwriteii',
'application/x-iwork-numbers-sffnumbers',
'application/vnd.oasis.opendocument.text-web',
'application/x-pagemaker',
'text/rtf',
'text/plain',
'application/x-fictionbook+xml',
'application/clarisworks',
'image/x-wpg',
'application/x-iwork-pages-sffpages',
'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
'application/x-iwork-keynote-sffkey',
'application/x-abiword',
'image/x-freehand',
'application/vnd.sun.xml.chart',
'application/x-t602',
'image/bmp',
'image/png',
'image/gif',
'image/tiff',
'image/jpg',
'image/jpeg',
'application/pdf',
];
private const TEMPLATE = '@ChillDocStore/Button/wopi_edit_document.html.twig';
private DiscoveryInterface $discovery;
@@ -31,15 +123,7 @@ final class WopiEditTwigExtensionRuntime implements RuntimeExtensionInterface
public function isEditable(StoredObject $document): bool
{
$mime_type = $this->discovery->discoverMimeType($document->getType());
foreach ($mime_type as $item) {
if (array_key_exists('default', $item) && 'true' === $item['default']) {
return true;
}
}
return false;
return in_array($document->getType(), self::SUPPORTED_MIMES, true);
}
public function renderEditButton(Environment $environment, StoredObject $document, ?array $options = null): string

View File

@@ -116,6 +116,6 @@ class AccompanyingCourseDocumentWorkflowHandler implements EntityWorkflowHandler
public function supportsFreeze(EntityWorkflow $entityWorkflow, array $options = []): bool
{
return true;
return false;
}
}