Skip to content

Commit

Permalink
fix: support master dims
Browse files Browse the repository at this point in the history
  • Loading branch information
Caele committed Jan 11, 2021
1 parent ccb9a6c commit 27ff553
Show file tree
Hide file tree
Showing 6 changed files with 478 additions and 114 deletions.
77 changes: 43 additions & 34 deletions apis/nucleus/src/components/listbox/ListBoxInline.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,50 +21,59 @@ import InstanceContext from '../../contexts/InstanceContext';
import ListBoxSearch from './ListBoxSearch';
import useObjectSelections from '../../hooks/useObjectSelections';

export default function ListBoxPortal({ app, fieldName, stateName, element, options }) {
export default function ListBoxPortal({ app, fieldIdentifier, stateName, element, options }) {
return ReactDOM.createPortal(
<ListBoxInline app={app} fieldName={fieldName} stateName={stateName} options={options} />,
<ListBoxInline app={app} fieldIdentifier={fieldIdentifier} stateName={stateName} options={options} />,
element
);
}

export function ListBoxInline({ app, fieldName, stateName = '$', options = {} }) {
const theme = useTheme();
export function ListBoxInline({ app, fieldIdentifier, stateName = '$', options = {} }) {
const { title, direction, listLayout, search = true } = options;
const [model] = useSessionModel(
{
qInfo: {
qType: 'njsListbox',
},
qListObjectDef: {
qStateName: stateName,
qShowAlternatives: true,
qInitialDataFetch: [
const listdef = {
qInfo: {
qType: 'njsListbox',
},
qListObjectDef: {
qStateName: stateName,
qShowAlternatives: true,
qInitialDataFetch: [
{
qTop: 0,
qLeft: 0,
qWidth: 0,
qHeight: 0,
},
],
qDef: {
qSortCriterias: [
{
qTop: 0,
qLeft: 0,
qWidth: 0,
qHeight: 0,
qSortByState: 1,
qSortByAscii: 1,
qSortByNumeric: 1,
qSortByLoadOrder: 1,
},
],
qDef: {
qSortCriterias: [
{
qSortByState: 1,
qSortByAscii: 1,
qSortByNumeric: 1,
qSortByLoadOrder: 1,
},
],
qFieldDefs: [fieldName],
},
},
title,
},
app,
fieldName,
stateName
);
title,
};

let fieldName;
let isMaster = false;

// Something something lib dimension
if (fieldIdentifier.qLibraryId) {
listdef.qListObjectDef.qLibraryId = fieldIdentifier.qLibraryId;
fieldName = fieldIdentifier.qLibraryId;
isMaster = true;
} else {
listdef.qListObjectDef.qDef.qFieldDefs = [fieldIdentifier];
fieldName = fieldIdentifier;
}

const theme = useTheme();
const [model] = useSessionModel(listdef, app, fieldName, stateName);

const lock = useCallback(() => {
model.lock('/qListObjectDef');
Expand Down Expand Up @@ -137,7 +146,7 @@ export function ListBoxInline({ app, fieldName, stateName = '$', options = {} })
<Grid item>
{showTitle && (
<Typography variant="h6" noWrap>
{layout.title || fieldName}
{!isMaster ? layout.title || fieldName : layout.qListObject.qDimensionInfo.qFallbackTitle}
</Typography>
)}
</Grid>
Expand Down

0 comments on commit 27ff553

Please sign in to comment.