Skip to content

Commit

Permalink
fix(coordinate-op-method): add missing fields
Browse files Browse the repository at this point in the history
fix #36
  • Loading branch information
strogonoff committed Nov 14, 2023
1 parent 3c55494 commit 92fe00f
Showing 1 changed file with 84 additions and 2 deletions.
86 changes: 84 additions & 2 deletions src/classes/coordinate-op-method.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

import update from 'immutability-helper';
import { jsx } from '@emotion/react';
import { ControlGroup } from '@blueprintjs/core';
import type { ItemClassConfiguration, ItemListView } from '@riboseinc/paneron-registry-kit/types';
import { Button, TextArea, ControlGroup, NumericInput } from '@blueprintjs/core';
import type { Citation, ItemClassConfiguration, ItemListView } from '@riboseinc/paneron-registry-kit/types';
import { PropertyDetailView } from '@riboseinc/paneron-registry-kit/views/util';

import {
type CommonGRItemData,
Expand All @@ -13,16 +14,28 @@ import {
COMMON_PROPERTIES,
ItemList,
RelatedItem,
InformationSourceEdit,
getInformationSourceStub,
} from './common';


export interface CoordinateOpMethod extends CommonGRItemData {
parameters: Readonly<string[]>
sourceCRSDimensionCount: number
targetCRSDimensionCount: number

/** Mutually exclusive with formulaCitation. */
formula?: string | null

/** Mutually exclusive with formula. */
formulaCitation?: Citation
}

export const DEFAULTS: CoordinateOpMethod = {
...SHARED_DEFAULTS,
parameters: [],
sourceCRSDimensionCount: 1,
targetCRSDimensionCount: 1,
} as const;


Expand Down Expand Up @@ -75,6 +88,75 @@ export const coordinateOpMethod: ItemClassConfiguration<CoordinateOpMethod> = {
</ControlGroup>
}
/>

<PropertyDetailView label="Source CRS dimension count" subLabel="Minimum is 1.">
<NumericInput
readOnly={!onChange}
buttonPosition={onChange ? undefined : 'none'}
onValueChange={onChange
? (valueAsNumber) => onChange(update(itemData, { sourceCRSDimensionCount: { $set: valueAsNumber } }))
: undefined}
value={itemData.sourceCRSDimensionCount ?? 0}
/>
</PropertyDetailView>

<PropertyDetailView label="Target CRS dimension count" subLabel="Minimum is 1.">
<NumericInput
readOnly={!onChange}
buttonPosition={onChange ? undefined : 'none'}
onValueChange={onChange
? (valueAsNumber) => onChange(update(itemData, { targetCRSDimensionCount: { $set: valueAsNumber } }))
: undefined}
value={itemData.targetCRSDimensionCount ?? 0}
/>
</PropertyDetailView>

<PropertyDetailView label="Formula" subLabel="Mutually exclusive with formula citation.">
<TextArea
fill
value={itemData.formula ?? ''}
disabled={itemData.formulaCitation !== undefined}
readOnly={!onChange}
onChange={(evt) => {
onChange
? onChange(update(itemData, { formula: { $set: evt.currentTarget.value } }))
: void 0;
}}
/>
</PropertyDetailView>

<PropertyDetailView
subLabel="Mutually exclusive with formula."
helperText={itemData.formulaCitation && onChange
? <Button
onClick={() => onChange(update(itemData, { $unset: ['formulaCitation'] }))}
icon="remove"
outlined
intent="danger">
Remove formula citation
</Button>
: onChange
? <Button
onClick={() => onChange(update(itemData, { formulaCitation: { $set: getInformationSourceStub() } }))}
intent="primary"
outlined
disabled={(itemData.formula ?? '') !== ''}
title="Add file citation"
icon="add">
Add
</Button>
: null}
label="Formula citation">
{itemData.formulaCitation
? <InformationSourceEdit
citation={itemData.formulaCitation}
onChange={onChange
? (citation) => onChange(update(itemData, { formulaCitation: { $set: citation } }))
: undefined}
/>
: "N/A"}
</PropertyDetailView>

</CommonEditView>
),
},
Expand Down

0 comments on commit 92fe00f

Please sign in to comment.