var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var Unibase; (function (Unibase) { let Forms; (function (Forms) { let Controls; (function (Controls) { class Series { init(formpropertyid, prop, callback) { var instance = Series.Instance(); var container = "control-container-" + prop.UniqueId; Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile('platform/series/managers/seriesmanager.js', function () { instance.sereisAutoComplete(container, prop).then(function () { if (callback != null) callback(); }); }); } loadControl(containerid, prop) { var requiredClass = 'required'; let ControlId = 'txt_' + prop.FormPropertyId; var Isrequired = prop.IsRequired != true ? 'hidden' : ''; var required = prop.IsRequired != true ? '' : 'required'; let html = '
' + '' + '
'; html += '
'; if (prop.ControlJsonText != "" && prop.ControlJsonText != null) { var Response = prop; var data = JSON.parse(prop.ControlJsonText); if (data != null && data != "") { html += ''; } } $("#" + containerid).html(html); if (prop.Value == "0") Unibase.Forms.Controls.Series.Instance().EditSeries(prop); if (prop.Value != "0") $('.divisManualSeries_' + prop.FormPropertyId).addClass("hidden"); $("#txtSeriesAutoComplete_" + prop.FormPropertyId).change(function () { var seriesTypeData = $("#txtSeriesAutoComplete_" + prop.FormPropertyId).select2('data')[0]; var isManual = seriesTypeData.AddlData; if (isManual) { $('#divAutoComplete_' + prop.FormPropertyId).addClass("hidden"); $('#divTxtBox_' + data.FormPropertyId).removeClass("hidden"); $("#TextSeries_" + data.FormPropertyId).addClass('required'); var code = $('#hdn_' + data.FormPropertyId).val(); if (code != null && code != undefined && code != "" && code != "0" && prop.Value != "0") { $('#TextSeries_' + data.FormPropertyId).val(code); $('#clearManualSeries').addClass("hidden"); $('#divTxtBox_' + data.FormPropertyId).addClass("floating-label-form-group-with-value"); } } else { $('#divAutoComplete_' + prop.FormPropertyId).removeClass("hidden"); $('#divTxtBox_' + data.FormPropertyId).addClass("hidden"); $('#TextSeries_' + data.FormPropertyId).val(""); $("#TextSeries_" + data.FormPropertyId).removeClass('required'); } }); } TextSeriesChange(FormPropertyId, SeriesId) { if ($('#TextSeries_' + FormPropertyId).val() != "") { $('#TextSeries_' + FormPropertyId).removeClass('required'); var hiddenpropid = $("#control-container-" + FormPropertyId).attr('data-formpropertyid'); if (hiddenpropid == FormPropertyId) { $('#hdn_' + FormPropertyId).val($('#TextSeries_' + FormPropertyId).val()); $('.txtSeriesAutoComplete_' + SeriesId).removeClass('required'); } } } clearManualSeries(containerId, codeFormPropertyId, seriesFormPropertyId) { $(".txtSeriesAutoComplete_" + seriesFormPropertyId + " option:selected").text(''); var html = ''; $('.txt_series_autocomplete').append(html); $(".txt_series_autocomplete").val(""); $('#TextSeries_' + codeFormPropertyId).val(""); $('#divAutoComplete_' + seriesFormPropertyId).removeClass("hidden"); $('#divTxtBox_' + codeFormPropertyId).addClass("hidden"); $('#TextSeries_' + codeFormPropertyId).val(""); $("#TextSeries_" + codeFormPropertyId).removeClass('required'); } EditSeries(prop) { if (prop.Value == "0") { var data = JSON.parse(prop.ControlJsonText); $('#divTxtBox_' + data.FormPropertyId).removeClass("hidden"); $('#divAutoComplete_' + prop.FormPropertyId).addClass("hidden"); var Code = $('#hdn_' + data.FormPropertyId).val(); $('#TextSeries_' + data.FormPropertyId).val(Code); $('#divTxtBox_' + data.FormPropertyId).addClass('floating-label-form-group-with-value'); var html = ''; $('.txt_series_autocomplete').append(html); $(".txt_series_autocomplete").val(0).trigger('change'); $(".TextManualSeries").prop('disabled', true); } } loadControlSettings(controlsettingjson, formpropertyid) { return null; } loadPropertySettings(propertysettings, formpropertyid) { return null; } bindEditFormDetails(formpropertyid, propval, DocPropertyName) { $("#txtSeriesAutoComplete_" + formpropertyid).val(propval).trigger('change'); } LoadSeriesAutoComplete(docPropertyName, DocPropertyId, containerid) { var FormPropertyId = $('#' + containerid).find(".txtSeriesAutoComplete_" + docPropertyName).parents(".divCustomProperties").data("formpropertyid"); var installedappid = $("#" + containerid).parents(".formValidate").find("#hf_FormInstalledAppId").val(); var appkeyid = $("#" + containerid).parents(".formValidate").find("#hf_FormAppKeyId").val(); var TextId = $('#' + containerid).find("#txtSeriesAutoComplete_" + FormPropertyId); var hiddenId = $('#' + containerid).find("#hfSeriesAutoCompleteId_" + FormPropertyId + '_' + docPropertyName); } sereisAutoComplete(containerid, prop) { return __awaiter(this, void 0, void 0, function* () { var installedappid = Unibase.Platform.Forms.Components.FormViewer.instance.InstalledAppId; var Forminstalledappid = Unibase.Platform.Forms.Components.FormViewer.instance.FormInstalledAppId; var issubform = $("#" + containerid).attr('data-issubform'); if (issubform == "true") { var subforminstalledappid = $("#" + containerid).parents(".control-group").attr("data-installedappid"); installedappid = Number(subforminstalledappid); } else if (installedappid == undefined) { var installedappid = Unibase.Platform.Forms.Components.FormViewer.instance.InstalledAppId; } else { var installedappid = Unibase.Platform.Forms.Components.FormViewer.instance.InstalledAppId; } var Id = Forminstalledappid; if (installedappid == Forminstalledappid || Forminstalledappid == 0) { Id = installedappid; } else { Id = Forminstalledappid; } yield Unibase.Platform.Series.Managers.SeriesManager.Instance().getActiveSeries(0, Id).then(function (response) { var controlData = []; var count = response.result.length; for (let i = 0; i < response.result.length; i++) { var controls = response.result[i]; if (count == 1) { controlData.push({ id: controls.SeriesId, text: controls.SeriesName, AddlData: controls.ManualNumbering, selected: true }); } else { controlData.push({ id: controls.SeriesId, text: controls.SeriesName, AddlData: controls.ManualNumbering }); } } $('.txtSeriesAutoComplete_' + prop.FormPropertyId).select2({ placeholder: 'Select Control', data: controlData, theme: "default select2ErrorClass", }); if (prop.Value == null && prop.Value !== "0") { $('.divisManualSeries_' + prop.DocPropertyId).removeClass("hidden"); $('#txtSeriesAutoComplete_' + prop.FormPropertyId).prop('disabled', false); } else { $('.divisManualSeries_' + prop.DocPropertyId).addClass("hidden"); $('#txtSeriesAutoComplete_' + prop.FormPropertyId).prop('disabled', true); } }); }); } static Instance() { if (this.instance === undefined) this.instance = new Series(); return this.instance; } } Controls.Series = Series; })(Controls = Forms.Controls || (Forms.Controls = {})); })(Forms = Unibase.Forms || (Unibase.Forms = {})); })(Unibase || (Unibase = {}));