@@ -49,6 +49,10 @@ discard block |
||
49 | 49 | return $itemO; |
50 | 50 | } |
51 | 51 | |
52 | + /** |
|
53 | + * @param string $classname |
|
54 | + * @param integer $index |
|
55 | + */ |
|
52 | 56 | protected function setItemIdentifier($item,$classname,$index){ |
53 | 57 | if($item instanceof BaseWidget){ |
54 | 58 | if($item->getIdentifier()===""){ |
@@ -93,6 +97,9 @@ discard block |
||
93 | 97 | return $this; |
94 | 98 | } |
95 | 99 | |
100 | + /** |
|
101 | + * @param integer $index |
|
102 | + */ |
|
96 | 103 | public function removeItem($index){ |
97 | 104 | return array_splice($this->content, $index, 1); |
98 | 105 | } |
@@ -108,6 +115,9 @@ discard block |
||
108 | 115 | return $this->addItem($function($object)); |
109 | 116 | } |
110 | 117 | |
118 | + /** |
|
119 | + * @param \Closure $callBack |
|
120 | + */ |
|
111 | 121 | public function apply($callBack){ |
112 | 122 | foreach ($this->content as $item){ |
113 | 123 | $callBack($item); |
@@ -27,9 +27,17 @@ discard block |
||
27 | 27 | trait FieldAsTrait{ |
28 | 28 | |
29 | 29 | abstract protected function _getFieldIdentifier($prefix,$name=""); |
30 | + |
|
31 | + /** |
|
32 | + * @param \Closure $callback |
|
33 | + */ |
|
30 | 34 | abstract public function setValueFunction($index,$callback); |
31 | 35 | abstract protected function _getFieldName($index); |
32 | 36 | abstract protected function _getFieldCaption($index); |
37 | + |
|
38 | + /** |
|
39 | + * @param string $event |
|
40 | + */ |
|
33 | 41 | abstract protected function _buttonAsSubmit(HtmlButton &$button,$event,$url,$responseElement=NULL,$parameters=NULL); |
34 | 42 | |
35 | 43 | /** |
@@ -68,12 +76,19 @@ discard block |
||
68 | 76 | } |
69 | 77 | } |
70 | 78 | |
79 | + /** |
|
80 | + * @param HtmlFormInput $field |
|
81 | + */ |
|
71 | 82 | protected function _prepareFormFields(&$field,$name,&$attributes){ |
72 | 83 | $field->setName($name); |
73 | 84 | $this->_addRules($field, $attributes); |
74 | 85 | return $field; |
75 | 86 | } |
76 | 87 | |
88 | + /** |
|
89 | + * @param \Closure $elementCallback |
|
90 | + * @param string $prefix |
|
91 | + */ |
|
77 | 92 | protected function _fieldAs($elementCallback,$index,$attributes=NULL,$prefix=null){ |
78 | 93 | $this->setValueFunction($index,function($value) use ($index,&$attributes,$elementCallback,$prefix){ |
79 | 94 | $caption=$this->_getFieldCaption($index); |
@@ -224,6 +239,9 @@ discard block |
||
224 | 239 | } |
225 | 240 | } |
226 | 241 | |
242 | + /** |
|
243 | + * @param integer $index |
|
244 | + */ |
|
227 | 245 | public function fieldAs($index,$type,$attributes=NULL){ |
228 | 246 | $method="fieldAs".\ucfirst($type); |
229 | 247 | if(\method_exists($this, $method)){ |
@@ -36,6 +36,10 @@ discard block |
||
36 | 36 | protected $_checkedMessage; |
37 | 37 | protected $_checkedClass; |
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); |
@@ -78,6 +82,9 @@ discard block |
||
78 | 82 | if(allChecked) {\$parentCheckbox.checkbox('set checked');}else if(allUnchecked){\$parentCheckbox.checkbox('set unchecked');}else{\$parentCheckbox.checkbox('set indeterminate');};".$checkedMessageCall); |
79 | 83 | } |
80 | 84 | |
85 | + /** |
|
86 | + * @param string $op |
|
87 | + */ |
|
81 | 88 | protected function _generateBehavior($op,$params,JsUtils $js){ |
82 | 89 | if(isset($this->_urls[$op])){ |
83 | 90 | $params=\array_merge($params,["attr"=>"data-ajax"]); |
@@ -145,6 +152,9 @@ discard block |
||
145 | 152 | \array_unshift($captions, $ck); |
146 | 153 | } |
147 | 154 | |
155 | + /** |
|
156 | + * @param string $checked |
|
157 | + */ |
|
148 | 158 | private function _setAllChecked($checked){ |
149 | 159 | $result="$('#".$this->identifier." [name=%quote%selection[]%quote%]').prop('checked',".$checked.");"; |
150 | 160 | if(isset($this->_checkedClass)){ |
@@ -224,6 +234,9 @@ discard block |
||
224 | 234 | return $this; |
225 | 235 | } |
226 | 236 | |
237 | + /** |
|
238 | + * @param PositionInTable $part |
|
239 | + */ |
|
227 | 240 | private function addToolbarRow($part,$table,$captions){ |
228 | 241 | $hasPart=$table->hasPart($part); |
229 | 242 | if($hasPart){ |
@@ -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(\is_array($this->_deleteBehavior)) |
|
54 | - $this->_generateBehavior("delete",$this->_deleteBehavior, $js); |
|
55 | - if(\is_array($this->_editBehavior)) |
|
56 | - $this->_generateBehavior("edit",$this->_editBehavior,$js); |
|
53 | + if(\is_array($this->_deleteBehavior)) { |
|
54 | + $this->_generateBehavior("delete",$this->_deleteBehavior, $js); |
|
55 | + } |
|
56 | + if(\is_array($this->_editBehavior)) { |
|
57 | + $this->_generateBehavior("edit",$this->_editBehavior,$js); |
|
58 | + } |
|
57 | 59 | return parent::run($js); |
58 | 60 | } |
59 | 61 | |
@@ -107,12 +109,14 @@ discard block |
||
107 | 109 | |
108 | 110 | $table->setRowCount(0, \sizeof($captions)); |
109 | 111 | $table->setHeaderValues($captions); |
110 | - if(isset($this->_compileParts)) |
|
111 | - $table->setCompileParts($this->_compileParts); |
|
112 | + if(isset($this->_compileParts)) { |
|
113 | + $table->setCompileParts($this->_compileParts); |
|
114 | + } |
|
112 | 115 | |
113 | 116 | if(isset($this->_searchField) && isset($js)){ |
114 | - if(isset($this->_urls["refresh"])) |
|
115 | - $this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
117 | + if(isset($this->_urls["refresh"])) { |
|
118 | + $this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
119 | + } |
|
116 | 120 | } |
117 | 121 | |
118 | 122 | $this->_generateContent($table); |
@@ -137,8 +141,9 @@ discard block |
||
137 | 141 | private function _generateMainCheckbox(&$captions){ |
138 | 142 | $ck=new HtmlCheckbox("main-ck-".$this->identifier,""); |
139 | 143 | $checkedMessageCall=""; |
140 | - if($this->_hasCheckedMessage) |
|
141 | - $checkedMessageCall="updateChecked();"; |
|
144 | + if($this->_hasCheckedMessage) { |
|
145 | + $checkedMessageCall="updateChecked();"; |
|
146 | + } |
|
142 | 147 | |
143 | 148 | $ck->setOnChecked($this->_setAllChecked("true").$checkedMessageCall); |
144 | 149 | $ck->setOnUnchecked($this->_setAllChecked("false").$checkedMessageCall); |
@@ -184,8 +189,9 @@ discard block |
||
184 | 189 | $menu->floatRight(); |
185 | 190 | $menu->setActiveItem($this->_pagination->getPage()-1); |
186 | 191 | $footer->setValues($menu); |
187 | - if(isset($this->_urls["refresh"])) |
|
188 | - $menu->postOnClick($this->_urls["refresh"],"{'p':$(this).attr('data-page')}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
192 | + if(isset($this->_urls["refresh"])) { |
|
193 | + $menu->postOnClick($this->_urls["refresh"],"{'p':$(this).attr('data-page')}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
194 | + } |
|
189 | 195 | } |
190 | 196 | |
191 | 197 | protected function _getFieldName($index){ |
@@ -228,7 +234,7 @@ discard block |
||
228 | 234 | $hasPart=$table->hasPart($part); |
229 | 235 | if($hasPart){ |
230 | 236 | $row=$table->getPart($part)->addRow(\sizeof($captions)); |
231 | - }else{ |
|
237 | + } else{ |
|
232 | 238 | $row=$table->getPart($part)->getRow(0); |
233 | 239 | } |
234 | 240 | $row->mergeCol(); |
@@ -253,7 +259,7 @@ discard block |
||
253 | 259 | $this->_urls["refresh"]=JArray::getValue($urls, "refresh",0); |
254 | 260 | $this->_urls["edit"]=JArray::getValue($urls, "edit",1); |
255 | 261 | $this->_urls["delete"]=JArray::getValue($urls, "delete",2); |
256 | - }else{ |
|
262 | + } else{ |
|
257 | 263 | $this->_urls=["refresh"=>$urls,"edit"=>$urls,"delete"=>$urls]; |
258 | 264 | } |
259 | 265 | return $this; |
@@ -309,8 +315,9 @@ discard block |
||
309 | 315 | |
310 | 316 | protected function getTargetSelector() { |
311 | 317 | $result=$this->_targetSelector; |
312 | - if(!isset($result)) |
|
313 | - $result="#".$this->identifier; |
|
318 | + if(!isset($result)) { |
|
319 | + $result="#".$this->identifier; |
|
320 | + } |
|
314 | 321 | return $result; |
315 | 322 | } |
316 | 323 | |
@@ -348,8 +355,9 @@ discard block |
||
348 | 355 | * @param callable $callback |
349 | 356 | */ |
350 | 357 | public function addCountCheckedInToolbar(array $checkedMessage=null,$callback=null){ |
351 | - if(isset($checkedMessage)) |
|
352 | - $this->_checkedMessage=$checkedMessage; |
|
358 | + if(isset($checkedMessage)) { |
|
359 | + $this->_checkedMessage=$checkedMessage; |
|
360 | + } |
|
353 | 361 | $checkedMessage=$this->getCheckedMessage(); |
354 | 362 | $this->_hasCheckboxes=true; |
355 | 363 | $this->_hasCheckedMessage=true; |
@@ -13,15 +13,28 @@ discard block |
||
13 | 13 | * @property InstanceViewer $_instanceViewer |
14 | 14 | */ |
15 | 15 | trait DataTableFieldAsTrait{ |
16 | + |
|
17 | + /** |
|
18 | + * @param \Closure $field |
|
19 | + */ |
|
16 | 20 | abstract public function addField($field); |
21 | + |
|
22 | + /** |
|
23 | + * @param integer $index |
|
24 | + * @param \Closure $field |
|
25 | + */ |
|
17 | 26 | abstract public function insertField($index,$field); |
27 | + |
|
28 | + /** |
|
29 | + * @param \Closure $field |
|
30 | + */ |
|
18 | 31 | abstract public function insertInField($index,$field); |
19 | 32 | abstract public function fieldAs($index,$type,$attributes=NULL); |
20 | 33 | /** |
21 | 34 | * @param string $caption |
22 | 35 | * @param callable $callback |
23 | 36 | * @param boolean $visibleHover |
24 | - * @return callable |
|
37 | + * @return \Closure |
|
25 | 38 | */ |
26 | 39 | private function getFieldButtonCallable($caption,$visibleHover=true,$callback=null){ |
27 | 40 | return $this->getCallable("getFieldButton",[$caption,$visibleHover],$callback); |
@@ -31,7 +44,7 @@ discard block |
||
31 | 44 | * @param callable $thisCallback |
32 | 45 | * @param array $parameters |
33 | 46 | * @param callable $callback |
34 | - * @return callable |
|
47 | + * @return \Closure |
|
35 | 48 | */ |
36 | 49 | private function getCallable($thisCallback,$parameters,$callback=null){ |
37 | 50 | $result=function($instance) use($thisCallback,$parameters,$callback){ |
@@ -83,6 +96,9 @@ discard block |
||
83 | 96 | }, $index,$attributes); |
84 | 97 | } |
85 | 98 | |
99 | + /** |
|
100 | + * @param HtmlButton $element |
|
101 | + */ |
|
86 | 102 | protected function _visibleOver($element){ |
87 | 103 | $this->_visibleHover=true; |
88 | 104 | return $element->addToProperty("class", "visibleover")->setProperty("style","visibility:hidden;"); |
@@ -93,7 +109,7 @@ discard block |
||
93 | 109 | * @param string $caption |
94 | 110 | * @param callable $callback |
95 | 111 | * @param boolean $visibleHover |
96 | - * @return \Ajax\semantic\widgets\datatable\DataTable |
|
112 | + * @return DataTableFieldAsTrait |
|
97 | 113 | */ |
98 | 114 | public function addFieldButton($caption,$visibleHover=true,$callback=null){ |
99 | 115 | $this->addField($this->getCallable("getFieldButton",[$caption,$visibleHover],$callback)); |
@@ -105,7 +121,7 @@ discard block |
||
105 | 121 | * @param int $index |
106 | 122 | * @param string $caption |
107 | 123 | * @param callable $callback |
108 | - * @return \Ajax\semantic\widgets\datatable\DataTable |
|
124 | + * @return DataTableFieldAsTrait |
|
109 | 125 | */ |
110 | 126 | public function insertFieldButton($index,$caption,$visibleHover=true,$callback=null){ |
111 | 127 | $this->insertField($index, $this->getFieldButtonCallable($caption,$visibleHover,$callback)); |
@@ -117,18 +133,26 @@ discard block |
||
117 | 133 | * @param int $index |
118 | 134 | * @param string $caption |
119 | 135 | * @param callable $callback |
120 | - * @return \Ajax\semantic\widgets\datatable\DataTable |
|
136 | + * @return DataTableFieldAsTrait |
|
121 | 137 | */ |
122 | 138 | public function insertInFieldButton($index,$caption,$visibleHover=true,$callback=null){ |
123 | 139 | $this->insertInField($index, $this->getFieldButtonCallable($caption,$visibleHover,$callback)); |
124 | 140 | return $this; |
125 | 141 | } |
126 | 142 | |
143 | + /** |
|
144 | + * @param string $icon |
|
145 | + * @param string $class |
|
146 | + */ |
|
127 | 147 | private function addDefaultButton($icon,$class=null,$visibleHover=true,$callback=null){ |
128 | 148 | $this->addField($this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback)); |
129 | 149 | return $this; |
130 | 150 | } |
131 | 151 | |
152 | + /** |
|
153 | + * @param string $icon |
|
154 | + * @param string $class |
|
155 | + */ |
|
132 | 156 | private function insertDefaultButtonIn($index,$icon,$class=null,$visibleHover=true,$callback=null){ |
133 | 157 | $this->insertInField($index,$this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback)); |
134 | 158 | return $this; |
@@ -146,7 +170,7 @@ discard block |
||
146 | 170 | * @param boolean $visibleHover |
147 | 171 | * @param array $deleteBehavior |
148 | 172 | * @param callable $callback |
149 | - * @return DataTable |
|
173 | + * @return DataTableFieldAsTrait |
|
150 | 174 | */ |
151 | 175 | public function addDeleteButton($visibleHover=true,$deleteBehavior=[],$callback=null){ |
152 | 176 | $this->_deleteBehavior=$deleteBehavior; |
@@ -48,8 +48,9 @@ discard block |
||
48 | 48 | |
49 | 49 | public function setAttached($value=true){ |
50 | 50 | $form=$this->getForm(); |
51 | - if($value) |
|
52 | - $form->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
51 | + if($value) { |
|
52 | + $form->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
53 | + } |
|
53 | 54 | return $form; |
54 | 55 | } |
55 | 56 | |
@@ -91,8 +92,9 @@ discard block |
||
91 | 92 | if(isset($url) && isset($responseElement)){ |
92 | 93 | $button->addEvent($event, "$('#".$form->getIdentifier()."').form('validate form');",true,true); |
93 | 94 | $params=["form"=>$form->getIdentifier(),"responseElement"=>$responseElement,"url"=>$url,"stopPropagation"=>true]; |
94 | - if(\is_array($parameters)) |
|
95 | - $params=\array_merge($params,$parameters); |
|
95 | + if(\is_array($parameters)) { |
|
96 | + $params=\array_merge($params,$parameters); |
|
97 | + } |
|
96 | 98 | $form->addValidationParam("_ajaxSubmit", new AjaxCall("postForm", $params)); |
97 | 99 | } |
98 | 100 | return $button; |