Skip to content

Commit

Permalink
feature Kunstmaan#251 add/delete folder mediachooser pop-up
Browse files Browse the repository at this point in the history
  • Loading branch information
KUNSTMAAN committed Apr 8, 2015
1 parent f8cb421 commit ffd733a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
6 changes: 6 additions & 0 deletions src/Kunstmaan/MediaBundle/Controller/ChooserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Kunstmaan\MediaBundle\Entity\Media;
use Kunstmaan\MediaBundle\Helper\Media\AbstractMediaHandler;
use Kunstmaan\MediaBundle\Helper\MediaManager;
use Kunstmaan\MediaBundle\Form\FolderType;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
Expand Down Expand Up @@ -112,6 +113,10 @@ public function chooserShowFolderAction(Request $request, $folderId)
$adminList = $this->get('kunstmaan_adminlist.factory')->createList($adminListConfigurator);
$adminList->bindRequest($request);

$sub = new Folder();
$sub->setParent($folder);
$subForm = $this->createForm(new FolderType($sub), $sub);

$linkChooserLink = null;
if (!empty($linkChooser)) {
$params = array();
Expand All @@ -134,6 +139,7 @@ public function chooserShowFolderAction(Request $request, $folderId)
'type' => $type,
'folder' => $folder,
'adminlist' => $adminList,
'subform' => $subForm->createView(),

);

Expand Down
18 changes: 12 additions & 6 deletions src/Kunstmaan/MediaBundle/Controller/FolderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,13 @@ public function deleteAction($folderId)
$folderId = $parentFolder->getId();
}

if (strpos($_SERVER['HTTP_REFERER'],'chooser')) {
$redirect = 'KunstmaanMediaBundle_chooser_show_folder';
} else $redirect = 'KunstmaanMediaBundle_folder_show';

return new RedirectResponse(
$this->generateUrl(
'KunstmaanMediaBundle_folder_show',
$redirect,
array(
'folderId' => $folderId
)
Expand Down Expand Up @@ -154,15 +158,17 @@ public function subCreateAction(Request $request, $folderId)
'Folder \'' . $folder->getName() . '\' has been created!'
);

return new Response(
'<script>window.location="' .
if (strpos($_SERVER['HTTP_REFERER'],'chooser') !== false) {
$redirect = 'KunstmaanMediaBundle_chooser_show_folder';
} else $redirect = 'KunstmaanMediaBundle_folder_show';

return new RedirectResponse(
$this->generateUrl(
'KunstmaanMediaBundle_folder_show',
$redirect,
array(
'folderId' => $folder->getId()
)
) .
'"</script>'
)
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@
{% endfor %}
</ul>
</div>
<button class="btn btn-default btn--raise-on-hover" data-target="#addsub-modal" data-toggle="modal" type="button">
{{ 'media.folder.addsub.action' |trans }}
</button>
<button class="btn btn-default btn--raise-on-hover" data-target="#delete-modal" data-toggle="modal" type="button">
{{ 'media.folder.delete.action' |trans }}
</button>
{% endblock %}
</div>
</div>
Expand Down Expand Up @@ -235,6 +241,8 @@
<!-- Modals -->
{% set urlParams = urlParams|merge({'folderId': folder.id}) %}
{% include 'KunstmaanMediaBundle:Media:addType-modal.html.twig' %}
{% include 'KunstmaanMediaBundle:Folder:addsub-modal.html.twig' %}
{% include 'KunstmaanMediaBundle:Folder:delete-modal.html.twig' %}

{% endblock %}

Expand Down

0 comments on commit ffd733a

Please # to comment.