fix render rows order on mobile
This commit is contained in:
parent
f5890c94b2
commit
7664e71506
@ -7,7 +7,7 @@ export const rows: FormTabRows = [
|
|||||||
{
|
{
|
||||||
title: 'Регистрация',
|
title: 'Регистрация',
|
||||||
},
|
},
|
||||||
[['radioObjectRegistration', 'radioTypePTS'], { gridTemplateColumns: ['1fr 1fr'] }],
|
[['radioObjectRegistration', 'radioTypePTS'], { gridTemplateColumns: ['1fr', '1fr 1fr'] }],
|
||||||
[['selectRegionRegistration', 'selectTownRegistration', 'selectObjectRegionRegistration']],
|
[['selectRegionRegistration', 'selectTownRegistration', 'selectObjectRegionRegistration']],
|
||||||
[['selectObjectCategoryTax', 'selectObjectTypeTax', 'tbxVehicleTaxInYear']],
|
[['selectObjectCategoryTax', 'selectObjectTypeTax', 'tbxVehicleTaxInYear']],
|
||||||
[['tbxLeaseObjectYear', 'tbxLeaseObjectMotorPower', 'tbxVehicleTaxInLeasingPeriod']],
|
[['tbxLeaseObjectYear', 'tbxLeaseObjectMotorPower', 'tbxVehicleTaxInLeasingPeriod']],
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import type { FormTabRows } from '../../lib/render-rows';
|
import type { FormTabRows } from '../../lib/render-rows';
|
||||||
|
import { transformRowsForMobile } from '../lib/utils';
|
||||||
|
|
||||||
export const id = 'leasing-object';
|
export const id = 'leasing-object';
|
||||||
export const title = 'ПЛ';
|
export const title = 'ПЛ';
|
||||||
@ -16,3 +17,5 @@ export const rows: FormTabRows = [
|
|||||||
[['selectLeaseObjectCategory', 'tbxEngineVolume', 'tbxMileage']],
|
[['selectLeaseObjectCategory', 'tbxEngineVolume', 'tbxMileage']],
|
||||||
[['tbxMaxMass', 'tbxEngineHours', 'tbxVIN']],
|
[['tbxMaxMass', 'tbxEngineHours', 'tbxVIN']],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
export const mobileRows = transformRowsForMobile(rows);
|
||||||
|
|||||||
@ -1,8 +1,14 @@
|
|||||||
import renderFormRows from '../../lib/render-rows';
|
import renderFormRows from '../../lib/render-rows';
|
||||||
import { id, rows, title } from './config';
|
import { id, mobileRows, rows, title } from './config';
|
||||||
|
import { Media } from '@/styles/media';
|
||||||
|
|
||||||
function LeasingObject() {
|
function LeasingObject() {
|
||||||
return renderFormRows(rows);
|
return (
|
||||||
|
<>
|
||||||
|
<Media lessThan="laptop">{renderFormRows(mobileRows)}</Media>
|
||||||
|
<Media greaterThanOrEqual="laptop">{renderFormRows(rows)}</Media>
|
||||||
|
</>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import type { FormTabRows } from '../../lib/render-rows';
|
import type { FormTabRows } from '../../lib/render-rows';
|
||||||
|
import { transformRowsForMobile } from '../lib/utils';
|
||||||
|
|
||||||
export const id = 'supplier-agent';
|
export const id = 'supplier-agent';
|
||||||
export const title = 'Поставщик/агент';
|
export const title = 'Поставщик/агент';
|
||||||
@ -20,3 +21,5 @@ export const rows: FormTabRows = [
|
|||||||
[['selectCalcBrokerRewardCondition', 'selectFinDepartmentRewardCondtion'], defaultRowStyle],
|
[['selectCalcBrokerRewardCondition', 'selectFinDepartmentRewardCondtion'], defaultRowStyle],
|
||||||
[['tbxCalcBrokerRewardSum', 'tbxFinDepartmentRewardSumm'], defaultRowStyle],
|
[['tbxCalcBrokerRewardSum', 'tbxFinDepartmentRewardSumm'], defaultRowStyle],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
export const mobileRows = transformRowsForMobile(rows);
|
||||||
|
|||||||
@ -1,8 +1,14 @@
|
|||||||
import renderFormRows from '../../lib/render-rows';
|
import renderFormRows from '../../lib/render-rows';
|
||||||
import { id, rows, title } from './config';
|
import { id, mobileRows, rows, title } from './config';
|
||||||
|
import { Media } from '@/styles/media';
|
||||||
|
|
||||||
function Leasing() {
|
function Leasing() {
|
||||||
return renderFormRows(rows);
|
return (
|
||||||
|
<>
|
||||||
|
<Media lessThan="laptop">{renderFormRows(mobileRows)}</Media>
|
||||||
|
<Media greaterThanOrEqual="laptop">{renderFormRows(rows)}</Media>
|
||||||
|
</>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|||||||
32
apps/web/Components/Calculation/Form/lib/utils.js
Normal file
32
apps/web/Components/Calculation/Form/lib/utils.js
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {import('../../lib/render-rows').FormTabRows} rows
|
||||||
|
* @returns {import('../../lib/render-rows').FormTabRows}
|
||||||
|
*/
|
||||||
|
export function transformRowsForMobile(rows) {
|
||||||
|
const mobileRows = [];
|
||||||
|
let columnGroups = {};
|
||||||
|
|
||||||
|
rows.forEach((row) => {
|
||||||
|
if (Array.isArray(row)) {
|
||||||
|
row[0].forEach((item, index) => {
|
||||||
|
if (!columnGroups[index]) {
|
||||||
|
columnGroups[index] = [];
|
||||||
|
}
|
||||||
|
columnGroups[index].push(item);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
Object.values(columnGroups).forEach((group) => {
|
||||||
|
mobileRows.push([group, { gridTemplateColumns: '1fr' }]);
|
||||||
|
});
|
||||||
|
columnGroups = {};
|
||||||
|
mobileRows.push(row);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Object.values(columnGroups).forEach((group) => {
|
||||||
|
mobileRows.push([group, { gridTemplateColumns: '1fr' }]);
|
||||||
|
});
|
||||||
|
|
||||||
|
return mobileRows;
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user