|
| 1 | +import * as React from "react"; |
| 2 | +import styled from "styled-components"; |
| 3 | + |
| 4 | +import { |
| 5 | + Stack, |
| 6 | + TextField, |
| 7 | + Dropdown, |
| 8 | + IDropdownOption, |
| 9 | + PrimaryButton, |
| 10 | + IStackTokens, |
| 11 | +} from "@fluentui/react"; |
| 12 | + |
| 13 | +import { WebFormStepType, WebFormStepMode } from "../utils/WebFormInterfaces"; |
| 14 | + |
| 15 | +const SidebarWrapper = styled.div` |
| 16 | + width: 300px; |
| 17 | + background: white; |
| 18 | + display: flex; |
| 19 | + flex-direction: column; |
| 20 | + flex-shrink: 0; |
| 21 | + text-align: start; |
| 22 | +`; |
| 23 | + |
| 24 | +const Message = styled.div` |
| 25 | + margin: 10px; |
| 26 | + padding: 10px; |
| 27 | + line-height: 1.4em; |
| 28 | +`; |
| 29 | + |
| 30 | +const verticalGapStackTokens: IStackTokens = { |
| 31 | + childrenGap: 10, |
| 32 | + padding: 10, |
| 33 | +}; |
| 34 | + |
| 35 | +const typeOptions: IDropdownOption[] = [ |
| 36 | + { key: WebFormStepType.Condition, text: "Condtion" }, |
| 37 | + { key: WebFormStepType.LoadForm, text: "Load Form" }, |
| 38 | + { key: WebFormStepType.LoadTab, text: "Load Tab" }, |
| 39 | + { key: WebFormStepType.LoadUserControl, text: "Load User Control" }, |
| 40 | + { key: WebFormStepType.Redirect, text: "Redirect" }, |
| 41 | +]; |
| 42 | + |
| 43 | +const modeOptions: IDropdownOption[] = [ |
| 44 | + { key: WebFormStepMode.Insert, text: "Insert" }, |
| 45 | + { key: WebFormStepMode.Edit, text: "Edit" }, |
| 46 | + { key: WebFormStepMode.ReadOnly, text: "Read Only" }, |
| 47 | +]; |
| 48 | + |
| 49 | +export interface ISelectedEntityProps { |
| 50 | + title: string; |
| 51 | + entity: string; |
| 52 | + type: WebFormStepType; |
| 53 | + mode: WebFormStepMode; |
| 54 | + id: string; |
| 55 | + condition:string; |
| 56 | +} |
| 57 | + |
| 58 | +interface ISidebarProps { |
| 59 | + selected: Partial<ISelectedEntityProps>; |
| 60 | + openRecord: Function; |
| 61 | +} |
| 62 | + |
| 63 | +export const Sidebar = (props: ISidebarProps) => { |
| 64 | + const selected = props.selected; |
| 65 | + console.log("selected", selected); |
| 66 | + |
| 67 | + return ( |
| 68 | + <SidebarWrapper> |
| 69 | + {selected !== undefined && selected.type ? ( |
| 70 | + <Stack tokens={verticalGapStackTokens}> |
| 71 | + <TextField label="Name" value={selected.title} /> |
| 72 | + <TextField label="Entity" value={selected.entity} /> |
| 73 | + <Dropdown |
| 74 | + label="Type" |
| 75 | + selectedKey={selected.type} |
| 76 | + options={typeOptions} |
| 77 | + /> |
| 78 | + {selected.type == WebFormStepType.Condition ? (<TextField label="Condition" value={selected.condition} />): null} |
| 79 | + <Dropdown |
| 80 | + label="Mode" |
| 81 | + selectedKey={selected.mode} |
| 82 | + options={modeOptions} |
| 83 | + disabled={selected.mode == null} |
| 84 | + /> |
| 85 | + <PrimaryButton |
| 86 | + iconProps={{ iconName: "OpenInNewWindow" }} |
| 87 | + text="Open Record" |
| 88 | + onClick={() => props.openRecord(selected.id)} |
| 89 | + /> |
| 90 | + </Stack> |
| 91 | + ) : ( |
| 92 | + <Message>Click on a Node</Message> |
| 93 | + )} |
| 94 | + </SidebarWrapper> |
| 95 | + ); |
| 96 | +}; |
0 commit comments