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.

cascadingautocomplete.component.js 7.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. var Unibase;
  2. (function (Unibase) {
  3. let Forms;
  4. (function (Forms) {
  5. let Controls;
  6. (function (Controls) {
  7. class CascadingAutocomplete {
  8. constructor() {
  9. this.cascadingArray = [];
  10. this.loadCascading = true;
  11. }
  12. init(formpropertyid, prop, callback) {
  13. var instance = CascadingAutocomplete.Instance();
  14. var container = "control-container-" + formpropertyid;
  15. instance.loadControlSettings(prop.ControlJsonText, prop.FormPropertyId);
  16. instance.loadPropertySettings(prop.PropertySettings, prop.FormPropertyId);
  17. if (callback != null)
  18. callback();
  19. }
  20. loadControl(containerid, prop) {
  21. var instance = this;
  22. var Isrequired = prop.IsRequired != true ? 'hidden' : '';
  23. var required = prop.IsRequired != true ? '' : 'required';
  24. var reqMark = prop.IsRequired != true ? '' : '*';
  25. var CurrentStageId = $("#hf_" + $("#hfLayout_InstalledPageId").val() + "_StageId").val();
  26. if (prop.StagesForRequired != null && prop.StagesForRequired != "") {
  27. var StagesForRequired = prop.StagesForRequired.split('|');
  28. Isrequired = StagesForRequired.find(x => x == CurrentStageId) ? '' : 'hidden';
  29. required = StagesForRequired.find(x => x == CurrentStageId) ? 'required' : '';
  30. reqMark = StagesForRequired.find(x => x == CurrentStageId) ? '*' : '';
  31. }
  32. var data = JSON.parse(prop.ControlJsonText);
  33. var cascArray = CascadingAutocomplete.instance.cascadingArray;
  34. var isexist = Unibase.Forms.Controls.CascadingAutocomplete.Instance().cascadingArray.find(x => x.UniqueId == prop.UniqueId) ? true : false;
  35. data["UniqueId"] = prop.UniqueId;
  36. if (isexist == false)
  37. CascadingAutocomplete.instance.cascadingArray.push(data);
  38. const { helpTooltipHtml, helpTextHtml } = Unibase.Platform.Forms.Components.FormViewer.Instance().getControlHelpHtml(prop);
  39. var html = `<div id="div_${prop.UniqueId}">
  40. <label for="ddl_cascading_${prop.UniqueId}" id="lbl_cascading_${prop.UniqueId}" class="font-bold" style="color:grey">${helpTooltipHtml}<span class="label-name">${prop.LabelName}</span><span class="text-danger ${Isrequired}" id="spnCascading_${prop.UniqueId}"> *</span></label>` +
  41. '<div class="input-group">' +
  42. '<select id="ddl_cascading_' + prop.UniqueId + '" class="ddl_cascading_' + prop.DocPropertyName + ' form-control type-control text-control ' + required + ' " data-isdefault="' + prop.IsDefault + '" style="width:100%;" placeholder = "' + prop.Placeholder + '" data-placeholder="' + prop.Placeholder + '" data-label="' + prop.LabelName + '" data-propertyid="' + prop.DocPropertyId + '" data-propertyname="' + prop.DocPropertyName + '" data-formpropertyid="' + prop.FormPropertyId + '" value="0" ></select>' +
  43. '<input type="hidden" id="hfddl_cascading_' + prop.UniqueId + '" value="0" data-autotextid="ddl_cascading_' + prop.UniqueId + '" class="hfAutoCompleteId_' + prop.DocPropertyName + ' form-control value-control" />' + helpTextHtml + '</div></div>';
  44. $("#" + containerid).html(html);
  45. $("#ddl_cascading_" + prop.UniqueId).select2({
  46. placeholder: prop.Placeholder,
  47. width: '100%',
  48. });
  49. $("#" + containerid).find("#ddl_cascading_" + prop.UniqueId).on('change', function () {
  50. if (instance.loadCascading) {
  51. Unibase.Forms.Controls.CascadingAutocomplete.Instance().ChildCascadingData(false, prop.FormPropertyId, Number($("#ddl_cascading_" + prop.UniqueId).val()), 0, '');
  52. }
  53. instance.loadCascading = true;
  54. });
  55. }
  56. loadControlSettings(controlsettingjson, formpropertyid) {
  57. return null;
  58. }
  59. loadPropertySettings(propertysettings, formpropertyid) {
  60. return null;
  61. }
  62. bindEditFormDetails(formpropertyid, propval, DocPropertyName) {
  63. var instance = this;
  64. if (propval != "") {
  65. var cascInfo = JSON.parse(propval);
  66. instance.ChildCascadingData(true, cascInfo.ParentFormPropertyId, cascInfo.ReportColumnText, cascInfo.ReportColumnValueId, cascInfo.ReportColumnValue);
  67. if (cascInfo.ReportColumnValueId != 0) {
  68. var cascOption = new Option(cascInfo.ReportColumnValue, cascInfo.ReportColumnValueId, true);
  69. $("#ddl_cascading_" + formpropertyid).append(cascOption);
  70. instance.loadCascading = false;
  71. jQuery("#ddl_cascading_" + formpropertyid).val(cascInfo.ReportColumnValueId).trigger('change');
  72. }
  73. }
  74. }
  75. ChildCascadingData(isEditForm, ParentFormPropertyId, ParentTextColumnValue, Id, Value) {
  76. var instance = this;
  77. var hdn_cascading_array = CascadingAutocomplete.instance.cascadingArray;
  78. if (hdn_cascading_array != undefined) {
  79. var list = hdn_cascading_array.filter(x => x.ParentFormPropertyId == ParentFormPropertyId);
  80. for (var i = 0; i < list.length; i++) {
  81. var listitem = list[i];
  82. var casFormPropId = listitem.UniqueId;
  83. var response = listitem;
  84. var reportId = response.ReportId;
  85. var formPropertyId = response.FormPropertyId;
  86. var parentFormPropertyId = response.ParentFormPropertyId;
  87. var applyFor = response.ApplyFor;
  88. var formId = Number($(".formValidate:visible").find("#hf_FormId").val());
  89. if (!isEditForm) {
  90. $("#ddl_cascading_" + casFormPropId).val(null).trigger("change");
  91. }
  92. var url = _appsettings.server_url() + '/apis/v4/unibase/platform/forms/getcascadingautocompletedata/formpropertyid/' + formPropertyId + '/parentidcolumn/' + applyFor + '/parentcolumnvalue/' + ParentTextColumnValue + '/parentformpropertyid/' + parentFormPropertyId;
  93. AutoCompleteHelper.getHelper().Create("#ddl_cascading_" + casFormPropId, "#hfddl_cascading_" + casFormPropId, url, function (response) {
  94. });
  95. }
  96. }
  97. }
  98. static Instance() {
  99. if (this.instance === undefined) {
  100. this.instance = new CascadingAutocomplete();
  101. }
  102. return this.instance;
  103. }
  104. }
  105. Controls.CascadingAutocomplete = CascadingAutocomplete;
  106. })(Controls = Forms.Controls || (Forms.Controls = {}));
  107. })(Forms = Unibase.Forms || (Unibase.Forms = {}));
  108. })(Unibase || (Unibase = {}));