Skip to content

Commit 21fb759

Browse files
committed
Add toggle for DataElement
1 parent af34697 commit 21fb759

File tree

5 files changed

+11
-4
lines changed

5 files changed

+11
-4
lines changed

Ajax/common/traits/JsUtilsAjaxTrait.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,7 @@ private function _postForm($url, $form, $responseElement, $parameters=[]) {
471471
$async=($async)?"true":"false";
472472
$jsCallback=isset($jsCallback) ? $jsCallback : "";
473473
$retour=$this->_getAjaxUrl($url, $attr);
474+
$retour.="\n$('#".$form."').trigger('ajaxSubmit');";
474475
$retour.="\nvar params=$('#".$form."').serialize();\n";
475476
if(isset($params)){
476477
$retour.="params+='&'+".self::_correctParams($params).";\n";

Ajax/semantic/html/collections/form/traits/FormTrait.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,9 @@ protected function _buttonAsSubmit(BaseHtml &$button,$event,$url,$responseElemen
121121
public function setSubmitParams($url,$responseElement=NULL,$parameters=NULL){
122122
$form=$this->getForm();
123123
$params=["form"=>$form->getIdentifier(),"responseElement"=>$responseElement,"url"=>$url,"stopPropagation"=>true];
124-
if(\is_array($parameters))
124+
if(\is_array($parameters)){
125125
$params=\array_merge($params,$parameters);
126+
}
126127
$form->addValidationParam("_ajaxSubmit", new AjaxCall("postForm", $params));
127128
return $this;
128129
}

Ajax/semantic/html/elements/HtmlButton.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,9 @@ public function setNegative() {
165165
* formatted to toggle on/off
166166
* @return HtmlButton
167167
*/
168-
public function setToggle() {
168+
public function setToggle($active="") {
169169
$this->onCreate("$('#".$this->identifier."').state();");
170-
return $this->addToProperty("class", "toggle");
170+
return $this->addToProperty("class", "toggle ".$active);
171171
}
172172

173173
/**

Ajax/semantic/widgets/base/InstanceViewer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ protected function _getValue($property,$index){
9999
if($property instanceof \ReflectionProperty){
100100
$value=$this->_getPropertyValue($property);
101101
$propertyName=$property->getName();
102-
}elseif(\is_callable($property))
102+
}elseif(\is_callable($property) && array_search($property, ["system"])===false)
103103
$value=$property($this->instance);
104104
elseif(\is_array($property)){
105105
$values=\array_map(function($v) use ($index){return $this->_getValue($v, $index);}, $property);

Ajax/semantic/widgets/dataelement/DataElement.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,9 @@ public function setColWidths($widths){
120120
$this->_colWidths=$widths;
121121
return $this;
122122
}
123+
124+
public function run(JsUtils $js){
125+
$js->execOn("click", ".ui.toggle", 'var active=$(this).hasClass("active");$(this).children("i").toggleClass("up",active).toggleClass("down",!active);$(this).closest("td").next("td").children().toggle(active);');
126+
parent::run($js);
127+
}
123128
}

0 commit comments

Comments
 (0)