parent
d091e50639
commit
f0f631a09e
@ -1,3 +1,5 @@ |
|||||||
mopa_bootstrap: |
mopa_bootstrap: |
||||||
form: ~ # Adds twig form theme support |
# form: # Adds twig form theme support |
||||||
|
# horizontal_label_class: 'aa' |
||||||
|
# horizontal_input_wrapper_class: 'dd' |
||||||
menu: ~ # enables twig helpers for menu |
menu: ~ # enables twig helpers for menu |
||||||
|
@ -0,0 +1,16 @@ |
|||||||
|
<?php |
||||||
|
/* For licensing terms, see /license.txt */ |
||||||
|
|
||||||
|
namespace Chamilo\CoreBundle\Entity\Repository; |
||||||
|
|
||||||
|
use Doctrine\Common\Collections\Criteria; |
||||||
|
use Doctrine\ORM\EntityRepository; |
||||||
|
use Gedmo\Tree\Entity\Repository\NestedTreeRepository; |
||||||
|
|
||||||
|
/** |
||||||
|
* Class ResourceNodeRepository |
||||||
|
* @package Chamilo\CoreBundle\Entity\Repository |
||||||
|
*/ |
||||||
|
class ResourceNodeRepository extends EntityRepository |
||||||
|
{ |
||||||
|
} |
@ -0,0 +1,71 @@ |
|||||||
|
<?php |
||||||
|
/* For licensing terms, see /license.txt */ |
||||||
|
|
||||||
|
namespace Chamilo\NotebookBundle\Form\Type; |
||||||
|
|
||||||
|
use Chamilo\CoreBundle\Entity\ToolResourceRights; |
||||||
|
use Symfony\Component\Form\AbstractType; |
||||||
|
use Symfony\Component\Form\FormBuilderInterface; |
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver; |
||||||
|
|
||||||
|
/** |
||||||
|
* Class ResourceLinkType |
||||||
|
* @package Chamilo\NotebookBundle\Form\Type |
||||||
|
*/ |
||||||
|
class ResourceLinkType extends AbstractType |
||||||
|
{ |
||||||
|
/** |
||||||
|
* {@inheritdoc} |
||||||
|
*/ |
||||||
|
public function buildForm(FormBuilderInterface $builder, array $options) |
||||||
|
{ |
||||||
|
$builder |
||||||
|
->add( |
||||||
|
'sharing', |
||||||
|
'choice', |
||||||
|
array( |
||||||
|
'choices' => array( |
||||||
|
'public' => 'Public', |
||||||
|
//'private' => 'Only me', |
||||||
|
'this_course' => 'This course', |
||||||
|
'another_course' => 'Another course', |
||||||
|
'user'=> 'User' |
||||||
|
), |
||||||
|
'attr' => array('class' => 'sharing_options') |
||||||
|
) |
||||||
|
) |
||||||
|
->add('search', 'hidden', array('attr' => array('class' => 'extra_hidden'))) |
||||||
|
->add( |
||||||
|
'mask', |
||||||
|
'choice', |
||||||
|
array('choices' => ToolResourceRights::getMaskList()) |
||||||
|
) |
||||||
|
/*->add( |
||||||
|
'rights', |
||||||
|
'collection', |
||||||
|
array( |
||||||
|
'type' => new ResourceRightsType(), |
||||||
|
'allow_add' => true, |
||||||
|
) |
||||||
|
)*/ |
||||||
|
; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* {@inheritdoc} |
||||||
|
*/ |
||||||
|
public function configureOptions(OptionsResolver $resolver) |
||||||
|
{ |
||||||
|
$resolver->setDefaults(array( |
||||||
|
'data_class' => 'Chamilo\CoreBundle\Entity\Resource\ResourceLink' |
||||||
|
)); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* {@inheritdoc} |
||||||
|
*/ |
||||||
|
public function getName() |
||||||
|
{ |
||||||
|
return 'chamilo_resource_link_type'; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,46 @@ |
|||||||
|
<?php |
||||||
|
/* For licensing terms, see /license.txt */ |
||||||
|
|
||||||
|
namespace Chamilo\NotebookBundle\Form\Type; |
||||||
|
|
||||||
|
use Symfony\Component\Form\AbstractType; |
||||||
|
use Symfony\Component\Form\FormBuilderInterface; |
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver; |
||||||
|
|
||||||
|
/** |
||||||
|
* Class ResourceNodeType |
||||||
|
* @package Chamilo\NotebookBundle\Form\Type |
||||||
|
*/ |
||||||
|
class ResourceNodeType extends AbstractType |
||||||
|
{ |
||||||
|
/** |
||||||
|
* {@inheritdoc} |
||||||
|
*/ |
||||||
|
public function buildForm(FormBuilderInterface $builder, array $options) |
||||||
|
{ |
||||||
|
$builder |
||||||
|
->add('tool') |
||||||
|
->add('links', 'collection', array( |
||||||
|
'type' =>new ResourceLinkType()) |
||||||
|
) |
||||||
|
; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* {@inheritdoc} |
||||||
|
*/ |
||||||
|
public function configureOptions(OptionsResolver $resolver) |
||||||
|
{ |
||||||
|
$resolver->setDefaults(array( |
||||||
|
'data_class' => 'Chamilo\CoreBundle\Entity\Resource\ResourceNode' |
||||||
|
)); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* {@inheritdoc} |
||||||
|
*/ |
||||||
|
public function getName() |
||||||
|
{ |
||||||
|
return 'chamilo_resource_node_type'; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,53 @@ |
|||||||
|
<?php |
||||||
|
/* For licensing terms, see /license.txt */ |
||||||
|
|
||||||
|
namespace Chamilo\NotebookBundle\Form\Type; |
||||||
|
|
||||||
|
use Chamilo\CoreBundle\Entity\ToolResourceRights; |
||||||
|
use Symfony\Component\Form\AbstractType; |
||||||
|
use Symfony\Component\Form\FormBuilderInterface; |
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver; |
||||||
|
|
||||||
|
/** |
||||||
|
* Class ResourceRightsType |
||||||
|
* @package Chamilo\NotebookBundle\Form\Type |
||||||
|
*/ |
||||||
|
class ResourceRightsType extends AbstractType |
||||||
|
{ |
||||||
|
/** |
||||||
|
* {@inheritdoc} |
||||||
|
*/ |
||||||
|
public function buildForm(FormBuilderInterface $builder, array $options) |
||||||
|
{ |
||||||
|
$builder |
||||||
|
->add( |
||||||
|
'role', |
||||||
|
'choice', |
||||||
|
array('choices' => ToolResourceRights::getDefaultRoles()) |
||||||
|
) |
||||||
|
->add( |
||||||
|
'mask', |
||||||
|
'choice', |
||||||
|
array('choices' => ToolResourceRights::getMaskList()) |
||||||
|
) |
||||||
|
; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* {@inheritdoc} |
||||||
|
*/ |
||||||
|
public function configureOptions(OptionsResolver $resolver) |
||||||
|
{ |
||||||
|
$resolver->setDefaults(array( |
||||||
|
'data_class' => 'Chamilo\CoreBundle\Entity\Resource\ResourceRights' |
||||||
|
)); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* {@inheritdoc} |
||||||
|
*/ |
||||||
|
public function getName() |
||||||
|
{ |
||||||
|
return 'chamilo_resource_rights_type'; |
||||||
|
} |
||||||
|
} |
@ -1,11 +1,141 @@ |
|||||||
|
<script> |
||||||
|
var $collectionHolder; |
||||||
|
|
||||||
|
// setup an "add a tag" link |
||||||
|
var $addTagLink = $('<a href="#" class="btn add_tag_link">Add option</a>'); |
||||||
|
var $newLinkLi = $('<li></li>').append($addTagLink); |
||||||
|
|
||||||
|
jQuery(document).ready(function() { |
||||||
|
// Get the ul that holds the collection of tags |
||||||
|
$collectionHolder = $('ul.tags'); |
||||||
|
|
||||||
|
// add the "add a tag" anchor and li to the tags ul |
||||||
|
$collectionHolder.append($newLinkLi); |
||||||
|
|
||||||
|
// count the current form inputs we have (e.g. 2), use that as the new |
||||||
|
// index when inserting a new item (e.g. 2) |
||||||
|
$collectionHolder.data('index', $collectionHolder.find(':input').length); |
||||||
|
|
||||||
|
$addTagLink.on('click', function(e) { |
||||||
|
// prevent the link from creating a "#" on the URL |
||||||
|
e.preventDefault(); |
||||||
|
|
||||||
|
// add a new tag form (see next code block) |
||||||
|
addTagForm($collectionHolder, $newLinkLi); |
||||||
|
}); |
||||||
|
}); |
||||||
|
|
||||||
|
function repoFormatResult(repo) { |
||||||
|
console.log(repo); |
||||||
|
var markup = '<div class="row-fluid">' + |
||||||
|
'<div class="span2"><img src="' + repo.owner.avatar_url + '" /></div>' + |
||||||
|
'<div class="span10">' + |
||||||
|
'<div class="row-fluid">' + |
||||||
|
'<div class="span6">' + repo.full_name + '</div>' + |
||||||
|
'<div class="span3"><i class="fa fa-code-fork"></i> ' + repo.forks_count + '</div>' + |
||||||
|
'<div class="span3"><i class="fa fa-star"></i> ' + repo.stargazers_count + '</div>' + |
||||||
|
'</div>'; |
||||||
|
|
||||||
|
if (repo.description) { |
||||||
|
markup += '<div>' + repo.description + '</div>'; |
||||||
|
} |
||||||
|
|
||||||
|
markup += '</div></div>'; |
||||||
|
|
||||||
|
return markup; |
||||||
|
} |
||||||
|
|
||||||
|
function addTagForm($collectionHolder, $newLinkLi) { |
||||||
|
// Get the data-prototype explained earlier |
||||||
|
var prototype = $collectionHolder.data('prototype'); |
||||||
|
|
||||||
|
// get the new index |
||||||
|
var index = $collectionHolder.data('index'); |
||||||
|
|
||||||
|
// Replace '__name__' in the prototype's HTML to |
||||||
|
// instead be a number based on how many items we have |
||||||
|
var newForm = prototype.replace(/__name__/g, index); |
||||||
|
|
||||||
|
// increase the index with one for the next item |
||||||
|
$collectionHolder.data('index', index + 1); |
||||||
|
|
||||||
|
// Display the form in the page in an li, before the "Add a tag" link li |
||||||
|
var $newFormLi = $('<li></li>').append(newForm); |
||||||
|
$newLinkLi.before($newFormLi); |
||||||
|
|
||||||
|
$('.sharing_options').on('change', function() { |
||||||
|
|
||||||
|
var inputId = this.id; |
||||||
|
var hiddenInput = inputId.replace("sharing", "search"); |
||||||
|
var field = $('#' + hiddenInput); |
||||||
|
var select2 = $('#s2id_' + hiddenInput); |
||||||
|
|
||||||
|
var url = ''; |
||||||
|
switch (this.value) { |
||||||
|
case 'another_course': |
||||||
|
field.show(); |
||||||
|
select2.show(); |
||||||
|
url = Routing.generate('chamilo_core_user_user_mycourses'); |
||||||
|
break; |
||||||
|
case 'user': |
||||||
|
field.show(); |
||||||
|
select2.show(); |
||||||
|
url = Routing.generate('chamilo_core_user_user_mycourses'); |
||||||
|
break; |
||||||
|
default: |
||||||
|
field.hide(); |
||||||
|
select2.hide(); |
||||||
|
break; |
||||||
|
} |
||||||
|
|
||||||
|
if (url != '') { |
||||||
|
field.select2({ |
||||||
|
tags: true, |
||||||
|
tokenSeparators: [',', ' '], |
||||||
|
ajax: { |
||||||
|
url: url, |
||||||
|
dataType: 'json', |
||||||
|
type: "GET", |
||||||
|
delay: 250, |
||||||
|
data: function (params) { |
||||||
|
return { |
||||||
|
q: params.term, // search term |
||||||
|
page: params.page |
||||||
|
}; |
||||||
|
}, |
||||||
|
results: function (data, page) { |
||||||
|
data = data.items; |
||||||
|
return { |
||||||
|
results: $.map(data, function (item) { |
||||||
|
return { |
||||||
|
text: item.title, |
||||||
|
slug: item.title, |
||||||
|
id: item.id |
||||||
|
} |
||||||
|
}) |
||||||
|
}; |
||||||
|
} |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
</script> |
||||||
|
|
||||||
<div class="box box-primary"> |
<div class="box box-primary"> |
||||||
<div class="box-header"> |
<div class="box-header"> |
||||||
<h3 class="box-title">Create</h3> |
<h3 class="box-title">Create</h3> |
||||||
</div> |
</div> |
||||||
<form method="post" action="{{ path('chamilo_notebook_new', {'course': course } ) }}"> |
<form method="post" action="{{ path('chamilo_notebook_new', {'course': course }) }}"> |
||||||
<div class="box-body"> |
<div class="box-body"> |
||||||
{{ form_widget(form) }} |
{{ form_start(form) }} |
||||||
|
|
||||||
|
{{ form_row(form.name) }} |
||||||
|
{{ form_row(form.description) }} |
||||||
|
|
||||||
|
<ul class="tags" data-prototype="{{ form_widget(form.rights.vars.prototype)|e }}"> |
||||||
|
</ul> |
||||||
|
{{ form_end(form) }} |
||||||
</div> |
</div> |
||||||
</form> |
</form> |
||||||
</div> |
|
||||||
</div> |
</div> |
||||||
|
Loading…
Reference in new issue