Built files from Bizgaze WebServer
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

radiobox.component.js 8.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. var Unibase;
  2. (function (Unibase) {
  3. let Forms;
  4. (function (Forms) {
  5. let Controls;
  6. (function (Controls) {
  7. class RadioBox {
  8. init(formpropertyid, prop, callback) {
  9. var instance = RadioBox.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 regExpr = "";
  17. var ErrMsg = "";
  18. var Isrequired = prop.IsRequired != true ? 'hidden' : '';
  19. var required = prop.IsRequired != true ? '' : 'required';
  20. var CurrentStageId = $("#hf_" + $("#hfLayout_InstalledPageId").val() + "_StageId").val();
  21. if (prop.StagesForRequired != null && prop.StagesForRequired != "") {
  22. var StagesForRequired = prop.StagesForRequired.split('|');
  23. Isrequired = StagesForRequired.find(x => x == CurrentStageId) ? '' : 'hidden';
  24. required = StagesForRequired.find(x => x == CurrentStageId) ? 'required' : '';
  25. }
  26. const { helpTooltipHtml, helpTextHtml } = Unibase.Platform.Forms.Components.FormViewer.Instance().getControlHelpHtml(prop);
  27. var html = '<div id="div_' + prop.DocPropertyName + '" class="div_' + prop.DocPropertyName + '_' + prop.FormPropertyId + '"><label for= "lbl" id = "lbl_' + prop.DocPropertyName + '" >' + helpTooltipHtml + '<span class="label-name">' + prop.LabelName + '</span><span class="text-danger ' + Isrequired + '" id="spnIsRequired_' + prop.DocPropertyName + '"> *</span></label ><br />' +
  28. '<input type="hidden" id="hdnRdb_' + prop.DocPropertyName + '" value="0" class="value-control" data-isdefault="' + prop.IsDefault + '" data-propdoctypename="' + prop.DocTypeName + '" data-required="' + prop.IsRequired + '" data-regularexp="' + regExpr + '" data-validatemsg="' + ErrMsg + '" placeholder = "' + prop.Placeholder + '" data-placeholder="' + prop.Placeholder + '" data-label="' + prop.LabelName + '" />' +
  29. '<span id="spnRdb_' + prop.DocPropertyName + '" class="spnRdb_' + prop.DocPropertyName + ' text-control" ></span>' +
  30. '<input type = "hidden" id = "hfId_' + prop.DocPropertyName + '" value = "0" ><label for="Validation" id="lblValidation_' + prop.DocPropertyName + '"></label><input type = "hidden" id = "hfFormPropertyId" value = "' + prop.FormPropertyId + '" />' + helpTextHtml + '</div>';
  31. $("#" + containerid).html(html);
  32. Unibase.Forms.Controls.RadioBox.Instance().getControlOptions(containerid, prop.DocPropertyName, prop);
  33. }
  34. getControlOptions(containerid, DocPropertyName, prop) {
  35. var hiddenids = $('#hdnRdb_' + DocPropertyName).val();
  36. var html = '';
  37. var data = JSON.parse(prop.ControlJsonText);
  38. if (prop.PropertySettings[0].ControlPropertyValue == "true") {
  39. html = '<span class="row">';
  40. }
  41. for (var i = 0; i < data.length; i++) {
  42. var assignValue = "";
  43. if (hiddenids != '') {
  44. if (hiddenids == data[i].ColumnValue) {
  45. assignValue = "checked";
  46. }
  47. }
  48. var textcolumn;
  49. if (data[i].ColumnValue.includes(" ") || data[i].ColumnValue.includes("/") || data[i].ColumnValue.includes("&")) {
  50. textcolumn = data[i].ColumnValue.replaceAll(" ", "").replaceAll("/", "").replaceAll("&", "");
  51. }
  52. else {
  53. textcolumn = data[i].ColumnValue;
  54. }
  55. if (Unibase.Forms.Controls.SubForm.Instance().Index != undefined && Unibase.Forms.Controls.SubForm.Instance().Index != 0) {
  56. var id = DocPropertyName + '_' + textcolumn + Number($("#SubFormIndex").val());
  57. }
  58. else {
  59. var id = DocPropertyName + '_' + textcolumn;
  60. }
  61. var columnvalue = prop.datatypeid == 3 ? data[i].ColumnNumber : data[i].ColumnValue;
  62. let val = columnvalue;
  63. if (prop.PropertySettings[0].ControlPropertyValue == "true") {
  64. html += '<div class="custom-control custom-radio col-sm-6 col-md-4 col-xl-3 p-0"><label id="lbl_' + id + '" class="btn btn-xs btn-rounded btn btn-light lblid_' + id + ' setting_radio' + DocPropertyName + ' mx-10 d-block" onclick="Unibase.Forms.Controls.RadioBox.Instance().radioButtonClick(' + "'" + DocPropertyName + "' ," + "'" + columnvalue + "'" + " ," + "'" + id + "'" + ')" style="height:30px" for="rdb_' + id + '">' + data[i].ColumnText + '</label><input type="radio" id="rdb_' + id + '" name="roleid" class="radio-tabview type-control custom-control-input rdb_' + DocPropertyName + '"/></div>';
  65. if (i == data.length - 1) {
  66. html += '</span>';
  67. }
  68. }
  69. else {
  70. html += '<div class="custom-control custom-radio">' +
  71. '<input type = "radio" id="rdb_' + id + '" name="' + DocPropertyName + '" class="type-control custom-control-input rdb_' + DocPropertyName + '_' + columnvalue + '" onclick="Unibase.Forms.Controls.RadioBox.Instance().radioButtonClick(' + "'" + DocPropertyName + "' ," + "'" + columnvalue + "'" + " ," + "'" + id + "'" + ')" ' + assignValue + '>' +
  72. '<label class="custom-control-label" for="rdb_' + id + '">' + data[i].ColumnText + '</label></div >';
  73. }
  74. }
  75. $("#" + containerid).find('.div_' + DocPropertyName + '_' + prop.FormPropertyId).find(".spnRdb_" + DocPropertyName).html(html);
  76. }
  77. loadControlSettings(controlsettingjson, formpropertyid) {
  78. return null;
  79. }
  80. loadPropertySettings(propertysettings, formpropertyid) {
  81. if (propertysettings != null) {
  82. for (var i = 0; i < propertysettings.length; i++) {
  83. var data = propertysettings[i];
  84. if (data.ControlPropertyName == "IsTabView") {
  85. $("#txt_" + formpropertyid).attr("MaxLength", data.ControlPropertyValue);
  86. }
  87. }
  88. }
  89. }
  90. bindEditFormDetails(formpropertyid, propval, DocPropertyName) {
  91. let value = propval;
  92. propval = propval.replaceAll(" ", "").replaceAll("/", "").replaceAll("&", "");
  93. if ($(".rdb_" + DocPropertyName).hasClass("radio-tabview")) {
  94. var _id = $(".lblid_" + DocPropertyName + "_" + propval);
  95. if (_id.length > 0) {
  96. var id = _id.attr("id").replace("lbl_", "");
  97. Unibase.Forms.Controls.RadioBox.Instance().radioButtonClick(DocPropertyName, value, id);
  98. }
  99. }
  100. else {
  101. $(".rdb_" + DocPropertyName + "_" + propval).prop("checked", true);
  102. $("#hdnRdb_" + DocPropertyName).val(value);
  103. }
  104. }
  105. radioButtonClick(DocPropertyName, ColumnValue, id) {
  106. if ($(".rdb_" + DocPropertyName).hasClass("radio-tabview")) {
  107. $(".setting_radio" + DocPropertyName).removeClass("btn-primary");
  108. $(".setting_radio" + DocPropertyName).addClass("btn-light");
  109. $("#lbl_" + id).removeClass("btn-light");
  110. $("#lbl_" + id).addClass("btn-primary");
  111. $("#hdnRdb_" + DocPropertyName).val(ColumnValue);
  112. }
  113. else {
  114. $("#hdnRdb_" + DocPropertyName).val(ColumnValue);
  115. }
  116. }
  117. static Instance() {
  118. if (this.instance === undefined) {
  119. this.instance = new RadioBox();
  120. }
  121. return this.instance;
  122. }
  123. }
  124. Controls.RadioBox = RadioBox;
  125. })(Controls = Forms.Controls || (Forms.Controls = {}));
  126. })(Forms = Unibase.Forms || (Unibase.Forms = {}));
  127. })(Unibase || (Unibase = {}));