modifs.mineures sans commentaires
This commit is contained in:
parent
fcd8dc3c2b
commit
be128e0389
|
@ -5,9 +5,12 @@ use nur\v\BasePlugin;
|
||||||
use nur\v\js;
|
use nur\v\js;
|
||||||
|
|
||||||
class formfilePlugin extends BasePlugin {
|
class formfilePlugin extends BasePlugin {
|
||||||
function __construct(?string $readyLabelPrefix=null, ?string $readyLabelSuffix=null) {
|
const AUTOSUBMIT_ON_CHANGE = '$(this).closest("form").submit();';
|
||||||
|
|
||||||
|
function __construct(?string $readyLabelPrefix=null, ?string $readyLabelSuffix=null, ?string $afterModified_js=null) {
|
||||||
$this->readyLabelPrefix = $readyLabelPrefix;
|
$this->readyLabelPrefix = $readyLabelPrefix;
|
||||||
$this->readyLabelSuffix = $readyLabelSuffix;
|
$this->readyLabelSuffix = $readyLabelSuffix;
|
||||||
|
$this->afterModified_js = $afterModified_js;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var bool */
|
/** @var bool */
|
||||||
|
|
|
@ -88,6 +88,8 @@ class CTable extends ComponentPrintable implements IParametrable {
|
||||||
"table_class" => ["?array", null, "classe CSS du tableau"],
|
"table_class" => ["?array", null, "classe CSS du tableau"],
|
||||||
"table_attrs" => ["?array", null, "autres attributs à placer sur le tableau"],
|
"table_attrs" => ["?array", null, "autres attributs à placer sur le tableau"],
|
||||||
"before_table" => ["?content", null, "Contenu à afficher avant le tableau s'il y a des lignes à afficher"],
|
"before_table" => ["?content", null, "Contenu à afficher avant le tableau s'il y a des lignes à afficher"],
|
||||||
|
"row_func" => ["?callable", null, "fonction avec la signature (\$vs, \$row, \$rawRow) retournant la ligne à afficher"],
|
||||||
|
"col_func" => ["?callable", null, "fonction avec la signature (\$vs, \$value, \$col, \$index) retournant la colonne à afficher"],
|
||||||
"after_table" => ["?content", null, "Contenu à afficher après le tableau s'il y a des lignes à afficher"],
|
"after_table" => ["?content", null, "Contenu à afficher après le tableau s'il y a des lignes à afficher"],
|
||||||
"no_data" => ["?content", null, "Contenu à afficher s'il n'y a pas de lignes à afficher"],
|
"no_data" => ["?content", null, "Contenu à afficher s'il n'y a pas de lignes à afficher"],
|
||||||
"on_exception" => ["?callable", null, "fonction à appeler en cas d'exception"],
|
"on_exception" => ["?callable", null, "fonction à appeler en cas d'exception"],
|
||||||
|
@ -125,7 +127,7 @@ class CTable extends ComponentPrintable implements IParametrable {
|
||||||
/** @var array */
|
/** @var array */
|
||||||
protected $filterCtx;
|
protected $filterCtx;
|
||||||
|
|
||||||
function pp_setFilterFunc(?callable $filterFunc): void {
|
function pp_setFilterFunc($filterFunc): void {
|
||||||
if ($filterFunc === null) $this->filterCtx = null;
|
if ($filterFunc === null) $this->filterCtx = null;
|
||||||
else $this->filterCtx = func::_prepare($filterFunc);
|
else $this->filterCtx = func::_prepare($filterFunc);
|
||||||
}
|
}
|
||||||
|
@ -133,7 +135,7 @@ class CTable extends ComponentPrintable implements IParametrable {
|
||||||
/** @var array */
|
/** @var array */
|
||||||
protected $mapCtx;
|
protected $mapCtx;
|
||||||
|
|
||||||
function pp_setMapFunc(?callable $mapFunc): void {
|
function pp_setMapFunc($mapFunc): void {
|
||||||
if ($mapFunc === null) $this->mapCtx = null;
|
if ($mapFunc === null) $this->mapCtx = null;
|
||||||
else $this->mapCtx = func::_prepare($mapFunc);
|
else $this->mapCtx = func::_prepare($mapFunc);
|
||||||
}
|
}
|
||||||
|
@ -164,6 +166,22 @@ class CTable extends ComponentPrintable implements IParametrable {
|
||||||
/** @var array|string */
|
/** @var array|string */
|
||||||
protected $ppBeforeTable;
|
protected $ppBeforeTable;
|
||||||
|
|
||||||
|
/** @var array */
|
||||||
|
protected $rowCtx;
|
||||||
|
|
||||||
|
function pp_setRowFunc($rowFunc): void {
|
||||||
|
if ($rowFunc === null) $this->rowCtx = null;
|
||||||
|
else $this->rowCtx = func::_prepare($rowFunc);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @var array */
|
||||||
|
protected $colCtx;
|
||||||
|
|
||||||
|
function pp_setColFunc($colFunc): void {
|
||||||
|
if ($colFunc === null) $this->colCtx = null;
|
||||||
|
else $this->colCtx = func::_prepare($colFunc);
|
||||||
|
}
|
||||||
|
|
||||||
/** @var array|string */
|
/** @var array|string */
|
||||||
protected $ppAfterTable;
|
protected $ppAfterTable;
|
||||||
|
|
||||||
|
@ -591,7 +609,11 @@ class CTable extends ComponentPrintable implements IParametrable {
|
||||||
}
|
}
|
||||||
|
|
||||||
function rowTr(array $row): array {
|
function rowTr(array $row): array {
|
||||||
return v::tr($this->row($row));
|
$vs = $this->row($row);
|
||||||
|
if ($this->rowCtx !== null) {
|
||||||
|
$vs = func::_call($this->rowCtx, [$vs, $row, $this->rawRow]);
|
||||||
|
}
|
||||||
|
return v::tr($vs);
|
||||||
}
|
}
|
||||||
|
|
||||||
function row(array $row): ?iterable {
|
function row(array $row): ?iterable {
|
||||||
|
@ -613,12 +635,18 @@ class CTable extends ComponentPrintable implements IParametrable {
|
||||||
protected $col;
|
protected $col;
|
||||||
|
|
||||||
function colTd($value): array {
|
function colTd($value): array {
|
||||||
$result = A::get($this->results, $this->col);
|
$vs = $this->col($value);
|
||||||
$valid = $result === null || $result["valid"];
|
if ($this->colCtx !== null) {
|
||||||
return v::td([
|
$vs = func::_call($this->colCtx, [$vs, $value, $this->col, $this->index, $this->row, $this->rawRow]);
|
||||||
"class" => ["danger" => !$valid],
|
} else {
|
||||||
$this->col($value),
|
$result = A::get($this->results, $this->col);
|
||||||
]);
|
$valid = $result === null || $result["valid"];
|
||||||
|
$vs= [
|
||||||
|
"class" => ["danger" => !$valid],
|
||||||
|
$vs,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
return v::td($vs);
|
||||||
}
|
}
|
||||||
|
|
||||||
function col($value): ?iterable {
|
function col($value): ?iterable {
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
namespace nur\v\plugins;
|
||||||
|
|
||||||
|
use nur\v\BasePlugin;
|
||||||
|
use nur\v\js;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class autosubmitSelectPlugin: soumet le formulaire sur l'événement change
|
||||||
|
*/
|
||||||
|
class autosubmitOnChangePlugin extends BasePlugin {
|
||||||
|
const HAVE_JQUERY = true;
|
||||||
|
|
||||||
|
function __construct(string $selector, bool $cond=true) {
|
||||||
|
$this->selector = $selector;
|
||||||
|
$this->cond = $cond;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string sélecteur pour les composants concernés.
|
||||||
|
*/
|
||||||
|
private $selector;
|
||||||
|
|
||||||
|
/** @var bool ce plugin est-il activé? */
|
||||||
|
private $cond;
|
||||||
|
|
||||||
|
function printJquery(): void {
|
||||||
|
if (!$this->cond) return;
|
||||||
|
?>
|
||||||
|
$(<?=js::qv($this->selector)?>).change(function() {
|
||||||
|
$(this).closest("form").submit();
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue