Skip to content

Commit 073ff97

Browse files
committed
Fix groupBy bug on captions
1 parent 393036e commit 073ff97

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

Ajax/semantic/html/collections/menus/HtmlMenu.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function setActiveItem($index) {
5353
}
5454

5555
private function getItemToInsert($item) {
56-
if ($item instanceof HtmlInput || $item instanceof HtmlImg || $item instanceof HtmlIcon || $item instanceof HtmlButtonGroups || $item instanceof HtmlButton || $item instanceof HtmlLabel) {
56+
if ($item instanceof HtmlInput || $item instanceof HtmlImg || $item instanceof HtmlIcon || $item instanceof HtmlButtonGroups || $item instanceof HtmlButton || $item instanceof HtmlLabel || $item instanceof HtmlDropdown) {
5757
$itemO=new HtmlMenuItem("item-" . $this->identifier . "-" . \sizeof($this->content) , $item);
5858
$itemO->addClass("no-active");
5959
$item=$itemO;
@@ -241,6 +241,6 @@ public function run(JsUtils $js){
241241
if($this->identifier!=="" && !isset($this->_bsComponent))
242242
$this->onClick('if(!$(this).hasClass("dropdown")&&!$(this).hasClass("no-active")){$(this).addClass("active").siblings().removeClass("active");}',false,false);
243243
$result= parent::run($js);
244-
return $result->setItemSelector(".item");
244+
return $result->setItemSelector(">.item");
245245
}
246246
}

Ajax/semantic/html/modules/HtmlDropdown.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ public function asSearch($name=NULL,$multiple=false,$selection=true){
287287
}
288288

289289
public function setSelect($name=NULL,$multiple=false){
290+
$this->_template='<%tagName% id="%identifier%" %properties%>%items%</%tagName%>';
290291
if(!isset($name))
291292
$name="select-".$this->identifier;
292293
$this->input=null;

Ajax/semantic/widgets/base/InstanceViewer.php

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
use Ajax\service\JString;
44
use Ajax\service\JArray;
55
use Ajax\service\JReflection;
6+
use Ubiquity\utils\base\UArray;
67

78
class InstanceViewer {
89
protected $widgetIdentifier;
@@ -312,29 +313,26 @@ public function getCaption($index){
312313

313314
public function getCaptions(){
314315
$hasGroupby=is_array($this->groupByFields);
315-
$count=$this->count()-$this->getGroupByFieldsCount();
316+
$count=$this->count();
317+
$moreAdded=false;
316318
if(isset($this->captions)){
317319
$captions= \array_values($this->captions);
320+
$gbSize=$hasGroupby?sizeof($this->groupByFields):0;
318321
$captionsSize=\sizeof($captions);
319-
for($i=$captionsSize;$i<$count;$i++){
322+
for($i=$captionsSize;$i<$count-$gbSize;$i++){
320323
$captions[]="";
324+
$moreAdded=true;
321325
}
322326
}else{
323327
$captions=[];
324328
$index=0;
325-
if(!$hasGroupby){
326-
while($index<$count){
327-
$captions[]=$this->getCaption($index++);
328-
}
329-
}else{
330-
while($index<$count){
331-
if($hasGroupby && array_search($index, $this->groupByFields)===false){
332-
$captions[]=$this->getCaption($index);
333-
}
334-
$index++;
335-
}
329+
while($index<$count){
330+
$captions[]=$this->getCaption($index++);
336331
}
337332
}
333+
if($hasGroupby && sizeof($captions)>=$count && !$moreAdded){
334+
$captions=UArray::removeByKeys($captions, $this->groupByFields);
335+
}
338336
if(isset($this->captionCallback) && \is_callable($this->captionCallback)){
339337
$callback=$this->captionCallback;
340338
$callback($captions,$this->instance);

0 commit comments

Comments
 (0)