Case description:

You need to show a ModalBox with build-in Iframe.

Realization algorithm

1)First of all, you need to create an Iframe module. (IntDonateIframeControl)

Ext.define("Terrasoft.controls.IntDonateIframeControl", {
    extend: "Terrasoft.Component",
    alternateClassName: "Terrasoft.IntDonateIframeControl",
    tpl: [
        /*jshint quotmark:true */
        '<iframe id="{id}" src="{src}" class="{wrapClass}"></iframe>'
        /*jshint quotmark:false */
    ],
    id: null,
    src: "https://academy.terrasoft.ru/",
    wrapClass: ["usr-iframe"],
    setIframeSrc: function(value) {
        value = value || "";
        if (this.src !== value) {
            this.src = value;
            this.safeRerender();
        }
    },
    init: function() {
        this.callParent(arguments);
        var selectors = this.selectors = this.selectors || {};
        selectors.wrapEl = selectors.wrapEl || "#" + this.id;
    },
    LoadPageBySrc: function() {
        var iframe = this.getWrapEl();
        iframe.dom.src = this.src;
    },
    onAfterRender: function() {
        this.callParent(arguments);
        this.LoadPageBySrc();
    },
    onAfterReRender: function() {
        this.callParent(arguments);
        this.LoadPageBySrc();
    },
    getBindConfig: function() {
        var bindConfig = this.callParent(arguments);
        return Ext.apply(bindConfig, {
            src: {
                changeMethod: "setIframeSrc"
            }
        });
    },
    getTplData: function() {
        var tplData = this.callParent(arguments);
        return Ext.apply(tplData, {
            src: this.src,
            wrapClass: this.wrapClass
        });
    }
});

2)You need to create a page that will contain Iframe and will be displayed in Modal Box.(IntDonateModalPage)

define("IntDonateModalPage", ["IntDonateIframeControl", "css!IntDonateIframeControl"], function() {
    return {
        attributes: {
            "TestText": {
                dataValueType: Terrasoft.DataValueType.TEXT,
                type: Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN
            }
        },
        messages: {
        },
        methods: {
            init: function(callback, scope) {
                this.callParent(arguments);
            },
            getHeader: function() {
                return this.get("Resources.Strings.PageCaption");
            },
            onRender: function() {
                this.callParent(arguments);
                var moduleInfo = this.get("moduleInfo");
                var boxSizes = moduleInfo.modalBoxSize;
                var width = boxSizes.width;
                var height = boxSizes.height;
                this.updateSize(width, height);
            }
        },
        //Insert already existed Iframe
        diff: [
            {
                "operation": "insert",
                "parentName": "CardContentContainer",
                "propertyName": "items",
                "name": "IntDonateIframe",
                "values": {
                    "generator": function() {
                        return {
                            "className": "Terrasoft.IntDonateIframeControl"
                        };
                    }
                }
            },
            {
                "operation": "insert",
                "name": "MyContainer",
                "propertyName": "items",
                "values": {
                    "itemType": Terrasoft.ViewItemType.CONTAINER,
                    "items": []
                }
            },
            {
                "operation": "insert",
                "parentName": "MyContainer",
                "propertyName": "items",
                "name": "MyGridContainer",
                "values": {
                    "itemType": Terrasoft.ViewItemType.GRID_LAYOUT,
                    "items": []
                }
            },
            {
                "operation": "insert",
                "parentName": "MyGridContainer",
                "propertyName": "items",
                "name": "TestText",
                "values": {
                    "bindTo": "TestText",
                    "caption": "Test text",
                    "layout": {"column": 0, "row": 0, "colSpan": 10}
                }
            }
        ]
    };
});

3)In page, you need to insert a button. After button click, Modal Dialog with Iframe should appear. (IntExcelReportPage)

define("IntExcelReportPage", ["IntReportConstants", "MaskHelper"],
    function(constants, MaskHelper) {
    return {
        entitySchemaName: "IntExcelReport",
        details: /**SCHEMA_DETAILS*/{}/**SCHEMA_DETAILS*/,
        modules: /**SCHEMA_MODULES*/{}/**SCHEMA_MODULES*/,
        diff: /**SCHEMA_DIFF*/[
            {
                "operation": "insert",
                "name": "DonateButton",
                "values": {
                    "itemType": Terrasoft.ViewItemType.BUTTON,
                    "style": Terrasoft.controls.ButtonEnums.style.RED,
                    "caption": {
                        "bindTo": "Resources.Strings.DonateButton"
                    },
                    "click": {
                        "bindTo": "donateButtonClick"
                    }
                },
                "parentName": "RightContainer",
                "propertyName": "items",
                "index": 1
            }
        ]/**SCHEMA_DIFF*/,
        messages: {},
        attributes: {},
        mixins: {},
        methods: {
            subscribeSandboxEvents: function() {
                this.callParent(arguments);
                this.sandbox.subscribe("GetMasterEntitySchema", function() {
                    return this.get("IntEntitySchemaName");
                }, this, [this.getDetailId("IntRelatedSchemasDetail") + "_DetailModalBox"]);
                this.sandbox.subscribe("IntUploadFileClick", this.onFilesSelected, this, [this.sandbox.id]);
                this.sandbox.subscribe("GetModuleInfo", this.getDonateModalBoxConfig, this,
                    [this.getDonateModalBoxId()]);
            },
            donateButtonClick: function() {
                this.sandbox.loadModule("ModalBoxSchemaModule", {
                    id: this.getDonateModalBoxId()
                });
            },
            getDonateModalBoxConfig: function() {
                return {
                    "schemaName": "IntDonateModalPage",
                    "modalBoxSize": {
                        "width": "680px",
                        "height": "400px"
                    }
                };
            },
            getDonateModalBoxId: function() {
                return this.sandbox.id + "_DonateModalBox";
            }
        }
    };
});

Result

NB!

It's vital to note, that some websites don't allow insert them as Iframe

Like 0

Like

Share

2 comments

Hi,

Can you explain the values that variables IntReportConstants,

IntEntitySchemaName,

IntRelatedSchemasDetail,

IntUploadFileClick

in IntExcelReportPage hold?

 

 

Hi,



I know this post was old, but how to fix this?

 

Message GetMasterEntitySchema is not defined in CardModuleV2 (SectionModuleV2_AccountSectionV2_CardModuleV2) module 





I'm following this tutorial.



Thank you.

Show all comments

Case:

We need to add input mask on a "Phone number" field ( format "(99)999-99-99").

1. Create MultiMaskEdit client module and copy the source code listed bellow (skip this step if schema "MultiMaskEdit" already present in the configuration)

MultiMaskEdit code

define("MultiMaskEdit", ["ext-base", "terrasoft"], function(Ext, Terrasoft) {
    /**
     * @class Terrasoft.controls.MultiMaskEdit
     */
    Ext.define("Terrasoft.controls.MultiMaskEdit", {
        extend: "Terrasoft.TextEdit",
        alternateClassName: "Terrasoft.MultiMaskEdit",
 
        /**
         * @public
         * @type {Terrasoft.Align}
         */
        textAlign: Terrasoft.Align.LEFT,
        /**
         * @protected
         * @overridden
         */
        onFocus: function() {
            this.callParent(arguments);
            var value = this.getTypedValue();
            this.setDomValue(value);
        },
        /**
         * @protected
         * @virtual
         * @return {String}
         */
        getInitValue: function() {
            var value = this.callParent(arguments);
            if (!Ext.isEmpty(value) && !Ext.isEmpty(this.masks)) {
                var formatValue = this.formatValue(value);
                this.value = formatValue.value;
                var validationInfo = this.getValidationInfo(formatValue);
                this.setValidationInfo(validationInfo);
            }
            return this.value;
        },
        getValidationInfo: function(value) {
            var formatValue = (!Ext.isEmpty(value) && Ext.isBoolean(value.isComplete)) ? value : this.formatValue(value);
            var validationInfo = {
                isValid: true,
                invalidMessage: ""
            };
            if (!formatValue.isComplete) {
                validationInfo = {
                    isValid: false,
                    invalidMessage: this.getIncorrectNumberMessage()
                };
            }
            return validationInfo;
        },
        getIncorrectNumberMessage: function() {
            return "Invalid number";
        },
        /**
         * @protected
         * @overridden
         * @param  {Event} e DOM keypress
         * @param  {String} type (optional)
         * значение Terrasoft.DataValueType.FLOAT
         */
        onKeyPress: function(e) {
            this.callParent(arguments);
            if (this.readonly || Ext.isEmpty(this.masks)) {
                return;
            }
            var isSpecialKey = Ext.isGecko && e.isSpecialKey();
            if (isSpecialKey) {
                return;
            }
            e.preventDefault();
            var keyUnicode = e.getKey();
            var key = String.fromCharCode(keyUnicode);
            if (this.baseCharsRe && !this.baseCharsRe.test(key)) {
                return;
            }
            var domEl = e.getTarget();
            var info = this.getInputInfo(domEl);
            var formatValue = this.formatValueByInsChar(key, info.caretPosition, info.valueBeforeCaret, info.valueSelected,
                info.valueAfterCaret);
            if (!formatValue) {
                return;
            }
            domEl.value = formatValue.value;
            Terrasoft.utils.dom.setCaretPosition(domEl, formatValue.pos);
            if (!this.validationInfo.isValid && formatValue.isComplete) {
                var validationInfo = {
                    isValid: true,
                    invalidMessage: ""
                };
                this.setValidationInfo(validationInfo);
            }
        },
        getInputInfo: function(domEl) {
            var selectedTextLength = Terrasoft.utils.dom.getSelectedTextLength(domEl);
            var caretPosition = Terrasoft.utils.dom.getCaretPosition(domEl);
            var value = domEl.value;
            var valueBeforeCaret = "";
            var valueAfterCaret = "";
            var valueSelected = "";
            if (Ext.isIE) {
                valueBeforeCaret = value.slice(0, caretPosition - selectedTextLength);
                valueAfterCaret = value.slice(caretPosition);
                caretPosition -= selectedTextLength;
            } else {
                valueBeforeCaret = value.slice(0, caretPosition);
                valueAfterCaret = value.slice(caretPosition + selectedTextLength);
            }
            if (selectedTextLength > 0) {
                valueSelected = value.slice(caretPosition, selectedTextLength + caretPosition);
            }
            return {
                selectedTextLength: selectedTextLength,
                caretPosition: caretPosition,
                value: value,
                valueBeforeCaret: valueBeforeCaret,
                valueAfterCaret: valueAfterCaret,
                valueSelected: valueSelected
            };
        },
        /**
         * @protected
         */
        onKeyDown: function(e) {
            this.callParent(arguments);
            if (Ext.isEmpty(this.masks)) {
                return;
            }
            var key = e.getKey();
            var matches, masks, placeHolders, commonStr;
            if (key === e.BACKSPACE || key === e.DELETE) {
                e.preventDefault();
                var domEl = e.getTarget();
                var info = this.getInputInfo(domEl);
 
                if (info.valueBeforeCaret === "" && info.valueAfterCaret === "") {
                    this.setDomValue("");
                }
 
                else if (info.selectedTextLength > 0) {
 
                    if (Ext.isEmpty(info.valueAfterCaret)) {
                        this.setDomValue(this.removeEndPlaceHolders(info.valueBeforeCaret));
                    } else {
 
                        matches = this.getMatchesByValue(info.valueBeforeCaret);
                        if (matches.matches.length === 0) {
                            return;
                        }
 
                        masks = this.getPropertyValuesFromArray(matches.matches, "mask");
 
                        placeHolders = this.getPropertyValuesFromArray(masks, "placeHolder");
                        var replaceText = this.getCommonStartString(placeHolders).substr(info.caretPosition, info.selectedTextLength);
                        if (replaceText.length === info.selectedTextLength) {
                            this.setDomValue(info.valueBeforeCaret + replaceText + info.valueAfterCaret);
                        }
                    }
                } else if (key === e.BACKSPACE && !Ext.isEmpty(info.valueBeforeCaret)) {
                    matches = this.getMatchesByValue(info.valueBeforeCaret);
                    if (matches.matches.length === 0) {
                        return;
                    }
 
                    masks = this.getPropertyValuesFromArray(matches.matches, "mask");
 
                    placeHolders = this.getPropertyValuesFromArray(masks, "placeHolder");
                    commonStr = this.getCommonStartString(placeHolders);
                    if (commonStr.length >= info.caretPosition) {
                        this.setDomValueAndCaret(info.valueBeforeCaret.slice(0, -1) + commonStr.substr(info.caretPosition - 1, 1) +
                            info.valueAfterCaret, info.caretPosition - 1);
                    }
                } else if (key === e.DELETE && !Ext.isEmpty(info.valueAfterCaret)) {
 
                    matches = this.getMatchesByValue(info.valueBeforeCaret);
                    if (matches.matches.length === 0) {
                        return;
                    }
 
                    masks = this.getPropertyValuesFromArray(matches.matches, "mask");
 
                    placeHolders = this.getPropertyValuesFromArray(masks, "placeHolder");
                    commonStr = this.getCommonStartString(placeHolders);
                    if (commonStr.length > info.caretPosition) {
                        this.setDomValueAndCaret(info.valueBeforeCaret + commonStr.substr(info.caretPosition, 1) +
                            info.valueAfterCaret.slice(1), info.caretPosition + 1);
                    }
                }
            }
        },
        maskConfig: {
            definitions: {
                //numbers
                "9": {
                    re: "[0-9]"
                },
                //cyryllic
                "к": {
                    re: "[а-яА-ЯёЁ]"
                },
                //латинские
                "l": {
                    re: "[a-zA-Z]"
                },
                //any letter
                "c": {
                    re: "[а-яА-ЯёЁa-zA-Z]"
                },
                //any letter or number
                "#": {
                    re: "[а-яА-ЯёЁA-Za-z0-9]"
                }
            },
            placeHolderChar: "_"
        },
        mask: [],
        /**
         * @protected
         * @overridden
         */
        init: function() {
            this.callParent(arguments);
            this.reSpecChars = [
                "\\", "(", ")", "+"
            ];
            this.addEvents(
                "paste");
            this.on("paste", this.onPaste, this);
            this.setMasks(this.mask);
        },
        /**
         * @protected
         * */
        setMasks: function(value) {
            this.masks = [];
            if (Ext.isEmpty(value)) {
                value = {
                    formats: []
                };
            }
            Terrasoft.each(value.formats, function(format, i) {
                this.masks[i] = this.getMaskByFormat(format);
            }, this);
            this.changeValue(this.value);
        },
        /**
         * {@link Terrasoft.Bindable}.
         * @overridden
         */
        getBindConfig: function() {
            var bindConfig = this.callParent(arguments);
            var multiMaskEditBindConfig = {
                mask: {
                    changeMethod: "setMasks"
                }
            };
            Ext.apply(bindConfig, multiMaskEditBindConfig);
            return bindConfig;
        },
        getMaskByFormat: function(format) {
            var mask = {};
            var matches = [];
            var placeHolderChar;
            var placeHolder = "";
            var def;
            var allRe = "";
 
            if (format) {
                Terrasoft.each(format.split(""), function(c) {
                    def = this.maskConfig.definitions[c];
                    if (def) {
                        allRe += def.re;
                        placeHolderChar = def.placeHolderChar || this.maskConfig.placeHolderChar || "_";
                        matches.push({
                            re: new RegExp(def.re),
                            placeHolderChar: placeHolderChar
                        });
 
                        placeHolder += placeHolderChar;
                    } else {
                        placeHolder += c;
                        matches.push(c);
                        if (this.reSpecChars.indexOf(c) > 0) {
                            allRe += "\\" + c;
                        } else {
                            allRe += c;
                        }
                    }
                }, this);
                mask.placeHolder = placeHolder;
                mask.matches = matches;
                if (allRe !== "") {
                    mask.re = {};
                    mask.re.full = new RegExp("^" + allRe + "$");
                }
            }
            return mask;
        },
        /**
         * @param value
         */
        removeEndPlaceHolders: function(value) {
            if (!Ext.isEmpty(value)) {
                var pos;
 
                for (var i = (value.length - 1); i >= 0; i--) {
 
                    if (value[i] !== this.maskConfig.placeHolderChar) {
                        break;
                    }
                    pos = i;
                }
                if (pos === 0) {
                    value = "";
                } else if (pos) {
                    value = value.slice(0, pos);
                }
            }
            return value;
        },
        /**
         * @param mask
         * @param c
         * @param pos
         * @param textBefore
         * @param textReplaced
         * @param textAfter
         * @param allowAutoFill
         * @returns {*}
         */
        maskValidateByInsChar: function(mask, c, pos, textBefore, textReplaced, textAfter, allowAutoFill) {
            var replacedLength = textReplaced.length;
            if (replacedLength > 0) {
                textAfter = mask.placeHolder.slice(pos, pos + textReplaced.length) + textAfter;
            }
            var value = textBefore + textAfter;
            var maskValidate;
            var match;
            if (!Ext.isEmpty(textAfter)) {
                match = mask.matches[pos];
                if (match && !match.re && mask.matches[pos] === c) {
                    return {
                        value: value,
                        pos: pos,
                        result: this.maskValidateValue(mask, value)
                    };
                }
            }
            value = textBefore + c + textAfter;
            match = mask.matches[pos];
            if (match) {
                if (match.re) {
                    if (textAfter[0] === mask.placeHolder.substr(pos, 1)) {
                        value = textBefore + c + textAfter.substring(1);
                        maskValidate = this.maskValidateValue(mask, value);
                        if (maskValidate.isValid) {
                            return {
                                value: value,
                                pos: pos,
                                result: maskValidate
                            };
                        }
                    }
                }
            }
            maskValidate = this.maskValidateValue(mask, value);
            if (maskValidate.isValid) {
                return {
                    value: value,
                    pos: pos,
                    result: maskValidate
                };
            }
            if (match && !match.re && allowAutoFill && pos < mask.placeHolder.length) {
                var result = this.maskValidateByInsChar(mask, c, pos + 1, textBefore + match,
                    textReplaced, textAfter.substring(1), allowAutoFill);
                if (result) {
                    return result;
                }
                return this.maskValidateByInsChar(mask, c, pos + 1, textBefore + match,
                    textReplaced, textAfter.substring(2), allowAutoFill);
            }
            //}
        },
        /**
         * @param c
         * @param pos
         * @param textBefore
         * @param textAfter
         * @param allowAutoFill
         * @returns {*}
         */
        formatValueByInsChar: function(c, pos, textBefore, textReplaced, textAfter, allowAutoFill) {
            var maskValidation;
            var bestResults = [];
            Terrasoft.each(this.masks, function(item) {
                maskValidation = this.maskValidateByInsChar(item, c, pos, textBefore, textReplaced, textAfter, allowAutoFill);
                if (maskValidation) {
                    maskValidation.mask = item;
                    if (bestResults.length === 0) {
                        bestResults.push(maskValidation);
                    } else if (maskValidation.pos < bestResults[0].pos) {
                        bestResults = [maskValidation];
                    }
                }
            }, this);
            if (bestResults.length > 0) {
                maskValidation = bestResults[0];
 
                var formatValue = this.formatValue(maskValidation.value);
                formatValue.insPos = maskValidation.pos;
                return formatValue;
            }
        },
        /**
         * @param mask
         * @param value
         * @returns {*}
         */
        maskValidateValue: function(mask, value) {
            var match;
            var matchPos = 0;
            if (mask.re.full.test(value)) {
                return {
                    matchPos: value.length,
                    inputPos: value.length,
                    isValid: true,
                    isComplete: true
                };
            }
            var result = {
                matchPos: 0,
                inputPos: 0,
                isValid: true,
                isComplete: false
            };
            value = this.removeEndPlaceHolders(value);
            if (Ext.isEmpty(value)) {
                return result;
            } else {
                Terrasoft.each(value.split(""), function(c, i) {
                    match = mask.matches[i];
                    if (!match) {
                        result = {
                            isValid: false,
                            isComplete: false
                        };
                        return false;
                    } else if (match.re) {
                        if (!match.re.test(c)) {
                            if (match.placeHolderChar === c) {
                                if (!result.inputPos) {
                                    result.inputPos = i;
                                }
                            } else {
                                result = {
                                    isValid: false,
                                    isComplete: false
                                };
                                return false;
                            }
                        }
                    } else if (c !== match) {
                        result = {
                            isValid: false,
                            isComplete: false
                        };
                        return false;
                    }
                    matchPos = i;
                }, this);
                result.matchPos = matchPos;
                if (!result.inputPos) {
                    if (result.isValid) {
                        result.inputPos = result.matchPos + 1;
                    } else {
                        result.inputPos = value.length;
                    }
                }
            }
            return result;
        },
        /**
         * @param value
         * @returns {{matches: Array, matchPos: number, inputPos: number}}
         */
        getMatchesByValue: function(value) {
            var matches = [];
            var minPositions = [];
            var matchPos = 0;
            var inputPos = 0;
            var maskValidation;
            var isComplete = false;
            Terrasoft.each(this.masks, function(mask) {
                maskValidation = this.maskValidateValue(mask, value);
                if (maskValidation.isValid) {
                    var maskMinPos = mask.matches.length;
                    Terrasoft.each(mask.matches, function(match, pos) {
                        if (typeof match === "object" && maskMinPos > pos) {
                            maskMinPos = pos;
                        }
                    });
                    minPositions.push(maskMinPos);
                    if (maskValidation.isComplete) {
                        isComplete = true;
                    }
                    matches.push({
                        mask: mask,
                        validation: maskValidation
                    });
                    if (matchPos < maskValidation.matchPos) {
                        matchPos = maskValidation.matchPos;
                    }
                    if (inputPos < maskValidation.inputPos) {
                        inputPos = maskValidation.inputPos;
                    }
                }
            }, this);
            var minPos = Math.min.apply(0, minPositions);
            return {
                matches: matches,
                matchPos: matchPos,
                inputPos: inputPos,
                minPos: minPos,
                isComplete: isComplete
            };
        },
        /**
         * @param values
         * @returns {*}
         */
        getCommonStartString: function(values) {
            var valuesCount = values.length;
            if (valuesCount === 0) {
                return "";
            } else if (valuesCount === 1) {
                return values[0];
            }
            var commonStr = "";
            var minLen = values[0].length;
            Terrasoft.each(values, function(value) {
                minLen = Math.min(minLen, value.length);
            });
            var isMatch;
            var c;
            for (var i = 0; i < minLen; i++) {
                isMatch = true;
                for (var j = 1; j < valuesCount; j++) {
                    isMatch = values[j][i] === values[j - 1][i];
                    if (!isMatch) {
                        break;
                    }
                    c = values[j][i];
                }
                if (isMatch) {
                    commonStr += c;
                } else {
                    return commonStr;
                }
            }
            return commonStr;
        },
        /**
         * @param a
         * @param name
         * @returns {Array}
         */
        getPropertyValuesFromArray: function(a, name) {
            var result = [];
            Terrasoft.each(a, function(e) {
                result.push(e[name]);
            }, this);
            return result;
        },
        /**
         * @overridden
         * @protected
         */
        initDomEvents: function() {
            this.callParent(arguments);
            var el = this.getEl();
            el.on({
                "paste": {
                    fn: this.onPaste,
                    scope: this
                }
            });
        },
        onBeforePasteFormatValue: Ext.emptyFn,
        onPaste: function(e) {
            if (Ext.isEmpty(this.masks)) {
                return;
            }
            var getSplitText = function(v, p) {
                return {
                    pos: p,
                    before: v.substr(0, p),
                    after: v.substr(p)
                };
            };
            e.preventDefault();
            if (e.browserEvent.clipboardData && e.browserEvent.clipboardData.getData) {
                if (/text\/plain/.test(e.browserEvent.clipboardData.types)) {
                    var clipBoardValue = e.browserEvent.clipboardData.getData("text/plain");
                    clipBoardValue = this.onBeforePasteFormatValue(clipBoardValue) || clipBoardValue;
                    if (Ext.isEmpty(clipBoardValue)) {
                        return;
                    }
                    var domEl = e.getTarget();
                    var info = this.getInputInfo(domEl);
                    var pos = info.caretPosition;
                    var splitText = {
                        before: info.valueBeforeCaret,
                        after: info.valueAfterCaret
                    };
                    var newValue = splitText.before + splitText.after;
                    Terrasoft.each(clipBoardValue.split(""), function(c) {
                        var formatValue = this.formatValueByInsChar(c, pos, splitText.before, "", splitText.after, true);
                        if (formatValue) {
                            newValue = formatValue.value;
                            pos = formatValue.insPos + 1;
                            splitText = getSplitText(newValue, pos);
                        }
                    }, this);
                    domEl.value = newValue;
                }
            }
            return;
        },
        /**
         * @param value
         * @returns {*}
         */
        formatValue: function(value) {
            var newValue = value;
            var placeHolders;
            if (Ext.isEmpty(value)) {
                placeHolders = this.getPropertyValuesFromArray(this.masks, "placeHolder");
                newValue = this.getCommonStartString(placeHolders);
                if (!Ext.isEmpty(newValue)) {
                    return this.formatValue(newValue);
                }
                return {
                    pos: 0,
                    value: "",
                    isComplete: false
                };
            }
            var matches = this.getMatchesByValue(value);
            if (matches.matches.length === 0) {
                if (matches.matchPos > 0) {
                    newValue = value.substr(0, matches.matchPos + 1);
                } else {
 
                    return {
                        pos: 0,
                        value: value,
                        isComplete: false
                    };
                }
                return this.formatValue(newValue);
            }
            var masks = this.getPropertyValuesFromArray(matches.matches, "mask");
            placeHolders = this.getPropertyValuesFromArray(masks, "placeHolder");
            var afterText = this.getCommonStartString(placeHolders).substr(matches.matchPos + 1);
            newValue = value.substr(0, matches.matchPos + 1) + afterText;
            matches = this.getMatchesByValue(newValue);
            return {
                pos: matches.inputPos,
                min: matches.minPos,
                value: newValue,
                isComplete: matches.isComplete
            };
        },
        /**
         * @param value
         * @param caretPosition
         */
        setDomValueAndCaret: function(value, caretPosition) {
            var formatValue = this.formatValue(value);
            if (!this.validationInfo.isValid && formatValue.isComplete) {
                var validationInfo = {
                    isValid: true,
                    invalidMessage: ""
                };
                this.setValidationInfo(validationInfo);
            }
            var el = this.getEl();
            if (el) {
                el.dom.value = formatValue.value;
                caretPosition = caretPosition > formatValue.min ? caretPosition : formatValue.min;
                Terrasoft.utils.dom.setCaretPosition(el.dom, caretPosition);
            }
        },
        /**
         * @param {String} value
         * @protected
         * @virtual
         */
        setDomValue: function(value) {
            this.setDomValueAndCaret(value);
        },
        /**
         * @protected
         * @param  {String} value
         * @return {Boolean}
         */
        changeValue: function(value) {
            if (!Ext.isEmpty(this.masks)) {
                var formatValue = this.formatValue(value);
                if (formatValue.value === this.formatValue(null).value) {
                    value = null;
                    formatValue.isComplete = true;
                    var el = this.getEl();
                    if (el) {
                        el.dom.value = "";
                    }
                }
                var validationInfo = this.getValidationInfo(formatValue);
                this.setValidationInfo(validationInfo);
            }
            return this.callParent(arguments);
        }
    });
});

2. In the target schema add dependency to "MultiMaskEdit" schema and specify input mask format and className for the "Phone" filed in the controlConfig.

AccountMiniPage code

define("AccountMiniPage", ["MultiMaskEdit"], function() {
    return {
        entitySchemaName: "Account",
        diff: /**SCHEMA_DIFF*/[
            {
                "operation": "merge",
                "name": "Phone",
                "values": {
                    "controlConfig": {
                        "className": "Terrasoft.controls.MultiMaskEdit",
                        "mask": {
                            "formats": ["(99)999-99-99"]
                        }
                    }
                }
            }
        ]/**SCHEMA_DIFF*/
    };
});

Result:

Like 0

Like

Share

12 comments

Dear all, anyone knows where, I mean, the menus I must access to find the place where this code must be inserted?

Andre VItal,

Hello.

You have to do it in the configuration. You can read more in the article below, there is another example of the implementation:

https://academy.bpmonline.com/documents/technic-sdk/7-13/how-add-field-…

Best regards,

Matt

 

Matt Watts,

I tried creating a module where the code for 

MultiMaskEdit  is added then on my section page I have added 

define("UsrInterview1Page", [ "MultiMaskEdit", "css!UsrInterviewcss1"], function() {

//rest of the code

But the page seems to be unresponsive, did I miss out something?

Please help me in resolving this issue.

manikanta,

Hello.

First of all, please make sure that the MultiMaskEdit is a module, not a source code, most likely it is the cause of your issue. Secondly, please make sure that you have validated your code and eliminated all mistakes caused by the incorrect html tags, for example &gt; should be changed to >, &lt; to < and &amp; to simply &.

Lastly, please make sure that you have added your code to the correct target schema, i.e. if you need it for the account mini page then you should add the code from the second part of the article to the AccountMiniPage schema.

If you have done everything correctly you should be able to see the validation mask on the desired page.

Best regards,

Matt

Hello,

Thank you! Works fine on my side but I can no longer access to MiniPage Wizard.

Did I do something wrong!

Thank you for your help!

Dear Thibaut,

Please try validating the code as descrbed by Matt previously and also try generating source code and compiling of the instance.

Best regards,

Oscar

Dear Oscar,

Thank you for your reply.

I validated the code, generate source + compiling instance and the issue persist.

I get the error "Schema does not contain marker comments: 'SCHEMA_DETAILS'" in browser console when I try to load the designer page.

Any idea?

Thank you!

Hello,

Solved the issue by adding these 2 rows in the second code.

modules: /**SCHEMA_MODULES*/{}/**SCHEMA_MODULES*/,

details: /**SCHEMA_DETAILS*/{}/**SCHEMA_DETAILS*/,

Regards

Hi all,

 

I follow the guide and add to the contact page:

But when I open contact, it's only blank.

What I do wrong?

Regards,

Phuong Nguyen

Phuong Akira,

 

The Mobile phone column in the diff should be MobilePhone (without a space):

{

                "operation": "merge",

                "name": "MobilePhone",

                "values": {

                    "controlConfig": {

                        "className": "Terrasoft.controls.MultiMaskEdit",

                        "mask": {

                            "formats": ["(99)999-99-99"]

                        }

                    }

                }

  },

Aside from that, everything would work. I've replicated it on my demo instance and it worked well. 

Also please make sure to replace &gt; to >, &lt; to < and &amp; to simply &. in MultiMaskEdit module.

 

Hello, 

 

Anyonw knows if there is posible change the format depends of another field? Like depends of the country change the format.

Federico Buffa,

You have an opportunity to specify all formats which you use in formats array in the diff and after the user start typing maskhelper select the proper format from those which you populate 

ex:

define("AccountPageV2", ["GlbMultiMaskEdit"], function() {

    return {

        entitySchemaName: "Account",

        attributes: {},

        modules: /**SCHEMA_MODULES*/{}/**SCHEMA_MODULES*/,

        details: /**SCHEMA_DETAILS*/{}/**SCHEMA_DETAILS*/,

        businessRules: /**SCHEMA_BUSINESS_RULES*/{}/**SCHEMA_BUSINESS_RULES*/,

        messages:{

        },

        methods: {

            onEntityInitialized: function(){

                this.callParent(arguments);

            }

        },

        dataModels: /**SCHEMA_DATA_MODELS*/{}/**SCHEMA_DATA_MODELS*/,

        diff: /**SCHEMA_DIFF*/[

            {

                "operation": "merge",

                "name": "AccountPhone",

                "values": {

                    "controlConfig": {

                        "className": "Terrasoft.controls.GlbMultiMaskEdit",

                        "mask": {

                            "formats": ["+38(99)999-99-99", "+546(999)-9999-9", "+1(999)-9-999-9", "(999)-0-00-999"]

                        }

                    }

                }

            }

        ]/**SCHEMA_DIFF*/

    };

}); 

 

Best regards,

Angela

Show all comments

Client context

MobileApplicationInvoiceManifest not found;

MobileApplicationoportunityManifest not found;

MobileApplicationLeadManifest not found;

Cause

The specified manifest is registered in the "Mobile application manifest" system setting by mistake.

Solution

Simply remove this manifest from the list in the specified system setting.

Necessary conditions

Admin rights. Clearing Redis after removing the manifest.

Like 0

Like

Share

0 comments
Show all comments

Symptoms

Connecting to the on-site application results in the following error (outdated browser): 

ServiceStack.Redis.RedisResponseException: MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error., sPort: 53192, LastCommand: \\r\\n в ServiceStack.Redis.RedisNativeClient.CreateResponseError(String error)\\r\\n в ServiceStack.Redis.RedisNativeClient.ReadInt()\\r\\n в ServiceStack.Redis.RedisNativeClient.Expire(String key, Int32 seconds)\\r\\n в ServiceStack.Redis.RedisClient.ExpireEntryIn(String key, TimeSpan expireIn)\\r\\n в Terrasoft.Redis.RedisSessionStateStoreProvider.ResetItemTimeout(HttpContext context, String id)\\r\\n в System.Web.SessionState.SessionStateModule.BeginAcquireState(Object source, EventArgs e, AsyncCallback cb, Object extraData)\\r\\n in System.Web.HttpApplication.AsyncEventExecutionStep.System.Web.HttpApplication

Cause

This error is caused by Redis settings on the server.

Solution

Use third-party documentation to learn more. 

http://stackoverflow.com/questions/19581059/misconf-redis-is-configured-to-save-rdb-snapshots;

http://stackoverflow.com/questions/19873048/redis-is-configured-to-save-rdb-snapshots-but-is-currently-not-able-to-persist;

https://gist.github.com/kapkaev/4619127.

Use the mobile version of the application to ensure correct operation - the application may not work properly in mobile browsers.

 

Like 0

Like

Share

0 comments
Show all comments

Case

After I create a section via section wizard, I face errors when trying to edit this section via the wizard.

The error message: System schemas for the Smracalendar1 section detected. Cannot proceed.

Solution

The reason of the error is that you have deleted the objects, created by the section wizard. These objects must exist for the section wizard. If they cannot be found, the wizard will be trying to create a new section.

The following objects are created when a section is added:

You only left the following objects available in the sysytem:

Possible solutions: add the deleted objects manually or create the section again and copy the data into it.

 

Like 0

Like

Share

0 comments
Show all comments

Case description:

We need to add custom button into the active row of detail.

Algorithm of realization:

  1. Create replacing client module of your detail.
  2. Add localizable string for caption of your button.
  3. Add following code into diff section:

    {
        "operation": "merge",
        "name": "DataGrid",
        "parentName": "Detail",
        "propertyName": "items",
        "values": {
            "activeRowActions": [],
            "activeRowAction": {"bindTo": "onActiveRowAction"}
        }
    },
    {
        "operation": "insert",
        "name": "DataGridActiveRowSomeButton",
        "parentName": "DataGrid",
        "propertyName": "activeRowActions",
        "values": {
            "className": "Terrasoft.Button",
            "style": Terrasoft.controls.ButtonEnums.style.GREEN,
            "caption": resources.localizableStrings.SomeButtonCaption,
            "tag": "someButton"
        }
    }

    With this code you can add button into the active row (element with name equal to "DataGridActiveRowSomeButton") and set method which will handle clicks on this button (activeRowActions into element with name equal to DataGrid).

  4. Add following code into the methods section:

    onActiveRowAction: function(buttonTag) {
        switch (buttonTag) {
            case "someButton":
                this.onSomeButtonClicked();
                break;
            default:
                break;
        }
    },
    onSomeButtonClicked: function() {
        //TODO your logic
        var message = "";
     
        message += "Mobile phone ";
        message += this.getActiveRow().get("MobilePhone");
     
        this.showInformationDialog(message);
    }

     

  5. Here is full example:

define("AccountContactsDetailV2", ["AccountContactsDetailV2Resources"],
    function (resources) {
        return {
            entitySchemaName: "Contact",
            methods: {
                onActiveRowAction: function (buttonTag) {
                    switch (buttonTag) {
                        case "someButton":
                            this.onSomeButtonClicked();
                            break;
                        default:
                            break;
                    }
                },
                onSomeButtonClicked: function () {
                    //TODO your logic
                    var message = "";
                    message += "Mobile phone ";
                    message += this.getActiveRow().get("MobilePhone");
                    this.showInformationDialog(message);
                }
            },
            diff: /**SCHEMA_DIFF*/[
                {
                    "operation": "merge",
                    "name": "DataGrid",
                    "parentName": "Detail",
                    "propertyName": "items",
                    "values": {
                        "activeRowActions": [],
                        "activeRowAction": { "bindTo": "onActiveRowAction" }
                    }
                },
                {
                    "operation": "insert",
                    "name": "DataGridActiveRowSomeButton",
                    "parentName": "DataGrid",
                    "propertyName": "activeRowActions",
                    "values": {
                        "className": "Terrasoft.Button",
                        "style": Terrasoft.controls.ButtonEnums.style.GREEN,
                        "caption": resources.localizableStrings.SomeButtonCaption,
                        "tag": "someButton"
                    }
                }
            ]/**SCHEMA_DIFF*/
        };
    }
);

 

Like 0

Like

Share

6 comments

How to add one more button next to some button in the datagrid. based on above example. When i tried it is displaying only one button at a time (the first insert). Please find below my code for adding two buttons next to each other in the detail data grid. Kindly help me resolve the same asap

 

diff: /**SCHEMA_DIFF*/[

            {

                        "operation": "merge",

                        "name": "DataGrid",

                        "parentName": "Detail",

                        "propertyName": "items",

                        "values": {

                            "activeRowActions": [],

                            "activeRowAction": {"bindTo": "onActiveRowAction"}

                        }

                    },

             {

                "operation": "insert",

                "name": "DataGridActiveRowSomeButton",

                "parentName": "DataGrid",

                "propertyName": "activeRowActions",

                "values": {

                    "className": "Terrasoft.Button",

                    //"click": {"bindTo": "onButton1Click"},

                    "visible": true,

                    "enabled": true,

                    "style": Terrasoft.controls.ButtonEnums.style.BLUE,

                    "caption": resources.localizableStrings.HierarchyButtonCaption,

                    "tag": "someButton"

                }

            },

            {

                "operation": "insert",

                "name": "DataGridActiveRowSomeButton",

                "parentName": "DataGrid",

                "propertyName": "activeRowActions",

                "values": {

                "className": "Terrasoft.Button",

                    "visible": true,

                    "enabled": true,

                    "style": Terrasoft.controls.ButtonEnums.style.GREEN,

                    "caption": resources.localizableStrings.AddConcessionButtonCaption,

                    "tag": "someButton"

                }

            }

Sri Saranya,

Probably because they have the same name. The tags you have there are also the same, so both those buttons would execute the same code.

Hi All,

How to add the  visibility and enable to a button in "activeRowActions" :



I have implemented the below code. But the button is not visible eventhough we are returning visibility as true.



Hi team how come can change a boolean using this button and save the changes?

Adharsh, you can add a attribute boolean in the detail and setup the parameter in the function onRender, you can find a example in the AccountContactsDetailV2

 

				onRender: function() {
					this.callParent(arguments);
					this.initializeIsOrganizationExists();
				},

 

I tried this but didnt work well. Any ideas?

Show all comments

Case:

We need to bind column setup of some grid to package.

Implementation:

  1. Set up column setup and save this one for all users:

     
  2. Go to DB and find key of SysProfileData record by query:

    SELECT * FROM "SysProfileData" ORDER BY "ModifiedOn" DESC

  3. Create new data binding in configuration section of bpm`online like below:

    IMPORTANT!!! All checkboxes are VERY important. You should rewrite Data field in DB and merge SysProfileData record by Key, Contact and Culture fields.

Like 3

Like

Share

3 comments

When following this methodology in Freedom UI, when trying to install the data I get the following error message:
Duplicates data in object "SysProfileData". 
 

Any info on why this would be happening? The update key is set to the 3 columns specified:

And the bound data is specified individually (rather than with a condition, as I don't think that's possible any more in Freedom UI) but the 2 records have different Keys:

It looks like adding "Object" (column SysUserId) to the update key of the data binding worked for me, but not sure if this will always work or is the recommended way to do things. It would be nice if Creatio could confirm whether this is the right way of binding column setup in Freedom UI.

Harvey Adcock,


Greetings,

You are correct, the SysUserId should be migrated as well. 

Show all comments

Quetion

How do I update page fields by developer means after updating records in the database (via ESQ)?

Answer

You can use the this.set(‘ColumnName’, ‘NewValue’) method to update a field value by developer means. We recommend updating fields in the callback function with preliminaty checking of the database updates.

Example of a code:

someMethod: function(){
    var value = this.get('UsrRequired');
    var updateQuery = Ext.create("Terrasoft.UpdateQuery", {
        rootSchemaName: "UsrRuleTest"});
    var filters = updateQuery.filters;
    filters.addItem(this.Terrasoft.createColumnFilterWithParameter(
        this.Terrasoft.ComparisonType.EQUAL, "Id", 'IdValue’)); updateQuery.setParameterValue("UsrSomething", value, this.Terrasoft.DataValueType.TEXT); updateQuery.execute(function(result){ if(result.success) this.set('UsrTest0', value); }, this); }

 

Like 0

Like

Share

0 comments
Show all comments

Symptoms

An error occurred during synchronization % 0D% 0A% 0D% 0ATtype: Terrasoft.ServerException% 0D% 0AMessage: A request to the server returned an error% 0D% 0AAdditional information:% 0D% 0A% 09 {"requestUri": "https://tatpharm.bpmonline.com/ 0 / ServiceModel / EntityDataService.svc / ProductLineCollection / $ count /? $ Filter = ((CreatedOn ge datetime'2015-06-22T17% 3A38% 3A02% 2B06% 3A00 'or ModifiedOn ge datetime'2015-06-22T17% 3A38% 3A02% 2B06% 3A00 ')) "," statusCode ": 404," statusText ":" Not Found "," headers ": []," body ":" \ r \ n \ r \ n \ r \ n The resource cannot be found.

Cause

The object referred to is already deleted or moved.

Solution

1. Synchronize, make sure that the settings include the correct date and time of the last synchronization.

2. Clear the mobile application cache (by clicking the corresponding “Clear Cache” button. If there is no such button, you first need to perform a demo login - the corresponding button is below the authorization data, after which the cache is cleared).

3. Re-synchronize.

Like 0

Like

Share

0 comments
Show all comments

Symptoms

While accessing the section:

Type: Terrasoft.SourceCodeException 

Message: Uncaught TypeError: Cannot read property 'getComponent' of undefined 

AdditionalInfo: Script: file:///storage/emulated/0/BPMonline700/AppStructure/rev_0/src/MobileSocialMessageGridPageController.js?hash=c73dfb1d-eca1-40b3-8d5c-c6de590f5a6c%0D%0A%09Line: 160 

Stack trace: 

    at Ext.define.showException (file:///android_asset/www/appV2/Common/Terrasoft.Mobile.Combined.js:39893:41

    at Ext.define.showUncaughtException (file:///android_asset/www/appV2/Common/Terrasoft.Mobile.Combined.js:3461:25

    at Ext.define.onWindowError (file:///android_asset/www/appV2/Common/Terrasoft.Mobile.Combined.js:2987:18

Cause

Manifest lacks components.

Solution

Connect the schemas that are responsible for the "Feed" section in the "Support" workplace in the mobile application manifest.

-  MobileSocialMessageActionsSettingsSupport;

-  MobileSocialMessageGridPageSettingsSupport.

Additionally, remove the schemas that relate to the main workplace, and not to "Support".

-   MobileSocialMessageGridPageSettingsDefaultWorkplace;

-   MobileSocialMessageRecordPageSettingsDefaultWorkplace.

Like 0

Like

Share

0 comments
Show all comments