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

Adding base for the client side Max&Min default values on create unit… #1364

Draft
wants to merge 1 commit into
base: development
Choose a base branch
from
Draft
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
35 changes: 35 additions & 0 deletions src/client/app/components/unit/CreateUnitModalComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ export default function CreateUnitModalComponent() {
secInRate: 3600,
suffix: '',
note: '',
defaultMeterMinimumValue:-999999999999,
defaultMeterMaximumValue:999999999999,
// These two values are necessary but are not used.
// The client code makes the id for the selected unit and default graphic unit be -99
// so it can tell it is not yet assigned and do the correct logic for that case.
Expand Down Expand Up @@ -266,6 +268,39 @@ export default function CreateUnitModalComponent() {
<FormattedMessage id="error.required" />
</FormFeedback>
</FormGroup></Col>

</Row>
<Row xs='1' lg='2'>
{/* default Meter Minimum Value input */}
<Col><FormGroup>
<Label for='defaultMeterMinimumValue'>{translate('default.meter.minimum.value')}</Label>
<Input
id='defaultMeterMinimumValue'
name='defaultMeterMinimumValue'
type='number'
onChange={e => handleNumberChange(e)}
defaultValue={state.defaultMeterMinimumValue}
maxLength={50} />
<FormFeedback>
<FormattedMessage id="error.required" />
</FormFeedback>
</FormGroup></Col>
{/* default Meter Maximum Value input input */}
<Col><FormGroup>
<Label for='defaultMeterMaximumValue'>{translate('default.meter.maximum.value')}</Label>
<Input
id='defaultMeterMaximumValue'
name='defaultMeterMaximumValue'
type='number'
onChange={e => handleNumberChange(e)}
defaultValue={state.defaultMeterMaximumValue}
maxLength={50} />
<FormFeedback>
<FormattedMessage id="error.required" />
</FormFeedback>
</FormGroup></Col>


</Row>
{/* Note input */}
<FormGroup>
Expand Down
2 changes: 2 additions & 0 deletions src/client/app/types/redux/units.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export interface UnitData {
displayable: DisplayableType;
preferredDisplay: boolean;
note: string;
defaultMeterMinimumValue:number,
defaultMeterMaximumValue:number
}

export interface UnitEditData {
Expand Down
6 changes: 5 additions & 1 deletion src/server/models/Unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ class Unit {
* @param {*} displayable Can be none, all, or admin. Restrict the type of user that can see this unit.
* @param {*} preferredDisplay True if this unit is always displayed. If not, the user needs to ask to see (for future enhancement).
* @param {*} note Note about this unit.
* @param {*} defaultMeterMinimumValue The default minimum value for meters.
* @param {*} defaultMeterMaximumValue The default maximum value for meters.
*/
constructor(id, name, identifier = name, unitRepresent, secInRate = 3600, typeOfUnit, suffix = '', displayable, preferredDisplay, note) {
constructor(id, name, identifier = name, unitRepresent, secInRate = 3600, typeOfUnit, suffix = '', displayable, preferredDisplay,defaultMeterMinimumValue, defaultMeterMaximumValue, note) {
this.id = id;
this.name = name;
this.identifier = identifier;
Expand All @@ -29,6 +31,8 @@ class Unit {
this.suffix = suffix;
this.displayable = displayable;
this.preferredDisplay = preferredDisplay;
this.defaultMeterMinimumValue = defaultMeterMinimumValue;
this.defaultMeterMaximumValue = defaultMeterMaximumValue;
this.note = note;
}

Expand Down
Loading