Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
// mixins.js
const docMixin = {
types: ['Doc'],
init(args) {},
extend: {
myMixin() {
console.log('myMixin was called - this is all it does');
},
}
}
export {
docMixin,
};
// app.js
import { docMixin } from './mixins';
// CODE
export default enigma.create({
schema, url, mixins: [docMixin] // add docMixin
}).open().then(global => global.openDoc(config.appId));
// mixins.js
const docMixin = {
types: ['Doc'],
init(args) {},
extend: {
myMixin() {
console.log('myMixin was called - this is all it does');
},
mGetData({ object }) {
return new Promise((res) => {
this.createSessionObject(object).then((obj) => {
console.log(obj)
obj.getLayout().then((layout) => {
const data = layout.qHyperCube.qDataPages;
res(data);
})
})
})
},
}
}
export {
docMixin,
};
// index.js
const hypercube = {
qInfo: { qId: 'Sales by Year', qType: 'data'},
qHyperCubeDef: {
qDimensions: [
// { qDef: { qFieldDefs: ['[Country]']} },
{ qDef: { qFieldDefs: ['[Product Group Desc]']} }
],
qMeasures: [
{ qDef: { qDef: 'SUM([Sales Margin Amount])'}, },
],
qInitialDataFetch: [{
qTop: 0, qLeft: 0, qWidth: 10, qHeight: 1000,
}],
qInterColumnSortOrder: [],
qSuppressZero: true,
qSuppressMissing: true,
}
}
// CODE
(async () => {
const app = await appPromise;
app.myMixin()
const data = await app.mGetData({ object: hypercube })
console.log(data)
})()
// CODE
mPrintTable({ object }) {
return new Promise((res) => {
this.mGetData({ object }).then((qObj) => {
const table = []
qObj[0].qMatrix.map((o) => {
const row = {}
o.map((c,i) => {
let val = c.qNum === "NaN" ? c.qText : c.qNum
row[`c${i}`] = val;
})
table.push(row);
})
console.table(table);
res(table);
})
})
},
// CODE
const table = await app.mPrintTable({ object: hypercube })
console.log(table);
// CODE
// mixins.js
// docMixin CODE
const objectMixin = {
types: ['GenericObject'],
init(args) {},
extend: {
objectMixin(msg) {
console.log('layout mixin', msg)
this.getLayout().then((layout) => {
console.log("Layout: ", layout)
})
}
},
}
export {
docMixin, objectMixin
};
// app.js
import { docMixin, objectMixin } from './mixins'; // import the objectMixin
// CODE
export default enigma.create({
schema, url, mixins: [docMixin, objectMixin] // add it to our mixins array
}).open().then(global => global.openDoc(config.appId));
app.createSessionObject(hypercube).then((obj) => {
console.log(obj)
obj.objectMixin('hey there')
obj.myMixin()
})
const objectMixin2 = {
types: ['GenericObject'],
init(args) {},
extend: {
objectMixin2() {
console.log('layout mixin #2')
this.getLayout().then((layout) => {
console.log("Layout #2: ", layout)
})
}
},
}
export {
docMixin, objectMixin, objectMixin2
};
import { docMixin, objectMixin, objectMixin2 } from './mixins';
export default enigma.create({
schema, url, mixins: [docMixin, objectMixin, objectMixin2]
}).open().then(global => global.openDoc(config.appId));
app.createSessionObject(hypercube).then((obj) => {
console.log(obj)
obj.objectMixin2('hey there')
})
// mixins.js
mGetData({ object }) {
return new Promise((res) => {
this.createSessionObject(object).then((obj) => {
console.log(obj)
obj.objectMixin('from inside mGetData') // NEW CODE
obj.getLayout().then((layout) => {
const data = layout.qHyperCube.qDataPages;
res(data);
})
})
})
},
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.