Skip to content
Snippets Groups Projects
Commit e8dd62db authored by Ghislain Loas's avatar Ghislain Loas
Browse files

Merge branch 'hotline#41579_module_formations_hs' into 'hotline-master'

Hotline#41579 module formations hs

See merge request !1661
parents 65c46a7a b48f62b0
3 merge requests!1677Hotline master,!1669Master,!1668Hotline master
- ticket #41579 : Boîte formations : Correction d'une erreur empêchant la sélection des formations à afficher
\ No newline at end of file
......@@ -16,15 +16,14 @@
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class ZendAfi_Form_Decorator_FormationSelector extends Zend_Form_Decorator_Abstract {
public function render($content) {
$helper = $this->_element
->getView()
->getHelper('TreeSelect');
$view = $this->_element->getView();
$helper = $view->getHelper('TreeSelect');
if (!$this->_element->isCategoriesSelectable())
$helper->categoriesNotSelectable();
......@@ -32,12 +31,11 @@ class ZendAfi_Form_Decorator_FormationSelector extends Zend_Form_Decorator_Abstr
return $helper->treeSelect($this->_element->getSelectedFormations(),
'',
true,
$this->_element->getView()->url(['module' => 'admin',
'controller' => 'formation',
'action' => 'get']),
$view->url(['module' => 'admin',
'controller' => 'formation',
'action' => 'get']),
'form',
null,
'selected_formations');
}
}
?>
\ No newline at end of file
}
\ No newline at end of file
......@@ -18,11 +18,9 @@
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
//////////////////////////////////////////////////////////////////////////////////////////////////////
// OPAC3 - Widget de sélection des catégories
//////////////////////////////////////////////////////////////////////////////////////////////////////
class ZendAfi_View_Helper_TreeSelect extends ZendAfi_View_Helper_BaseHelper {
protected
$_categories_selectable = true,
$_items_selectable = true,
......@@ -33,8 +31,8 @@ class ZendAfi_View_Helper_TreeSelect extends ZendAfi_View_Helper_BaseHelper {
$default_visibility,
$url_data_source,
$form_selector,
$input_id_categories_name = "id_categorie",
$input_id_items_name = "id_items"){
$input_id_categories_name = null,
$input_id_items_name = null){
$this->id_items = $this->_dedupe($id_items);
$this->id_categories = $this->_dedupe($id_categories);
......@@ -76,21 +74,24 @@ class ZendAfi_View_Helper_TreeSelect extends ZendAfi_View_Helper_BaseHelper {
protected function _renderContent() {
$url_icon = URL_ADMIN_IMG.'loading.gif';
$treeselect_classes = 'treeselect ' . $this->input_id_categories_name;
$url_icon = URL_ADMIN_IMG . 'loading.gif';
$treeselect_classes = 'treeselect ' . $this->_getInputIdCategoriesName();
return $this->_tag('div',
$this->view->tagImg($url_icon, ['alt' => $this->_('Chargement')]),
['class' => 'icon_loading'])
. $this->_tag('div', '', ['class' => trim($treeselect_classes),
'style' => 'display: none;'])
. $this->_tagInput(['type' => 'hidden',
'id' => $this->input_id_categories_name,
'name' => $this->input_id_categories_name,
'id' => $this->_getInputIdCategoriesName(),
'name' => $this->_getInputIdCategoriesName(),
'value' => $this->id_categories])
. $this->_tagInput(['type' => 'hidden',
'id' => $this->input_id_items_name,
'name' => $this->input_id_items_name,
'id' => $this->_getInputIdItemsName(),
'name' => $this->_getInputIdItemsName(),
'value' => $this->id_items]);
}
......@@ -100,18 +101,31 @@ class ZendAfi_View_Helper_TreeSelect extends ZendAfi_View_Helper_BaseHelper {
}
protected function _getInputIdCategoriesName() {
return $this->input_id_categories_name
? $this->input_id_categories_name : 'id_categorie';
}
protected function _getInputIdItemsName() {
return $this->input_id_items_name
? $this->input_id_items_name : 'id_items';
}
protected function _getJSTreeSelect(){
$js_id_items = str_replace('-', ',', $this->id_items);
$js_id_categories = str_replace('-', ',', $this->id_categories);
$js_default_visibility = $this->default_visibility ? "true" : "false";
$js_default_visibility = $this->default_visibility ? 'true' : 'false';
$input_id_categories_name = $this->_getInputIdCategoriesName();
$content = <<<CONTENT
var pack_ids = function(datas) {
return \$.map(datas, function(d){return d.id}).join('-');
};
var $this->input_id_categories_name = function(data){
var classes = '.treeselect.$this->input_id_categories_name';
var $input_id_categories_name = function(data){
var classes = '.treeselect.$input_id_categories_name';
\$(".icon_loading").fadeOut('fast', function(){\$(this).remove()});
\$(classes).
treeselect({ datas: data }).
......@@ -145,7 +159,7 @@ CONTENT;
\$(document).ready(function(){
\$.getJSON("$this->url_data_source",
function(data){
$this->input_id_categories_name(data)});
$input_id_categories_name(data)});
});
CONTENT;
......
......@@ -41,10 +41,17 @@ class Admin_AccueilControllerFormationsTestWithDefaultSettings extends Admin_Abs
/** @test */
public function treeselectFormationsBeDisplay() {
$this->assertXPath('//div[@class="treeselect"]');
$this->assertXPath('//div[@class="treeselect id_categorie"]');
}
/** @test **/
/** @test */
public function treeselectScriptShouldContainsSelectorOfTreeselectDiv() {
$this->assertXPathContentContains('//script', '.treeselect.id_categorie');
}
/** @test */
public function yearCategoriesShouldNotSelectable() {
$this->assertXPathContentContains('//script', 'categoriesNotSelectable');
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment