Skip to content

Commit

Permalink
Everything now truly works -> VALIDATED
Browse files Browse the repository at this point in the history
  • Loading branch information
Kylar13 committed May 18, 2016
1 parent 0ec085a commit 187dec5
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 71 deletions.
50 changes: 25 additions & 25 deletions app/Resources/views/default/view_profile.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -57,39 +57,17 @@
<li class="collection-item avatar">
<img src="{{ asset(comment.author.profilePicture) }}" alt="this is a handsome dude" class="circle">
<span class="title"><strong>{{ comment.title|upper }}</strong></span>
<p>by <a href="{{ path('profile', {'username': comment.author.username}) }}">{{ comment.author.username }}</a> {{ comment.author.username }} on {{ comment.getDateString }}<br>
<p>by <a href="{{ path('profile', {'username': comment.author.username}) }}">{{ comment.author.username }}</a> on {{ comment.getDateString }}<br>
<div class="card-panel orange-grey lighten-5 fr-view">
{{ comment.comment|raw }}
</div>
</p>
{% if is_granted("EDIT", comment) %}
<a href="{{ '#edit_'~comment.author.username }}" class="modal-trigger"><i class="material-icons right-margin2 secondary-content">mode_edit</i></a>
<a href="{{ '#edit_'~user.username }}" class="modal-trigger"><i class="material-icons right-margin2 secondary-content">mode_edit</i></a>
<a href="{{ '#del_'~comment.author.username }}" class="modal-trigger"><i class="material-icons red-text secondary-content">delete</i></a>
{% endif %}
</li>

<!-- Edit Modal Structure -->
<div id="{{ 'edit_'~comment.author.username }}" class="modal modal-fixed-footer">
<div class="modal-content">
<h4>Edit Comment</h4>
{{ form_start(formEdit)}}
<div class="col s6">
{{ form_row(formEdit.title) }}
</div>
<div class="col s12">
{{ form_row(formEdit.comment, {'label': ' '}, {'attr': {'length' : '500', 'class' : 'materialize-textarea white-text'}}) }}
</div>
<div class="col right top-margin3">
{{ form_row(formEdit.submit, { 'label': 'Submit' , 'attr': {'class': 'hidden'}}) }}
</div>
{{ form_end(formEdit) }}

</div>
<div class="modal-footer">
<a href="#!" onclick="submitEdit()" class=" modal-action modal-close waves-effect waves-green btn-flat">Send</a>
</div>
</div>

<!-- Delete Modal Structure -->

<div id="{{ 'del_'~comment.author.username }}" class="modal">
Expand All @@ -98,7 +76,7 @@
<p>Are you sure you want to delete this comment?</p>
</div>
<div class="modal-footer">
<a href="#!" class=" modal-action modal-close waves-effect waves-green btn-flat">Yes</a>
<a href="{{ path('delete_comment', {'username': user.username}) }}" class=" modal-action modal-close waves-effect waves-green btn-flat">Yes</a>
<a href="#!" class=" modal-action modal-close waves-effect waves-green btn-flat">No</a>
</div>
</div>
Expand Down Expand Up @@ -141,4 +119,26 @@
</div>
</div>

<!-- Edit Modal Structure -->
<div id="{{ 'edit_'~user.username }}" class="modal modal-fixed-footer">
<div class="modal-content">
<h4>Edit Comment</h4>
{{ form_start(formEdit)}}
<div class="col s6">
{{ form_row(formEdit.title) }}
</div>
<div class="col s12">
{{ form_row(formEdit.comment, {'label': ' '}, {'attr': {'length' : '500', 'class' : 'materialize-textarea white-text'}}) }}
</div>
<div class="col right top-margin3">
{{ form_row(formEdit.submit, { 'label': 'Submit' , 'attr': {'class': 'hidden'}}) }}
</div>
{{ form_end(formEdit) }}

</div>
<div class="modal-footer">
<a href="#!" onclick="submitEdit()" class=" modal-action modal-close waves-effect waves-green btn-flat">Send</a>
</div>
</div>

{% endblock %}
1 change: 1 addition & 0 deletions app/config/routing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ delete_comment:
_controller: AppBundle:Profile:deleteComment
_format: html
methods:
- GET
- POST

resend_email:
Expand Down
72 changes: 36 additions & 36 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions src/AppBundle/Controller/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,6 @@ public function showAction($username){
}
}

dump($userComment);
$canComment2 = false;
foreach($this->getUser()->getPurchases() as $purchase){
if($purchase->getProduct()->getOwner() == $user){
Expand All @@ -446,6 +445,7 @@ public function showAction($username){

$formCreate = $this->createForm(CommentType::class, $newComment, array('username' => $username));

dump($userComment);
$formEdit = $this->createForm(CommentType::class, $userComment, array('username' => $username,
'route' => 'edit_comment'));

Expand Down Expand Up @@ -530,10 +530,7 @@ public function deleteCommentAction($username){
}
}

dump($userComment);

if(!is_null($userComment)){
dump("Hallo");
$this->getDoctrine()->getManager()->remove($userComment);
$this->getDoctrine()->getManager()->flush();
}
Expand Down
7 changes: 4 additions & 3 deletions src/AppBundle/Entity/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ class Product

/**
* @var DateTime
* @Validator\Range(
* min="now"
* )
*
* @ORM\Column(name="expiring_date", type="datetime")
*/
Expand All @@ -83,9 +86,7 @@ class Product
/**
* @var string
*
* @Validator\Range(
* min="now"
* )
*
* @ORM\Column(name="picture", type="string", length=550)
*
*/
Expand Down
6 changes: 3 additions & 3 deletions src/AppBundle/Form/CommentType.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ public function __construct(UrlGeneratorInterface $router)
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->setAction($this->router->generate($options['route'], array('username' => $options['username'])))
->setMethod('POST')
->add('title', TextType::class)
->add('comment', FroalaEditorType::class)
->add('submit', SubmitType::class);
->add('submit', SubmitType::class)
->setAction($this->router->generate($options['route'], array('username' => $options['username'])))
->setMethod('POST');

}

Expand Down

0 comments on commit 187dec5

Please sign in to comment.