mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-06-05 22:09:38 +02:00
refactor: ♻️ Refactor generale
This commit is contained in:
6
.idea/inspectionProfiles/Project_Default.xml
generated
6
.idea/inspectionProfiles/Project_Default.xml
generated
@@ -210,12 +210,6 @@
|
|||||||
<inspection_tool class="IfStatementWithTooManyBranchesJS" enabled="true" level="WARNING" enabled_by_default="true">
|
<inspection_tool class="IfStatementWithTooManyBranchesJS" enabled="true" level="WARNING" enabled_by_default="true">
|
||||||
<option name="m_limit" value="3" />
|
<option name="m_limit" value="3" />
|
||||||
</inspection_tool>
|
</inspection_tool>
|
||||||
<inspection_tool class="IgnoreCoverEntry" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
||||||
<inspection_tool class="IgnoreDuplicateEntry" enabled="false" level="ERROR" enabled_by_default="false" />
|
|
||||||
<inspection_tool class="IgnoreIncorrectEntry" enabled="false" level="ERROR" enabled_by_default="false" />
|
|
||||||
<inspection_tool class="IgnoreRelativeEntry" enabled="false" level="ERROR" enabled_by_default="false" />
|
|
||||||
<inspection_tool class="IgnoreSyntaxEntry" enabled="false" level="ERROR" enabled_by_default="false" />
|
|
||||||
<inspection_tool class="IgnoreUnusedEntry" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
|
||||||
<inspection_tool class="InconsistentLineSeparators" enabled="true" level="WARNING" enabled_by_default="true" />
|
<inspection_tool class="InconsistentLineSeparators" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||||
<inspection_tool class="IncrementDecrementResultUsedJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
<inspection_tool class="IncrementDecrementResultUsedJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||||
<inspection_tool class="InvertedIfElseConstructsInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
|
<inspection_tool class="InvertedIfElseConstructsInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
|
||||||
|
@@ -4,6 +4,7 @@ import {mdiChevronLeft} from '@mdi/js';
|
|||||||
import MdIcon from '@osm/Components/MdIcon';
|
import MdIcon from '@osm/Components/MdIcon';
|
||||||
import Page, {PageAttributes} from '@osm/Components/Page';
|
import Page, {PageAttributes} from '@osm/Components/Page';
|
||||||
import Model from '@osm/Models/Model';
|
import Model from '@osm/Models/Model';
|
||||||
|
import {showSnackbar} from '@osm/utils/misc';
|
||||||
import {Builder} from 'coloquent';
|
import {Builder} from 'coloquent';
|
||||||
import {
|
import {
|
||||||
Children,
|
Children,
|
||||||
@@ -20,14 +21,8 @@ export default abstract class RecordPage<M extends Model<any, any>, A extends Re
|
|||||||
abstract recordType: Class<M> & typeof Model<any, any>;
|
abstract recordType: Class<M> & typeof Model<any, any>;
|
||||||
record?: M;
|
record?: M;
|
||||||
|
|
||||||
public oninit(vnode: Vnode<A, this>): void {
|
async oninit(vnode: Vnode<A, this>) {
|
||||||
super.oninit(vnode);
|
super.oninit(vnode);
|
||||||
m.redraw();
|
|
||||||
}
|
|
||||||
|
|
||||||
async onbeforeupdate(vnode: VnodeDOM<A, this>) {
|
|
||||||
super.onbeforeupdate(vnode);
|
|
||||||
|
|
||||||
const {id: recordId} = route().params as {id: number | string};
|
const {id: recordId} = route().params as {id: number | string};
|
||||||
if (recordId !== this.record?.getId()) {
|
if (recordId !== this.record?.getId()) {
|
||||||
await this.loadRecord(recordId);
|
await this.loadRecord(recordId);
|
||||||
@@ -39,7 +34,9 @@ export default abstract class RecordPage<M extends Model<any, any>, A extends Re
|
|||||||
try {
|
try {
|
||||||
const response = await this.modelQuery().find(recordId);
|
const response = await this.modelQuery().find(recordId);
|
||||||
this.record = response.getData() || undefined;
|
this.record = response.getData() || undefined;
|
||||||
} catch {
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
void showSnackbar(__('Errore durante il caricamento del record'));
|
||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -103,6 +103,7 @@ export default abstract class RecordsPage<
|
|||||||
}
|
}
|
||||||
|
|
||||||
modelQuery() {
|
modelQuery() {
|
||||||
|
// @ts-ignore
|
||||||
let query = this.modelType.query<M>();
|
let query = this.modelType.query<M>();
|
||||||
|
|
||||||
for (const [attribute, value] of this.filters) {
|
for (const [attribute, value] of this.filters) {
|
||||||
@@ -323,8 +324,9 @@ export default abstract class RecordsPage<
|
|||||||
return this.recordDialogsStates.get(key)!;
|
return this.recordDialogsStates.get(key)!;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected cellValueModifier(value: unknown, attribute: string, record: M): Match<string, unknown> {
|
protected cellValueModifier(value: unknown, attribute: string, record: M): Match<string, unknown, string[], string> {
|
||||||
return match(attribute)
|
return match(attribute)
|
||||||
|
.returnType()
|
||||||
.with('createdAt', 'updatedAt', () => dayjs(value as Date).format('DD/MM/YYYY HH:mm'));
|
.with('createdAt', 'updatedAt', () => dayjs(value as Date).format('DD/MM/YYYY HH:mm'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user