Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: submit enable when replace gpkg ( MAPCO-5944 ) #571

Merged
merged 4 commits into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/common/i18n/en.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"general.empty-string": " ",
"general.whats-new.tooltip": "What's new?",
"general.logo.text": "Catalog App",
"general.version.tooltip": "Catalog App version",
Expand Down
1 change: 1 addition & 0 deletions src/common/i18n/he.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"general.empty-string": " ",
"general.whats-new.tooltip": "מה חדש?",
"general.logo.text": "אפליקצית קטלוג",
"general.version.tooltip": "אפליקצית קטלוג גרסה",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ export const LookupOptionsPresentorComponent: React.FC<LookupTablesPresentorProp
}, [innerValue]);

if (!lookupTablesData || !lookupTablesData.dictionary || fieldInfo.lookupTable == null) return null;
const lookupOptions = lookupTablesData.dictionary[fieldInfo.lookupTable];
const lookupOptions = [
{value: '', translationCode: 'general.empty-string'},
...lookupTablesData.dictionary[fieldInfo.lookupTable]
];

if (formik === undefined || mode === Mode.VIEW || (mode === Mode.EDIT && fieldInfo.isManuallyEditable !== true)) {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const ResolutionValuePresentorComponent: React.FC<ResolutionValuePresento
}, [innerValue]);

useEffect(() => {
if (!formik?.getFieldProps(`${fieldNamePrefix ?? ''}${fieldInfo.dependentField.name}`).value && lookupOptions) {
if (lookupOptions) {
const filteredOptions = lookupOptions?.filter(option => option.properties[fieldInfo.lookupTableBinding.valueFromPropertyName] === Number(value));
if (!!filteredOptions?.length) {
formik?.setFieldValue(`${fieldNamePrefix ?? ''}${fieldInfo.dependentField.name}` as string, filteredOptions[0].properties[fieldInfo.dependentField.valueFromPropertyName]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ interface IngestionFieldsProps {
validateSources?: boolean;
reloadFormMetadata?: (
ingestionFields: FormValues,
metadata: MetadataFile
metadata: MetadataFile,
removePrevData?: boolean
) => void;
formik?: EntityFormikHandlers;
manageMetadata?: boolean;
Expand Down Expand Up @@ -357,7 +358,8 @@ export const IngestionFields: React.FC<PropsWithChildren<IngestionFieldsProps>>
directory: directory,
fileNames: fileNames.join(','),
},
selected.metadata as MetadataFile
selected.metadata as MetadataFile,
true // ONLY WHEN (RE-)SELECTING FILE, removePrevData should be TRUE
);
}
};
Expand Down
10 changes: 2 additions & 8 deletions src/discrete-layer/components/layer-details/layer-details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
ValidationConfigModelType,
ValidationValueType,
} from '../../models';
import { getEnumKeys } from '../../components/layer-details/utils';
import { DEFAULT_ENUM, getEnumKeys, isEnumType } from '../../components/layer-details/utils';
import { ILayerImage } from '../../models/layerImage';
import { links } from '../../models/links';
import { getLinkUrl, getLinkUrlWithToken } from '../helpers/layersUtils';
Expand Down Expand Up @@ -155,13 +155,7 @@ export const getValuePresentor = (
formik={formik}
fieldNamePrefix={fieldNamePrefix}/>
);
case 'DemDataType':
case 'NoDataValue':
case 'VerticalDatum':
case 'Units':
case 'UndulationModel':
case 'Transparency':
case 'ProductType': {
case (isEnumType(basicType) ? basicType : DEFAULT_ENUM): {
let options: string[] = [];
if (basicType === 'ProductType') {
options = getEnumKeys(enumsMap as IEnumsMapType, basicType, layerRecord.__typename);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import { emphasizeByHTML } from '../../../../common/helpers/formatters';
import { getStatusColoredBackground } from '../../../../common/helpers/style';
import { Mode } from '../../../../common/models/mode.enum';
import { removePropertiesWithPrefix } from '../../../../common/helpers/object';
import {
EntityDescriptorModelType,
LayerMetadataMixedUnion,
Expand All @@ -36,25 +37,27 @@
LayerRecordTypes,
} from '../entity-types-keys';
import { LayersDetailsComponent } from '../layer-details';
import { IRecordFieldInfo } from '../layer-details.field-info';
import { FieldInfoName, IRecordFieldInfo } from '../layer-details.field-info';
import EntityRasterForm from './layer-datails-form.raster';
import {
clearSyncWarnings,
cleanUpEntityPayload,
filterModeDescriptors,
getFlatEntityDescriptors,
// getRecordForUpdate,
getValidationType,
getYupFieldConfig
getYupFieldConfig,
getBasicType,
isEnumType
} from '../utils';
import suite from '../validate';
import { getUIIngestionFieldDescriptors } from './ingestion.utils';

import './entity.raster.dialog.css';

const IS_EDITABLE = 'isManuallyEditable';

Check warning on line 57 in src/discrete-layer/components/layer-details/raster/entity.raster.dialog.tsx

View workflow job for this annotation

GitHub Actions / build_and_test (ubuntu-latest, 16.13.x)

'IS_EDITABLE' is assigned a value but never used
const DEFAULT_ID = 'DEFAULT_UI_ID';
const DEFAULT_TYPE_NAME = 'DEFAULT_TYPE_NAME';
const IMMEDIATE_EXECUTION = 0;

Check warning on line 60 in src/discrete-layer/components/layer-details/raster/entity.raster.dialog.tsx

View workflow job for this annotation

GitHub Actions / build_and_test (ubuntu-latest, 16.13.x)

'IMMEDIATE_EXECUTION' is assigned a value but never used
const NONE = 0;
const START = 0;

Expand All @@ -71,33 +74,32 @@
getFlatEntityDescriptors(
record['__typename'] as LayerRecordTypes,
descriptors
).filter(
field => field.default
).forEach(
descriptor => record[descriptor.fieldName as string] = descriptor.default
);
).forEach((field) => {
const fieldName = field.fieldName as string;
const fieldNameType = getBasicType(field.fieldName as FieldInfoName, DEFAULT_TYPE_NAME);
if((field.lookupTable || isEnumType(fieldNameType))) {
record[fieldName] = '';
}
if (field.default){
record[fieldName] = field.default;
}
}
)
};

export const NESTED_FORMS_PRFIX = 'polygonPart_';

export const buildRecord = (recordType: RecordType, descriptors: EntityDescriptorModelType[]): ILayerImage => {
const record = {} as Record<string, unknown>;
switch (recordType) {
case RecordType.RECORD_RASTER:
LayerRasterRecordModelKeys.forEach((key) => {
record[key as string] = undefined;
});
// record.updateDate = moment();
record.sensors = [];
record.productType = ProductType.ORTHOPHOTO;
record['__typename'] = LayerRasterRecordModel.properties['__typename'].name.replaceAll('"','');
break;
default:
break;
}

LayerRasterRecordModelKeys.forEach((key) => {
record[key as string] = undefined;
});

setDefaultValues(record, descriptors);


record.productType = ProductType.ORTHOPHOTO;
record['__typename'] = LayerRasterRecordModel.properties['__typename'].name.replaceAll('"','');
record.id = DEFAULT_ID;
record.type = recordType;

Expand Down Expand Up @@ -368,7 +370,8 @@
}
});

const newSchema = {...schema};
const newSchema = removePropertiesWithPrefix(schema, NESTED_FORMS_PRFIX);

for(let i=0; i < partsNumber; i++ ){
newSchema[`${NESTED_FORMS_PRFIX}${i+startIndex}`] = Yup.object().shape({...nestedYupSchema});
}
Expand Down Expand Up @@ -514,13 +517,6 @@
layerRecord={
mode === Mode.UPDATE
? {...props.layerRecord} as LayerMetadataMixedUnion : layerRecord

// ? getRecordForUpdate(
// props.layerRecord as LayerMetadataMixedUnion,
// layerRecord,
// descriptors as FieldConfigModelType[]
// )
// : layerRecord
}
schemaUpdater = {schemaUpdater}
yupSchema={Yup.object({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,8 @@ export const InnerRasterForm = (

const reloadFormMetadata = (
ingestionFields: FormValues,
metadata: MetadataFile
metadata: MetadataFile,
removePrevData = false
): void => {
setIsSelectedFiles(!!ingestionFields.fileNames);

Expand Down Expand Up @@ -514,8 +515,15 @@ export const InnerRasterForm = (

resetForm();

if(removePrevData){
setPolygonPartsMode('MANUAL');
setExpandedParts([]);
}

const relevantValues = removePrevData ? removePropertiesWithPrefix(values, NESTED_FORMS_PRFIX) : values;

setValues({
...values,
...relevantValues,
...transformEntityToFormFields((isEmpty(metadata.recordModel) ? layerRecord : metadata.recordModel)),
...ingestionFields,
});
Expand Down Expand Up @@ -675,13 +683,12 @@ export const InnerRasterForm = (
ppList = ref;
}
const updateListRowHeights = (idx=0) => {
ppList.recomputeRowHeights(idx);
ppList.forceUpdate();
ppList?.recomputeRowHeights(idx);
ppList?.forceUpdate();
}

const renderRow: ListRowRenderer = ({ index, key, style }) => {
const data = Object.values(layerPolygonParts);
console.log('***** RENDERROW *****', index);

let polygon_part = data[index];
if(!polygon_part){
Expand Down Expand Up @@ -804,6 +811,10 @@ export const InnerRasterForm = (

const ppDataKeys = Object.keys(parsedPPData);
schemaUpdater(ppDataKeys.length);

setTimeout(async () => {
await validateForm();
}, 0);

setExpandedParts(new Array(ppDataKeys.length).fill(false));

Expand Down
8 changes: 8 additions & 0 deletions src/discrete-layer/components/layer-details/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ import {

const JSON_INDENTATION = 4;

export const DEFAULT_ENUM = 'DEFAULT_ENUM';

export const ENUM_TYPES = ['DemDataType', 'DemDataType', 'NoDataValue', 'VerticalDatum', 'Units', 'UndulationModel', 'Transparency', 'ProductType' ]

export const isEnumType = (typeName: string) => {
return ENUM_TYPES.some(enumType => enumType === typeName);
}

export const getEntityDescriptors = (
layerRecordTypename: LayerRecordTypes,
entityDescriptors: EntityDescriptorModelType[]
Expand Down
Loading