@@ -36,6 +36,10 @@ discard block |
||
| 36 | 36 | protected $_targetSelector; |
| 37 | 37 | protected $_checkedMessage; |
| 38 | 38 | |
| 39 | + /** |
|
| 40 | + * @param string $identifier |
|
| 41 | + * @param string $model |
|
| 42 | + */ |
|
| 39 | 43 | public function __construct($identifier,$model,$modelInstance=NULL) { |
| 40 | 44 | parent::__construct($identifier, $model,$modelInstance); |
| 41 | 45 | $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0,0), false); |
@@ -75,6 +79,9 @@ discard block |
||
| 75 | 79 | if(allChecked) {\$parentCheckbox.checkbox('set checked');}else if(allUnchecked){\$parentCheckbox.checkbox('set unchecked');}else{\$parentCheckbox.checkbox('set indeterminate');};".$checkedMessageCall); |
| 76 | 80 | } |
| 77 | 81 | |
| 82 | + /** |
|
| 83 | + * @param string $op |
|
| 84 | + */ |
|
| 78 | 85 | protected function _generateBehavior($op,JsUtils $js){ |
| 79 | 86 | if(isset($this->_urls[$op])) |
| 80 | 87 | $js->getOnClick("#".$this->identifier." .".$op, $this->_urls[$op],$this->getTargetSelector(),["preventDefault"=>false,"attr"=>"data-ajax"]); |
@@ -210,6 +217,9 @@ discard block |
||
| 210 | 217 | return $this; |
| 211 | 218 | } |
| 212 | 219 | |
| 220 | + /** |
|
| 221 | + * @param PositionInTable $part |
|
| 222 | + */ |
|
| 213 | 223 | private function addToolbarRow($part,$table,$captions){ |
| 214 | 224 | $hasPart=$table->hasPart($part); |
| 215 | 225 | if($hasPart){ |
@@ -310,6 +320,9 @@ discard block |
||
| 310 | 320 | }, $index,$attributes); |
| 311 | 321 | } |
| 312 | 322 | |
| 323 | + /** |
|
| 324 | + * @param HtmlButton $element |
|
| 325 | + */ |
|
| 313 | 326 | protected function _visibleOver($element){ |
| 314 | 327 | $this->_visibleHover=true; |
| 315 | 328 | return $element->addToProperty("class", "visibleover")->setProperty("style","visibility:hidden;"); |
@@ -50,10 +50,12 @@ discard block |
||
| 50 | 50 | $js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');",["preventDefault"=>false,"stopPropagation"=>true]); |
| 51 | 51 | $js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');",["preventDefault"=>false,"stopPropagation"=>true]); |
| 52 | 52 | } |
| 53 | - if($this->_hasDelete) |
|
| 54 | - $this->_generateBehavior("delete", $js); |
|
| 55 | - if($this->_hasEdit) |
|
| 56 | - $this->_generateBehavior("edit", $js); |
|
| 53 | + if($this->_hasDelete) { |
|
| 54 | + $this->_generateBehavior("delete", $js); |
|
| 55 | + } |
|
| 56 | + if($this->_hasEdit) { |
|
| 57 | + $this->_generateBehavior("edit", $js); |
|
| 58 | + } |
|
| 57 | 59 | return parent::run($js); |
| 58 | 60 | } |
| 59 | 61 | |
@@ -76,8 +78,9 @@ discard block |
||
| 76 | 78 | } |
| 77 | 79 | |
| 78 | 80 | protected function _generateBehavior($op,JsUtils $js){ |
| 79 | - if(isset($this->_urls[$op])) |
|
| 80 | - $js->getOnClick("#".$this->identifier." .".$op, $this->_urls[$op],$this->getTargetSelector(),["preventDefault"=>false,"attr"=>"data-ajax"]); |
|
| 81 | + if(isset($this->_urls[$op])) { |
|
| 82 | + $js->getOnClick("#".$this->identifier." .".$op, $this->_urls[$op],$this->getTargetSelector(),["preventDefault"=>false,"attr"=>"data-ajax"]); |
|
| 83 | + } |
|
| 81 | 84 | } |
| 82 | 85 | |
| 83 | 86 | /** |
@@ -102,12 +105,14 @@ discard block |
||
| 102 | 105 | |
| 103 | 106 | $table->setRowCount(0, \sizeof($captions)); |
| 104 | 107 | $table->setHeaderValues($captions); |
| 105 | - if(isset($this->_compileParts)) |
|
| 106 | - $table->setCompileParts($this->_compileParts); |
|
| 108 | + if(isset($this->_compileParts)) { |
|
| 109 | + $table->setCompileParts($this->_compileParts); |
|
| 110 | + } |
|
| 107 | 111 | |
| 108 | 112 | if(isset($this->_searchField) && isset($js)){ |
| 109 | - if(isset($this->_urls["refresh"])) |
|
| 110 | - $this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
| 113 | + if(isset($this->_urls["refresh"])) { |
|
| 114 | + $this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
| 115 | + } |
|
| 111 | 116 | } |
| 112 | 117 | |
| 113 | 118 | $this->_generateContent($table); |
@@ -132,8 +137,9 @@ discard block |
||
| 132 | 137 | private function _generateMainCheckbox(&$captions){ |
| 133 | 138 | $ck=new HtmlCheckbox("main-ck-".$this->identifier,""); |
| 134 | 139 | $checkedMessageCall=""; |
| 135 | - if($this->_hasCheckedMessage) |
|
| 136 | - $checkedMessageCall="updateChecked();"; |
|
| 140 | + if($this->_hasCheckedMessage) { |
|
| 141 | + $checkedMessageCall="updateChecked();"; |
|
| 142 | + } |
|
| 137 | 143 | $ck->setOnChecked("$('#".$this->identifier." [name=%quote%selection[]%quote%]').prop('checked',true);".$checkedMessageCall); |
| 138 | 144 | $ck->setOnUnchecked("$('#".$this->identifier." [name=%quote%selection[]%quote%]').prop('checked',false);".$checkedMessageCall); |
| 139 | 145 | \array_unshift($captions, $ck); |
@@ -170,8 +176,9 @@ discard block |
||
| 170 | 176 | $menu->floatRight(); |
| 171 | 177 | $menu->setActiveItem($this->_pagination->getPage()-1); |
| 172 | 178 | $footer->setValues($menu); |
| 173 | - if(isset($this->_urls["refresh"])) |
|
| 174 | - $menu->postOnClick($this->_urls["refresh"],"{'p':$(this).attr('data-page')}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
| 179 | + if(isset($this->_urls["refresh"])) { |
|
| 180 | + $menu->postOnClick($this->_urls["refresh"],"{'p':$(this).attr('data-page')}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
| 181 | + } |
|
| 175 | 182 | } |
| 176 | 183 | |
| 177 | 184 | protected function _getFieldName($index){ |
@@ -214,7 +221,7 @@ discard block |
||
| 214 | 221 | $hasPart=$table->hasPart($part); |
| 215 | 222 | if($hasPart){ |
| 216 | 223 | $row=$table->getPart($part)->addRow(\sizeof($captions)); |
| 217 | - }else{ |
|
| 224 | + } else{ |
|
| 218 | 225 | $row=$table->getPart($part)->getRow(0); |
| 219 | 226 | } |
| 220 | 227 | $row->mergeCol(); |
@@ -239,7 +246,7 @@ discard block |
||
| 239 | 246 | $this->_urls["refresh"]=JArray::getValue($urls, "refresh",0); |
| 240 | 247 | $this->_urls["edit"]=JArray::getValue($urls, "edit",1); |
| 241 | 248 | $this->_urls["delete"]=JArray::getValue($urls, "delete",2); |
| 242 | - }else{ |
|
| 249 | + } else{ |
|
| 243 | 250 | $this->_urls=["refresh"=>$urls,"edit"=>$urls,"delete"=>$urls]; |
| 244 | 251 | } |
| 245 | 252 | return $this; |
@@ -304,8 +311,9 @@ discard block |
||
| 304 | 311 | return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle,$index,$attributes){ |
| 305 | 312 | $button=new HtmlButton($id,$value,$cssStyle); |
| 306 | 313 | $button->postOnClick($url,"$(event.target).closest('tr').find(':input').serialize()",$responseElement,$attributes["ajax"]); |
| 307 | - if(!isset($attributes["visibleHover"]) || $attributes["visibleHover"]) |
|
| 308 | - $this->_visibleOver($button); |
|
| 314 | + if(!isset($attributes["visibleHover"]) || $attributes["visibleHover"]) { |
|
| 315 | + $this->_visibleOver($button); |
|
| 316 | + } |
|
| 309 | 317 | return $button; |
| 310 | 318 | }, $index,$attributes); |
| 311 | 319 | } |
@@ -317,8 +325,9 @@ discard block |
||
| 317 | 325 | |
| 318 | 326 | protected function getTargetSelector() { |
| 319 | 327 | $result=$this->_targetSelector; |
| 320 | - if(!isset($result)) |
|
| 321 | - $result="#".$this->identifier; |
|
| 328 | + if(!isset($result)) { |
|
| 329 | + $result="#".$this->identifier; |
|
| 330 | + } |
|
| 322 | 331 | return $result; |
| 323 | 332 | } |
| 324 | 333 | |
@@ -356,8 +365,9 @@ discard block |
||
| 356 | 365 | * @param callable $callback |
| 357 | 366 | */ |
| 358 | 367 | public function addCountCheckedInToolbar(array $checkedMessage=null,$callback=null){ |
| 359 | - if(isset($checkedMessage)) |
|
| 360 | - $this->_checkedMessage=$checkedMessage; |
|
| 368 | + if(isset($checkedMessage)) { |
|
| 369 | + $this->_checkedMessage=$checkedMessage; |
|
| 370 | + } |
|
| 361 | 371 | $checkedMessage=$this->getCheckedMessage(); |
| 362 | 372 | $this->_hasCheckboxes=true; |
| 363 | 373 | $this->_hasCheckedMessage=true; |
@@ -11,14 +11,27 @@ discard block |
||
| 11 | 11 | * @property InstanceViewer $_instanceViewer |
| 12 | 12 | */ |
| 13 | 13 | trait DataTableFieldAsTrait{ |
| 14 | + |
|
| 15 | + /** |
|
| 16 | + * @param \Closure $field |
|
| 17 | + */ |
|
| 14 | 18 | abstract public function addField($field); |
| 19 | + |
|
| 20 | + /** |
|
| 21 | + * @param integer $index |
|
| 22 | + * @param \Closure $field |
|
| 23 | + */ |
|
| 15 | 24 | abstract public function insertField($index,$field); |
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * @param \Closure $field |
|
| 28 | + */ |
|
| 16 | 29 | abstract public function insertInField($index,$field); |
| 17 | 30 | /** |
| 18 | 31 | * @param string $caption |
| 19 | 32 | * @param callable $callback |
| 20 | 33 | * @param boolean $visibleHover |
| 21 | - * @return callable |
|
| 34 | + * @return \Closure |
|
| 22 | 35 | */ |
| 23 | 36 | private function getFieldButtonCallable($caption,$visibleHover=true,$callback=null){ |
| 24 | 37 | return $this->getCallable("getFieldButton",[$caption,$visibleHover],$callback); |
@@ -28,7 +41,7 @@ discard block |
||
| 28 | 41 | * @param callable $thisCallback |
| 29 | 42 | * @param array $parameters |
| 30 | 43 | * @param callable $callback |
| 31 | - * @return callable |
|
| 44 | + * @return \Closure |
|
| 32 | 45 | */ |
| 33 | 46 | private function getCallable($thisCallback,$parameters,$callback=null){ |
| 34 | 47 | $result=function($instance) use($thisCallback,$parameters,$callback){ |
@@ -66,7 +79,7 @@ discard block |
||
| 66 | 79 | * @param string $caption |
| 67 | 80 | * @param callable $callback |
| 68 | 81 | * @param boolean $visibleHover |
| 69 | - * @return \Ajax\semantic\widgets\datatable\DataTable |
|
| 82 | + * @return DataTableFieldAsTrait |
|
| 70 | 83 | */ |
| 71 | 84 | public function addFieldButton($caption,$visibleHover=true,$callback=null){ |
| 72 | 85 | $this->addField($this->getCallable("getFieldButton",[$caption,$visibleHover],$callback)); |
@@ -78,7 +91,7 @@ discard block |
||
| 78 | 91 | * @param int $index |
| 79 | 92 | * @param string $caption |
| 80 | 93 | * @param callable $callback |
| 81 | - * @return \Ajax\semantic\widgets\datatable\DataTable |
|
| 94 | + * @return DataTableFieldAsTrait |
|
| 82 | 95 | */ |
| 83 | 96 | public function insertFieldButton($index,$caption,$visibleHover=true,$callback=null){ |
| 84 | 97 | $this->insertField($index, $this->getFieldButtonCallable($caption,$visibleHover,$callback)); |
@@ -90,18 +103,26 @@ discard block |
||
| 90 | 103 | * @param int $index |
| 91 | 104 | * @param string $caption |
| 92 | 105 | * @param callable $callback |
| 93 | - * @return \Ajax\semantic\widgets\datatable\DataTable |
|
| 106 | + * @return DataTableFieldAsTrait |
|
| 94 | 107 | */ |
| 95 | 108 | public function insertInFieldButton($index,$caption,$visibleHover=true,$callback=null){ |
| 96 | 109 | $this->insertInField($index, $this->getFieldButtonCallable($caption,$visibleHover,$callback)); |
| 97 | 110 | return $this; |
| 98 | 111 | } |
| 99 | 112 | |
| 113 | + /** |
|
| 114 | + * @param string $icon |
|
| 115 | + * @param string $class |
|
| 116 | + */ |
|
| 100 | 117 | private function addDefaultButton($icon,$class=null,$visibleHover=true,$callback=null){ |
| 101 | 118 | $this->addField($this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback)); |
| 102 | 119 | return $this; |
| 103 | 120 | } |
| 104 | 121 | |
| 122 | + /** |
|
| 123 | + * @param string $icon |
|
| 124 | + * @param string $class |
|
| 125 | + */ |
|
| 105 | 126 | private function insertDefaultButtonIn($index,$icon,$class=null,$visibleHover=true,$callback=null){ |
| 106 | 127 | $this->insertInField($index,$this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback)); |
| 107 | 128 | return $this; |
@@ -56,8 +56,9 @@ discard block |
||
| 56 | 56 | */ |
| 57 | 57 | private function getFieldButton($caption,$visibleHover=true){ |
| 58 | 58 | $bt= new HtmlButton("",$caption); |
| 59 | - if($visibleHover) |
|
| 60 | - $this->_visibleOver($bt); |
|
| 59 | + if($visibleHover) { |
|
| 60 | + $this->_visibleOver($bt); |
|
| 61 | + } |
|
| 61 | 62 | return $bt; |
| 62 | 63 | } |
| 63 | 64 | |
@@ -110,8 +111,9 @@ discard block |
||
| 110 | 111 | private function getDefaultButton($icon,$class=null,$visibleHover=true){ |
| 111 | 112 | $bt=$this->getFieldButton("",$visibleHover); |
| 112 | 113 | $bt->asIcon($icon); |
| 113 | - if(isset($class)) |
|
| 114 | - $bt->addClass($class); |
|
| 114 | + if(isset($class)) { |
|
| 115 | + $bt->addClass($class); |
|
| 116 | + } |
|
| 115 | 117 | return $bt; |
| 116 | 118 | } |
| 117 | 119 | |