Skip to content

Commit

Permalink
🔨 #292 BASE melhorando componente
Browse files Browse the repository at this point in the history
  • Loading branch information
bjverde committed Jan 28, 2024
1 parent 151cac0 commit 99421ee
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ class TFormDinRichTextEditor extends TFormDinGenericField
private $showCountChar;
private $intMaxLength;

private THtmlEditor $adiantiObjRichEditor; //Somente obj Adianti Customizada
private $adiantiObjFull; //obj Adianti completo com todos os elementos para fazer o memo

/**
Expand All @@ -28,8 +27,8 @@ class TFormDinRichTextEditor extends TFormDinGenericField
* @return TFormDinRichTextEditor
*/
public function __construct($id
,$label
,$intMaxLength
,string $label
,int|NULL $intMaxLength
,$boolRequired=null
,$intColumns='100%'
,$intRows='100%'
Expand All @@ -38,66 +37,13 @@ public function __construct($id
,$boolShowCountChar=false
)
{
TScript::importFromFile('app/lib/widget/FormDin5/javascript/FormDin5RichEditor.js?appver='.FormDinHelper::version());
$this->setAdiantiObjRichEditor($id);
parent::__construct($this->getAdiantiObjRichEditor(),$id,$label,$boolRequired,$value,$placeholder);
$this->setSize($intColumns, $intRows);
$this->setMaxLength($label,$intMaxLength);

$this->setAdiantiObjTFull($id,$boolShowCountChar,$intMaxLength);

$adiantiObj = new THtmlEditor($label);
parent::__construct($adiantiObj,$id,$label,$boolRequired,$value,$placeholder);
$this->setMaxLength($label,$intMaxLength);
//$this->setSize($intColumns, $intRows);
return $this->getAdiantiObj();
}

public function setAdiantiObjRichEditor($id){
$this->adiantiObjRichEditor = new THtmlEditor($id);
}

public function getAdiantiObjRichEditor(): THtmlEditor {
return $this->adiantiObjRichEditor;
}

private function setAdiantiObjTFull( $idField, $boolShowCountChar,$intMaxLength )
{
$adiantiObjRichEditor = $this->getAdiantiObjRichEditor();
$adiantiObj = null;
$div = new TElement('div');
$div->add($adiantiObjRichEditor);

TScript::create( " setToolBarRichEditor('{$adiantiObjRichEditor->id}', [
['style', ['bold', 'italic', 'underline', 'clear']],
['font', ['strikethrough', 'superscript', 'subscript']],
['fontsize', ['fontsize']],
['color', ['color']],
['para', ['ul', 'ol', 'paragraph']],
['height', ['height']]
]); " );

if( $boolShowCountChar && ($intMaxLength>=1) ){
$adiantiObjRichEditor->maxlength = $intMaxLength;
$adiantiObjRichEditor->setId($idField);

$charsText = new TElement('span');
$charsText->setProperty('id',$idField.'_counter');
$charsText->setProperty('name',$idField.'_counter');
$charsText->setProperty('class', 'tformdinmemo_counter');
$charsText->add('caracteres: 0 / '.$intMaxLength);


$div->add($charsText);
$div->add($script);


}
$adiantiObj = $div;

$this->adiantiObjFull = $adiantiObj;
}

public function getAdiantiObjFull(){
return $this->adiantiObjFull;
}

/**
* Seta o tamanho maximo do campo
* @param string $label - 01 nome do campo
Expand All @@ -108,6 +54,7 @@ public function setMaxLength($label,$intMaxLength)
{
$this->intMaxLength = (int) $intMaxLength;
if($intMaxLength>=1){
$this->getAdiantiObj()->setMaxLength($intMaxLength);
$this->getAdiantiObj()->addValidation($label, new TMaxLengthValidator, array($intMaxLength));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ public function addMemoField(string $strName
*/
public function addRichTextEditor(string $id
, string $label
, int $intMaxLength
, int|null $intMaxLength
, $boolRequired=null
, $intColumns=null
, $intRows=null
Expand All @@ -861,8 +861,8 @@ public function addRichTextEditor(string $id
,$boolLabelAbove
,$boolNoWrapLabel
);
$objField = $formField->getAdiantiObjFull();
$label = $formField->getLabel();
$objField = $formField->getAdiantiObj();
$label = $formField->getLabel();
$this->addElementFormList($objField,self::TYPE_FIELD,$label,$boolNewLine,$boolLabelAbove);
return $formField;
}
Expand Down

0 comments on commit 99421ee

Please sign in to comment.