tia
Version:
Time is All (logs driven test engine with ExtJs support)
129 lines • 5.08 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const component_1 = require("./component");
const tia_extjs_query_1 = require("../tia-extjs-query");
const extjs_utils_1 = require("../../extjs-utils");
const compName = 'FormFieldBase';
/**
* gT.eC.formFieldBase.a or gT.eC.formFieldBase.actions
*/
class FormFieldBaseActions extends component_1.ComponentActions {
/**
* Sets value to any form field.
* Note: use this method only if other methods do not work (except setRawValueByEJ, which is very last resort).
* Because it does not emulate user action,
* and uses pure ExtJs API to set the control value.
* https://docs.sencha.com/extjs/6.5.3/classic/Ext.form.field.Base.html#method-setValue
* @param value - value to set to the form field.
*/
static async setValueByEJ(tEQ, strValue, idForLog, enableLog) {
let realValue = gT.e.utils.locKeyToStrAndEscapeSlashes(strValue);
if (realValue !== strValue && gT.e.utils.debugLocale) {
realValue += ` ("${strValue}")`;
}
return gT.e.q.wrap({
tEQ,
compName,
idForLog,
act: async () => {
await tia_extjs_query_1.queryAndAction({
tEQ,
action: `cmp.setValue('${realValue}');`,
idForLog,
enableLog: false,
});
},
actionDesc: 'Set Value',
enableLog,
});
}
/**
* Sets raw value to any form field.
* Note: use this method only as very last resort, if other methods do not work (even setValueByEJ).
* Because it does not emulate user action,
* and uses pure ExtJs API to set the control value.
* Also it does not send onChange event to ExtJs component.
* https://docs.sencha.com/extjs/6.5.3/classic/Ext.form.field.Base.html#method-setRawValue
* @param value - value to set to the form field.
*/
static async setRawValueByEJ(tEQ, strValue, idForLog, enableLog) {
let realValue = gT.e.utils.locKeyToStrAndEscapeSlashes(strValue);
if (realValue !== strValue && gT.e.utils.debugLocale) {
realValue += ` ("${strValue}")`;
}
return gT.e.q.wrap({
tEQ,
compName,
idForLog,
act: async () => {
await tia_extjs_query_1.queryAndAction({
tEQ,
action: `cmp.setRawValue('${realValue}');`,
idForLog,
enableLog: false,
});
},
actionDesc: 'Set Raw Value',
enableLog,
});
}
}
FormFieldBaseActions.compName = compName;
exports.FormFieldBaseActions = FormFieldBaseActions;
/**
* gT.eC.formFieldBase.c or gT.eC.formFieldBase.checks
*/
class FormFieldBaseChecks extends component_1.ComponentChecks {
}
FormFieldBaseChecks.compName = compName;
exports.FormFieldBaseChecks = FormFieldBaseChecks;
/**
* gT.eC.formFieldBase.g or gT.eC.formFieldBase.grabs
*/
class FormFieldBaseGrabs extends component_1.ComponentGrabs {
/**
* Returns raw form field value to the log.
* See ExtJs docs on getRawValue for the corresponding Component.
* @param mapperCallback - callback to map a raw value to string. if omitted - val is used as is.
*/
static async rawValue(tEQ, idForLog, mapperCallback) {
const { val, disp } = await tia_extjs_query_1.queryAndAction({
tEQ,
action: 'return { val: cmp.getRawValue(), disp: tiaEJ.ctByObj.getCompDispIdProps(cmp)};',
idForLog,
enableLog: false,
});
const result = mapperCallback ? mapperCallback(val) : val;
return extjs_utils_1.getCISRVal(tEQ, this.compName, `${idForLog ? `${idForLog} ` : ''}${disp}:`, result);
}
}
FormFieldBaseGrabs.compName = compName;
exports.FormFieldBaseGrabs = FormFieldBaseGrabs;
/**
* gT.eC.formFieldBase.l or gT.eC.formFieldBase.logs
*/
class FormFieldBaseLogs extends component_1.ComponentLogs {
/**
* Prints raw form field value to the log.
* See ExtJs docs on getRawValue for the corresponding Component.
* @param mapperCallback - callback to map a raw value to a log string. if omitted - val is used as is.
*/
static async rawValue(tEQ, idForLog, mapperCallback) {
const str = await FormFieldBaseGrabs.rawValue(tEQ, idForLog, mapperCallback);
gIn.logger.logln(str);
}
}
FormFieldBaseLogs.compName = compName;
exports.FormFieldBaseLogs = FormFieldBaseLogs;
class FormFieldBaseAPI {
}
FormFieldBaseAPI.a = FormFieldBaseActions;
FormFieldBaseAPI.actions = FormFieldBaseActions;
FormFieldBaseAPI.c = FormFieldBaseChecks;
FormFieldBaseAPI.checks = FormFieldBaseChecks;
FormFieldBaseAPI.g = FormFieldBaseGrabs;
FormFieldBaseAPI.grabs = FormFieldBaseGrabs;
FormFieldBaseAPI.l = FormFieldBaseLogs;
FormFieldBaseAPI.logs = FormFieldBaseLogs;
exports.FormFieldBaseAPI = FormFieldBaseAPI;
//# sourceMappingURL=form-field-base.js.map