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.

timepicker.component.js 5.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. var Unibase;
  2. (function (Unibase) {
  3. let Forms;
  4. (function (Forms) {
  5. let Controls;
  6. (function (Controls) {
  7. class TimePicker {
  8. init(formpropertyid, prop, callback) {
  9. var instance = TimePicker.Instance();
  10. instance.loadControlSettings(prop.ControlJsonText, prop.FormPropertyId);
  11. instance.loadPropertySettings(prop.PropertySettings, prop.FormPropertyId);
  12. var formid = $("#time_" + prop.DocPropertyName).parents('.formValidate').attr('id');
  13. var errormsg = $("#" + formid).find('.bizgaze_FormErrorMessages').attr('id');
  14. if (callback != null)
  15. callback();
  16. }
  17. loadControl(containerid, prop) {
  18. var regExpr = "";
  19. var ErrMsg = "";
  20. var validationlist = prop.Validations;
  21. if (validationlist != null) {
  22. for (var i = 0; i < validationlist.length; i++) {
  23. regExpr += validationlist[i].RegularExp + '||';
  24. ErrMsg += validationlist[i].ErrorMessage + '||';
  25. }
  26. }
  27. var Isrequired = prop.IsRequired != true ? 'hidden' : '';
  28. var requiredClass = prop.IsRequired != true ? '' : 'required';
  29. var reqMark = prop.IsRequired != true ? '' : '*';
  30. var CurrentStageId = $("#hf_" + $("#hfLayout_InstalledPageId").val() + "_StageId").val();
  31. if (prop.IncludedStages != null && prop.IncludedStages != "") {
  32. var StagesForRequired = prop.IncludedStages.split('|');
  33. Isrequired = StagesForRequired.find(x => x == CurrentStageId) ? '' : 'hidden';
  34. requiredClass = StagesForRequired.find(x => x == CurrentStageId) ? 'required' : '';
  35. reqMark = StagesForRequired.find(x => x == CurrentStageId) ? '*' : '';
  36. }
  37. if (prop.ExcludedStages != null && prop.ExcludedStages != "") {
  38. var ExcludedStages = prop.ExcludedStages.split('|');
  39. Isrequired = ExcludedStages.find(x => x == CurrentStageId) ? 'hidden' : '';
  40. requiredClass = ExcludedStages.find(x => x == CurrentStageId) ? '' : 'required';
  41. reqMark = ExcludedStages.find(x => x == CurrentStageId) ? '' : '*';
  42. }
  43. let ControlId = 'txt_' + prop.DocPropertyId;
  44. if (prop.IsRequired)
  45. requiredClass = 'required';
  46. const { helpTooltipHtml, helpTextHtml } = Unibase.Platform.Forms.Components.FormViewer.Instance().getControlHelpHtml(prop);
  47. let html = '<div class="floating-label-form-group floating-label-form-group-with-value">' +
  48. '<label for="lbl" id="lbl_' + prop.ControlId + '">' + helpTooltipHtml + '<span class="label-name">' + prop.LabelName + '</span><span class="text-danger ' + Isrequired + '" id="spnIsRequired_' + prop.DocPropertyId + '"> *</span></label>' +
  49. '<div class="input-group">' +
  50. '<input type="time" id = "time_' + prop.DocPropertyName + '" class="type-control form-control value-control ' + requiredClass + '" data - propdoctypename="${prop.DocTypeName}" data-regularexp="' + regExpr + '" data - validatemsg="' + ErrMsg + '" placeholder = "' + prop.Placeholder + '" data-placeholder="' + prop.Placeholder + '" data-label="' + prop.LabelName + reqMark + '" /> ' +
  51. '<input type="hidden" id="hfId" value=""><label for="Validation" id="lblValidation_"' + prop.DocPropertyName + '"></label><input type="hidden" id="hfFormPropertyId" value="" /></div>' + helpTextHtml + '</div>';
  52. $("#" + containerid).append(html);
  53. }
  54. loadControlSettings(controlsettingjson, formpropertyid) {
  55. return null;
  56. }
  57. loadPropertySettings(propertysettings, formpropertyid) {
  58. return null;
  59. }
  60. bindEditFormDetails(formpropertyid, propval, DocPropertyName) {
  61. var time = propval.split(" ");
  62. let timeVal = time[1];
  63. let meridiem = time[2];
  64. if (typeof meridiem != "undefined") {
  65. let [hours, minutes] = timeVal.split(':');
  66. let formattedTime = "";
  67. if (meridiem == 'PM') {
  68. if (hours === '12') {
  69. hours = '00';
  70. }
  71. hours = parseInt(hours, 10) + 12;
  72. formattedTime = `${hours}:${minutes}`;
  73. time[1] = formattedTime;
  74. }
  75. else if (hours.length == 1) {
  76. hours = "0" + hours;
  77. formattedTime = `${hours}:${minutes}`;
  78. time[1] = formattedTime;
  79. }
  80. }
  81. $("#time_" + DocPropertyName).val(time[1]);
  82. }
  83. static Instance() {
  84. if (this.instance === undefined) {
  85. this.instance = new TimePicker();
  86. }
  87. return this.instance;
  88. }
  89. }
  90. Controls.TimePicker = TimePicker;
  91. })(Controls = Forms.Controls || (Forms.Controls = {}));
  92. })(Forms = Unibase.Forms || (Unibase.Forms = {}));
  93. })(Unibase || (Unibase = {}));