123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- var Unibase;
- (function (Unibase) {
- let Forms;
- (function (Forms) {
- let Controls;
- (function (Controls) {
- class CheckBox {
- init(formpropertyid, prop, callback) {
- var instance = CheckBox.Instance();
- instance.loadControlSettings(prop.ControlJsonText, prop.FormPropertyId);
- instance.loadPropertySettings(prop.PropertySettings, prop.FormPropertyId);
- if (callback != null)
- callback();
- }
- loadControl(containerid, prop) {
- var Isrequired = prop.IsRequired != true ? 'hidden' : '';
- var required = prop.IsRequired != true ? '' : 'required';
- var reqMark = prop.IsRequired != true ? '' : '*';
- var CurrentStageId = $("#hf_" + $("#hfLayout_InstalledPageId").val() + "_StageId").val();
- if (prop.StagesForRequired != null && prop.StagesForRequired != "") {
- var StagesForRequired = prop.StagesForRequired.split('|');
- Isrequired = StagesForRequired.find(x => x == CurrentStageId) ? '' : 'hidden';
- required = StagesForRequired.find(x => x == CurrentStageId) ? 'required' : '';
- reqMark = StagesForRequired.find(x => x == CurrentStageId) ? '*' : '';
- }
- const { helpTooltipHtml, helpTextHtml } = Unibase.Platform.Forms.Components.FormViewer.Instance().getControlHelpHtml(prop);
- var html = `<div id="div_${prop.DocPropertyName}" class="div_${prop.DocPropertyId} form-group floating-label mt-sm-10 mb-0"><br><label for= "lbl" id="lbl_${prop.DocPropertyName}" style="align:center;">${helpTooltipHtml}<span class="label-name">${prop.LabelName}</span><span class="text-danger ${Isrequired}" id="spnIsRequired_${prop.DocPropertyName}">*</span></label>` +
- '<input type="hidden" id="hdnchk_' + prop.DocPropertyName + '" class="form-control value-control ' + required + '" data-isdefault="' + prop.IsDefault + '" data-required="' + prop.IsRequired + '" data-regularexp="" data-validatemsg="" placeholder = "' + prop.Placeholder + '" data-placeholder="' + prop.Placeholder + '" data-label="' + prop.LabelName + '" data-ismultiple="' + prop.IsMultiple + '" value="false" />' +
- '<span id="spnChk_' + prop.FormPropertyId + '" data-isswitch="' + prop.IsSwitch + '"></span><input type="hidden" id="hfId" value="false"><label for="Validation" id="lblValidation_' + prop.DocPropertyName + '"></label><input type="hidden" id="hfFormPropertyId" value="" />' + helpTextHtml + '</div>';
- $("#" + containerid).html(html);
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("platform/controls/subform/subform.component.js", function () {
- Unibase.Forms.Controls.CheckBox.instance.GetDocPropertiesByPropId(containerid, prop.DocPropertyName, prop);
- });
- }
- GetDocPropertiesByPropId(containerid, DocPropertyName, prop) {
- var html = "";
- var data1 = JSON.parse(prop.ControlJsonText);
- var instance = Unibase.Forms.Controls.CheckBox.Instance();
- for (var i = 0; i < data1.length; i++) {
- var res = data1[i];
- if (Unibase.Forms.Controls.SubForm.Instance().Index != undefined && Unibase.Forms.Controls.SubForm.Instance().Index != 0) {
- var id = DocPropertyName + '_' + res.ColumnText + Number($("#SubFormIndex").val());
- }
- else {
- var id = DocPropertyName;
- if (res.ColumnText != null && res.ColumnText != "") {
- id = DocPropertyName + '_' + res.ColumnText;
- }
- }
- if (res.IsSwitch == true) {
- if (res.ColumnText == undefined)
- res.ColumnText = "";
- if (res.IsMultiple == false)
- html += '<label id="lblCheckBox_' + DocPropertyName + '" class="lblCheckBox_' + DocPropertyName + ' ' + ' switch m-t pull-right"><input type="checkbox" id="chk_' + DocPropertyName + '" class="type-control chk_' + id + '" name="' + DocPropertyName + '" onclick="Unibase.Forms.Controls.CheckBox.Instance().CheckBoxClickSingle(' + res.DocPropertyId + ',' + "'" + DocPropertyName + "'" + ')" placeholder = "' + prop.Placeholder + '"/><span></span></label>';
- else
- html += '<div class="switch m-t"><input type="checkbox" id="chk_' + DocPropertyName + '" class="type-control chk_' + id + '" name="' + DocPropertyName + '" onclick="Unibase.Forms.Controls.CheckBox.Instance().CheckBoxClickSingle(' + res.DocPropertyId + ',' + "'" + DocPropertyName + "'" + ')" placeholder = "' + prop.Placeholder + '"/><label class="col-sm-6" for="chk_' + id + '">' + res.ColumnText + '</label><span></span> </div>';
- }
- else {
- var checkclass = "";
- if (res.ColumnText == null || res.ColumnText == "") {
- res.ColumnText = "";
- checkclass += "pull-right";
- }
- var onclick = "Unibase.Forms.Controls.CheckBox.Instance().CheckBoxClick('" + DocPropertyName + "'," + res.CheckBoxColumnId + ")";
- if (res.IsMultiple == false) {
- onclick = "Unibase.Forms.Controls.CheckBox.Instance().CheckBoxClickSingle(" + prop.DocPropertyId + ",'" + DocPropertyName + "')";
- }
- var _subform = $(".btnAddSubForm");
- if (_subform.length > 0) {
- const Index = Number($(".btnAddSubForm").attr("data-subformcount")) - 1;
- html += '<div class="custom-control custom-checkbox divEnablePieces checkbox-primary ' + checkclass + '"><input type="checkbox" class="type-control custom-control-input" id = chk_' + id + '_' + Index + ' name="' + DocPropertyName + '" onclick="' + onclick + '" placeholder = "' + prop.Placeholder + '"><label class="custom-control-label" for = chk_' + id + '_' + Index + '>' + res.ColumnText + '</label><span></span> </div>';
- }
- else {
- html += '<div class="custom-control custom-checkbox divEnablePieces checkbox-primary ' + checkclass + '"><input type="checkbox" class="type-control custom-control-input" id = chk_' + id + ' name="' + DocPropertyName + '" onclick="' + onclick + '" placeholder = "' + prop.Placeholder + '"><label class="custom-control-label" for = chk_' + id + '>' + res.ColumnText + '</label><span></span> </div>';
- }
- }
- }
- $("#" + containerid).find('.div_' + prop.DocPropertyId).find("#spnChk_" + prop.FormPropertyId).html(html);
- }
- loadControlSettings(controlsettingjson, formpropertyid) {
- return null;
- }
- loadPropertySettings(propertysettings, formpropertyid) {
- return null;
- }
- bindEditFormDetails(formpropertyid, propval, DocPropertyName) {
- if (propval == "True") {
- $("#chk_" + DocPropertyName).prop("checked", true);
- $("#hdnchk_" + DocPropertyName).val("true");
- }
- }
- CheckBoxClick(DocPropertyName, CheckBoxColumnId) {
- var ids = $("#hdnchk_" + DocPropertyName).val();
- if ($("#chk_" + CheckBoxColumnId).is(':checked')) {
- if (ids != "") {
- ids += CheckBoxColumnId + "|";
- }
- else {
- ids = CheckBoxColumnId + "|";
- }
- }
- else {
- var tg = ids.split('|');
- ids = "";
- for (var i = 0; i < tg.length; i++) {
- var a = tg[i];
- if (a != CheckBoxColumnId && tg[i] != '') {
- ids += tg[i] + "|";
- }
- }
- }
- $("#hdnchk_" + DocPropertyName).val(ids);
- }
- CheckBoxClickSingle(DocPropertyId, DocPropertyName) {
- if ($("#chk_" + DocPropertyName).is(':checked')) {
- $("#hdnchk_" + DocPropertyName).val("true");
- }
- else {
- $("#hdnchk_" + DocPropertyName).val("false");
- }
- }
- static Instance() {
- if (this.instance === undefined) {
- this.instance = new CheckBox();
- }
- return this.instance;
- }
- }
- Controls.CheckBox = CheckBox;
- })(Controls = Forms.Controls || (Forms.Controls = {}));
- })(Forms = Unibase.Forms || (Unibase.Forms = {}));
- })(Unibase || (Unibase = {}));
|