Skip to content

Commit

Permalink
Clean up bundle for treeBrowser
Browse files Browse the repository at this point in the history
  • Loading branch information
wouterj committed May 5, 2015
1 parent c274a96 commit 788e97a
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 497 deletions.
1 change: 0 additions & 1 deletion Controller/TreeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ public function treeAction(Request $request)
return $this->render($this->template, array(
'repository_name' => $this->repositoryName,
'root_node' => $root,
//'selected_node' => $selected,
'routing_defaults' => $this->defaults,
//'confirm_move' => $this->confirmMove,
//'create_in_overlay' => $createInOverlay ? $createInOverlay : false,
Expand Down
6 changes: 3 additions & 3 deletions Form/Type/TreeManagerType.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ class TreeManagerType extends AbstractType
public function buildView(FormView $view, FormInterface $form, array $options)
{
$view->vars['root'] = $options['root'];
$view->vars['create_in_overlay'] = $options['create_in_overlay'];
$view->vars['edit_in_overlay'] = $options['edit_in_overlay'];
$view->vars['delete_in_overlay'] = $options['delete_in_overlay'];
//$view->vars['create_in_overlay'] = $options['create_in_overlay'];
//$view->vars['edit_in_overlay'] = $options['edit_in_overlay'];
//$view->vars['delete_in_overlay'] = $options['delete_in_overlay'];
parent::buildView($view, $form, $options);
}

Expand Down
15 changes: 0 additions & 15 deletions Form/Type/TreeModelType.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ class TreeModelType extends AbstractType
*/
protected $defaults = array();

/**
* @var TreeInterface
*/
protected $tree;

/**
* @param array $defaults
*/
Expand All @@ -44,14 +39,6 @@ public function setDefaults(array $defaults)
$this->defaults = $defaults;
}

/**
* @param TreeInterface $tree
*/
public function setTree(TreeInterface $tree)
{
$this->tree = $tree;
}

/**
* {@inheritDoc}
*/
Expand All @@ -68,8 +55,6 @@ public function buildForm(FormBuilderInterface $builder, array $options)
*/
public function buildView(FormView $view, FormInterface $form, array $options)
{
parent::buildView($view, $form, $options);
$view->vars['tree'] = $this->tree;
$view->vars['root_node'] = $form->getConfig()->getAttribute('root_node');
$view->vars['select_root_node'] = $form->getConfig()->getAttribute('select_root_node');
$view->vars['repository_name'] = $form->getConfig()->getAttribute('repository_name');
Expand Down
3 changes: 0 additions & 3 deletions Resources/config/doctrine_phpcr_form_types.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
<call method="setDefaults">
<argument>%sonata_admin_doctrine_phpcr.tree_block.defaults%</argument>
</call>
<call method="setTree">
<argument type="service" id="sonata.admin.doctrine_phpcr.phpcr_odm_tree" />
</call>
</service>

<service id="sonata.admin.doctrine_phpcr.form.type.phpcr_odm_tree_manager" class="Sonata\DoctrinePHPCRAdminBundle\Form\Type\TreeManagerType">
Expand Down
19 changes: 14 additions & 5 deletions Resources/views/Form/form_admin_fields.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,16 @@ file that was distributed with this source code.
{% include 'CmfTreeBrowserBundle:Base:tree.html.twig' %}
<script>
jQuery(function ($) {
var defaults = {% include 'SonataDoctrinePHPCRAdminBundle:Tree:routing_defaults.html.twig' with {'routing_defaults': routing_defaults} %};
{% set routing_default_values = {} %}
{% for default in routing_defaults %}
{% if 'locale' == default %}
{% set routing_default_values = routing_default_values|merge({'_locale': app.request.locale}) %}
{% elseif 'format' == default %}
{% set routing_default_values = routing_default_values|merge({'_format': app.request.format}) %}
{% else %}
{% set routing_default_values = routing_default_values|merge({default: app.request.attributes.get(default)}) %}
{% endif %}
{% endfor %}
$('#{{ id }}-tree-selector').cmfTree({
request: {
Expand All @@ -157,8 +166,7 @@ file that was distributed with this source code.
url: '{{ path('_cmf_resource', {
repositoryName: repository_name,
path: '__path__'
}) }}'.replace('__path__', nodePath)
{# todo: include routing defaults #}
}|merge(routing_default_values)) }}'.replace('__path__', nodePath)
};
},
},
Expand All @@ -179,11 +187,12 @@ file that was distributed with this source code.
{% block doctrine_phpcr_odm_tree_manager_widget %}
{{ render(controller('sonata.admin.doctrine_phpcr.tree_controller:treeAction', {
'root': form.vars.root,
'selected': false,
})) }}
{# 'selected': false,
'create_in_overlay': form.vars.create_in_overlay,
'edit_in_overlay': form.vars.edit_in_overlay,
'delete_in_overlay': form.vars.delete_in_overlay
})) }}
})) #}
{% endblock %}

{% block choice_field_mask_widget %}
Expand Down
Loading

0 comments on commit 788e97a

Please sign in to comment.