Skip to content

Instantly share code, notes, and snippets.

@theredpea
Created February 28, 2018 02:59
Show Gist options
  • Select an option

  • Save theredpea/8c35b73eaa8b382344185ef77a57d369 to your computer and use it in GitHub Desktop.

Select an option

Save theredpea/8c35b73eaa8b382344185ef77a57d369 to your computer and use it in GitHub Desktop.
define("apis/qfield", ["core.utils/deferred", "core.utils/notification", "apis/qfieldvalue"], function(a, b, c) {
"use strict";
function d(b, c, d, e, f, g, h) {
return b.waitFor ? b.waitFor.then(function() {
return b.field[c].apply(b.field, [d, e, f, g, h].filter(function(a) {
return void 0 !== a
}))
}) : a.resolve()
}
function e(c, d, e) {
var f = this;
if (f.qapp = c,
f.fldname = d,
f.rows = [],
f.qapp.model.session) {
b.create(f, "OnData");
var g = new a;
f.waitFor = g.promise,
f.qapp.model.waitForOpen.promise.then(function() {
(c.model.enigmaModel || c.model).getField(d, e || "$").then(function(a) {
f.field = a,
g.resolve()
})
})
}
}
return e.prototype.clear = function() {
return d(this, "clear")
}
,
e.prototype.lock = function() {
return d(this, "lock")
}
,
e.prototype.unlock = function() {
return d(this, "unlock")
}
,
e.prototype.clearOther = function(a) {
return d(this, "clearAllButThis", a || !1)
}
,
e.prototype.selectAll = function(a) {
return d(this, "selectAll", a || !1)
}
,
e.prototype.selectExcluded = function(a) {
return d(this, "selectExcluded", a || !1)
}
,
e.prototype.selectAlternative = function(a) {
return d(this, "selectAlternative", a || !1)
}
,
e.prototype.selectPossible = function(a) {
return d(this, "selectPossible", a || !1)
}
,
e.prototype.toggleSelect = function(a, b) {
return d(this, "toggleSelect", a, b || !1)
}
,
e.prototype.selectMatch = function(a, b) {
return d(this, "select", a, b || !1)
}
,
e.prototype.select = function(a, b, c) {
return d(this, "lowLevelSelect", a, b || !1, c || !1)
}
,
e.prototype.selectValues = function(a, b, c) {
var e = [];
return a.forEach(function(a) {
"number" == typeof a ? e.push({
qIsNumeric: !0,
qNumber: a
}) : "string" == typeof a ? e.push({
qText: a
}) : e.push(a)
}),
d(this, "selectValues", e, b || !1, c || !1)
}
,
e.prototype.getData = function(a) {
if (this.requestActive)
return this;
this.requestActive = !0,
this.genericObject && (this.genericObject.close(),
delete this.genericObject);
var b = this;
return this.qapp.createGenericObject({
qListObjectDef: {
qDef: {
qFieldDefs: [this.fldname]
},
qFrequencyMode: a && a.freq || "V",
qInitialDataFetch: [{
qTop: 0,
qLeft: 0,
qHeight: a && a.rows || 200,
qWidth: 1
}]
}
}, function(a) {
b.rows.length = 0,
a.qListObject.qDataPages.forEach(function(a) {
a.qMatrix.forEach(function(a) {
b.rows.push(new c(a[0],b))
})
}),
b.rowCount = a.qListObject.qDimensionInfo.qCardinal,
b.stateCounts = a.qListObject.qDimensionInfo.qStateCounts,
b.requestActive = !1,
b.OnData.emit()
}).then(function(a) {
b.genericObject = a
}),
this
}
,
e.prototype.getMoreData = function() {
if (this.requestActive)
return this;
if (this.rowCount <= this.rows.length)
return this;
this.requestActive = !0;
var a = this
, b = {
qTop: this.rows.length,
qLeft: 0,
qWidth: 1,
qHeight: 50
};
return a.genericObject.getListObjectData("/qListObjectDef", [b]).then(function(b) {
b.qDataPages[0].qMatrix.forEach(function(b) {
a.rows.push(new c(b[0],a))
}),
a.requestActive = !1,
a.OnData.emit()
}),
this
}
,
e
}),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment