Commit 006a31f9 authored by Laurent's avatar Laurent
Browse files

hotline #69403 : fix add album to record in frontoffice

parent f2698065
- ticket #69403 : Catalogue : correction de l'ajout d'un album à partir d'une notice en front
\ No newline at end of file
......@@ -118,10 +118,8 @@ class Class_Album extends Storm_Model_Abstract {
protected $_default_attribute_values = ['notice_id' => null,
'titre' => '',
'sous_titre' => '',
'editeur' => '',
'fichier' => '',
'pdf' => '',
'auteur' => '',
'description' => '',
'date_maj' => '',
'genre' => '',
......
......@@ -399,10 +399,10 @@ class ZendAfi_Controller_Plugin_Manager_Album extends ZendAfi_Controller_Plugin_
/**
* @param Class_Album $album
* @param ZendAfi_Form_Album $form
* @return null
*/
public function _validateAndSaveAlbum($album) {
$form = $this->_albumForm($album);
protected function _validateAndSaveAlbum($album, $form) {
$this->_view->form = $form;
if (
......@@ -493,11 +493,12 @@ class ZendAfi_Controller_Plugin_Manager_Album extends ZendAfi_Controller_Plugin_
* @param string $titre
*/
protected function _renderAlbumForm($album, $titre) {
if ($this->_validateAndSaveAlbum($album))
$form = $this->_albumForm($album);
if ($this->_validateAndSaveAlbum($album, $form))
return $this->_redirectToEdit($album);;
$this->_view->titre = $titre;
$this->_view->errors = $album->getErrors();
$this->_view->errors = $form->getErrors();
$this->_view->album = $album;
$this->_view->form->getElement('fichier')
->setValue($album->getFichier());
......
......@@ -33,13 +33,13 @@ class ZendAfi_View_Helper_Admin_RenderForm extends ZendAfi_View_Helper_RenderFor
if ('true' == $form->getAttrib('data-disable-onchange'))
$this->view->disable_onchange = true;
$this->_tabify($form);
$this->_customizeRendering();
$content = parent::renderForm($form, $buttons);
return parent::renderForm($form, $buttons);
}
$this->_tabify($form);
return $content;
}
protected function _tabify($form) {
......
......@@ -15,6 +15,10 @@
background: var(--main-background);
}
.admin-form .errors {
color: var(--error-text);
}
.admin-form input {
height: auto;
width: auto;
......
......@@ -3169,6 +3169,24 @@ class Admin_AlbumControllerAddAlbumToAjaxPostNoVisibleTest extends Admin_AlbumCo
}
/**
* @test
* @expectedException Storm_Model_Exception
* */
public function albumShouldNotHaveEditorField() {
Class_Album::findFirstBy(['titre' => 'Dark'])->getEditeur();
}
/**
* @test
* @expectedException Storm_Model_Exception
* */
public function albumShouldNotHaveAuteurField() {
Class_Album::findFirstBy(['titre' => 'Dark'])->getAuteur();
}
/** @test */
public function darkAlbumShouldBeSaved() {
$this->assertNotNull(Class_Album::findFirstBy(['titre' => 'Dark']));
......@@ -3184,6 +3202,40 @@ class Admin_AlbumControllerAddAlbumToAjaxPostNoVisibleTest extends Admin_AlbumCo
class Admin_AlbumControllerAddAlbumToAjaxWithErrorsTest extends Admin_AlbumControllerTestCase {
/** @test */
public function withoutTitleShouldDisplayError() {
$this->postDispatch('/admin/album/link_album_to/id_notice/8',
['titre' => '',
'visible' => '0',
'status' => Class_Album::STATUS_VALIDATED,
'type_doc_id' => 100,
'frbr_type' => ['1:source'],
'frbr_url' => [Class_Url::siteUrl().'/admin/recherche/viewnotice/id_notice/8/clef/DIAMANTSEMPOISONNES--HENRYA--PAYOT-2007-1/id/8']], true);
$this->assertXPathContentContains('//ul[@class="errors"]/li',
'Une valeur est requise',
$this->_response->getBody());
}
/** @test */
public function withoutFrbrTypeShouldDisplayError() {
$this->postDispatch('/admin/album/link_album_to/id_notice/8',
['titre' => 'Dark chocolate',
'visible' => '0',
'status' => Class_Album::STATUS_VALIDATED,
'type_doc_id' => 100,
'frbr_type' => [''],
'frbr_url' => [Class_Url::siteUrl().'/admin/recherche/viewnotice/id_notice/8/clef/DIAMANTSEMPOISONNES--HENRYA--PAYOT-2007-1/id/8']], true);
$this->assertXPathContentContains('//script',
'Un champ de cette ligne ne peut \\u00eatre vide',
$this->_response->getBody());
}
}
class Admin_AlbumControllerConfigActionTest extends Admin_AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;
......
Markdown is supported
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