Skip to content

Commit

Permalink
Merge pull request #286 from ucdavis/JCS/MoreExample
Browse files Browse the repository at this point in the history
Jcs/more example
  • Loading branch information
cydoval authored Jan 17, 2024
2 parents b44f771 + dd48d6d commit cc184c0
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const EntryEditButtons = (props: Props) => {
className="flex-fill"
disabled={removeMutation.isLoading}
onClick={remove}
noMargin={true}
margin={false}
>
<FontAwesomeIcon icon={faTrash} />
Remove
Expand Down
4 changes: 2 additions & 2 deletions Finjector.Web/ClientApp/src/components/Entry/FolderSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ interface FolderSearchProps {
selectedFolderId?: number;
}

const FolderSearch = ({
const FolderSearch: React.FC<FolderSearchProps> = ({
updateFolderId,
selectedFolderId,
}: FolderSearchProps) => {
}) => {
const [selectedFolder, setSelectedFolder] = useState<Folder | undefined>();

const typeaheadRef = useRef<any>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,16 @@ const SaveAndUseButton = (props: Props) => {
};

return (
// <div className="row">
// <div className="col-md-6">
<div className="d-flex">
<FinjectorButton
className="flex-fill"
disabled={saveMutation.isLoading || !savedChart.name}
onClick={saveAndUse}
margin={false}
>
{isInPopup ? "Save and use" : "Save"}
</FinjectorButton>
</div>
// </div>
// </div>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const CopyToClipboardButton: React.FC<CopyToClipboardButtonProps> = ({
id={`copy-button-${id}`}
onClick={handleCopy}
onMouseEnter={onHover}
noMargin={true}
margin={false}
{...props}
>
<FontAwesomeIcon icon={faCopy} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@ interface FinjectorButtonProps
extends React.ButtonHTMLAttributes<HTMLButtonElement> {
children: React.ReactNode;
to?: string; // when using it as a Link
noMargin?: boolean; // removes the margin on the button
margin?: boolean; // removes the margin on the button
}

const FinjectorButton: React.FC<FinjectorButtonProps> = ({
children,
className,
to,
color,
noMargin,
margin = true,
...props
}) => {
// default className is "btn btn-new ms-1"
// if color is provided, it will add "btn-{color}" e.g. "btn-warning"
// if noMargin is true, it will remove "ms-1"
// if margin is false, it will remove "ms-2"
// if className is provided, it will add that className
const classNameString = `btn btn-new ${className ?? ""}${
!!color ? ` btn-${color}` : ""
}${noMargin ? "" : " ms-2"}`;
}${margin ? " ms-2" : ""}`;

if (!!to) {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export default function FormComponent(props: Props) {
</div>
</div>

<FinjectorButton type="submit" noMargin={true} disabled={loading}>
<FinjectorButton type="submit" margin={false} disabled={loading}>
{props.buttonText(loading)}
</FinjectorButton>
</form>
Expand Down
25 changes: 25 additions & 0 deletions Finjector.Web/ClientApp/src/pages/Example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,21 @@ const Example: React.FC = () => {
}
};

const openFinjectorImport = async (e: any) => {
e.preventDefault();

const result = await window.Finjector.findChartSegmentString(
window.location.origin + "/import"
);

if (result.status === "success") {
alert(result.data);
// stick the chart string in the input
//const input = document.getElementById("ccoa-input") as HTMLInputElement;
//input.value = result.data;
}
};

return (
<main className="form-signin w-100 m-auto">
<h1>For Example / Test Use Only</h1>
Expand Down Expand Up @@ -53,6 +68,16 @@ const Example: React.FC = () => {
Example PPM account: K30APSD227-TASK01-APLS002-770000
</small>

<hr />
<button
type="button"
onClick={openFinjectorImport}
className="btn btn-secondary"
id="import"
>
Import
</button>

<hr />
<button className="w-100 btn btn-lg btn-primary" type="submit">
Fake Submit
Expand Down
2 changes: 1 addition & 1 deletion Finjector.Web/ClientApp/src/pages/Paste.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const Paste = () => {
className="btn btn-primary"
disabled={error !== "" || coa === ""}
onClick={() => navigate(`/entry/${coa}`)}
noMargin={true}
margin={false}
>
NEXT
</FinjectorButton>
Expand Down
1 change: 1 addition & 0 deletions Finjector.Web/Controllers/ChartsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public async Task<IActionResult> AllCharts()
var charts = await _dbContext.Coas.Include(c => c.Folder).ThenInclude(f => f.Team).Where(c =>
c.Folder.FolderPermissions.Any(fp => fp.User.Iam == iamId) ||
c.Folder.Team.TeamPermissions.Any(tp => tp.User.Iam == iamId))
.OrderBy(a => a.Name)
.ToListAsync();


Expand Down
2 changes: 1 addition & 1 deletion Finjector.Web/Controllers/FolderController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public async Task<IActionResult> Get(int id)
.AsSplitQuery()
.SingleOrDefaultAsync(f => f.Id == id);

var charts = await _dbContext.Coas.Where(c => c.FolderId == id).ToListAsync();
var charts = await _dbContext.Coas.Where(c => c.FolderId == id).OrderBy(a => a.Name).ToListAsync();

return Ok(new { folder, charts });
}
Expand Down

0 comments on commit cc184c0

Please sign in to comment.