Merge pull request #24209 from rycks/dev_add_formsetup_select_user

NEW add setAsSelectUser into factory for generic setup page
This commit is contained in:
Laurent Destailleur 2023-03-27 08:55:54 +02:00 committed by GitHub
commit 0436111e1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -834,6 +834,8 @@ class FormSetupItem
$out.= $this->generateInputFieldMultiSelect(); $out.= $this->generateInputFieldMultiSelect();
} elseif ($this->type == 'select') { } elseif ($this->type == 'select') {
$out.= $this->generateInputFieldSelect(); $out.= $this->generateInputFieldSelect();
} elseif ($this->type == 'selectUser') {
$out.= $this->generateInputFieldSelectUser();
} elseif ($this->type == 'textarea') { } elseif ($this->type == 'textarea') {
$out.= $this->generateInputFieldTextarea(); $out.= $this->generateInputFieldTextarea();
} elseif ($this->type== 'html') { } elseif ($this->type== 'html') {
@ -993,6 +995,14 @@ class FormSetupItem
return $this->form->selectarray($this->confKey, $this->fieldOptions, $this->fieldValue); return $this->form->selectarray($this->confKey, $this->fieldOptions, $this->fieldValue);
} }
/**
* @return string
*/
public function generateInputFieldSelectUser()
{
return $this->form->select_dolusers($this->fieldValue, $this->confKey);
}
/** /**
* get the type : used for old module builder setup conf style conversion and tests * get the type : used for old module builder setup conf style conversion and tests
* because this two class will quickly evolve it's important to not set or get directly $this->type (will be protected) so this method exist * because this two class will quickly evolve it's important to not set or get directly $this->type (will be protected) so this method exist
@ -1067,6 +1077,8 @@ class FormSetupItem
$out.= $this->generateOutputFieldMultiSelect(); $out.= $this->generateOutputFieldMultiSelect();
} elseif ($this->type == 'select') { } elseif ($this->type == 'select') {
$out.= $this->generateOutputFieldSelect(); $out.= $this->generateOutputFieldSelect();
} elseif ($this->type == 'selectUser') {
$out.= $this->generateOutputFieldSelectUser();
} elseif ($this->type== 'html') { } elseif ($this->type== 'html') {
$out.= $this->fieldValue; $out.= $this->fieldValue;
} elseif ($this->type== 'color') { } elseif ($this->type== 'color') {
@ -1136,6 +1148,8 @@ class FormSetupItem
/** /**
* generateOutputFieldMultiSelect
*
* @return string * @return string
*/ */
public function generateOutputFieldMultiSelect() public function generateOutputFieldMultiSelect()
@ -1157,6 +1171,8 @@ class FormSetupItem
} }
/** /**
* generateOutputFieldColor
*
* @return string * @return string
*/ */
public function generateOutputFieldColor() public function generateOutputFieldColor()
@ -1165,6 +1181,8 @@ class FormSetupItem
return $this->generateInputField(); return $this->generateInputField();
} }
/** /**
* generateInputFieldColor
*
* @return string * @return string
*/ */
public function generateInputFieldColor() public function generateInputFieldColor()
@ -1174,6 +1192,8 @@ class FormSetupItem
} }
/** /**
* generateOutputFieldSelect
*
* @return string * @return string
*/ */
public function generateOutputFieldSelect() public function generateOutputFieldSelect()
@ -1186,12 +1206,27 @@ class FormSetupItem
return $outPut; return $outPut;
} }
/**
* generateOutputFieldSelectUser
*
* @return string
*/
public function generateOutputFieldSelectUser()
{
$outPut = '';
$user = new User($this->db);
$user->fetch($this->fieldValue);
$outPut = $user->firstname . " " . $user->lastname;
return $outPut;
}
/* /*
* METHODS FOR SETTING DISPLAY TYPE * METHODS FOR SETTING DISPLAY TYPE
*/ */
/** /**
* Set type of input as string * Set type of input as string
*
* @return self * @return self
*/ */
public function setAsString() public function setAsString()
@ -1202,6 +1237,7 @@ class FormSetupItem
/** /**
* Set type of input as color * Set type of input as color
*
* @return self * @return self
*/ */
public function setAsColor() public function setAsColor()
@ -1212,6 +1248,7 @@ class FormSetupItem
/** /**
* Set type of input as textarea * Set type of input as textarea
*
* @return self * @return self
*/ */
public function setAsTextarea() public function setAsTextarea()
@ -1222,6 +1259,7 @@ class FormSetupItem
/** /**
* Set type of input as html editor * Set type of input as html editor
*
* @return self * @return self
*/ */
public function setAsHtml() public function setAsHtml()
@ -1232,6 +1270,7 @@ class FormSetupItem
/** /**
* Set type of input as emailtemplate selector * Set type of input as emailtemplate selector
*
* @param string $templateType email template type * @param string $templateType email template type
* @return self * @return self
*/ */
@ -1243,6 +1282,7 @@ class FormSetupItem
/** /**
* Set type of input as thirdparty_type selector * Set type of input as thirdparty_type selector
*
* @return self * @return self
*/ */
public function setAsThirdpartyType() public function setAsThirdpartyType()
@ -1253,6 +1293,7 @@ class FormSetupItem
/** /**
* Set type of input as Yes * Set type of input as Yes
*
* @return self * @return self
*/ */
public function setAsYesNo() public function setAsYesNo()
@ -1263,6 +1304,7 @@ class FormSetupItem
/** /**
* Set type of input as secure key * Set type of input as secure key
*
* @return self * @return self
*/ */
public function setAsSecureKey() public function setAsSecureKey()
@ -1273,6 +1315,7 @@ class FormSetupItem
/** /**
* Set type of input as product * Set type of input as product
*
* @return self * @return self
*/ */
public function setAsProduct() public function setAsProduct()
@ -1284,6 +1327,7 @@ class FormSetupItem
/** /**
* Set type of input as a category selector * Set type of input as a category selector
* TODO add default value * TODO add default value
*
* @param int $catType Type of category ('customer', 'supplier', 'contact', 'product', 'member'). Old mode (0, 1, 2, ...) is deprecated. * @param int $catType Type of category ('customer', 'supplier', 'contact', 'product', 'member'). Old mode (0, 1, 2, ...) is deprecated.
* @return self * @return self
*/ */
@ -1294,8 +1338,8 @@ class FormSetupItem
} }
/** /**
* Set type of input as a simple title * Set type of input as a simple title. No data to store
* no data to store *
* @return self * @return self
*/ */
public function setAsTitle() public function setAsTitle()
@ -1306,8 +1350,8 @@ class FormSetupItem
/** /**
* Set type of input as a simple title * Set type of input as a simple title. No data to store
* no data to store *
* @param array $fieldOptions A table of field options * @param array $fieldOptions A table of field options
* @return self * @return self
*/ */
@ -1322,8 +1366,8 @@ class FormSetupItem
} }
/** /**
* Set type of input as a simple title * Set type of input as a simple title. No data to store
* no data to store *
* @param array $fieldOptions A table of field options * @param array $fieldOptions A table of field options
* @return self * @return self
*/ */
@ -1336,4 +1380,15 @@ class FormSetupItem
$this->type = 'select'; $this->type = 'select';
return $this; return $this;
} }
/**
* Set type of input as a simple title. No data to store
*
* @return self
*/
public function setAsSelectUser()
{
$this->type = 'selectUser';
return $this;
}
} }