-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/1.5 load widget entities form in ajax #385
Merged
paulandrieux
merged 11 commits into
Victoire:1.5
from
Charlie-Lucas:feature/1.5-load-widget-entities-form-in-ajax
May 4, 2016
+192
−101
Merged
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
1e40ee6
only generate the static form and the widget businessEntityForm if ne…
Charlie-Lucas 3cd58b4
remove generation of all widget forms and render automatically the ed…
Charlie-Lucas d5de10a
create a new action entity to load the forms for a specific BE
Charlie-Lucas 559c841
display only the static or the widget BE form and be able to load the…
Charlie-Lucas 4c61d14
style CI fix
Charlie-Lucas e53568c
reorder request parameters
Charlie-Lucas 563cb2a
correct heritance of widgets
Charlie-Lucas e17e986
style CI fix
Charlie-Lucas fb81b45
fix behat tests
Charlie-Lucas 78edaf0
rename entityAction to partialFormAction
Charlie-Lucas db380fa
rename widget partial Form routes
Charlie-Lucas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
Bundle/CoreBundle/Resources/views/Widget/Form/_entity.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<ul class="vic-nav vic-nav-tabs vic-modal-nav-tabs"> | ||
<li class="{% if widget.mode == constant('MODE_ENTITY', widget) or widget.mode == constant('MODE_STATIC', widget) %}vic-active {% endif %}vic-seperate"><a href="#picker-{{ class|lower }}-entity" data-toggle="vic-tab">{{ ('form.widget.tab.picker.label')|trans({}, 'victoire') }}</a></li> | ||
<li{% if widget.mode == constant('MODE_QUERY', widget) %} class="vic-active"{% endif %}><a href="#picker-{{ class|lower }}-query" data-toggle="vic-tab">{{ ('form.widget.tab.query.label')|trans({}, 'victoire') }}</a></li> | ||
|
||
{% if is_business_entity_allowed(class|lower, view) %} | ||
<li{% if widget.mode == constant('MODE_BUSINESS_ENTITY', widget) %} class="vic-active"{% endif %}><a href="#picker-{{ class|lower }}-businessEntity" data-toggle="vic-tab">{{ ('form.widget.tab.entity_instance.label')|trans({}, 'victoire') }}</a></li> | ||
{% endif %} | ||
</ul> | ||
<div class="vic-tab-content vic-modal-tab-content"> | ||
{% for subForm in entityForms %} | ||
{{ subForm|raw }} | ||
{% endfor %} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -116,6 +116,48 @@ public function newAction($type, $viewReference, $slot = null, $position = null, | |
return $response; | ||
} | ||
|
||
/** | ||
* @param $widget | ||
* @param View $view | ||
* @param null $businessEntityId | ||
* @param null $namespace | ||
* @param null $position | ||
* @param null $parentWidgetMap | ||
* @param null $slot | ||
* | ||
* @return string | ||
* | ||
* @Route("/victoire-dcms/widget/entity/create/{viewReference}/{businessEntityId}/{type}/{slot}/{parentWidgetMap}/{position}", name="victoire_core_widget_entity_create", defaults={"widget_id":null, "slot":null, "businessEntityId":null, "position":null, "parentWidgetMap":null, "_format": "json"}) | ||
* @Route("/victoire-dcms/widget/entity/update/{viewReference}/{businessEntityId}/{type}/{widget_id}/{slot}/{parentWidgetMap}", name="victoire_core_widget_entity_edit", defaults={"widget_id":null, "slot":null, "businessEntityId":null, "position":null, "parentWidgetMap":null, "_format": "json"}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rename into victoire_widget_partialForm_create|update |
||
* @ParamConverter("widget", class="VictoireWidgetBundle:Widget", options={"id" = "widget_id"}) | ||
*/ | ||
public function entityAction($viewReference, $slot, $position, $parentWidgetMap, $businessEntityId, $type, Widget $widget = null) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Charlie-Lucas I don't understand this name, please try to find a better and more explicit name |
||
{ | ||
try { | ||
$view = $this->getViewByReferenceId($viewReference); | ||
|
||
if (!$reference = $this->get('victoire_view_reference.repository') | ||
->getOneReferenceByParameters(['id' => $viewReference])) { | ||
$reference = new ViewReference($viewReference); | ||
} | ||
$view->setReference($reference); | ||
$businessEntity = null; | ||
if ($businessEntityId) { | ||
$businessEntity = $this->get('victoire_core.helper.business_entity_helper')->findById($businessEntityId); | ||
} | ||
$new = $widget ? false : true; | ||
$response = new JsonResponse( | ||
$this->get('victoire_widget.widget_manager')->newEntityForms( | ||
$widget, $businessEntity, $type, $slot, $view, $position, $parentWidgetMap, $new | ||
) | ||
); | ||
} catch (Exception $ex) { | ||
$response = $this->getJsonReponseFromException($ex); | ||
} | ||
|
||
return $response; | ||
} | ||
|
||
/** | ||
* Create a widget. | ||
* This action needs 2 routes to handle the presence or not of "businessEntityId" and 'parentWidgetMap' | ||
|
@@ -197,13 +239,19 @@ public function editAction(Widget $widget, $viewReference, $mode = Widget::MODE_ | |
} | ||
$widget->setCurrentView($widgetView); | ||
$this->get('victoire_core.current_view')->setCurrentView($view); | ||
$businessEntity = null; | ||
$businessEntityId = $businessEntityId == null ? $widget->getBusinessEntityId() : $businessEntityId; | ||
if ($businessEntityId) { | ||
$businessEntity = $this->get('victoire_core.helper.business_entity_helper')->findById($businessEntityId); | ||
} | ||
|
||
try { | ||
$response = new JsonResponse( | ||
$this->get('widget_manager')->editWidget( | ||
$this->get('request'), | ||
$widget, | ||
$view, | ||
$businessEntityId, | ||
$businessEntity, | ||
$mode | ||
) | ||
); | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please rename into routeName