Skip to content

Commit

Permalink
(Org Card): #70 Multi select does not support some characters
Browse files Browse the repository at this point in the history
  • Loading branch information
bisoladebiyi committed Apr 16, 2024
1 parent 9bd7317 commit 5c628b1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
15 changes: 10 additions & 5 deletions src/CustomPlugin/OrgChartComponent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ const OrgChartComponent: React.FC<OrgChartComponentProps> = ({
const d3Container = useRef(null);
let chart: OrgChart<unknown> | null = null;
let showFieldNames = pluginPresets[appActiveState.activePresetIdx].settings?.show_field_names;
let colIDs = shownColumns?.map((s) => s.key);
let colIDs = shownColumns?.map((s) => s?.key);
let fields =
pluginPresets[appActiveState.activePresetIdx].settings?.columns ||
appActiveState.activeTable?.columns;
let fieldsIDs = fields?.map((f) => f.key);
let _shownColumns = fieldsIDs
?.map((id) => shownColumns?.find((c) => c.key === id))
?.map((id) => shownColumns?.find((c) => c?.key === id))
.filter((c) => c !== undefined);

const fitToScreen = () => {
Expand Down Expand Up @@ -53,12 +53,17 @@ const OrgChartComponent: React.FC<OrgChartComponentProps> = ({
.duration(0)
.nodeWidth((d: d3.HierarchyNode<unknown>) => 250)
.nodeHeight((d: d3.HierarchyNode<any>) => {
let multiFieldKey = appActiveState.activeTable?.columns.find(
(c) => c.type === 'multiple-select'
)?.key;
let multiNo = d.data[multiFieldKey!]?.length;

let image =
appActiveState.activeCoverImg &&
colIDs?.includes(appActiveState.activeCoverImg.key) &&
d.data[appActiveState.activeCoverImg.key];
let height = shownColumns?.length! * 43;
let imgShown = shownColumns?.map((c) => c.type).includes('image');
let height = shownColumns?.length! * (43 + multiNo + 1);
let imgShown = shownColumns?.map((c) => c?.type).includes('image');

if (!imgShown) {
height += 40;
Expand Down Expand Up @@ -106,7 +111,7 @@ const OrgChartComponent: React.FC<OrgChartComponentProps> = ({
? `<h6 style="text-transform: uppercase;color: #9ba4b5;font-size: 10px;font-weight: 600;" margin: 0;>${c.name}</h6>`
: ''
}
<div style="display: flex;flex-direction: row;gap: 8px;">
<div style="display: flex;flex-direction: row;gap: 8px;flex-wrap: wrap;">
${_shownColumns![i]?.data.options.map((select: any) =>
d.data[c.key]?.includes(select.id)
? `<span key='${select.id}' style='color: ${select.textColor}; padding: 2px 10px; border-radius: 8px; background: ${select.color}'>${select.name}</span>`
Expand Down
10 changes: 6 additions & 4 deletions src/CustomPlugin/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ const CustomPlugin: React.FC<ICustomPluginProps> = ({
pluginPresets,
appActiveState,
shownColumns,
downloadPdfRef
downloadPdfRef,
}) => {
const [cardData, setCardData] = useState<any[]>();
let multiFields = appActiveState.activeTable?.columns.filter((c) => c.type === 'multiple-select');
let __shownColumns = shownColumns?.map((s) =>
s?.type === 'multiple-select' ? multiFields?.find((_s) => s.key === _s.key) : s
);

useEffect(() => {
let data = parseRowsData(
Expand All @@ -22,16 +26,14 @@ const CustomPlugin: React.FC<ICustomPluginProps> = ({
setCardData(data);
}, [appActiveState]);


return (
<OrgChartComponent
cardData={cardData}
pluginPresets={pluginPresets}
shownColumns={shownColumns}
shownColumns={__shownColumns}
appActiveState={appActiveState}
downloadPdfRef={downloadPdfRef}
/>

);
};

Expand Down
2 changes: 1 addition & 1 deletion src/utils/Interfaces/CustomPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export interface ICustomPluginProps {
pluginPresets: PresetsArray;
appActiveState: AppActiveState;
activeViewRows?: TableRow[];
shownColumns?: TableColumn[];
shownColumns?: (TableColumn | undefined)[];
downloadPdfRef: React.MutableRefObject<null>;
}

Expand Down

0 comments on commit 5c628b1

Please sign in to comment.