Built files from Bizgaze WebServer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

checkbox.component.js 9.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. var Unibase;
  2. (function (Unibase) {
  3. let Forms;
  4. (function (Forms) {
  5. let Controls;
  6. (function (Controls) {
  7. class CheckBox {
  8. init(formpropertyid, prop, callback) {
  9. var instance = CheckBox.Instance();
  10. instance.loadControlSettings(prop.ControlJsonText, prop.FormPropertyId);
  11. instance.loadPropertySettings(prop.PropertySettings, prop.FormPropertyId);
  12. if (callback != null)
  13. callback();
  14. }
  15. loadControl(containerid, prop) {
  16. var Isrequired = prop.IsRequired != true ? 'hidden' : '';
  17. var required = prop.IsRequired != true ? '' : 'required';
  18. var reqMark = prop.IsRequired != true ? '' : '*';
  19. var CurrentStageId = $("#hf_" + $("#hfLayout_InstalledPageId").val() + "_StageId").val();
  20. if (prop.StagesForRequired != null && prop.StagesForRequired != "") {
  21. var StagesForRequired = prop.StagesForRequired.split('|');
  22. Isrequired = StagesForRequired.find(x => x == CurrentStageId) ? '' : 'hidden';
  23. required = StagesForRequired.find(x => x == CurrentStageId) ? 'required' : '';
  24. reqMark = StagesForRequired.find(x => x == CurrentStageId) ? '*' : '';
  25. }
  26. const { helpTooltipHtml, helpTextHtml } = Unibase.Platform.Forms.Components.FormViewer.Instance().getControlHelpHtml(prop);
  27. 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>` +
  28. '<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" />' +
  29. '<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>';
  30. $("#" + containerid).html(html);
  31. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("platform/controls/subform/subform.component.js", function () {
  32. Unibase.Forms.Controls.CheckBox.instance.GetDocPropertiesByPropId(containerid, prop.DocPropertyName, prop);
  33. });
  34. }
  35. GetDocPropertiesByPropId(containerid, DocPropertyName, prop) {
  36. var html = "";
  37. var data1 = JSON.parse(prop.ControlJsonText);
  38. var instance = Unibase.Forms.Controls.CheckBox.Instance();
  39. for (var i = 0; i < data1.length; i++) {
  40. var res = data1[i];
  41. if (Unibase.Forms.Controls.SubForm.Instance().Index != undefined && Unibase.Forms.Controls.SubForm.Instance().Index != 0) {
  42. var id = DocPropertyName + '_' + res.ColumnText + Number($("#SubFormIndex").val());
  43. }
  44. else {
  45. var id = DocPropertyName;
  46. if (res.ColumnText != null && res.ColumnText != "") {
  47. id = DocPropertyName + '_' + res.ColumnText;
  48. }
  49. }
  50. if (res.IsSwitch == true) {
  51. if (res.ColumnText == undefined)
  52. res.ColumnText = "";
  53. if (res.IsMultiple == false)
  54. 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>';
  55. else
  56. 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>&nbsp</div>';
  57. }
  58. else {
  59. var checkclass = "";
  60. if (res.ColumnText == null || res.ColumnText == "") {
  61. res.ColumnText = "";
  62. checkclass += "pull-right";
  63. }
  64. var onclick = "Unibase.Forms.Controls.CheckBox.Instance().CheckBoxClick('" + DocPropertyName + "'," + res.CheckBoxColumnId + ")";
  65. if (res.IsMultiple == false) {
  66. onclick = "Unibase.Forms.Controls.CheckBox.Instance().CheckBoxClickSingle(" + prop.DocPropertyId + ",'" + DocPropertyName + "')";
  67. }
  68. var _subform = $(".btnAddSubForm");
  69. if (_subform.length > 0) {
  70. const Index = Number($(".btnAddSubForm").attr("data-subformcount")) - 1;
  71. 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>&nbsp</div>';
  72. }
  73. else {
  74. 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>&nbsp</div>';
  75. }
  76. }
  77. }
  78. $("#" + containerid).find('.div_' + prop.DocPropertyId).find("#spnChk_" + prop.FormPropertyId).html(html);
  79. }
  80. loadControlSettings(controlsettingjson, formpropertyid) {
  81. return null;
  82. }
  83. loadPropertySettings(propertysettings, formpropertyid) {
  84. return null;
  85. }
  86. bindEditFormDetails(formpropertyid, propval, DocPropertyName) {
  87. if (propval == "True") {
  88. $("#chk_" + DocPropertyName).prop("checked", true);
  89. $("#hdnchk_" + DocPropertyName).val("true");
  90. }
  91. }
  92. CheckBoxClick(DocPropertyName, CheckBoxColumnId) {
  93. var ids = $("#hdnchk_" + DocPropertyName).val();
  94. if ($("#chk_" + CheckBoxColumnId).is(':checked')) {
  95. if (ids != "") {
  96. ids += CheckBoxColumnId + "|";
  97. }
  98. else {
  99. ids = CheckBoxColumnId + "|";
  100. }
  101. }
  102. else {
  103. var tg = ids.split('|');
  104. ids = "";
  105. for (var i = 0; i < tg.length; i++) {
  106. var a = tg[i];
  107. if (a != CheckBoxColumnId && tg[i] != '') {
  108. ids += tg[i] + "|";
  109. }
  110. }
  111. }
  112. $("#hdnchk_" + DocPropertyName).val(ids);
  113. }
  114. CheckBoxClickSingle(DocPropertyId, DocPropertyName) {
  115. if ($("#chk_" + DocPropertyName).is(':checked')) {
  116. $("#hdnchk_" + DocPropertyName).val("true");
  117. }
  118. else {
  119. $("#hdnchk_" + DocPropertyName).val("false");
  120. }
  121. }
  122. static Instance() {
  123. if (this.instance === undefined) {
  124. this.instance = new CheckBox();
  125. }
  126. return this.instance;
  127. }
  128. }
  129. Controls.CheckBox = CheckBox;
  130. })(Controls = Forms.Controls || (Forms.Controls = {}));
  131. })(Forms = Unibase.Forms || (Unibase.Forms = {}));
  132. })(Unibase || (Unibase = {}));