").css( { "xmargin": "10px" }).dxBox( {
height : "100%",
direction : "col",
items : [
{
ratio : 1,
template : function() {
return $("
").append( flexTab.form.element() ).dxScrollView( {
height : "100%"
})
}
},
{
baseSize : 30,
template : function() {
return toolbar;
}
}
]
})
return template;
}
// DistributorProfile.prototype.buildFlexFieldItems = function( fields, targetArray, colCount ) {
// if( ! colCount ) {
// colCount = 1;
// }
// let parseConfig = function( configString ) {
// let fieldConfig = {};
// if( ! configString ) {
// return fieldConfig;
// }
// let fieldConfigAVP = configString.split( "," );
// fieldConfigAVP.forEach( function( avp ) {
// let parts = avp.split( "=" );
// fieldConfig[parts[0]] = parts[1];
// })
// return fieldConfig;
// }
// let formItems = [];
// let colSpanCount = function() {
// let colSpan = 0;
// formItems.forEach( function( fi ) {
// if( fi.colSpan ) {
// colSpan += fi.colSpan
// } else {
// colSpan ++;
// }
// })
// return colSpan;
// }
// fields.forEach( function( field ) {
// let fieldItem = {
// flexField : true,
// dataField : `${field.category}.${field.name}`,
// label : { text : field.label, location : "left" },
// isRequired : field.required == "Y" ? true : false,
// validationRules : []
// }
// // select
// if( field.type == "SELECT" ) {
// fieldItem.editorType = "dxSelectBox",
// fieldItem.editorOptions = {
// dataSource : { store : { type : "array", key : "value", data : field.lookupValues } },
// displayExpr : "text",
// valueExpr : "value",
// showClearButton : true
// }
// if( colCount == 1 ) {
// let fieldConfig = parseConfig( field.config );
// if( fieldConfig.size ) {
// fieldItem.editorOptions.width = `${fieldConfig.size}em`;
// } else {
// fieldItem.editorOptions.width = 300;
// }
// //console.log( "SELECTBOX" );
// //console.log( fieldConfig );
// }
// }
// // radio
// if( field.type == "RADIO" ) {
// fieldItem.editorType = "dxRadioGroup";
// fieldItem.editorOptions = {
// layout : "horizontal",
// dataSource : { store : { type : "array", key : "value", data : field.lookupValues } },
// displayExpr : "text",
// valueExpr : "value",
// showClearButton : true
// }
// }
// // textarea
// if ( field.type == "TEXTAREA" ) {
// if( colCount != 1 ) {
// let colSpan = colSpanCount() % colCount;
// if( colSpan ) {
// colSpan = colCount - colSpan;
// formItems.push( { flexField : true, itemType : "empty", colSpan : colSpan });
// }
// fieldItem.colSpan = colCount;
// }
// fieldItem.editorType = "dxTextArea";
// fieldItem.editorOptions = {
// maxLength : field.maxLength
// }
// let fieldConfig = parseConfig( field.config );
// if( fieldConfig.rows ) {
// fieldItem.editorOptions.minHeight = fieldConfig.rows * 30;
// }
// if( colCount == 1 ) {
// if( fieldConfig.cols ) {
// fieldItem.editorOptions.width = `${fieldConfig.cols}em`;
// }
// if( fieldConfig.size ) {
// fieldItem.editorOptions.width = `${fieldConfig.size}em`;
// }
// }
// }
// // checkbox
// if( field.type == "CHECKBOX" ) {
// fieldItem = {
// flexField : true,
// itemType : "group",
// items : [],
// colCount : colCount == 1 ? 3 : 2
// }
// if( true || colCount != 1 ) {
// // fieldItem.caption = field.label;
// // fieldItem.captionTemplate = function( itemData, container ) {
// // container.append( $("
").css( {"color" : "red" } ).text( itemData.caption ));
// // }
// fieldItem.label = { text : field.label, location : "left", template : function( itemData, container ) {
// container.append($("
").text( itemData.text ).css( { "xcolor" : "red" } ) ); // css( { "font-weight" : "bold" } ).
// } }
// }
// if( field.lookupValues ) {
// field.lookupValues.forEach( function( cbi ) {
// let checkBoxItem = {
// dataField : `${field.category}.${field.name}.${cbi.value}`,
// label : { text : cbi.text, location : 'left' },
// editorType : "dxCheckBox"
// }
// fieldItem.items.push( checkBoxItem );
// })
// }
// }
// // this is not fully implemented, and as such it is not in the list of fields returned by flexFields
// if( field.type == "FILE" ) {
// fieldItem.template = function( options, itemElement ) {
// let customEditors = options.component.option( "customEditors" );
// if( ! customEditors ) {
// customEditors = {};
// }
// let editorContainer = $("");
// let fileUploader = $("
").dxFileUploader({
// }).dxFileUploader( "instance" );
// editorContainer.append( fileUploader.element() );
// itemElement.append( editorContainer ).addClass( "find-me" );
// customEditors[fieldItem.dataField] = fileUploader;
// options.component.option( "customEditors", customEditors );
// }
// }
// /*
// if( ! fieldItem.editorType && field.type != 'CHECKBOX' ) {
// console.log( "FIELDTYPE " + field.type );
// console.log( field )
// }
// */
// // all other- default is a text box with a length limit
// if( ! fieldItem.editorType && field.type != "FILE" ) {
// fieldItem.editorOptions = {};
// if( field.format == "email" ) {
// fieldItem.editorType = "dxTextBox";
// fieldItem.editorOptions.placeholder = "mailbox@company.com";
// fieldItem.validationRules.push( { type : "email" } );
// }
// if( field.format == "url" ) {
// fieldItem.editorType = "dxTextBox";
// fieldItem.editorOptions.placeholder = "https://company.com";
// let validURLPattern = /^https?:\/\/([-\w\.]+)+(:\d+)?(:\w+)?(@\d+)?(@\w+)?([-\w\.]+)(\/([\w\/_\.]*(\?\S+)?)?)?/i;
// fieldItem.validationRules.push( { type : "pattern", message : "Invalid URL", pattern : validURLPattern } );
// }
// if( field.format == "date" ) {
// fieldItem.editorType = "dxDateBox";
// fieldItem.editorOptions.placeholder = "mm/dd/yyyy";
// fieldItem.editorOptions.openOnFieldClick = true;
// }
// if( field.format == "integer" || field.format == "decimal" ) {
// fieldItem.editorType = "dxNumberBox";
// fieldItem.editorOptions.showSpinButtons = false;
// if( field.format == "integer" ) {
// fieldItem.editorOptions.format = "#";
// }
// if( field.format == "decimal" ) {
// fieldItem.editorOptions.format = "#.0#";
// }
// if( field.maxLength > 0 ) {
// fieldItem.editorOptions.maxLength = field.maxLength;
// }
// }
// if( ! fieldItem.itemType && ! fieldItem.editorType) {
// fieldItem.editorType = "dxTextBox";
// }
// if( fieldItem.editorType == "dxTextBox" && field.maxLength > 0 ) {
// fieldItem.editorOptions.maxLength = field.maxLength;
// }
// if( colCount == 1 ) {
// let fieldConfig = parseConfig( field.config );
// if( fieldConfig.size ) {
// fieldItem.editorOptions.width = `${fieldConfig.size}em`;
// }
// }
// }
// if( field.lockEdit == "Y" ) {
// if( field.type != "CHECKBOX" ) {
// fieldItem.editorOptions = fieldItem.editorOptions ? fieldItem.editorOptions : {};
// fieldItem.editorOptions.readOnly = true;
// }else{
// let x = 0;
// field.lookupValues.forEach( function( ) {
// //fieldItem.items[x].readOnly = true; //does not work
// fieldItem.items[x].disabled = true;
// x++;
// })
// }
// }
// formItems.push( fieldItem );
// if( field.type == "CHECKBOX" ) {
// let fieldSeparatorItem = { name : `fieldSeparator_${field.name}`, itemType : "empty" }
// console.log( "fieldSeparatorItem", fieldSeparatorItem );
// formItems.push( fieldSeparatorItem )
// }
// })
// if( colCount != 1 ) {
// let colSpan = colSpanCount() % colCount;
// if( colSpan ) {
// colSpan = colCount - colSpan;
// formItems.push( { itemType : "empty", colSpan : colSpan })
// }
// }
// if( targetArray ) {
// formItems.forEach( function( fi ) {
// targetArray.push( fi );
// })
// }
// return formItems;
// }