Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: listbox properties spec #1228

Merged
merged 3 commits into from
May 2, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
139 changes: 137 additions & 2 deletions apis/nucleus/src/components/listbox/default-properties.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,32 @@
/**
* see: https://qlik.dev/apis/json-rpc/qix/schemas#%23%2Fdefinitions%2Fschemas%2Fentries%2FValueExpression
* @name ValueExpression
* @type object
* @property {string} qValueExpression.qExpr
*/

/**
* Extends `ListObjectDef`, see Engine API: `ListObjectDef`.
* @interface ListObjectDef
* @extends EngineAPI.IListObjectDef
* @property {boolean} [frequencyEnabled=false] Show frequency count. also requires qListObjectDef.qFrequencyMode to be set
*/

/**
* @name ListboxProperties
* @type object
*/

/**
* @lends ListboxProperties
*/
const listdef = {
qInfo: {
qType: 'njsListbox',
},
/**
* @type {ListObjectDef}
*/
qListObjectDef: {
qStateName: '',
qShowAlternatives: true,
Expand All @@ -26,15 +51,125 @@ const listdef = {
],
},
},
/**
* Show histogram bar.
* also requires (qListObjectDef.qFrequencyMode 'V' and frequencyMax) or qListObjectDef.qFrequencyMode 'P'
* @type {boolean=}
* @default
*/
histogram: false,
/**
* frequencyMax calculation
* needed for histogram when not using qListObjectDef.qFrequencyMode: 'P'
* use an expression in the form `Max(AGGR(Count([field]), [field]))` (when needed)
* or 'fetch' that triggers an extra engine call but needed for library dimension that could change field when using the object
* @type {('fetch' | ValueExpression)=}
*/
frequencyMax: undefined,
/**
* Show values as checkboxes instead of as fields.
* @type {boolean=}
* @default
*/
checkboxes: false,
/**
* enables search.
T-Wizard marked this conversation as resolved.
Show resolved Hide resolved
* @type {boolean=}
* @default
*/
searchEnabled: true,
/**
* show title.
T-Wizard marked this conversation as resolved.
Show resolved Hide resolved
* @type {boolean=}
* @default
*/
showTitle: true,
/**
* start search with wildcard search.
T-Wizard marked this conversation as resolved.
Show resolved Hide resolved
* @type {boolean=}
* @default
*/
wildCardSearch: false,
/**
* layout settings.
T-Wizard marked this conversation as resolved.
Show resolved Hide resolved
* @type {object=}
*/
layoutOptions: {
/**
* dense mode.
T-Wizard marked this conversation as resolved.
Show resolved Hide resolved
* @type {boolean=}
* @default
*/
dense: false,
/**
* layout mode.
T-Wizard marked this conversation as resolved.
Show resolved Hide resolved
* @type {('singleColumn' | 'grid')=}
* @default
T-Wizard marked this conversation as resolved.
Show resolved Hide resolved
*/
dataLayout: 'singleColumn',
/**
* layout order.
T-Wizard marked this conversation as resolved.
Show resolved Hide resolved
* Only used when dataLayout is 'grid'
* @type {('row' | 'column')=}
* @default
*/
layoutOrder: 'row',
maxVisibleColumns: { auto: true },
maxVisibleRows: { auto: true },
/**
* max visible columns.
T-Wizard marked this conversation as resolved.
Show resolved Hide resolved
* Only used when dataLayout is 'grid'
* and layoutOrder is 'row'
* @type {object=}
*/
maxVisibleColumns: {
/**
* auto max visible columns. (as many as it can fit)
T-Wizard marked this conversation as resolved.
Show resolved Hide resolved
* Only used when dataLayout is 'grid'
* and layoutOrder is 'row'
* @type {boolean=}
* @default
*/
auto: true,
/**
* fixed number of max visible columns.
T-Wizard marked this conversation as resolved.
Show resolved Hide resolved
* Only used when dataLayout is 'grid'
* layoutOrder is 'row'
* and auto is false
* @type {number=}
* @default
*/
maxColumns: 3,
},
/**
* max visible rows.
T-Wizard marked this conversation as resolved.
Show resolved Hide resolved
* Only used when dataLayout is 'grid'
* and layoutOrder is 'column'
* @type {object=}
*/
maxVisibleRows: {
/**
* auto max visible rows. (as many as it can fit)
T-Wizard marked this conversation as resolved.
Show resolved Hide resolved
* Only used when dataLayout is 'grid'
* and layoutOrder is 'column'
* @type {boolean=}
* @default
*/
auto: true,
/**
* fixed number of max visible rows.
T-Wizard marked this conversation as resolved.
Show resolved Hide resolved
* Only used when dataLayout is 'grid'
* layoutOrder is 'column'
* and auto is false
* @type {number=}
* @default
*/
maxRows: 3,
},
},
/**
* listbox title
T-Wizard marked this conversation as resolved.
Show resolved Hide resolved
* @type {string=}
* @default
*/
title: '',
};
export default listdef;
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,11 @@ describe('useExistingModel', () => {
layoutOrder: 'row',
maxVisibleColumns: {
auto: true,
maxColumns: 3,
},
maxVisibleRows: {
auto: true,
maxRows: 3,
},
});

Expand All @@ -121,7 +123,7 @@ describe('useExistingModel', () => {
dense: false,
dataLayout: 'grid',
layoutOrder: 'column',
maxVisibleColumns: { auto: true },
maxVisibleColumns: { auto: true, maxColumns: 3 },
maxVisibleRows: { auto: false, maxRows: 1 },
});
});
Expand All @@ -136,9 +138,11 @@ describe('useExistingModel', () => {
layoutOrder: 'row',
maxVisibleColumns: {
auto: true,
maxColumns: 3,
},
maxVisibleRows: {
auto: true,
maxRows: 3,
},
});
});
Expand Down
2 changes: 1 addition & 1 deletion apis/nucleus/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ function nuked(configuration = {}) {
* @param {boolean=} [options.checkboxes=false] Show values as checkboxes instead of as fields (not applicable for existing objects)
* @param {boolean=} [options.dense=false] Reduces padding and text size (not applicable for existing objects)
* @param {string=} [options.stateName="$"] Sets the state to make selections in (not applicable for existing objects)
* @param {object=} [options.properties={}] Properties object to extend default properties with
* @param {ListboxProperties=} [options.properties={}] Properties object to extend default properties with
* @returns {Promise<void>} A promise that resolves when the data is fetched.
*
* @since 1.1.0
Expand Down
20 changes: 20 additions & 0 deletions apis/nucleus/src/object/__tests__/filterpane-handler.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ describe('filterpane-handler', () => {
qType: expect.any(String),
},
title: 'A',
searchEnabled: true,
showTitle: true,
wildCardSearch: false,
checkboxes: false,
histogram: false,
layoutOptions: {
Expand All @@ -47,9 +50,11 @@ describe('filterpane-handler', () => {
layoutOrder: 'row',
maxVisibleColumns: {
auto: true,
maxColumns: 3,
},
maxVisibleRows: {
auto: true,
maxRows: 3,
},
},
qListObjectDef: {
Expand Down Expand Up @@ -95,6 +100,9 @@ describe('filterpane-handler', () => {
qType: expect.any(String),
},
title: 'lib dim title',
searchEnabled: true,
showTitle: true,
wildCardSearch: false,
checkboxes: false,
histogram: false,
layoutOptions: {
Expand All @@ -103,9 +111,11 @@ describe('filterpane-handler', () => {
layoutOrder: 'row',
maxVisibleColumns: {
auto: true,
maxColumns: 3,
},
maxVisibleRows: {
auto: true,
maxRows: 3,
},
},
qListObjectDef: {
Expand Down Expand Up @@ -156,6 +166,9 @@ describe('filterpane-handler', () => {
qType: expect.any(String),
},
title: 'C',
searchEnabled: true,
showTitle: true,
wildCardSearch: false,
checkboxes: true,
histogram: false,
layoutOptions: {
Expand All @@ -164,9 +177,11 @@ describe('filterpane-handler', () => {
layoutOrder: 'row',
maxVisibleColumns: {
auto: true,
maxColumns: 3,
},
maxVisibleRows: {
auto: true,
maxRows: 3,
},
},
qListObjectDef: {
Expand Down Expand Up @@ -218,6 +233,9 @@ describe('filterpane-handler', () => {
qType: expect.any(String),
},
title: 'My custom title',
searchEnabled: true,
showTitle: true,
wildCardSearch: false,
checkboxes: true,
histogram: false,
layoutOptions: {
Expand All @@ -226,9 +244,11 @@ describe('filterpane-handler', () => {
layoutOrder: 'row',
maxVisibleColumns: {
auto: true,
maxColumns: 3,
},
maxVisibleRows: {
auto: true,
maxRows: 3,
},
},
qListObjectDef: {
Expand Down
3 changes: 3 additions & 0 deletions apis/stardust/api-spec/spec.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ module.exports = {
'EngineAPI.INxMeasure': {
url: 'https://qlik.dev/apis/json-rpc/qix/schemas#%23%2Fdefinitions%2Fschemas%2Fentries%2FNxMeasure',
},
'EngineAPI.IListObjectDef': {
url: 'https://qlik.dev/apis/json-rpc/qix/schemas#%23%2Fdefinitions%2Fschemas%2Fentries%2FListObjectDef',
},
Emitter: {
url: 'https://nodejs.org/api/events.html#class-eventemitter',
},
Expand Down
Loading