Skip to content

Commit

Permalink
Merge branch 'main' into 184773092-scroll-row-values
Browse files Browse the repository at this point in the history
  • Loading branch information
eireland committed Oct 3, 2023
2 parents 2350ef9 + 44a47c5 commit 3956671
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 9 deletions.
5 changes: 3 additions & 2 deletions src/components/app.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
.selectView {
padding: 10px;

height: 100vh;

.buttons {
display: flex;
gap: 5px;
}
}
}
14 changes: 12 additions & 2 deletions src/components/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function App() {
const {connected, selectedDataSet, dataSets, collections, items, interactiveState,
updateInteractiveState: _updateInteractiveState,
handleSelectDataSet: _handleSelectDataSet, handleUpdateAttributePosition,
handleAddCollection, handleAddAttribute, handleSetCollections
handleAddCollection, handleAddAttribute, handleSetCollections, handleSelectSelf
} = useCodapState();

const updateInteractiveState = useCallback((update: Partial<InteractiveState>) => {
Expand All @@ -29,6 +29,10 @@ function App() {
updateInteractiveState({dataSetName});
}, [_handleSelectDataSet, updateInteractiveState]);

const handleShowComponent = () => {
handleSelectSelf();
};

const renderSelectView = () => {
return (
<div className={css.selectView}>
Expand Down Expand Up @@ -71,6 +75,7 @@ function App() {
interactiveState={interactiveState}
handleSelectDataSet={handleSelectDataSet}
updateInteractiveState={updateInteractiveState}
handleShowComponent={handleShowComponent}
/>
);

Expand All @@ -88,11 +93,16 @@ function App() {
handleAddCollection={handleAddCollection}
handleAddAttribute={handleAddAttribute}
handleSetCollections={handleSetCollections}
handleShowComponent={handleShowComponent}
/>
);

default:
return renderSelectView();
return (
<div onClick={handleShowComponent}>
{renderSelectView()}
</div>
);
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/components/hierarchy-view/hierarchy.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.hierarchyWrapper {
height: 100vh;
}

.hierarchy {
display: flex;
flex-direction: row;
Expand Down
7 changes: 4 additions & 3 deletions src/components/hierarchy-view/hierarchy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ interface IProps {
handleAddCollection: (newCollectionName: string) => void
handleAddAttribute: (collection: ICollection, newAttrName: string) => void,
handleSetCollections: (collections: Array<ICollection>) => void
handleShowComponent: () => void
}

export const Hierarchy = (props: IProps) => {
const {selectedDataSet, dataSets, collections, handleSelectDataSet, handleSetCollections,
handleUpdateAttributePosition, handleAddCollection, handleAddAttribute} = props;
handleUpdateAttributePosition, handleAddCollection, handleAddAttribute, handleShowComponent} = props;

const {activeAttr, handleDragStart, handleDragOver, handleDragEnd} = useDragging({collections,
handleSetCollections, handleUpdateAttributePosition});
Expand All @@ -44,7 +45,7 @@ export const Hierarchy = (props: IProps) => {
};

return (
<>
<div className={css.hierarchyWrapper} onClick={handleShowComponent}>
<div className={css.hierarchy} style={{gap: CollectionGap}}>
<DndContext
collisionDetection={closestCorners}
Expand Down Expand Up @@ -76,7 +77,7 @@ export const Hierarchy = (props: IProps) => {
{JSON.stringify(selectedDataSet, null, 2)}
</div>
}
</>
</div>
);
};

Expand Down
3 changes: 3 additions & 0 deletions src/components/nested-table.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.nestedTableWrapper {
height: 100vh;
}
7 changes: 5 additions & 2 deletions src/components/nested-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { Menu } from "./menu";
import { LandscapeView } from "./landscape-view";
import { FlatTable } from "./flat-table";

import css from "./nested-table.scss";

const portrait = "Portrait";
const landscape = "Landscape";
const none = "";
Expand All @@ -18,11 +20,12 @@ interface IProps {
interactiveState: InteractiveState
handleSelectDataSet: (e: React.ChangeEvent<HTMLSelectElement>) => void
updateInteractiveState: (update: Partial<InteractiveState>) => void
handleShowComponent: () => void
}

export const NestedTable = (props: IProps) => {
const {selectedDataSet, dataSets, collections, items, interactiveState,
handleSelectDataSet, updateInteractiveState} = props;
handleSelectDataSet, updateInteractiveState, handleShowComponent} = props;
const [collectionClasses, setCollectionClasses] = useState<Array<ICollectionClass>>([]);
const [paddingStyle, setPaddingStyle] = useState<Record<string, string>>({padding: "0px"});

Expand Down Expand Up @@ -127,7 +130,7 @@ export const NestedTable = (props: IProps) => {
};

return (
<div>
<div className={css.nestedTableWrapper} onClick={handleShowComponent}>
<Menu
dataSets={dataSets}
collections={collections}
Expand Down
5 changes: 5 additions & 0 deletions src/hooks/useCodapState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,12 @@ export const useCodapState = () => {
setInteractiveState(newState);
}, [interactiveState, setInteractiveState]);

const handleSelectSelf = async () => {
connect.selectSelf();
};

return {
handleSelectSelf,
dataSets,
selectedDataSet,
collections,
Expand Down
22 changes: 22 additions & 0 deletions src/scripts/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,28 @@ export const connect = {
await codapInterface.sendRequest(message);
},


// Selects this component. In CODAP this will bring this component to the front.
selectSelf: async function () {
let myCODAPId = null;
const selectComponent = async function (id) {
return await codapInterface.sendRequest({
action: "notify",
resource: `component[${id}]`,
values: {request: "select"}
});
}
if (myCODAPId == null) {
const r1 = await codapInterface.sendRequest({action: 'get', resource: 'interactiveFrame'});
if (r1.success) {
myCODAPId = r1.values.id;
}
}
if (myCODAPId != null) {
return await selectComponent(myCODAPId);
}
},

iFrameDescriptor: {
version: '0.0.1',
name: 'multidata-plugin',
Expand Down

0 comments on commit 3956671

Please sign in to comment.