mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-23 06:47:40 +01:00
Correzioni JS per inizializzazione select automatica
Rimozione debugbar e correzione su formattazione numerica per compatibilità con PHP8.
This commit is contained in:
parent
f3d16f46c1
commit
d1c18fecad
@ -1041,7 +1041,7 @@ div.tip {
|
||||
background: #222222;
|
||||
}
|
||||
|
||||
.decimal-number {
|
||||
.number-input {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
|
@ -42,6 +42,8 @@ function initDateInput(input) {
|
||||
minDate: moment($this.attr('min-date')).isValid() ? $this.attr('min-date') : false,
|
||||
maxDate: moment($this.attr('max-date')).isValid() ? $this.attr('max-date') : false,
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function initTimestampInput(input) {
|
||||
@ -72,7 +74,9 @@ function initTimestampInput(input) {
|
||||
|
||||
$this.on("dp.hide", function (e) {
|
||||
$('#tecnici > div').addClass('table-responsive');
|
||||
})
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function initTimeInput(input) {
|
||||
@ -88,6 +92,8 @@ function initTimeInput(input) {
|
||||
minDate: moment($this.attr('min-date')).isValid() ? $this.attr('min-date') : false,
|
||||
maxDate: moment($this.attr('max-date')).isValid() ? $this.attr('max-date') : false,
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -42,7 +42,13 @@ function input(name) {
|
||||
if (!element.data("input-controller")) {
|
||||
return new Input(element);
|
||||
} else {
|
||||
return element.data("input-controller");
|
||||
const controller = element.data("input-controller");
|
||||
|
||||
if (!element.data("input-init")) {
|
||||
controller.init();
|
||||
}
|
||||
|
||||
return controller;
|
||||
}
|
||||
}
|
||||
|
||||
@ -54,49 +60,53 @@ function input(name) {
|
||||
function Input(element) {
|
||||
this.element = element;
|
||||
|
||||
// Controllo sulla gestione precedente
|
||||
if (this.element.data("input-controller")) {
|
||||
return this.element.data("input-controller");
|
||||
}
|
||||
|
||||
this.element.data("input-controller", this);
|
||||
this.element.data("required", this.element.attr("required"));
|
||||
|
||||
let htmlElement = element[0];
|
||||
this.init();
|
||||
}
|
||||
|
||||
|
||||
Input.prototype.init = function () {
|
||||
let initCompleted = false;
|
||||
let htmlElement = this.element[0];
|
||||
|
||||
// Operazioni di inizializzazione per input specifici
|
||||
// Inizializzazione per date
|
||||
if (this.element.hasClass('timestamp-picker')) {
|
||||
initTimestampInput(htmlElement);
|
||||
initCompleted = initTimestampInput(htmlElement);
|
||||
} else if (this.element.hasClass('datepicker')) {
|
||||
initDateInput(htmlElement);
|
||||
initCompleted = initDateInput(htmlElement);
|
||||
} else if (this.element.hasClass('timepicker')) {
|
||||
initTimeInput(htmlElement);
|
||||
initCompleted = initTimeInput(htmlElement);
|
||||
}
|
||||
|
||||
// Inizializzazione per campi numerici
|
||||
else if (this.element.hasClass('decimal-number')) {
|
||||
initNumberInput(htmlElement);
|
||||
else if (this.element.hasClass('number-input')) {
|
||||
initCompleted = initNumberInput(htmlElement);
|
||||
}
|
||||
|
||||
// Inizializzazione per textarea
|
||||
else if (this.element.hasClass('editor-input')) {
|
||||
initEditorInput(htmlElement);
|
||||
initCompleted = initEditorInput(htmlElement);
|
||||
}
|
||||
|
||||
// Inizializzazione per textarea
|
||||
else if (this.element.hasClass('autosize')) {
|
||||
initTextareaInput(htmlElement);
|
||||
initCompleted = initTextareaInput(htmlElement);
|
||||
}
|
||||
|
||||
// Inizializzazione per select
|
||||
else if (this.element.hasClass('superselect') || this.element.hasClass('superselectajax')) {
|
||||
initSelectInput(htmlElement);
|
||||
else if (this.element.hasClass('select-input')) {
|
||||
initCompleted = initSelectInput(htmlElement);
|
||||
}
|
||||
|
||||
// Inizializzazione alternativa per maschere
|
||||
else {
|
||||
initMaskInput(htmlElement);
|
||||
initCompleted = initMaskInput(htmlElement);
|
||||
}
|
||||
|
||||
this.element.data("input-init", initCompleted);
|
||||
}
|
||||
|
||||
Input.prototype.getElement = function () {
|
||||
@ -200,7 +210,7 @@ Input.prototype.get = function () {
|
||||
}
|
||||
|
||||
// Gestione dei valori numerici
|
||||
if (this.element.hasClass("decimal-number")) {
|
||||
if (this.element.hasClass("number-input")) {
|
||||
const autonumeric = this.element.data("autonumeric");
|
||||
|
||||
if (autonumeric) {
|
||||
|
@ -42,6 +42,8 @@ function initMaskInput(input) {
|
||||
regex: "[0-9,.+\-]*",
|
||||
});
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -22,7 +22,7 @@
|
||||
* @deprecated
|
||||
*/
|
||||
function initNumbers() {
|
||||
$('.decimal-number').each(function () {
|
||||
$('.number-input').each(function () {
|
||||
input(this);
|
||||
});
|
||||
}
|
||||
@ -30,7 +30,7 @@ function initNumbers() {
|
||||
function initNumberInput(input) {
|
||||
let $input = $(input);
|
||||
if (AutoNumeric.isManagedByAutoNumeric(input)) {
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
let min = $input.attr('min-value') && $input.attr('min-value') !== "undefined" ? $input.attr('min-value') : null;
|
||||
@ -58,4 +58,6 @@ function initNumberInput(input) {
|
||||
});
|
||||
|
||||
$input.data("autonumeric", autonumeric);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -170,12 +170,19 @@ function updateSelectOption(name, value) {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* @param input
|
||||
*/
|
||||
function initSelectInput(input) {
|
||||
if ($(input).hasClass('superselect')){
|
||||
let $input = $(input);
|
||||
|
||||
if ($input.hasClass('superselect')) {
|
||||
initStaticSelectInput(input);
|
||||
} else {
|
||||
initDynamicSelectInput(input);
|
||||
}
|
||||
|
||||
return $input.data('select');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -18,6 +18,8 @@
|
||||
|
||||
function initTextareaInput(input) {
|
||||
autosize($(input));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function initEditorInput(input) {
|
||||
@ -45,4 +47,6 @@ function initEditorInput(input) {
|
||||
$input.trigger("change", event);
|
||||
});
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
17
core.php
17
core.php
@ -148,23 +148,6 @@ Monolog\ErrorHandler::register($logger, [], Monolog\Logger::ERROR, Monolog\Logge
|
||||
// Database
|
||||
$dbo = $database = database();
|
||||
|
||||
/* SESSIONE */
|
||||
if (!API\Response::isAPIRequest()) {
|
||||
// Barra di debug (necessario per loggare tutte le query)
|
||||
if (App::debug()) {
|
||||
$debugbar = new DebugBar\DebugBar();
|
||||
|
||||
$debugbar->addCollector(new DebugBar\DataCollector\MemoryCollector());
|
||||
$debugbar->addCollector(new DebugBar\DataCollector\PhpInfoCollector());
|
||||
|
||||
$debugbar->addCollector(new DebugBar\DataCollector\RequestDataCollector());
|
||||
$debugbar->addCollector(new DebugBar\DataCollector\TimeDataCollector());
|
||||
|
||||
$debugbar->addCollector(new DebugBar\Bridge\MonologCollector($logger));
|
||||
$debugbar->addCollector(new Extensions\EloquentCollector($dbo->getCapsule()));
|
||||
}
|
||||
}
|
||||
|
||||
/* INTERNAZIONALIZZAZIONE */
|
||||
// Istanziamento del gestore delle traduzioni del progetto
|
||||
$lang = !empty($config['lang']) ? $config['lang'] : (isset($_GET['lang']) ? $_GET['lang'] : null);
|
||||
|
@ -58,7 +58,6 @@ if (Auth::check()) {
|
||||
window.onbeforeunload = null;
|
||||
</script>';
|
||||
|
||||
echo $debugbarRenderer->render();
|
||||
}
|
||||
|
||||
$custom_css = setting('CSS Personalizzato');
|
||||
|
@ -260,15 +260,6 @@ echo '
|
||||
</script>';
|
||||
|
||||
if (Auth::check()) {
|
||||
// Barra di debug
|
||||
if (App::debug()) {
|
||||
$debugbarRenderer = $debugbar->getJavascriptRenderer();
|
||||
$debugbarRenderer->setIncludeVendors(false);
|
||||
$debugbarRenderer->setBaseUrl($paths['assets'].'/php-debugbar');
|
||||
|
||||
echo $debugbarRenderer->renderHead();
|
||||
}
|
||||
|
||||
if (setting('Abilita esportazione Excel e PDF')) {
|
||||
echo '
|
||||
<script type="text/javascript" charset="utf-8" src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
|
||||
|
@ -253,7 +253,7 @@ WHERE (SELECT COUNT(*) FROM in_interventi_tecnici WHERE in_interventi_tecnici.id
|
||||
->sortBy('data');
|
||||
|
||||
echo '
|
||||
<select class="superselect openstamanager-input" id="mese-promemoria">';
|
||||
<select class="superselect openstamanager-input select-input" id="mese-promemoria">';
|
||||
|
||||
foreach ($mesi as $mese) {
|
||||
$data = new Carbon\Carbon($mese['data']);
|
||||
|
@ -237,7 +237,7 @@ class DefaultHandler implements HandlerInterface
|
||||
*/
|
||||
protected function number(&$values, &$extras)
|
||||
{
|
||||
$values['class'][] = 'decimal-number';
|
||||
$values['class'][] = 'number-input';
|
||||
|
||||
$values['value'] = !empty($values['value']) ? $values['value'] : 0;
|
||||
|
||||
|
@ -31,6 +31,7 @@ class SelectHandler implements HandlerInterface
|
||||
public function handle(&$values, &$extras)
|
||||
{
|
||||
$values['class'][] = 'openstamanager-input';
|
||||
$values['class'][] = 'select-input';
|
||||
|
||||
$source = isset($values['ajax-source']) ? $values['ajax-source'] : (isset($values['select-source']) ? $values['select-source'] : null);
|
||||
|
||||
|
@ -144,7 +144,7 @@ class Formatter
|
||||
}
|
||||
|
||||
if (is_object($this->numberFormatter)) {
|
||||
$result = $this->numberFormatter->format($value);
|
||||
$result = $this->numberFormatter->format(floatval($value));
|
||||
} else {
|
||||
$number = number_format($value, $this->getPrecision(), self::getStandardFormats()['number']['decimals'], self::getStandardFormats()['number']['thousands']);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user