mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
allow to close editor
This commit is contained in:
parent
bf0a24b38e
commit
57a9f52fa1
@ -9,6 +9,7 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluatio
|
|||||||
use Chill\PersonBundle\Entity\SocialWork\Evaluation;
|
use Chill\PersonBundle\Entity\SocialWork\Evaluation;
|
||||||
use GuzzleHttp\Exception\TransferException;
|
use GuzzleHttp\Exception\TransferException;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
use Symfony\Component\HttpFoundation\HeaderUtils;
|
use Symfony\Component\HttpFoundation\HeaderUtils;
|
||||||
@ -60,8 +61,11 @@ class DocGeneratorTemplateController extends AbstractController
|
|||||||
*/
|
*/
|
||||||
public function generateDocFromTemplateAction(
|
public function generateDocFromTemplateAction(
|
||||||
\ChampsLibres\AsyncUploaderBundle\TempUrl\TempUrlGeneratorInterface $tempUrlGenerator,
|
\ChampsLibres\AsyncUploaderBundle\TempUrl\TempUrlGeneratorInterface $tempUrlGenerator,
|
||||||
DocGeneratorTemplate $template, string $entityClassName, int $entityId): Response
|
DocGeneratorTemplate $template,
|
||||||
{
|
string $entityClassName,
|
||||||
|
int $entityId,
|
||||||
|
Request $request
|
||||||
|
): Response {
|
||||||
$getUrlGen = $tempUrlGenerator->generate(
|
$getUrlGen = $tempUrlGenerator->generate(
|
||||||
'GET',
|
'GET',
|
||||||
$template->getFile());
|
$template->getFile());
|
||||||
@ -134,7 +138,8 @@ class DocGeneratorTemplateController extends AbstractController
|
|||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
return $this->redirectToRoute('chill_wopi_file_edit', [
|
return $this->redirectToRoute('chill_wopi_file_edit', [
|
||||||
'fileId' => $genDocName
|
'fileId' => $genDocName,
|
||||||
|
'returnPath' => $request->query->get('returnPath', "/")
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
} catch (TransferException $e) {
|
} catch (TransferException $e) {
|
||||||
|
@ -109,7 +109,8 @@ export default {
|
|||||||
this.toggleEditEvaluation();
|
this.toggleEditEvaluation();
|
||||||
},
|
},
|
||||||
buildEditLink(storedObject) {
|
buildEditLink(storedObject) {
|
||||||
return `/wopi/edit/${storedObject.filename}`;
|
return `/fr/chill_wopi/edit/${storedObject.filename}?returnPath=` + encodeURIComponent(
|
||||||
|
window.location.pathname + window.location.search + window.location.hash);
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
6
src/Bundle/ChillWopiBundle/chill.webpack.config.js
Normal file
6
src/Bundle/ChillWopiBundle/chill.webpack.config.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
// this file loads all assets from the Chill person bundle
|
||||||
|
module.exports = function(encore, entries)
|
||||||
|
{
|
||||||
|
encore.addEntry('page_wopi_editor', __dirname + '/src/Resources/public/page/editor/index.js');
|
||||||
|
//home/julien/dev/département-vendee/chill/vendor/chill-project/chill-bundles/src/Bundle/ChillWopiBundle/src/Resources/public/page/editor/index.js
|
||||||
|
};
|
@ -16,6 +16,7 @@ use Chill\WopiBundle\Service\Controller\ResponderInterface;
|
|||||||
use Exception;
|
use Exception;
|
||||||
use loophp\psr17\Psr17Interface;
|
use loophp\psr17\Psr17Interface;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||||
use Symfony\Component\Routing\RouterInterface;
|
use Symfony\Component\Routing\RouterInterface;
|
||||||
use Symfony\Component\Security\Core\Security;
|
use Symfony\Component\Security\Core\Security;
|
||||||
@ -61,7 +62,7 @@ final class Test
|
|||||||
$storedObject = $this->storedObjectRepository->findOneBy(['filename' => $fileId]);
|
$storedObject = $this->storedObjectRepository->findOneBy(['filename' => $fileId]);
|
||||||
|
|
||||||
if (null === $storedObject) {
|
if (null === $storedObject) {
|
||||||
throw new Exception(sprintf('Unable to find object named %s', $fileId));
|
throw new NotFoundHttpException(sprintf('Unable to find object named %s', $fileId));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([] === $discoverExtension = $this->wopiDiscovery->discoverMimeType($storedObject->getType())) {
|
if ([] === $discoverExtension = $this->wopiDiscovery->discoverMimeType($storedObject->getType())) {
|
||||||
@ -86,6 +87,7 @@ final class Test
|
|||||||
],
|
],
|
||||||
UrlGeneratorInterface::ABSOLUTE_URL
|
UrlGeneratorInterface::ABSOLUTE_URL
|
||||||
),
|
),
|
||||||
|
'closebutton' => 1
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -93,7 +95,7 @@ final class Test
|
|||||||
return $this
|
return $this
|
||||||
->responder
|
->responder
|
||||||
->render(
|
->render(
|
||||||
'@Wopi/Editor/page.html.twig',
|
'@ChillWopi/Editor/page.html.twig',
|
||||||
$configuration
|
$configuration
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -0,0 +1,46 @@
|
|||||||
|
require('./index.scss');
|
||||||
|
|
||||||
|
window.addEventListener('DOMContentLoaded', function(e) {
|
||||||
|
let frameholder = document.getElementById('frameholder');
|
||||||
|
let office_frame = document.createElement('iframe');
|
||||||
|
office_frame.name = 'office_frame';
|
||||||
|
office_frame.id = 'office_frame';
|
||||||
|
|
||||||
|
// The title should be set for accessibility
|
||||||
|
office_frame.title = 'Office Frame';
|
||||||
|
|
||||||
|
// This attribute allows true fullscreen mode in slideshow view
|
||||||
|
// when using PowerPoint's 'view' action.
|
||||||
|
office_frame.setAttribute('allowfullscreen', 'true');
|
||||||
|
|
||||||
|
// The sandbox attribute is needed to allow automatic redirection to the O365 sign-in page in the business user flow
|
||||||
|
office_frame.setAttribute('sandbox', 'allow-scripts allow-same-origin allow-forms allow-popups allow-top-navigation allow-popups-to-escape-sandbox');
|
||||||
|
frameholder.appendChild(office_frame);
|
||||||
|
|
||||||
|
document.getElementById('office_form').submit();
|
||||||
|
console.log(office_frame);
|
||||||
|
|
||||||
|
const url = new URL(editor_url);
|
||||||
|
const editor_domain = url.origin;
|
||||||
|
|
||||||
|
window.addEventListener("message", function(message) {
|
||||||
|
if (message.origin !== editor_domain) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let data = JSON.parse(message.data);
|
||||||
|
|
||||||
|
if ('UI_Close' === data.MessageId) {
|
||||||
|
closeEditor();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
function closeEditor() {
|
||||||
|
let
|
||||||
|
params = new URLSearchParams(window.location.search),
|
||||||
|
returnPath = params.get('returnPath');
|
||||||
|
|
||||||
|
window.location.assign(returnPath);
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
-ms-content-zooming: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
#office_frame {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
margin: 0;
|
||||||
|
border: none;
|
||||||
|
display: block;
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
<style type="text/css">
|
||||||
|
#office_frame {
|
||||||
|
width: 100%;
|
||||||
|
height: 800px;
|
||||||
|
margin: 0;
|
||||||
|
border: none;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<form id="office_form" name="office_form" target="office_frame" action="{{ server }}" method="post">
|
||||||
|
<input name="access_token" value="{{ access_token }}" type="hidden" />
|
||||||
|
<input name="access_token_ttl" value="{{ access_token_ttl }}" type="hidden" />
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<span id="frameholder"></span>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
var frameholder = document.getElementById('frameholder');
|
||||||
|
var office_frame = document.createElement('iframe');
|
||||||
|
office_frame.name = 'office_frame';
|
||||||
|
office_frame.id = 'office_frame';
|
||||||
|
|
||||||
|
// The title should be set for accessibility
|
||||||
|
office_frame.title = 'Office Frame';
|
||||||
|
|
||||||
|
// This attribute allows true fullscreen mode in slideshow view
|
||||||
|
// when using PowerPoint's 'view' action.
|
||||||
|
office_frame.setAttribute('allowfullscreen', 'true');
|
||||||
|
|
||||||
|
// The sandbox attribute is needed to allow automatic redirection to the O365 sign-in page in the business user flow
|
||||||
|
office_frame.setAttribute('sandbox', 'allow-scripts allow-same-origin allow-forms allow-popups allow-top-navigation allow-popups-to-escape-sandbox');
|
||||||
|
frameholder.appendChild(office_frame);
|
||||||
|
|
||||||
|
document.getElementById('office_form').submit();
|
||||||
|
</script>
|
@ -0,0 +1,33 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
|
||||||
|
<!-- Enable IE Standards mode -->
|
||||||
|
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||||
|
|
||||||
|
<title></title>
|
||||||
|
<meta name="description" content="">
|
||||||
|
<meta name="viewport"
|
||||||
|
content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
|
||||||
|
|
||||||
|
<link rel="shortcut icon" href="{{ favIconUrl }}" />
|
||||||
|
<script type="text/javascript">
|
||||||
|
const editor_url = "{{ server|escape('js') }}";
|
||||||
|
</script>
|
||||||
|
{{ encore_entry_link_tags('page_wopi_editor') }}
|
||||||
|
{{ encore_entry_script_tags('page_wopi_editor') }}
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<form id="office_form" name="office_form" target="office_frame" action="{{ server }}" method="post">
|
||||||
|
<input name="access_token" value="{{ access_token }}" type="hidden" />
|
||||||
|
<input name="access_token_ttl" value="{{ access_token_ttl }}" type="hidden" />
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<span id="frameholder"></span>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
x
Reference in New Issue
Block a user