Skip to content

Commit

Permalink
Fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
prestoncraw committed Nov 27, 2024
1 parent 1d4578e commit 4ea5024
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 13 deletions.
8 changes: 4 additions & 4 deletions common-pages/src/Note.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,13 @@ function Note(props: IProps) {

<div className="btn-group mr-2">
<button className={"btn btn-primary" + (note.Note === null ||note.Note.length === 0 ? ' disabled' : '')} onClick={() => { if (note.Note !== null && note.Note.length > 0) handleAdd(note); }} data-tooltip={"Add"} style={{ cursor: note.Note === null || note.Note.length === 0 ? 'not-allowed' : 'pointer' }} onMouseOver={() => setHover('add')} onMouseOut={() => setHover('none')}>Add Note</button>
<ToolTip Show={hover === 'add' && ( note.Note === null || note.Note.length === 0 )} Position={'top'} Theme={'dark'} Target={"Add"}>
<ToolTip Show={hover === 'add' && ( note.Note === null || note.Note.length === 0 )} Position={'top'} Target={"Add"}>
<p>{CrossMark} A note needs to be entered. </p>
</ToolTip>
</div>
<div className="btn-group mr-2">
<button className={"btn btn-default" + (note.Note === null || note.Note.length === 0 ? ' disabled' : '')} onClick={() => setNote((n) => ({...n, Note: ''}))} style={{ cursor: note.Note === null || note.Note.length === 0 ? 'not-allowed' : 'pointer' }} data-tooltip={"Remove"} onMouseOver={() => setHover('clear')} onMouseOut={() => setHover('none')} >Clear</button>
<ToolTip Show={hover === 'clear' && (note.Note === null || note.Note.length === 0)} Position={'top'} Theme={'dark'} Target={"Remove"}>
<ToolTip Show={hover === 'clear' && (note.Note === null || note.Note.length === 0)} Position={'top'} Target={"Remove"}>
<p>{CrossMark} The note field is already empty. </p>
</ToolTip>
</div>
Expand Down Expand Up @@ -287,13 +287,13 @@ function Note(props: IProps) {
<div className={"card-footer"} >
<div className="btn-group mr-2">
<button className={"btn btn-primary" + (note.Note === null ||note.Note.length === 0 ? ' disabled' : '')} onClick={() => { if (note.Note !== null && note.Note.length > 0) handleAdd(note); }} data-tooltip={"Add"} style={{ cursor: note.Note === null || note.Note.length === 0 ? 'not-allowed' : 'pointer' }} onMouseOver={() => setHover('add')} onMouseOut={() => setHover('none')}>Add Note</button>
<ToolTip Show={hover === 'add' && ( note.Note === null || note.Note.length === 0 )} Position={'top'} Theme={'dark'} Target={"Add"}>
<ToolTip Show={hover === 'add' && ( note.Note === null || note.Note.length === 0 )} Position={'top'} Target={"Add"}>
<p>{CrossMark} A note needs to be entered. </p>
</ToolTip>
</div>
<div className="btn-group mr-2">
<button className={"btn btn-default" + (note.Note === null || note.Note.length === 0 ? ' disabled' : '')} onClick={() => setNote((n) => ({...n, Note: ''}))} style={{ cursor: note.Note === null || note.Note.length === 0 ? 'not-allowed' : 'pointer' }} data-tooltip={"Remove"} onMouseOver={() => setHover('clear')} onMouseOut={() => setHover('none')} >Clear</button>
<ToolTip Show={hover === 'clear' && (note.Note === null || note.Note.length === 0)} Position={'top'} Theme={'dark'} Target={"Remove"}>
<ToolTip Show={hover === 'clear' && (note.Note === null || note.Note.length === 0)} Position={'top'} Target={"Remove"}>
<p>{CrossMark} The note field is already empty. </p>
</ToolTip>
</div>
Expand Down
4 changes: 2 additions & 2 deletions common-pages/src/ValueList/GroupInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ interface IProps {
}} hidden={record.ID === 0} data-tooltip={'Update'}
onMouseEnter={() => setHover('Update')} onMouseLeave={() => setHover('None')}>Update</button>
</div>
<ToolTip Show={hover === 'Clear' && (errors.length > 0)} Position={'top'} Theme={'dark'} Target={"Update"}>
<ToolTip Show={hover === 'Clear' && (errors.length > 0)} Position={'top'} Target={"Update"}>
{errors.map((t, i) => <p key={i}>{CrossMark} {t}</p>)}
</ToolTip>
<div className="btn-group mr-2">
<button className="btn btn-default" onClick={() => setRecord(props.Record)} disabled={warnings.length === 0} data-tooltip={'Clr'}
onMouseEnter={() => setHover('Clear')} onMouseLeave={() => setHover('None')}>Reset</button>
</div>
<ToolTip Show={hover === 'Clear' && (warnings.length > 0)} Position={'top'} Theme={'dark'} Target={"Clr"}>
<ToolTip Show={hover === 'Clear' && (warnings.length > 0)} Position={'top'} Target={"Clr"}>
{warnings.map((t, i) => <p key={i}>{Warning} {t}</p>)}
</ToolTip>
</div>
Expand Down
8 changes: 4 additions & 4 deletions common-pages/src/user/AdditionalField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ function AdditionalField<Field extends IField, Value extends IValue>(props: IPro
{(mode === 'Edit') ?
<button className="btn btn-default pull-right" data-tooltip='View' onClick={() => { setMode('View'); setEditValues(values) }} onMouseEnter={() => setHover('View')} onMouseLeave={() => setHover('None')}>View</button> :
<button className="btn btn-primary pull-right" onClick={() => setMode('Edit')}>Edit</button>}
<ToolTip Show={hover === 'View' && changedFields.length > 0} Position={'left'} Theme={'dark'} Target={"View"}>
<ToolTip Show={hover === 'View' && changedFields.length > 0} Position={'left'} Target={"View"}>
{changedFields.map((fld,i) => <p key={i}>{Warning} Changes to '{fld}' will be lost. </p>)}
</ToolTip>
</div>
Expand Down Expand Up @@ -234,14 +234,14 @@ function AdditionalField<Field extends IField, Value extends IValue>(props: IPro
<button className={"btn btn-primary" + (mode === 'View' ? ' disabled' : '')} onMouseEnter={() => setHover('New')} onMouseLeave={() => setHover('None')}
onClick={() => { if (mode === 'Edit') { setShowEdit(true); setNewField(props.EmptyField) } }} data-tooltip={'New'} >Add Field</button>
</div>
<ToolTip Show={hover === 'New' && mode === 'View'} Position={'top'} Theme={'dark'} Target={"New"}>
<ToolTip Show={hover === 'New' && mode === 'View'} Position={'top'} Target={"New"}>
<p> To add a new Field switch to Edit mode by clicking on the Edit Button on the upper right corner.</p>
</ToolTip>
<div className="btn-group mr-2">
<button className={"btn btn-primary" + (changedFields.length === 0 || mode==='View' || errorFields.length > 0 ? ' disabled' : '')} onClick={() => { if (errorFields.length === 0 && changedFields.length > 0 && mode === 'Edit') dispatch(props.AdditionalFieldSlice.UpdateValues({ParentID: props.Id, Values: editValues})); }}
onMouseEnter={() => setHover('Save')} onMouseLeave={() => setHover('None')} data-tooltip={'SaveValues'}>Save Changes</button>
</div>
<ToolTip Show={hover === 'Save' && (mode === 'View' || changedFields.length > 0)} Position={'top'} Theme={'dark'} Target={"SaveValues"}>
<ToolTip Show={hover === 'Save' && (mode === 'View' || changedFields.length > 0)} Position={'top'} Target={"SaveValues"}>
{mode==='View' ? <p> To change any Fields switch to Edit mode by clicking on the Edit Button on the upper right corner.</p> : null}
{changedFields.length > 0 && errorFields.length === 0 ? changedFields.map((fld,i) => <p key={i}> {HeavyCheckMark } Changes to '{fld}' are valid.</p>) : null}
{changedFields.length > 0 && errorFields.length > 0 ? errorFields.map((t,i) =><p key={i}> {CrossMark} {t}.</p> ) : null}
Expand All @@ -255,7 +255,7 @@ function AdditionalField<Field extends IField, Value extends IValue>(props: IPro
onMouseEnter={() => setHover('Clear')}
onMouseLeave={() => setHover('None')} data-tooltip={'Reset'}>Reset</button>
</div>
<ToolTip Show={hover === 'Clear' && (mode === 'View' || changedFields.length > 0)} Position={'top'} Theme={'dark'} Target={'Reset'}>
<ToolTip Show={hover === 'Clear' && (mode === 'View' || changedFields.length > 0)} Position={'top'} Target={'Reset'}>
{mode === 'View'? <p> To change any Fields switch to Edit mode by clicking on the Edit Button on the upper right corner.</p> : null}
{changedFields.length > 0? changedFields.map((fld,i) => <p key={i}>{Warning} Changes to '{fld}' will be lost. </p>) : null }
</ToolTip>
Expand Down
2 changes: 1 addition & 1 deletion common-pages/src/user/UserInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function UserInfo(props: IProps) {
<button className="btn btn-default" onClick={() => setUser(currentUser)} disabled={warnings.length === 0} data-tooltip={'Clr'}
onMouseEnter={() => setHover('Clear')} onMouseLeave={() => setHover('None')}>Reset</button>
</div>
<ToolTip Show={hover === 'Clear' && (warnings.length > 0)} Position={'top'} Theme={'dark'} Target={"Clr"}>
<ToolTip Show={hover === 'Clear' && (warnings.length > 0)} Position={'top'} Target={"Clr"}>
{warnings.map((t, i) => <p key={i}>{Warning} {t}</p>)}
</ToolTip>
</div>
Expand Down
40 changes: 38 additions & 2 deletions react-graph/src/LineLegend.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ******************************************************************************************************
// ******************************************************************************************************
// LineLegend.tsx - Gbtc
//
// Copyright © 2023, Grid Protection Alliance. All Rights Reserved.
Expand All @@ -24,7 +24,7 @@

import * as React from 'react';
import { LineStyle } from './GraphContext';
import { GetTextWidth, GetTextHeight, CreateGuid } from '@gpa-gemstone/helper-functions';
import { GetTextHeight, CreateGuid } from '@gpa-gemstone/helper-functions';
import { Warning } from '@gpa-gemstone/gpa-symbols';
import { ILegendRequiredProps, LegendContext } from './LegendContext';

Expand Down Expand Up @@ -99,4 +99,40 @@ function LineLegend(props: IProps) {
);
}

function GetTextWidth(font: string, fontSize: string, word: string, cssStyle?: string, height?: string, whiteSpace?: string, containerWidth?: string): number {
const text = document.createElement("span");

if (cssStyle !== undefined)
text.style.cssText = cssStyle;

// Set font properties
text.style.font = font;
text.style.fontSize = fontSize;
text.style.height = height ?? 'auto';
text.style.width = 'auto';
text.style.whiteSpace = whiteSpace ?? 'nowrap';
text.innerHTML = word;

// Create a container
const container = document.createElement('div');
container.style.position = 'absolute';
container.style.visibility = 'hidden';
container.style.overflow = 'visible'; // So overflowed text is measured
container.style.height = height ?? 'auto';
container.style.width = containerWidth ?? 'auto';
container.style.whiteSpace = whiteSpace ?? 'nowrap';

// Append text to the container
container.appendChild(text);
document.body.appendChild(container);

// Measure the width
const width = text.offsetWidth;

// Clean up
document.body.removeChild(container);

return Math.ceil(width);
}

export default LineLegend;

0 comments on commit 4ea5024

Please sign in to comment.