Skip to content

Commit 872df95

Browse files
committed
HtmlDropdown + combo buttongroups
1 parent 8f54ccd commit 872df95

File tree

4 files changed

+37
-7
lines changed

4 files changed

+37
-7
lines changed

Ajax/common/html/BaseHtml.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ protected function removeOldValues(&$oldValue, $allValues) {
104104

105105
protected function _getElementBy($callback,$elements){
106106
if (\is_array($elements)) {
107+
$elements=\array_values($elements);
107108
$flag=false;
108109
$index=0;
109110
while ( !$flag && $index < sizeof($elements) ) {

Ajax/semantic/html/elements/HtmlButtonGroups.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Ajax\semantic\html\base\HtmlSemDoubleElement;
66
use Ajax\semantic\html\base\HtmlSemCollection;
77
use Ajax\JsUtils;
8+
use Ajax\semantic\html\modules\HtmlDropdown;
89

910
/**
1011
* Semantic UI Buttongroups component
@@ -24,6 +25,16 @@ protected function createItem($value){
2425
return new HtmlButton("", $value);
2526
}
2627

28+
public function addDropdown($items,$asCombo=false){
29+
$dd= new HtmlDropdown("dd-".$this->identifier,null,$items);
30+
$dd->asButton();
31+
if($asCombo){
32+
$dd->setAction("combo");
33+
$dd->addToProperty("class", "combo");
34+
}
35+
return $this->addElement($dd);
36+
}
37+
2738

2839
public function addElement($element, $asIcon=false) {
2940
$item=$this->addItem($element);

Ajax/semantic/html/modules/HtmlDropdown.php

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,15 @@ public function __construct($identifier, $value="", $items=array(),$associative=
2828
parent::__construct($identifier, "div");
2929
$this->_template=include dirname(__FILE__).'/../templates/tplDropdown.php';
3030
$this->setProperty("class", "ui dropdown");
31-
$content=new HtmlSemDoubleElement("text-".$this->identifier,"div");
32-
$content->setClass("text");
33-
$this->setValue($value);
34-
$content->wrap("",new HtmlIcon("", "dropdown"));
35-
$this->content=array($content);
31+
$content=[];
32+
if(isset($value)){
33+
$text=new HtmlSemDoubleElement("text-".$this->identifier,"div");
34+
$text->setClass("text");
35+
$content=[$text];
36+
$this->setValue($value);
37+
}
38+
$content["arrow"]=new HtmlIcon("", "dropdown");
39+
$this->content=$content;
3640
$this->tagName="div";
3741
$this->_associative=$associative;
3842
$this->addItems($items);
@@ -53,6 +57,7 @@ public function addItem($item,$value=NULL,$image=NULL,$description=NULL){
5357
}
5458

5559
public function addIcon($icon,$before=true,$labeled=false){
60+
$this->removeArrow();
5661
$this->addIconP($icon,$before,$labeled);
5762
return $this->getElementById("text-".$this->identifier, $this->content)->setWrapAfter("");
5863
}
@@ -79,6 +84,13 @@ public function insertItem($item,$position=0){
7984
return $itemO;
8085
}
8186

87+
protected function removeArrow(){
88+
if(\sizeof($this->content)>1){
89+
unset($this->content["arrow"]);
90+
$this->content=\array_values($this->content);
91+
}
92+
}
93+
8294
protected function beforeAddItem($item,$value=NULL,$image=NULL,$description=NULL){
8395
$itemO=$item;
8496
if(\is_array($item)){
@@ -205,6 +217,7 @@ public function setSimple(){
205217
}
206218

207219
public function asButton($floating=false){
220+
$this->removeArrow();
208221
if($floating)
209222
$this->addToProperty("class", "floating");
210223
$this->removePropertyValue("class", "selection");
@@ -308,5 +321,7 @@ public function compile(JsUtils $js=NULL, &$view=NULL) {
308321
public function getInput() {
309322
return $this->input;
310323
}
311-
324+
public function addAction($action, $direction=Direction::RIGHT, $icon=NULL, $labeled=false) {
325+
return $this->_addAction($this, $action,$direction,$icon,$labeled);
326+
}
312327
}

Ajax/semantic/widgets/datatable/DataTable.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,10 @@ protected function _associatePaginationBehavior(HtmlMenu $menu,JsUtils $js=NULL)
202202
}
203203

204204
protected function _getFieldName($index){
205-
return parent::_getFieldName($index)."[]";
205+
$fieldName=parent::_getFieldName($index);
206+
if(\is_object($fieldName))
207+
$fieldName="field-".$index;
208+
return $fieldName."[]";
206209
}
207210

208211
protected function _getFieldCaption($index){

0 commit comments

Comments
 (0)