mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-06-05 22:09:38 +02:00
refactor: ♻️ Refactor generale
- Fix problemi rilevati da ESLint (per togliere alcune regole commentate) - Spostati i tipi nella cartella typings - Aggiunti alcuni alias per la cartella resources
This commit is contained in:
@ -49,7 +49,10 @@ return [
|
|||||||
| These aliases will be added to the Vite configuration and used
|
| These aliases will be added to the Vite configuration and used
|
||||||
| to generate a proper tsconfig.json file.
|
| to generate a proper tsconfig.json file.
|
||||||
*/
|
*/
|
||||||
'aliases' => [],
|
'aliases' => [
|
||||||
|
'@openstamanager/assets' => 'resources/static',
|
||||||
|
'@openstamanager/scss' => 'resources/scss',
|
||||||
|
],
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
@ -115,7 +118,7 @@ return [
|
|||||||
| the development server starts.
|
| the development server starts.
|
||||||
*/
|
*/
|
||||||
'commands' => [
|
'commands' => [
|
||||||
//'vite:aliases',
|
'vite:aliases',
|
||||||
// 'typescript:generate'
|
// 'typescript:generate'
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
/* eslint-disable no-console */
|
|
||||||
/*
|
/*
|
||||||
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
|
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
|
||||||
* Copyright (C) DevCode s.r.l.
|
* Copyright (C) DevCode s.r.l.
|
||||||
@ -17,4 +16,5 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
import gulp from 'gulp';
|
import gulp from 'gulp';
|
||||||
|
@ -60,7 +60,7 @@
|
|||||||
"redaxios": "^0.4.1"
|
"redaxios": "^0.4.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@maicol07/eslint-config": "^2.1.2",
|
"@maicol07/eslint-config": "^2.1.4",
|
||||||
"@openstamanager/vite-config": "github:devcode-it/openstamanager-vite-config",
|
"@openstamanager/vite-config": "github:devcode-it/openstamanager-vite-config",
|
||||||
"@types/gulp": "^4.0.0",
|
"@types/gulp": "^4.0.0",
|
||||||
"@types/lodash": "^4.14.178",
|
"@types/lodash": "^4.14.178",
|
||||||
|
16
pnpm-lock.yaml
generated
16
pnpm-lock.yaml
generated
@ -3,7 +3,7 @@ lockfileVersion: 5.3
|
|||||||
specifiers:
|
specifiers:
|
||||||
'@inertiajs/inertia': ^0.10.1
|
'@inertiajs/inertia': ^0.10.1
|
||||||
'@inertiajs/progress': ^0.2.7
|
'@inertiajs/progress': ^0.2.7
|
||||||
'@maicol07/eslint-config': ^2.1.2
|
'@maicol07/eslint-config': ^2.1.4
|
||||||
'@maicol07/inertia-mithril': ^0.4.2
|
'@maicol07/inertia-mithril': ^0.4.2
|
||||||
'@maicol07/mwc-card': ^0.25.3
|
'@maicol07/mwc-card': ^0.25.3
|
||||||
'@maicol07/mwc-layout-grid': ^0.25.3-1
|
'@maicol07/mwc-layout-grid': ^0.25.3-1
|
||||||
@ -113,7 +113,7 @@ dependencies:
|
|||||||
redaxios: 0.4.1
|
redaxios: 0.4.1
|
||||||
|
|
||||||
devDependencies:
|
devDependencies:
|
||||||
'@maicol07/eslint-config': 2.1.2
|
'@maicol07/eslint-config': 2.1.4
|
||||||
'@openstamanager/vite-config': github.com/devcode-it/openstamanager-vite-config/9399c4a34b39c0a80408db47575794f089465be5_sass@1.49.0
|
'@openstamanager/vite-config': github.com/devcode-it/openstamanager-vite-config/9399c4a34b39c0a80408db47575794f089465be5_sass@1.49.0
|
||||||
'@types/gulp': 4.0.9
|
'@types/gulp': 4.0.9
|
||||||
'@types/lodash': 4.14.178
|
'@types/lodash': 4.14.178
|
||||||
@ -1346,8 +1346,8 @@ packages:
|
|||||||
resolution: {integrity: sha512-B2JdRMwCGv+VpIRj3CYVQBx3muPDeE8y+HPgWqzrAHsO5/40BpwDFZeplIV790BaTqDVUDvZOKMSbuFM9zWC0w==}
|
resolution: {integrity: sha512-B2JdRMwCGv+VpIRj3CYVQBx3muPDeE8y+HPgWqzrAHsO5/40BpwDFZeplIV790BaTqDVUDvZOKMSbuFM9zWC0w==}
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/@maicol07/eslint-config/2.1.2:
|
/@maicol07/eslint-config/2.1.4:
|
||||||
resolution: {integrity: sha512-9h75NkOwRvAUh52O1NsvYeFaVkOGxd8QNwQtpPLxXYjoM2IrJO59Al6wG+rVaI2np25ssMVuag+s3RO0rzuzeg==}
|
resolution: {integrity: sha512-g6PHY17wIU9zKnQEEo8hd/6q7Zyz4iUC13JaMUITUMSwls19mNUqGnK4eYuo8+wzu8vPgvks/RA/AZE0T6wsgg==}
|
||||||
dependencies:
|
dependencies:
|
||||||
'@typescript-eslint/eslint-plugin': 5.9.1_46ff1e3eeda39b5395c18b563a83af7a
|
'@typescript-eslint/eslint-plugin': 5.9.1_46ff1e3eeda39b5395c18b563a83af7a
|
||||||
'@typescript-eslint/parser': 5.9.1_eslint@8.6.0+typescript@4.5.5
|
'@typescript-eslint/parser': 5.9.1_eslint@8.6.0+typescript@4.5.5
|
||||||
@ -2956,7 +2956,7 @@ packages:
|
|||||||
postcss: ^8.1.0
|
postcss: ^8.1.0
|
||||||
dependencies:
|
dependencies:
|
||||||
browserslist: 4.19.1
|
browserslist: 4.19.1
|
||||||
caniuse-lite: 1.0.30001301
|
caniuse-lite: 1.0.30001302
|
||||||
fraction.js: 4.1.2
|
fraction.js: 4.1.2
|
||||||
normalize-range: 0.1.2
|
normalize-range: 0.1.2
|
||||||
picocolors: 1.0.0
|
picocolors: 1.0.0
|
||||||
@ -3107,7 +3107,7 @@ packages:
|
|||||||
engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7}
|
engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
dependencies:
|
dependencies:
|
||||||
caniuse-lite: 1.0.30001301
|
caniuse-lite: 1.0.30001302
|
||||||
electron-to-chromium: 1.4.53
|
electron-to-chromium: 1.4.53
|
||||||
escalade: 3.1.1
|
escalade: 3.1.1
|
||||||
node-releases: 2.0.1
|
node-releases: 2.0.1
|
||||||
@ -3173,8 +3173,8 @@ packages:
|
|||||||
engines: {node: '>=6'}
|
engines: {node: '>=6'}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/caniuse-lite/1.0.30001301:
|
/caniuse-lite/1.0.30001302:
|
||||||
resolution: {integrity: sha512-csfD/GpHMqgEL3V3uIgosvh+SVIQvCh43SNu9HRbP1lnxkKm1kjDG4f32PP571JplkLjfS+mg2p1gxR7MYrrIA==}
|
resolution: {integrity: sha512-YYTMO+tfwvgUN+1ZnRViE53Ma1S/oETg+J2lISsqi/ZTNThj3ZYBOKP2rHwJc37oCsPqAzJ3w2puZHn0xlLPPw==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/cash-dom/8.1.0:
|
/cash-dom/8.1.0:
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
|
import {MaterialIcons} from '../typings';
|
||||||
import Component from './Component';
|
import Component from './Component';
|
||||||
|
|
||||||
type Attributes = {
|
type Attributes = {
|
||||||
icon?: string
|
icon?: MaterialIcons
|
||||||
};
|
};
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
|
@ -28,7 +28,7 @@ import type {
|
|||||||
SelectT,
|
SelectT,
|
||||||
TextAreaT,
|
TextAreaT,
|
||||||
TextFieldT
|
TextFieldT
|
||||||
} from '../../types';
|
} from '../../typings';
|
||||||
import {
|
import {
|
||||||
getFormData,
|
getFormData,
|
||||||
isFormValid,
|
isFormValid,
|
||||||
@ -57,6 +57,8 @@ export type ColumnsT = Record<string, string | ColumnT>;
|
|||||||
export type RowsT = Collection<IModel>;
|
export type RowsT = Collection<IModel>;
|
||||||
export type SectionsT = Record<string, SectionT>;
|
export type SectionsT = Record<string, SectionT>;
|
||||||
|
|
||||||
|
const FIELDS: string = 'text-field, text-area, material-select';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @abstract
|
* @abstract
|
||||||
*/
|
*/
|
||||||
@ -160,8 +162,8 @@ export class RecordsPage extends Page {
|
|||||||
const dialog = $('mwc-dialog#add-record-dialog');
|
const dialog = $('mwc-dialog#add-record-dialog');
|
||||||
|
|
||||||
dialog
|
dialog
|
||||||
// eslint-disable-next-line sonarjs/no-duplicate-string
|
// eslint-disable-next-line unicorn/no-array-callback-reference
|
||||||
.find('text-field, text-area, material-select')
|
.find(FIELDS)
|
||||||
.each(async (index, field) => {
|
.each(async (index, field) => {
|
||||||
field.innerHTML = await this.getFieldBody(field as HTMLFormElement);
|
field.innerHTML = await this.getFieldBody(field as HTMLFormElement);
|
||||||
(field as HTMLInputElement).value = this.getModelValue(instance, field.id) as string;
|
(field as HTMLInputElement).value = this.getModelValue(instance, field.id) as string;
|
||||||
@ -318,7 +320,8 @@ export class RecordsPage extends Page {
|
|||||||
|
|
||||||
openNewRecordDialog(form: Cash, dialog: Cash) {
|
openNewRecordDialog(form: Cash, dialog: Cash) {
|
||||||
form
|
form
|
||||||
.find('text-field, text-area, material-select')
|
// eslint-disable-next-line unicorn/no-array-callback-reference
|
||||||
|
.find(FIELDS)
|
||||||
.each(async (index, field) => {
|
.each(async (index, field) => {
|
||||||
field.innerHTML = await this.getFieldBody(field as HTMLFormElement);
|
field.innerHTML = await this.getFieldBody(field as HTMLFormElement);
|
||||||
(field as HTMLInputElement).value = $(field)
|
(field as HTMLInputElement).value = $(field)
|
||||||
@ -340,7 +343,6 @@ export class RecordsPage extends Page {
|
|||||||
if (isFormValid(form)) {
|
if (isFormValid(form)) {
|
||||||
const data = collect(getFormData(form));
|
const data = collect(getFormData(form));
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
// eslint-disable-next-line new-cap
|
|
||||||
const instance = this.rows.get(data.get('id'), new this.model() as IModel) as IModel;
|
const instance = this.rows.get(data.get('id'), new this.model() as IModel) as IModel;
|
||||||
|
|
||||||
const modelId = await this.setter(instance, data);
|
const modelId = await this.setter(instance, data);
|
||||||
@ -424,7 +426,6 @@ export class RecordsPage extends Page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (typeof column === 'object' && column.valueModifier) {
|
if (typeof column === 'object' && column.valueModifier) {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
||||||
value = column.valueModifier(model, field);
|
value = column.valueModifier(model, field);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -450,14 +451,13 @@ export class RecordsPage extends Page {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async getFieldBody(field: HTMLFormElement) {
|
async getFieldBody(field: HTMLFormElement & FieldT) {
|
||||||
const list = [];
|
const list = [];
|
||||||
|
|
||||||
switch (field.type ?? field.getAttribute('type')) {
|
switch (field.type ?? field.getAttribute('type')) {
|
||||||
case 'select':
|
case 'select': {
|
||||||
// eslint-disable-next-line no-case-declarations
|
const section = collect(this.sections)
|
||||||
const section = collect(this.sections).first((s) => field.id in s.fields);
|
.first((s) => field.id in s.fields);
|
||||||
// eslint-disable-next-line no-case-declarations
|
|
||||||
let {options} = section.fields[field.id] as SelectT;
|
let {options} = section.fields[field.id] as SelectT;
|
||||||
if (options instanceof Promise) {
|
if (options instanceof Promise) {
|
||||||
options = await options;
|
options = await options;
|
||||||
@ -474,18 +474,18 @@ export class RecordsPage extends Page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case 'checkbox':
|
case 'checkbox':
|
||||||
return '';
|
return '';
|
||||||
|
|
||||||
case 'radio':
|
case 'radio':
|
||||||
return '';
|
return '';
|
||||||
|
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (field.icon) {
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||||
list.push(render(<Mdi icon={(field as FieldT).icon} slot="icon"/>));
|
const {icon} = field;
|
||||||
|
if (typeof icon === 'string') {
|
||||||
|
list.push(render(<Mdi icon={icon} slot="icon"/>));
|
||||||
}
|
}
|
||||||
|
|
||||||
return list.join('');
|
return list.join('');
|
||||||
|
@ -21,7 +21,7 @@ export abstract class Model extends BaseModel {
|
|||||||
super();
|
super();
|
||||||
|
|
||||||
// Return a proxy of this object to allow dynamic attributes getters and setters
|
// Return a proxy of this object to allow dynamic attributes getters and setters
|
||||||
// eslint-disable-next-line no-constructor-return, @typescript-eslint/no-unsafe-return
|
// eslint-disable-next-line no-constructor-return
|
||||||
return new Proxy(this, {
|
return new Proxy(this, {
|
||||||
get(target, property: string, receiver): any {
|
get(target, property: string, receiver): any {
|
||||||
const snakeCasedProperty = snakeCase(property);
|
const snakeCasedProperty = snakeCase(property);
|
||||||
|
@ -12,7 +12,7 @@ import logoUrl from '/images/logo_completo.png';
|
|||||||
import LoadingButton from '../Components/LoadingButton';
|
import LoadingButton from '../Components/LoadingButton';
|
||||||
import Mdi from '../Components/Mdi';
|
import Mdi from '../Components/Mdi';
|
||||||
import Page from '../Components/Page';
|
import Page from '../Components/Page';
|
||||||
import type {ErrorResponse} from '../types';
|
import type {ErrorResponse} from '../typings';
|
||||||
import {
|
import {
|
||||||
getFormData,
|
getFormData,
|
||||||
isFormValid,
|
isFormValid,
|
||||||
|
@ -4,6 +4,7 @@ import '@material/mwc-checkbox';
|
|||||||
import '@material/mwc-formfield';
|
import '@material/mwc-formfield';
|
||||||
import '../WebComponents/TextField';
|
import '../WebComponents/TextField';
|
||||||
|
|
||||||
|
import logoUrl from '@openstamanager/assets/images/logo_completo.png';
|
||||||
import type {Cash} from 'cash-dom';
|
import type {Cash} from 'cash-dom';
|
||||||
import type {
|
import type {
|
||||||
Vnode,
|
Vnode,
|
||||||
@ -11,13 +12,10 @@ import type {
|
|||||||
} from 'mithril';
|
} from 'mithril';
|
||||||
import redaxios from 'redaxios';
|
import redaxios from 'redaxios';
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-absolute-path
|
|
||||||
import logoUrl from '/images/logo_completo.png';
|
|
||||||
|
|
||||||
import LoadingButton from '../Components/LoadingButton';
|
import LoadingButton from '../Components/LoadingButton';
|
||||||
import Mdi from '../Components/Mdi';
|
import Mdi from '../Components/Mdi';
|
||||||
import Page from '../Components/Page';
|
import Page from '../Components/Page';
|
||||||
import {ErrorResponse} from '../types';
|
import {ErrorResponse} from '../typings';
|
||||||
import {getFormData, isFormValid, showSnackbar} from '../utils';
|
import {getFormData, isFormValid, showSnackbar} from '../utils';
|
||||||
|
|
||||||
export default class LoginPage extends Page {
|
export default class LoginPage extends Page {
|
||||||
|
@ -11,13 +11,12 @@ import type {
|
|||||||
} from 'mithril';
|
} from 'mithril';
|
||||||
import redaxios from 'redaxios';
|
import redaxios from 'redaxios';
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-absolute-path
|
import logoUrl from '@openstamanager/assets/images/logo_completo.png';
|
||||||
import logoUrl from '/images/logo_completo.png';
|
|
||||||
|
|
||||||
import LoadingButton from '../Components/LoadingButton';
|
import LoadingButton from '../Components/LoadingButton';
|
||||||
import Mdi from '../Components/Mdi';
|
import Mdi from '../Components/Mdi';
|
||||||
import Page from '../Components/Page';
|
import Page from '../Components/Page';
|
||||||
import {ErrorResponse} from '../types';
|
import {ErrorResponse} from '../typings';
|
||||||
import {
|
import {
|
||||||
getFormData,
|
getFormData,
|
||||||
isFormValid,
|
isFormValid,
|
||||||
|
@ -16,9 +16,7 @@ import LocaleCode from 'locale-code';
|
|||||||
import type {Vnode, VnodeDOM} from 'mithril';
|
import type {Vnode, VnodeDOM} from 'mithril';
|
||||||
import redaxios, {Response} from 'redaxios';
|
import redaxios, {Response} from 'redaxios';
|
||||||
|
|
||||||
// @ts-ignore
|
import logoUrl from '@openstamanager/assets/images/logo_completo.png';
|
||||||
// eslint-disable-next-line import/no-absolute-path
|
|
||||||
import logoUrl from '/images/logo_completo.png';
|
|
||||||
|
|
||||||
import {Alert} from '../Components';
|
import {Alert} from '../Components';
|
||||||
import Mdi from '../Components/Mdi';
|
import Mdi from '../Components/Mdi';
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
import {Drawer as MWCDrawer} from '@material/mwc-drawer';
|
import {Drawer as MWCDrawer} from '@material/mwc-drawer';
|
||||||
import {css} from 'lit';
|
import {css} from 'lit';
|
||||||
// eslint-disable-next-line import/extensions
|
|
||||||
import {customElement} from 'lit/decorators.js';
|
import {customElement} from 'lit/decorators.js';
|
||||||
|
|
||||||
import type {JSXElement} from '../types';
|
import type {JSXElement} from '../typings';
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
namespace JSX {
|
namespace JSX {
|
||||||
@ -21,12 +20,12 @@ export default class MaterialDrawer extends MWCDrawer {
|
|||||||
:first-child {
|
:first-child {
|
||||||
border-right: none;
|
border-right: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mdc-drawer-app-content {
|
.mdc-drawer-app-content {
|
||||||
color: var(--mdc-theme-text-primary-on-background);
|
color: var(--mdc-theme-text-primary-on-background);
|
||||||
background-color: var(--mdc-theme-background);
|
background-color: var(--mdc-theme-background);
|
||||||
}
|
}
|
||||||
|
|
||||||
.mdc-drawer {
|
.mdc-drawer {
|
||||||
height: calc(100% - 64px);
|
height: calc(100% - 64px);
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,9 @@ import {Select as MWCSelect} from '@material/mwc-select';
|
|||||||
import {waitUntil} from 'async-wait-until';
|
import {waitUntil} from 'async-wait-until';
|
||||||
import type {TemplateResult} from 'lit';
|
import type {TemplateResult} from 'lit';
|
||||||
import {css, html} from 'lit';
|
import {css, html} from 'lit';
|
||||||
// eslint-disable-next-line import/extensions
|
|
||||||
import {customElement} from 'lit/decorators.js';
|
import {customElement} from 'lit/decorators.js';
|
||||||
|
|
||||||
import type {JSXElement} from '../types';
|
import type {JSXElement} from '../typings';
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
namespace JSX {
|
namespace JSX {
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import {TextArea as MWCTextArea} from '@material/mwc-textarea';
|
import {TextArea as MWCTextArea} from '@material/mwc-textarea';
|
||||||
// eslint-disable-next-line import/extensions
|
|
||||||
import {customElement} from 'lit/decorators.js';
|
import {customElement} from 'lit/decorators.js';
|
||||||
|
|
||||||
import {type JSXElement} from '../types';
|
import {type JSXElement} from '../typings';
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
namespace JSX {
|
namespace JSX {
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
import {TextField as MWCTextField} from '@material/mwc-textfield';
|
import {TextField as MWCTextField} from '@material/mwc-textfield';
|
||||||
|
import styles from '@openstamanager/scss/material/text-field.scss';
|
||||||
import {waitUntil} from 'async-wait-until';
|
import {waitUntil} from 'async-wait-until';
|
||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
import {
|
import {
|
||||||
type TemplateResult, css, html, unsafeCSS
|
type TemplateResult, css, html, unsafeCSS
|
||||||
} from 'lit';
|
} from 'lit';
|
||||||
// eslint-disable-next-line import/extensions
|
|
||||||
import {customElement, property} from 'lit/decorators.js';
|
import {customElement, property} from 'lit/decorators.js';
|
||||||
|
|
||||||
import styles from '../../scss/material/text-field.scss';
|
import type {JSXElement} from '../typings';
|
||||||
import type {JSXElement} from '../types';
|
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
namespace JSX {
|
namespace JSX {
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import {TopAppBar as MWCTopAppBar} from '@material/mwc-top-app-bar';
|
import {TopAppBar as MWCTopAppBar} from '@material/mwc-top-app-bar';
|
||||||
import {css} from 'lit';
|
import {css} from 'lit';
|
||||||
// eslint-disable-next-line import/extensions
|
|
||||||
import {customElement} from 'lit/decorators.js';
|
import {customElement} from 'lit/decorators.js';
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
|
@ -26,7 +26,7 @@ import $, {
|
|||||||
type Element
|
type Element
|
||||||
} from 'cash-dom';
|
} from 'cash-dom';
|
||||||
|
|
||||||
import type {JSXElement} from './types';
|
import type {JSXElement} from './typings';
|
||||||
|
|
||||||
// Declare Material JSX components
|
// Declare Material JSX components
|
||||||
declare global {
|
declare global {
|
||||||
|
@ -7,7 +7,7 @@ import redaxios from 'redaxios';
|
|||||||
import {registerSW} from 'virtual:pwa-register';
|
import {registerSW} from 'virtual:pwa-register';
|
||||||
|
|
||||||
import {type Page} from './Components';
|
import {type Page} from './Components';
|
||||||
import {OpenSTAManager} from './types/modules';
|
import {OpenSTAManager} from './typings/modules';
|
||||||
import {
|
import {
|
||||||
__ as translator,
|
__ as translator,
|
||||||
showSnackbar
|
showSnackbar
|
||||||
@ -72,7 +72,6 @@ $('#logout-button')
|
|||||||
window.location.href = route('auth.login');
|
window.location.href = route('auth.login');
|
||||||
});
|
});
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
||||||
const updateSW = registerSW({
|
const updateSW = registerSW({
|
||||||
async onNeedRefresh() {
|
async onNeedRefresh() {
|
||||||
const action = await showSnackbar(__('Aggiornamento del frontend disponibile!'), false, __('Ricarica'), __('Annulla'));
|
const action = await showSnackbar(__('Aggiornamento del frontend disponibile!'), false, __('Ricarica'), __('Annulla'));
|
||||||
|
2
resources/js/globals.d.ts
vendored
2
resources/js/globals.d.ts
vendored
@ -5,7 +5,7 @@ import type cash from 'cash-dom';
|
|||||||
import type Mithril from 'mithril';
|
import type Mithril from 'mithril';
|
||||||
import type router from 'ziggy-js';
|
import type router from 'ziggy-js';
|
||||||
|
|
||||||
import {OpenSTAManager} from './types/modules';
|
import {OpenSTAManager} from './typings/modules';
|
||||||
import type {__ as translator} from './utils';
|
import type {__ as translator} from './utils';
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
export * from './Components';
|
export * from './Components';
|
||||||
export * from './Models';
|
export * from './Models';
|
||||||
export * from './types';
|
export * from './typings';
|
||||||
export * from './utils';
|
export * from './utils';
|
||||||
export * from './Views';
|
export * from './Views';
|
||||||
export * from './WebComponents';
|
export * from './WebComponents';
|
||||||
|
89
resources/js/typings/forms.ts
Normal file
89
resources/js/typings/forms.ts
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
import {ListItemBase} from '@material/mwc-list/mwc-list-item-base.js';
|
||||||
|
import {
|
||||||
|
TextAreaCharCounter,
|
||||||
|
TextFieldInputMode,
|
||||||
|
TextFieldType
|
||||||
|
} from '@material/mwc-textfield';
|
||||||
|
|
||||||
|
import {MaterialIcons} from './icons';
|
||||||
|
|
||||||
|
export interface FieldT {
|
||||||
|
id?: string
|
||||||
|
name?: string
|
||||||
|
value?: string
|
||||||
|
label?: string
|
||||||
|
outlined?: boolean
|
||||||
|
helper?: string
|
||||||
|
icon?: string | MaterialIcons
|
||||||
|
placeholder?: string
|
||||||
|
disabled?: boolean
|
||||||
|
required?: boolean
|
||||||
|
validity?: ValidityState
|
||||||
|
validityTransform?: (
|
||||||
|
value: string,
|
||||||
|
nativeValidity: ValidityState,
|
||||||
|
) => Partial<ValidityState> | null
|
||||||
|
validateOnInitialRender?: boolean
|
||||||
|
validationMessage?: string
|
||||||
|
// Custom
|
||||||
|
type?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type TextFieldT = FieldT & {
|
||||||
|
type?: TextFieldType
|
||||||
|
prefix?: string
|
||||||
|
suffix?: string
|
||||||
|
iconTrailing?: string
|
||||||
|
charCounter?: boolean
|
||||||
|
helperPersistent?: boolean | string
|
||||||
|
minLength?: number
|
||||||
|
maxLength?: number
|
||||||
|
pattern?: string
|
||||||
|
min?: number | string
|
||||||
|
max?: number | string
|
||||||
|
size?: number | null
|
||||||
|
step?: number | null
|
||||||
|
autoValidate?: boolean
|
||||||
|
willValidate?: boolean
|
||||||
|
name?: string
|
||||||
|
inputMode?: TextFieldInputMode
|
||||||
|
readOnly?: boolean
|
||||||
|
autocapitalize?:
|
||||||
|
| 'on'
|
||||||
|
| 'off'
|
||||||
|
| 'sentences'
|
||||||
|
| 'none'
|
||||||
|
| 'words'
|
||||||
|
| 'characters'
|
||||||
|
endAligned?: boolean
|
||||||
|
elementType?: 'text-field'
|
||||||
|
};
|
||||||
|
|
||||||
|
export type TextAreaT = FieldT & {
|
||||||
|
rows?: number
|
||||||
|
cols?: number
|
||||||
|
type?: TextFieldType
|
||||||
|
iconTrailing?: string
|
||||||
|
charCounter?: boolean | TextAreaCharCounter
|
||||||
|
willValidate?: boolean
|
||||||
|
helperPersistent?: boolean | string
|
||||||
|
maxLength?: number
|
||||||
|
elementType?: 'text-area'
|
||||||
|
};
|
||||||
|
|
||||||
|
export type SelectOptionsT = {
|
||||||
|
label: string
|
||||||
|
value: string
|
||||||
|
}[];
|
||||||
|
|
||||||
|
export type SelectT = FieldT & {
|
||||||
|
multiple?: boolean
|
||||||
|
naturalMenuWidth?: boolean
|
||||||
|
fixedMenuPosition?: boolean
|
||||||
|
willValidate?: boolean
|
||||||
|
elementType?: 'material-select'
|
||||||
|
selected?: ListItemBase | null
|
||||||
|
items?: ListItemBase[]
|
||||||
|
index?: number
|
||||||
|
options?: SelectOptionsT | Promise<SelectOptionsT>
|
||||||
|
};
|
@ -1,103 +1,3 @@
|
|||||||
import type {ListItemBase} from '@material/mwc-list/mwc-list-item-base';
|
|
||||||
import type {
|
|
||||||
TextAreaCharCounter,
|
|
||||||
TextFieldInputMode,
|
|
||||||
TextFieldType
|
|
||||||
} from '@material/mwc-textfield';
|
|
||||||
import type {
|
|
||||||
Attributes,
|
|
||||||
CommonAttributes
|
|
||||||
} from 'mithril';
|
|
||||||
import type {Response} from 'redaxios';
|
|
||||||
|
|
||||||
export type ErrorResponse = Response<{errors: Record<string, string>}>;
|
|
||||||
|
|
||||||
export type JSXElement<T> = Omit<Partial<T>, 'children' | 'style'>
|
|
||||||
& CommonAttributes<any, any>
|
|
||||||
& {
|
|
||||||
children?: JSX.Element | JSX.Element[] | Attributes | Attributes[],
|
|
||||||
style?: string | CSSStyleDeclaration
|
|
||||||
};
|
|
||||||
|
|
||||||
export type FieldT = {
|
|
||||||
id?: string
|
|
||||||
name?: string
|
|
||||||
value?: string
|
|
||||||
label?: string
|
|
||||||
outlined?: boolean
|
|
||||||
helper?: string
|
|
||||||
icon?: string | MaterialIcons
|
|
||||||
placeholder?: string
|
|
||||||
disabled?: boolean
|
|
||||||
required?: boolean
|
|
||||||
validity?: ValidityState
|
|
||||||
validityTransform?: (
|
|
||||||
value: string,
|
|
||||||
nativeValidity: ValidityState,
|
|
||||||
) => Partial<ValidityState> | null
|
|
||||||
validateOnInitialRender?: boolean
|
|
||||||
validationMessage?: string
|
|
||||||
// Custom
|
|
||||||
type?: string
|
|
||||||
};
|
|
||||||
export type TextFieldT = FieldT & {
|
|
||||||
type?: TextFieldType
|
|
||||||
prefix?: string
|
|
||||||
suffix?: string
|
|
||||||
iconTrailing?: string
|
|
||||||
charCounter?: boolean
|
|
||||||
helperPersistent?: boolean | string
|
|
||||||
minLength?: number
|
|
||||||
maxLength?: number
|
|
||||||
pattern?: string
|
|
||||||
min?: number | string
|
|
||||||
max?: number | string
|
|
||||||
size?: number | null
|
|
||||||
step?: number | null
|
|
||||||
autoValidate?: boolean
|
|
||||||
willValidate?: boolean
|
|
||||||
name?: string
|
|
||||||
inputMode?: TextFieldInputMode
|
|
||||||
readOnly?: boolean
|
|
||||||
autocapitalize?:
|
|
||||||
| 'on'
|
|
||||||
| 'off'
|
|
||||||
| 'sentences'
|
|
||||||
| 'none'
|
|
||||||
| 'words'
|
|
||||||
| 'characters'
|
|
||||||
endAligned?: boolean
|
|
||||||
elementType?: 'text-field'
|
|
||||||
};
|
|
||||||
export type TextAreaT = FieldT & {
|
|
||||||
rows?: number
|
|
||||||
cols?: number
|
|
||||||
type?: TextFieldType
|
|
||||||
iconTrailing?: string
|
|
||||||
charCounter?: boolean | TextAreaCharCounter
|
|
||||||
willValidate?: boolean
|
|
||||||
helperPersistent?: boolean | string
|
|
||||||
maxLength?: number
|
|
||||||
elementType?: 'text-area'
|
|
||||||
};
|
|
||||||
|
|
||||||
export type SelectOptionsT = {
|
|
||||||
label: string
|
|
||||||
value: string
|
|
||||||
}[];
|
|
||||||
|
|
||||||
export type SelectT = FieldT & {
|
|
||||||
multiple?: boolean
|
|
||||||
naturalMenuWidth?: boolean
|
|
||||||
fixedMenuPosition?: boolean
|
|
||||||
willValidate?: boolean
|
|
||||||
elementType?: 'material-select'
|
|
||||||
selected?: ListItemBase | null
|
|
||||||
items?: ListItemBase[]
|
|
||||||
index?: number
|
|
||||||
options?: SelectOptionsT | Promise<SelectOptionsT>
|
|
||||||
};
|
|
||||||
|
|
||||||
export type MaterialIcons =
|
export type MaterialIcons =
|
||||||
| '10k'
|
| '10k'
|
||||||
| '10mp'
|
| '10mp'
|
7
resources/js/typings/index.ts
Normal file
7
resources/js/typings/index.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
/**
|
||||||
|
* This file exports only from files that has exportable types definition or interfaces.
|
||||||
|
*/
|
||||||
|
|
||||||
|
export * from './forms';
|
||||||
|
export * from './icons';
|
||||||
|
export * from './misc';
|
15
resources/js/typings/misc.ts
Normal file
15
resources/js/typings/misc.ts
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import type {
|
||||||
|
Attributes,
|
||||||
|
CommonAttributes
|
||||||
|
} from 'mithril';
|
||||||
|
import type {Response} from 'redaxios';
|
||||||
|
|
||||||
|
export type ErrorResponse = Response<{errors: Record<string, string>}>;
|
||||||
|
|
||||||
|
export type JSXElement<T> = Omit<Partial<T>, 'children' | 'style'>
|
||||||
|
& CommonAttributes<any, any>
|
||||||
|
& {
|
||||||
|
children?: JSX.Element | JSX.Element[] | Attributes | Attributes[],
|
||||||
|
style?: string | CSSStyleDeclaration
|
||||||
|
};
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
import {MaterialIcons} from '../types';
|
import {MaterialIcons} from './icons';
|
||||||
|
|
||||||
declare module OpenSTAManager {
|
declare module OpenSTAManager {
|
||||||
export type Modules = Record<string, Module>;
|
export type Modules = Record<string, Module>;
|
@ -16,14 +16,23 @@
|
|||||||
"dom.iterable"
|
"dom.iterable"
|
||||||
],
|
],
|
||||||
"types": [
|
"types": [
|
||||||
|
"vite/client",
|
||||||
"vite-plugin-pwa/client"
|
"vite-plugin-pwa/client"
|
||||||
],
|
],
|
||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
"paths": {
|
"paths": {
|
||||||
"/images/logo_completo.png": ["resources/static/images/logo_completo.png"]
|
"@openstamanager/assets/*": [
|
||||||
|
"resources/static/*"
|
||||||
|
],
|
||||||
|
"@openstamanager/scss/*": [
|
||||||
|
"resources/scss/*"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"exclude": ["**/node_modules", "**/.*/"],
|
"exclude": [
|
||||||
|
"**/node_modules",
|
||||||
|
"**/.*/"
|
||||||
|
],
|
||||||
"include": [
|
"include": [
|
||||||
"resources/js/**/*",
|
"resources/js/**/*",
|
||||||
"gulpfile.ts",
|
"gulpfile.ts",
|
||||||
|
Reference in New Issue
Block a user