Compare commits

..

3 Commits

Author SHA1 Message Date
Flatlogic Bot
12bcbe00bf Updated via schema editor on 2025-09-02 23:05 2025-09-02 23:06:27 +00:00
Flatlogic Bot
166ee1b5bc Updated via schema editor on 2025-09-02 23:03 2025-09-02 23:04:37 +00:00
Flatlogic Bot
f6126e3a5d alpha 2025-09-02 22:58:48 +00:00
20 changed files with 145 additions and 134 deletions

5
.gitignore vendored
View File

@ -1,3 +1,8 @@
node_modules/
*/node_modules/
*/build/
**/node_modules/
**/build/
.DS_Store
.env

File diff suppressed because one or more lines are too long

View File

@ -27,7 +27,7 @@ module.exports = class PrenotazioniDBApi {
transaction,
});
await prenotazioni.setTavolo(data.tavolo || null, {
await prenotazioni.setGioco(data.gioco || null, {
transaction,
});
@ -86,9 +86,9 @@ module.exports = class PrenotazioniDBApi {
);
}
if (data.tavolo !== undefined) {
await prenotazioni.setTavolo(
data.tavolo,
if (data.gioco !== undefined) {
await prenotazioni.setGioco(
data.gioco,
{ transaction },
);
@ -162,7 +162,7 @@ module.exports = class PrenotazioniDBApi {
transaction,
});
output.tavolo = await prenotazioni.getTavolo({
output.gioco = await prenotazioni.getGioco({
transaction,
});
@ -210,21 +210,21 @@ module.exports = class PrenotazioniDBApi {
{
model: db.tavoli,
as: 'tavolo',
as: 'gioco',
where: filter.tavolo
where: filter.gioco
? {
[Op.or]: [
{
id: {
[Op.in]: filter.tavolo
[Op.in]: filter.gioco
.split('|')
.map((term) => Utils.uuid(term)),
},
},
{
posti_totali: {
[Op.or]: filter.tavolo
[Op.or]: filter.gioco
.split('|')
.map((term) => ({ [Op.iLike]: `%${term}%` })),
},

View File

@ -154,7 +154,7 @@ module.exports = class TavoliDBApi {
const output = tavoli.get({ plain: true });
output.prenotazioni_tavolo = await tavoli.getPrenotazioni_tavolo({
output.prenotazioni_gioco = await tavoli.getPrenotazioni_gioco({
transaction,
});

View File

@ -0,0 +1,44 @@
module.exports = {
/**
* @param {QueryInterface} queryInterface
* @param {Sequelize} Sequelize
* @returns {Promise<void>}
*/
async up(queryInterface, Sequelize) {
/**
* @type {Transaction}
*/
const transaction = await queryInterface.sequelize.transaction();
try {
await queryInterface.renameColumn('prenotazioni', 'tavoloId', 'giocoId', {
transaction,
});
await transaction.commit();
} catch (err) {
await transaction.rollback();
throw err;
}
},
/**
* @param {QueryInterface} queryInterface
* @param {Sequelize} Sequelize
* @returns {Promise<void>}
*/
async down(queryInterface, Sequelize) {
/**
* @type {Transaction}
*/
const transaction = await queryInterface.sequelize.transaction();
try {
await queryInterface.renameColumn('prenotazioni', 'giocoId', 'tavoloId', {
transaction,
});
await transaction.commit();
} catch (err) {
await transaction.rollback();
throw err;
}
},
};

View File

@ -0,0 +1,36 @@
module.exports = {
/**
* @param {QueryInterface} queryInterface
* @param {Sequelize} Sequelize
* @returns {Promise<void>}
*/
async up(queryInterface, Sequelize) {
/**
* @type {Transaction}
*/
const transaction = await queryInterface.sequelize.transaction();
try {
await transaction.commit();
} catch (err) {
await transaction.rollback();
throw err;
}
},
/**
* @param {QueryInterface} queryInterface
* @param {Sequelize} Sequelize
* @returns {Promise<void>}
*/
async down(queryInterface, Sequelize) {
/**
* @type {Transaction}
*/
const transaction = await queryInterface.sequelize.transaction();
try {
await transaction.commit();
} catch (err) {
await transaction.rollback();
throw err;
}
},
};

View File

@ -45,9 +45,9 @@ module.exports = function (sequelize, DataTypes) {
});
db.prenotazioni.belongsTo(db.tavoli, {
as: 'tavolo',
as: 'gioco',
foreignKey: {
name: 'tavoloId',
name: 'giocoId',
},
constraints: false,
});

View File

@ -39,9 +39,9 @@ module.exports = function (sequelize, DataTypes) {
/// loop through entities and it's fields, and if ref === current e[name] and create relation has many on parent entity
db.tavoli.hasMany(db.prenotazioni, {
as: 'prenotazioni_tavolo',
as: 'prenotazioni_gioco',
foreignKey: {
name: 'tavoloId',
name: 'giocoId',
},
constraints: false,
});

View File

@ -27,12 +27,6 @@ const GiochiData = [
// type code here for "images" field
},
{
nome: 'Ticket to Ride',
// type code here for "images" field
},
];
const PrenotazioniData = [
@ -59,14 +53,6 @@ const PrenotazioniData = [
data_prenotazione: new Date('2023-11-12T12:00:00Z'),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
data_prenotazione: new Date('2023-11-13T13:00:00Z'),
},
];
const SerateData = [
@ -93,14 +79,6 @@ const SerateData = [
numero_tavoli: 6,
},
{
tema: 'Serata giochi da tavolo classici',
data: new Date('2023-12-06T19:00:00Z'),
numero_tavoli: 3,
},
];
const TavoliData = [
@ -133,16 +111,6 @@ const TavoliData = [
posti_occupati: 4,
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
posti_totali: 3,
posti_occupati: 1,
},
];
// Similar logic for "relation_many"
@ -180,62 +148,40 @@ async function associatePrenotazioniWithUtente() {
if (Prenotazioni2?.setUtente) {
await Prenotazioni2.setUtente(relatedUtente2);
}
const relatedUtente3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Prenotazioni3 = await Prenotazioni.findOne({
order: [['id', 'ASC']],
offset: 3,
});
if (Prenotazioni3?.setUtente) {
await Prenotazioni3.setUtente(relatedUtente3);
}
}
async function associatePrenotazioniWithTavolo() {
const relatedTavolo0 = await Tavoli.findOne({
async function associatePrenotazioniWithGioco() {
const relatedGioco0 = await Tavoli.findOne({
offset: Math.floor(Math.random() * (await Tavoli.count())),
});
const Prenotazioni0 = await Prenotazioni.findOne({
order: [['id', 'ASC']],
offset: 0,
});
if (Prenotazioni0?.setTavolo) {
await Prenotazioni0.setTavolo(relatedTavolo0);
if (Prenotazioni0?.setGioco) {
await Prenotazioni0.setGioco(relatedGioco0);
}
const relatedTavolo1 = await Tavoli.findOne({
const relatedGioco1 = await Tavoli.findOne({
offset: Math.floor(Math.random() * (await Tavoli.count())),
});
const Prenotazioni1 = await Prenotazioni.findOne({
order: [['id', 'ASC']],
offset: 1,
});
if (Prenotazioni1?.setTavolo) {
await Prenotazioni1.setTavolo(relatedTavolo1);
if (Prenotazioni1?.setGioco) {
await Prenotazioni1.setGioco(relatedGioco1);
}
const relatedTavolo2 = await Tavoli.findOne({
const relatedGioco2 = await Tavoli.findOne({
offset: Math.floor(Math.random() * (await Tavoli.count())),
});
const Prenotazioni2 = await Prenotazioni.findOne({
order: [['id', 'ASC']],
offset: 2,
});
if (Prenotazioni2?.setTavolo) {
await Prenotazioni2.setTavolo(relatedTavolo2);
}
const relatedTavolo3 = await Tavoli.findOne({
offset: Math.floor(Math.random() * (await Tavoli.count())),
});
const Prenotazioni3 = await Prenotazioni.findOne({
order: [['id', 'ASC']],
offset: 3,
});
if (Prenotazioni3?.setTavolo) {
await Prenotazioni3.setTavolo(relatedTavolo3);
if (Prenotazioni2?.setGioco) {
await Prenotazioni2.setGioco(relatedGioco2);
}
}
@ -272,17 +218,6 @@ async function associateTavoliWithSeratum() {
if (Tavoli2?.setSeratum) {
await Tavoli2.setSeratum(relatedSeratum2);
}
const relatedSeratum3 = await Serate.findOne({
offset: Math.floor(Math.random() * (await Serate.count())),
});
const Tavoli3 = await Tavoli.findOne({
order: [['id', 'ASC']],
offset: 3,
});
if (Tavoli3?.setSeratum) {
await Tavoli3.setSeratum(relatedSeratum3);
}
}
async function associateTavoliWithGioco() {
@ -318,17 +253,6 @@ async function associateTavoliWithGioco() {
if (Tavoli2?.setGioco) {
await Tavoli2.setGioco(relatedGioco2);
}
const relatedGioco3 = await Giochi.findOne({
offset: Math.floor(Math.random() * (await Giochi.count())),
});
const Tavoli3 = await Tavoli.findOne({
order: [['id', 'ASC']],
offset: 3,
});
if (Tavoli3?.setGioco) {
await Tavoli3.setGioco(relatedGioco3);
}
}
module.exports = {
@ -346,7 +270,7 @@ module.exports = {
await associatePrenotazioniWithUtente(),
await associatePrenotazioniWithTavolo(),
await associatePrenotazioniWithGioco(),
await associateTavoliWithSeratum(),

View File

@ -0,0 +1 @@
{}

View File

@ -89,11 +89,11 @@ const CardPrenotazioni = ({
<div className='flex justify-between gap-x-4 py-3'>
<dt className=' text-gray-500 dark:text-dark-600'>
Tavolo
Giochi
</dt>
<dd className='flex items-start gap-x-2'>
<div className='font-medium line-clamp-4'>
{dataFormatter.tavoliOneListFormatter(item.tavolo)}
{dataFormatter.tavoliOneListFormatter(item.gioco)}
</div>
</dd>
</div>

View File

@ -61,9 +61,9 @@ const ListPrenotazioni = ({
</div>
<div className={'flex-1 px-3'}>
<p className={'text-xs text-gray-500 '}>Tavolo</p>
<p className={'text-xs text-gray-500 '}>Giochi</p>
<p className={'line-clamp-2'}>
{dataFormatter.tavoliOneListFormatter(item.tavolo)}
{dataFormatter.tavoliOneListFormatter(item.gioco)}
</p>
</div>

View File

@ -59,8 +59,8 @@ export const loadColumns = async (
},
{
field: 'tavolo',
headerName: 'Tavolo',
field: 'gioco',
headerName: 'Giochi',
flex: 1,
minWidth: 120,
filterable: false,

View File

@ -38,7 +38,7 @@ const EditPrenotazioni = () => {
const initVals = {
utente: null,
tavolo: null,
gioco: null,
data_prenotazione: new Date(),
};
@ -106,12 +106,12 @@ const EditPrenotazioni = () => {
></Field>
</FormField>
<FormField label='Tavolo' labelFor='tavolo'>
<FormField label='Giochi' labelFor='gioco'>
<Field
name='tavolo'
id='tavolo'
name='gioco'
id='gioco'
component={SelectField}
options={initialValues.tavolo}
options={initialValues.gioco}
itemRef={'tavoli'}
showField={'posti_totali'}
></Field>

View File

@ -38,7 +38,7 @@ const EditPrenotazioniPage = () => {
const initVals = {
utente: null,
tavolo: null,
gioco: null,
data_prenotazione: new Date(),
};
@ -104,12 +104,12 @@ const EditPrenotazioniPage = () => {
></Field>
</FormField>
<FormField label='Tavolo' labelFor='tavolo'>
<FormField label='Giochi' labelFor='gioco'>
<Field
name='tavolo'
id='tavolo'
name='gioco'
id='gioco'
component={SelectField}
options={initialValues.tavolo}
options={initialValues.gioco}
itemRef={'tavoli'}
showField={'posti_totali'}
></Field>

View File

@ -36,7 +36,7 @@ const PrenotazioniTablesPage = () => {
{ label: 'Utente', title: 'utente' },
{ label: 'Tavolo', title: 'tavolo' },
{ label: 'Giochi', title: 'gioco' },
]);
const hasCreatePermission =

View File

@ -35,7 +35,7 @@ import moment from 'moment';
const initialValues = {
utente: '',
tavolo: '',
gioco: '',
data_prenotazione: '',
};
@ -77,10 +77,10 @@ const PrenotazioniNew = () => {
></Field>
</FormField>
<FormField label='Tavolo' labelFor='tavolo'>
<FormField label='Giochi' labelFor='gioco'>
<Field
name='tavolo'
id='tavolo'
name='gioco'
id='gioco'
component={SelectField}
options={[]}
itemRef={'tavoli'}

View File

@ -36,7 +36,7 @@ const PrenotazioniTablesPage = () => {
{ label: 'Utente', title: 'utente' },
{ label: 'Tavolo', title: 'tavolo' },
{ label: 'Giochi', title: 'gioco' },
]);
const hasCreatePermission =

View File

@ -61,9 +61,9 @@ const PrenotazioniView = () => {
</div>
<div className={'mb-4'}>
<p className={'block font-bold mb-2'}>Tavolo</p>
<p className={'block font-bold mb-2'}>Giochi</p>
<p>{prenotazioni?.tavolo?.posti_totali ?? 'No data'}</p>
<p>{prenotazioni?.gioco?.posti_totali ?? 'No data'}</p>
</div>
<FormField label='DataPrenotazione'>

View File

@ -77,7 +77,7 @@ const TavoliView = () => {
</div>
<>
<p className={'block font-bold mb-2'}>Prenotazioni Tavolo</p>
<p className={'block font-bold mb-2'}>Prenotazioni Giochi</p>
<CardBox
className='mb-6 border border-gray-300 rounded overflow-hidden'
hasTable
@ -90,9 +90,9 @@ const TavoliView = () => {
</tr>
</thead>
<tbody>
{tavoli.prenotazioni_tavolo &&
Array.isArray(tavoli.prenotazioni_tavolo) &&
tavoli.prenotazioni_tavolo.map((item: any) => (
{tavoli.prenotazioni_gioco &&
Array.isArray(tavoli.prenotazioni_gioco) &&
tavoli.prenotazioni_gioco.map((item: any) => (
<tr
key={item.id}
onClick={() =>
@ -111,7 +111,7 @@ const TavoliView = () => {
</tbody>
</table>
</div>
{!tavoli?.prenotazioni_tavolo?.length && (
{!tavoli?.prenotazioni_gioco?.length && (
<div className={'text-center py-4'}>No data</div>
)}
</CardBox>