Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 3 additions & 3 deletions packages/lib/datasource/xmla/src/classes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export class XmlaStore extends BaseDatasource {
if (this.useMdx) {
request = this.mdx
} else {
request = await this.getMdxRequest()
request = await this.getMdxRequest(requestConfig)
}

console.log('MDX Request in store:', request)
Expand Down Expand Up @@ -221,7 +221,7 @@ export class XmlaStore extends BaseDatasource {
return response
}

async getMdxRequest() {
async getMdxRequest(requestConfig: any = {}) {
await this.loadMetadata()
const properties = this.metadata.getProperties()
const levels = this.metadata.getLevels()
Expand All @@ -235,7 +235,7 @@ export class XmlaStore extends BaseDatasource {
this.requestParams.rows,
this.requestParams.columns,
this.requestParams.measures,
{},
requestConfig,
properties,
this.requestParams.filters,
levels,
Expand Down
21 changes: 16 additions & 5 deletions packages/lib/datasource/xmla/src/utils/MdxRequestConstructor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ export async function getMdxRequest(
filters: any[],
levels: any[],
) {
if (measures.length === 1 && pivotTableSettings?.showSingleMeasureHeader === false) {
rows = rows.filter(e => e.type !== 'Values')
columns = columns.filter(e => e.type !== 'Values')
}

const filtersRequest = getFiltersRequest(filters)

if (!rows.length || !columns.length) {
Expand All @@ -50,7 +55,8 @@ export async function getMdxRequest(
} else {
let withSection = 'WITH'
let selectSection = 'SELECT'
const fromSection = getFromPart(measures, cubename, filtersRequest.where)
const hasValues = rows.some((e: any) => e.type === 'Values') || columns.some((e: any) => e.type === 'Values')
const fromSection = getFromPart(measures, cubename, filtersRequest.where, hasValues)

if (!pivotTableSettings.showEmpty) selectSection += ' NON EMPTY'

Expand Down Expand Up @@ -377,8 +383,10 @@ async function getSingleHierarchyRequest(
filtersRequest: any,
levels: any[],
) {
const forceValues = (rows.length === 0 && columns.length === 0 && measures.length > 0 && pivotTableSettings?.showSingleMeasureHeader !== false)
const hasValues = rows.some((e: any) => e.type === 'Values') || columns.some((e: any) => e.type === 'Values') || forceValues
const selectPart = getSelectWithOptions(pivotTableSettings)
const fromPart = getFromPart(measures, cubename, filtersRequest.where)
const fromPart = getFromPart(measures, cubename, filtersRequest.where, hasValues)

if (rows.length) {
const request = await getRowsRequest(
Expand Down Expand Up @@ -433,8 +441,11 @@ async function getSingleHierarchyRequest(
${fromPart}
`
} else if (measures.length) {
const selectRequest = measures.map((e: any) => e.originalItem.MEASURE_UNIQUE_NAME).join(',')
return `
SELECT ${fromPart}
${selectPart}
{${selectRequest}} ON 0
${fromPart}
`
}
return ''
Expand All @@ -446,9 +457,9 @@ function getSelectWithOptions(pivotTableSettings: any) {
return result
}

function getFromPart(measures: any[], cubename: string, filtersWhere: any) {
function getFromPart(measures: any[], cubename: string, filtersWhere: any, hasValues: boolean = false) {
let measuresPart = ''
if (measures.length === 1) {
if (measures.length === 1 && !hasValues) {
measuresPart = `${measures[0].originalItem.MEASURE_UNIQUE_NAME}`
}

Expand Down
29 changes: 16 additions & 13 deletions packages/lib/datasource/xmla/src/utils/MdxRequestHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ const parseMdxRequest = (mdxResponce: any, params: QueryParams) => {

console.log('Params in helper', params)

columns[0].forEach((col: any) => {
columns[0]?.forEach((col: any) => {
// const colPropsShown = pivotTableStore.state.membersWithProps.includes(
// col.HIERARCHY_UNIQUE_NAME,
// );
Expand All @@ -118,7 +118,7 @@ const parseMdxRequest = (mdxResponce: any, params: QueryParams) => {
columnProperties.push(...colProps);
});

rows[0].forEach((row: any) => {
rows[0]?.forEach((row: any) => {
// const rowPropsShown = pivotTableStore.state.membersWithProps.includes(
// row.HIERARCHY_UNIQUE_NAME,
// );
Expand Down Expand Up @@ -299,31 +299,34 @@ const parseRequestToTable = (mdxResponce: any, mainAxis = 0) => {
rowProperties: {},
} as any

const getCaption = (member: any) => {
return optionalArrayToArray(member).map(m => m.Caption).join(' - ')
}

if (mainAxis === 0) {
axis1.forEach((item, index) => {
const newItem = item.Member.Caption
table.headers.push(newItem)
table.headers.push(getCaption(item.Member))
})

axis0.forEach((item, i) => {
console.log(i)
table.rows[i] = [item.Member.Caption]
table.rowProperties[item.Member.Caption] = item.Member;
const caption = getCaption(item.Member)
table.rows[i] = [caption]
table.rowProperties[caption] = item.Member;
axis1.forEach((subItem, j) => {
table.rows[i].push(cellsArray[j * axis0.length + i].Value)
table.rows[i].push(cellsArray[j * axis0.length + i]?.Value)
})
})
} else if (mainAxis === 1) {
axis0.forEach((item, index) => {
const newItem = item.Member.Caption
table.headers.push(newItem)
table.headers.push(getCaption(item.Member))
})

axis1.forEach((item, i) => {
table.items[i] = [item.Member.Caption]
table.rowProperties[item.Member.Caption] = item.Member;
const caption = getCaption(item.Member)
table.items[i] = [caption]
table.rowProperties[caption] = item.Member;
axis0.forEach((subItem, j) => {
table.items[i].push(cellsArray[i * axis0.length + j].Value)
table.items[i].push(cellsArray[i * axis0.length + j]?.Value)
})
})
}
Expand Down
31 changes: 19 additions & 12 deletions packages/ui/vue/common/xmla/src/QueryDesigner/QueryDesigner.vue
Original file line number Diff line number Diff line change
Expand Up @@ -150,21 +150,28 @@ const changeMeasures = (e: any) => {
}
}

if (queryConfig.value.measures.length > 1) {
queryConfig.value.columns.push({
type: "Values",
id: "Values",
children: [],
caption: "Values",
originalItem: {
HIERARCHY_UNIQUE_NAME: "Values",
} as any,
filters: null as any,
});
if (queryConfig.value.measures.length > 0) {
const hasValues = queryConfig.value.columns.some((e: any) => e.type === 'Values') ||
queryConfig.value.rows.some((e: any) => e.type === 'Values');
if (!hasValues) {
queryConfig.value.columns.push({
type: "Values",
id: "Values",
children: [],
caption: "Values",
originalItem: {
HIERARCHY_UNIQUE_NAME: "Values",
} as any,
filters: null as any,
});
}
} else {
queryConfig.value.columns = queryConfig.value.columns.filter(
(e) => (e as any).type !== 'Values',
);
queryConfig.value.rows = queryConfig.value.rows.filter(
(e) => (e as any).type !== 'Values',
);
}
};

Expand All @@ -178,7 +185,7 @@ const remove = (
const index = areaContent.findIndex((e) => e.id === item.id);

if (area === "measures") {
if (areaContent.length === 2) {
if (areaContent.length === 1) {
queryConfig.value["rows"] = queryConfig.value[
"rows"
].filter((e) => (e as any).type !== "Values");
Expand Down
1 change: 1 addition & 0 deletions packages/ui/vue/widget/table/pivot/model/model.ecore
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
<eStructuralFeatures xsi:type="ecore:EAttribute" name="cellTextAlign" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString" defaultValueLiteral="left" />
<eStructuralFeatures xsi:type="ecore:EAttribute" name="showRowsProperties" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean" defaultValueLiteral="false" />
<eStructuralFeatures xsi:type="ecore:EAttribute" name="showColumnsProperties" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean" defaultValueLiteral="false" />
<eStructuralFeatures xsi:type="ecore:EAttribute" name="showSingleMeasureHeader" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean" defaultValueLiteral="false" />

<!-- Nested Array Containment -->
<eStructuralFeatures xsi:type="ecore:EReference" name="rowLevelStyles" lowerBound="0" upperBound="-1" eType="#//LevelStyle" containment="true" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ const stylingProps = computed(() => ({
const dataProps = computed(() => ({
showRowsProperties: config.value?.showRowsProperties || defaultConfig.showRowsProperties,
showColumnsProperties: config.value?.showColumnsProperties || defaultConfig.showColumnsProperties,
showSingleMeasureHeader: config.value?.showSingleMeasureHeader ?? defaultConfig.showSingleMeasureHeader,
}))

const data = ref(null as any);
Expand All @@ -230,7 +231,6 @@ watch(datasourceId, (newVal, oldVal) => {
})

watch(() => dataProps.value, () => {
console.log(dataProps.value);
update();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,9 @@ const needsResultColors = (type?: string) => {
<template>
<va-collapse v-model="opened.dataSettings" header="Data settings" icon="palette">
<div class="settings-container">
<VaCheckbox v-model="widgetSettings.showRowsProperties" label="Show rows" style="margin: 0.5rem 0;"/>
<VaCheckbox v-model="widgetSettings.showColumnsProperties" label="Show columns" style="margin: 0.5rem 0;"/>
<VaCheckbox v-model="widgetSettings.showRowsProperties" label="Show rows properties" style="margin: 0.5rem 0;"/>
<VaCheckbox v-model="widgetSettings.showColumnsProperties" label="Show columns properties" style="margin: 0.5rem 0;"/>
<VaCheckbox v-model="widgetSettings.showSingleMeasureHeader" label="Show single measure header" style="margin: 0.5rem 0;"/>
</div>
</va-collapse>
<va-collapse v-model="opened.colorsSection" header="Farben" icon="palette">
Expand Down
1 change: 1 addition & 0 deletions packages/ui/vue/widget/table/pivot/src/gen/PivotTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export class PivotTable {
@Attribute() showRowsProperties: boolean = false;

@Attribute() showColumnsProperties: boolean = false;
@Attribute() showSingleMeasureHeader: boolean = false;
@Reference('LevelStyle') rowLevelStyles: Array<LevelStyle> = [];
@Reference('LevelStyle') columnLevelStyles: Array<LevelStyle> = [];
@Reference('ConditionalFormat') conditionalFormats: Array<ConditionalFormat> = [];
Expand Down
Loading