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;
 | 
			
		||||
 | 
			
		||||
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->readyLabelSuffix = $readyLabelSuffix;
 | 
			
		||||
    $this->afterModified_js = $afterModified_js;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /** @var bool  */
 | 
			
		||||
 | 
			
		||||
@ -88,6 +88,8 @@ class CTable extends ComponentPrintable implements IParametrable {
 | 
			
		||||
    "table_class" => ["?array", null, "classe CSS du 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"],
 | 
			
		||||
    "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"],
 | 
			
		||||
    "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"],
 | 
			
		||||
@ -125,7 +127,7 @@ class CTable extends ComponentPrintable implements IParametrable {
 | 
			
		||||
  /** @var array */
 | 
			
		||||
  protected $filterCtx;
 | 
			
		||||
 | 
			
		||||
  function pp_setFilterFunc(?callable $filterFunc): void {
 | 
			
		||||
  function pp_setFilterFunc($filterFunc): void {
 | 
			
		||||
    if ($filterFunc === null) $this->filterCtx = null;
 | 
			
		||||
    else $this->filterCtx = func::_prepare($filterFunc);
 | 
			
		||||
  }
 | 
			
		||||
@ -133,7 +135,7 @@ class CTable extends ComponentPrintable implements IParametrable {
 | 
			
		||||
  /** @var array */
 | 
			
		||||
  protected $mapCtx;
 | 
			
		||||
 | 
			
		||||
  function pp_setMapFunc(?callable $mapFunc): void {
 | 
			
		||||
  function pp_setMapFunc($mapFunc): void {
 | 
			
		||||
    if ($mapFunc === null) $this->mapCtx = null;
 | 
			
		||||
    else $this->mapCtx = func::_prepare($mapFunc);
 | 
			
		||||
  }
 | 
			
		||||
@ -164,6 +166,22 @@ class CTable extends ComponentPrintable implements IParametrable {
 | 
			
		||||
  /** @var array|string */
 | 
			
		||||
  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 */
 | 
			
		||||
  protected $ppAfterTable;
 | 
			
		||||
 | 
			
		||||
@ -591,7 +609,11 @@ class CTable extends ComponentPrintable implements IParametrable {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  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 {
 | 
			
		||||
@ -613,12 +635,18 @@ class CTable extends ComponentPrintable implements IParametrable {
 | 
			
		||||
  protected $col;
 | 
			
		||||
 | 
			
		||||
  function colTd($value): array {
 | 
			
		||||
    $result = A::get($this->results, $this->col);
 | 
			
		||||
    $valid = $result === null || $result["valid"];
 | 
			
		||||
    return v::td([
 | 
			
		||||
      "class" => ["danger" => !$valid],
 | 
			
		||||
      $this->col($value),
 | 
			
		||||
    ]);
 | 
			
		||||
    $vs = $this->col($value);
 | 
			
		||||
    if ($this->colCtx !== null) {
 | 
			
		||||
      $vs = func::_call($this->colCtx, [$vs, $value, $this->col, $this->index, $this->row, $this->rawRow]);
 | 
			
		||||
    } else {
 | 
			
		||||
      $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 {
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										35
									
								
								nur_src/v/plugins/autosubmitOnChangePlugin.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								nur_src/v/plugins/autosubmitOnChangePlugin.php
									
									
									
									
									
										Normal file
									
								
							@ -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…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user