Skip to content

Commit 5d65ddb

Browse files
committed
FormFields and fields...
1 parent 80f9660 commit 5d65ddb

File tree

10 files changed

+42
-14
lines changed

10 files changed

+42
-14
lines changed

Ajax/bootstrap/html/base/HtmlNavElement.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ public function __construct($identifier,$tagName){
2929
* Associate an ajax get to the elements, displayed in $targetSelector
3030
* $this->attr member is used to build each element url
3131
* @param string $targetSelector the target of the get
32-
* @param string $attr the html attribute used to build the elements url
3332
* @return HtmlNavElement
3433
*/
3534
public function autoGetOnClick($targetSelector){

Ajax/common/Widget.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ public function setDefaultValueFunction($defaultValueFunction){
264264
* @return string
265265
*/
266266
public function jsDisabled($disable=true){
267-
return "$('#".$this->identifier." .ui.input').toggleClass('disabled',".$disable.");";
267+
return "$('#".$this->identifier." .ui.input,#".$this->identifier." .ui.dropdown,#".$this->identifier." .ui.checkbox').toggleClass('disabled',".$disable.");";
268268
}
269269

270270
/**
@@ -275,7 +275,8 @@ public function jsDisabled($disable=true){
275275
public function addEditButtonInToolbar($caption,$callback=NULL){
276276
$bt=new HtmlButton($this->identifier."-editBtn",$caption);
277277
$bt->setToggle();
278-
$bt->onClick($this->jsDisabled(Javascript::prep_value("$(event.target).hasClass('active')")));
278+
$bt->setActive($this->_edition);
279+
$bt->onClick($this->jsDisabled(Javascript::prep_value("!$(event.target).hasClass('active')")));
279280
return $this->addInToolbar($bt,$callback);
280281
}
281282

Ajax/semantic/html/base/traits/BaseTrait.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,9 @@ public function asHeader(){
146146
* @return \Ajax\semantic\html\base\HtmlSemDoubleElement
147147
*/
148148
public function setActive($value=true){
149-
return $this->addToProperty("class", "active");
149+
if($value)
150+
$this->addToProperty("class", "active");
151+
return $this;
150152
}
151153

152154
/**

Ajax/semantic/html/collections/form/HtmlFormDropdown.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,8 @@ public static function multipleDropdown($identifier,$items=array(), $label=NULL,
2424
public function getDataField(){
2525
return $this->getField()->getInput();
2626
}
27+
public function asSelect($name=NULL,$multiple=false,$selection=true){
28+
$this->getField()->asSelect($name,$multiple,$selection);
29+
return $this;
30+
}
2731
}

Ajax/semantic/html/collections/form/HtmlFormField.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,12 @@ public function addRules(array $rules){
141141
return $this;
142142
}
143143

144+
public function addIcon($icon,$direction=Direction::LEFT){
145+
$field=$this->getField();
146+
return $field->addIcon($icon,$direction);
147+
}
148+
144149
public function getValidation() {
145150
return $this->_validation;
146151
}
147-
148-
149152
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ public function attachEvents($events=array()) {
3939
}
4040

4141
public function getField(){
42-
return $this->content["field"]->getField();
42+
//TODO check getField() ?
43+
return $this->content["field"];
4344
}
4445

4546
public function getHtmlCk(){

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,23 @@ public function setTransparent() {
6767

6868
public function setReadonly(){
6969
$this->getDataField()->setProperty("readonly", "");
70+
return $this;
7071
}
7172

7273
public function setName($name){
7374
$this->getDataField()->setProperty("name",$name);
75+
return $this;
7476
}
7577

78+
public function setFluid(){
79+
$this->getField()->addToProperty("class","fluid");
80+
return $this;
81+
}
82+
83+
public function setDisabled($disable=true) {
84+
$field=$this->getField();
85+
if($disable)
86+
$field->addToProperty("class", "disabled");
87+
return $this;
88+
}
7689
}

Ajax/semantic/html/elements/HtmlInput.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ public function __construct($identifier, $type="text", $value="", $placeholder="
2121

2222
public function getField() {
2323
return $this;
24-
//return $this->content["field"];
2524
}
2625

2726
public function getDataField() {

Ajax/semantic/widgets/base/FieldAsTrait.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
use Ajax\semantic\html\modules\HtmlProgress;
1212
use Ajax\semantic\html\modules\HtmlRating;
1313
use Ajax\semantic\html\elements\HtmlHeader;
14+
use Ajax\semantic\html\collections\form\HtmlFormCheckbox;
15+
use Ajax\semantic\html\collections\form\HtmlFormInput;
16+
use Ajax\semantic\html\collections\form\HtmlFormDropdown;
1417
/**
1518
* @author jc
1619
* @property InstanceViewer $_instanceViewer
@@ -121,8 +124,7 @@ public function fieldAsRadio($index,$attributes=NULL){
121124

122125
public function fieldAsInput($index,$attributes=NULL){
123126
return $this->_fieldAs(function($id,$name,$value){
124-
$input= new HtmlInput($id,"text",$value);
125-
//TODO check getField
127+
$input= new HtmlFormInput($id,"","text",$value);
126128
$input->setName($name);
127129
return $input;
128130
}, $index,$attributes,"input");
@@ -138,7 +140,7 @@ public function fieldAsHidden($index,$attributes=NULL){
138140

139141
public function fieldAsCheckbox($index,$attributes=NULL){
140142
return $this->_fieldAs(function($id,$name,$value){
141-
$input=new HtmlCheckbox($id,"",$this->_instanceViewer->getIdentifier());
143+
$input=new HtmlFormCheckbox($id,NULL,$this->_instanceViewer->getIdentifier());
142144
$input->setChecked(JString::isBooleanTrue($value));
143145
$input->getField()->setProperty("name", $name);
144146
return $input;
@@ -147,7 +149,8 @@ public function fieldAsCheckbox($index,$attributes=NULL){
147149

148150
public function fieldAsDropDown($index,$elements=[],$multiple=false,$attributes=NULL){
149151
return $this->_fieldAs(function($id,$name,$value) use($elements,$multiple){
150-
$dd=new HtmlDropdown($id,$value,$elements);
152+
//$dd=new HtmlDropdown($id,$value,$elements);
153+
$dd=new HtmlFormDropdown($id,$elements,NULL,$value);
151154
$dd->asSelect($name,$multiple);
152155
return $dd;
153156
}, $index,$attributes,"dd");

Ajax/semantic/widgets/datatable/DataTable.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,15 @@ private function _generatePagination($table){
128128

129129
protected function _setToolbarPosition($table,$captions=NULL){
130130
switch ($this->_toolbarPosition){
131-
case PositionInTable::BEFORETABLE:case PositionInTable::AFTERTABLE:
131+
case PositionInTable::BEFORETABLE:
132+
case PositionInTable::AFTERTABLE:
132133
if(isset($this->_compileParts)===false){
133134
$this->content[$this->_toolbarPosition]=$this->_toolbar;
134135
}
135136
break;
136-
case PositionInTable::HEADER:case PositionInTable::FOOTER: case PositionInTable::BODY:
137+
case PositionInTable::HEADER:
138+
case PositionInTable::FOOTER:
139+
case PositionInTable::BODY:
137140
$this->addToolbarRow($this->_toolbarPosition,$table, $captions);
138141
break;
139142
}

0 commit comments

Comments
 (0)