123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272 |
- 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 AutoComplete extends Unibase.Platform.Core.BaseComponent {
- constructor() {
- super(...arguments);
- this.FormAutoUniqueId = null;
- this.loadCascading = true;
- this.container = null;
- this.DocPropertyId = 0;
- this.FormPropertyId = 0;
- this.FormPropertyName = "";
- this.FormId = 0;
- this.totalreportdatafilter = [];
- this.totalreportid = 0;
- this.mappingtextcolumn = null;
- this.mappingidcolumn = null;
- }
- init(formpropertyid, prop, callback) {
- var instance = AutoComplete.Instance();
- var container = $("#txtAutoComplete_" + prop.UniqueId);
- instance.LoadAutoComplete(container, null).then(function () {
- if (callback != null)
- callback();
- });
- var autoSettingData = JSON.parse(prop.ControlJsonText);
- if (autoSettingData.AppConfigId != 0) {
- $(container).change(function () {
- if ($("#txtAutoComplete_" + prop.UniqueId + " option:selected").text() == "Create New") {
- var autoContainer = "autocomplete_" + prop.FormPropertyId;
- Unibase.Platform.Forms.Managers.FormManager.Instance().getFormByAppConfiguration(autoSettingData.AppConfigId).then(function (response) {
- var formid = response.result.FormId;
- $("#txtAutoComplete_" + prop.UniqueId).text('');
- $("#hfAutoCompleteId_" + prop.UniqueId).val('');
- Unibase.Forms.Controls.AutoComplete.localInstance(autoContainer).FormPropertyName = prop.FormPropertyName;
- Unibase.Forms.Controls.AutoComplete.localInstance(autoContainer).container = "#txtAutoComplete_" + prop.UniqueId;
- Unibase.Forms.Controls.AutoComplete.localInstance(autoContainer).DocPropertyId = prop.DocPropertyId;
- Unibase.Forms.Controls.AutoComplete.localInstance(autoContainer).FormPropertyId = prop.FormPropertyId;
- Unibase.Forms.Controls.AutoComplete.localInstance(autoContainer).FormId = formid;
- Unibase.Forms.Controls.AutoComplete.localInstance(autoContainer).FormAutoUniqueId = "autocomplete_" + prop.UniqueId + "_" + response.result.FormId;
- var successCallBack = {
- CallBack: function (id) {
- let AppConfigType = Unibase.Platform.Forms.Components.FormViewer.instance.AppConfigType;
- Unibase.Platform.Forms.Components.FormViewer.instance.AppConfigType = 0;
- Unibase.Platform.Forms.Managers.FormManager.Instance().getAutocompleteSelectedData(Unibase.Forms.Controls.AutoComplete.localInstance(autoContainer).DocPropertyId, id, Unibase.Forms.Controls.AutoComplete.localInstance(autoContainer).FormPropertyId, 0).then(function (response) {
- var selectedOptions = new Option(response.result[0].DisplayText, response.result[0].Value, true);
- $(Unibase.Forms.Controls.AutoComplete.localInstance(autoContainer).container).append(selectedOptions).trigger('change');
- Unibase.Platform.Forms.Components.FormViewer.instance.AppConfigType = AppConfigType;
- });
- },
- Parameters: null,
- };
- var formviewerObj = {
- FormId: formid,
- AppConfigurationId: autoSettingData.AppConfigId,
- Pk_Value: 0,
- PortletWidgetId: 0,
- OnSuccess: successCallBack,
- OnFail: null,
- OnLoad: null,
- FormContainer: null,
- };
- Unibase.Platform.Forms.Components.FormViewer.instance.init(formviewerObj);
- });
- }
- else {
- var IdFormPropertyid = $("#hfAutoCompleteId_" + prop.UniqueId).data("textformpropertyid");
- $("#hdn_" + IdFormPropertyid).val($("#txtAutoComplete_" + prop.UniqueId + " option:selected").text());
- }
- });
- }
- }
- loadControl(containerid, prop) {
- var instance = this;
- var jsfiles = ["platform/controls/cascadingautocomplete/cascadingautocomplete.component.js", "platform/controls/cascadingautocomplete/cascadingautocomplete.settings.js"];
- var Isrequired = prop.IsRequired != true ? 'hidden' : '';
- var required = prop.IsRequired != true ? '' : 'required';
- var CurrentStageId = $("#hf_" + $("#hfLayout_InstalledPageId").val() + "_StageId").val();
- if (prop.StagesForRequired != null && prop.StagesForRequired != "") {
- var StagesForRequired = prop.StagesForRequired.split('|');
- Isrequired = StagesForRequired.find(x => x == CurrentStageId) ? '' : 'hidden';
- required = StagesForRequired.find(x => x == CurrentStageId) ? 'required' : '';
- }
- var IsTagSelect = false;
- var text;
- if (prop.ControlJsonText != "" && prop.ControlJsonText != null && prop.ControlJsonText != undefined) {
- var text = JSON.parse(prop.ControlJsonText);
- if (text["IsTagSelect"] == true) {
- IsTagSelect = true;
- }
- }
- var divclass = text.ShowTotalReportData == true ? 'col-sm-11 col-11' : 'col-sm-12';
- const { helpTooltipHtml, helpTextHtml } = Unibase.Platform.Forms.Components.FormViewer.Instance().getControlHelpHtml(prop);
- var html = `<div id="div_${prop.DocPropertyName}" style=""><label for="lbl" id="lbl_${prop.DocPropertyName}">${helpTooltipHtml}<span class="label-name">${prop.LabelName}</span><span class="text-danger hide ${Isrequired}" id="spnIsRequired_${prop.FormPropertyId}"> *</span></label><div class="input-group ">` +
- '<div class="' + divclass + '" style="margin:0px;padding:0px;"><select id="txtAutoComplete_' + prop.UniqueId + '" class="txtAutoComplete_' + prop.DocPropertyName + ' form-control type-control text-control select_address ' + required + ' " data-isdefault="' + prop.IsDefault + '" style="width:100%;" placeholder = "' + prop.Placeholder + '" data-placeholder="' + prop.Placeholder + '" data-label="' + prop.LabelName + '" data-istagselect="' + IsTagSelect + '" data-propertyid="' + prop.DocPropertyId + '" data-propertyname="' + prop.DocPropertyName + '" data-formpropertyid="' + prop.FormPropertyId + '" data-formid="' + text.FormId + '" value="0" data-textformpropertyid="' + text.TextFormPropertyId + '" data-showtotalreportdata="' + text.ShowTotalReportData + '" ></select>' +
- '<input type="hidden" id="hfAutoCompleteId_' + prop.UniqueId + '" value="0" class="hfAutoCompleteId_' + prop.DocPropertyName + ' form-control value-control" data-autotextid="txtAutoComplete_' + prop.UniqueId + '" data-required="' + prop.IsRequired + '" data- data-regularexp="" data-validatemsg="" />' + helpTextHtml + '</div>';
- if (text.ShowTotalReportData == true) {
- html += '<div class=" col-sm-1 col-1 input-group-append" style=";margin:0px;padding:0px;">' +
- '<a class="CheckOutButton align-items-center btn btn-primary btn-xs d-flex h-100 justify-content-center" href="javascript:;" id="hf_totalreportdata_' + prop.UniqueId + '" onclick="javascript:return Unibase.Forms.Controls.AutoComplete.Instance().loadTotalReportData(' + text.TotalDataReportId + ',' + "'" + text.MappingTextColumn + "'" + ',' + "'" + text.MappingIdColumn + "','" + "txtAutoComplete_" + prop.UniqueId + "'" + ',' + prop.FormPropertyId + ')" > <i class="la la-retweet font-18 line-height-12"></i></a></div>';
- }
- html += '</div><input type="hidden" id="hfId_' + prop.DocPropertyName + '" value=""><label for="Validation" id="lblValidation_' + prop.DocPropertyName + '"></label></div>';
- $("#" + containerid).html(html);
- $("#" + containerid).find("#txtAutoComplete_" + prop.UniqueId).on('change', function () {
- instance.fileCacheHelper.loadJsFiles(jsfiles, function () {
- var controlJson = prop.ControlJsonText;
- if (instance.loadCascading) {
- Unibase.Forms.Controls.CascadingAutocomplete.Instance().ChildCascadingData(false, prop.FormPropertyId, Number($("#txtAutoComplete_" + prop.UniqueId).val()), 0, '');
- }
- instance.loadCascading = true;
- });
- });
- }
- loadTotalReportData(ReportId, TextColumn, IdColumn, Element, FormPropertyId) {
- Unibase.Platform.Analytics.Viewers.TableViewer.Instance().IsSelectable = true;
- Unibase.Platform.Analytics.Viewers.TableViewer.Instance().TextColumn = TextColumn;
- Unibase.Platform.Analytics.Viewers.TableViewer.Instance().IdColumn = IdColumn;
- Unibase.Platform.Analytics.Viewers.TableViewer.Instance().AutoCompleteElement = Element;
- var localinstance = Unibase.Platform.Analytics.Components.ReportViewer.Instance();
- let reportViewerInstance = Unibase.Platform.Helpers.NavigationHelper.reportViewerInstance;
- var isInstance = false;
- const containerid = "reportviewer_" + ReportId;
- if (reportViewerInstance.length > 0)
- isInstance = reportViewerInstance.find(rv => rv.childcontainerid == "reportviewer_" + ReportId) ? true : false;
- if (!isInstance) {
- reportViewerInstance.push({
- instance: localinstance,
- childcontainerid: containerid,
- parentcontainerid: null
- });
- }
- else {
- var tempinstance = reportViewerInstance.find(rv => rv.childcontainerid == "reportviewer_" + ReportId);
- localinstance = tempinstance.instance;
- }
- var autoContainer = "autocomplete_" + FormPropertyId;
- localinstance.dynamicFilters = Unibase.Forms.Controls.AutoComplete.localInstance(autoContainer).totalreportdatafilter;
- if (ReportId != undefined)
- Unibase.Platform.Helpers.NavigationHelper.Instance().popup(ReportId, containerid, localinstance, function () {
- $(`#ViewerFooter_${containerid}`).removeClass('d-none').find(`#div_pagination_${containerid}`).addClass('d-none');
- $(`#ReportClose_${containerid}`).removeClass('hidden pull-right');
- $(`#reportCloseBtn_${containerid}`).removeClass('d-none');
- }, Unibase.Platform.Helpers.Size.DockLeft);
- }
- reportOnClick(TextColumn, IdColumn, element) {
- var selectedOptions = new Option(TextColumn, IdColumn, true);
- $("#" + element).append(selectedOptions);
- jQuery("#" + element).val(IdColumn).trigger('change');
- Unibase.Platform.Helpers.NavigationHelper.Instance().closePopUp();
- Unibase.Platform.Analytics.Viewers.TableViewer.Instance().IsSelectable = false;
- }
- loadControlSettings() {
- return ``;
- }
- LoadAutoComplete(Container, Parameters) {
- return __awaiter(this, void 0, void 0, function* () {
- var DocPropertyId = Container.data('propertyid');
- var DocPropertyName = Container.data('propertyname');
- var FormPropertyId = Container.data('formpropertyid');
- var FormId = Container.data('formid');
- var ColumnName = "0";
- var Value = "0";
- var reportfilter = [];
- if (Parameters != null && Parameters != "") {
- ColumnName = Parameters.map(function (item) { return item.ColumnName; }).toString();
- Value = Parameters.map(function (item) { return item.Value + "|"; }).toString();
- }
- var uniqueid = $(Container).attr('id').split('_')[1];
- var textCol = Container;
- var idCol = $("#hfAutoCompleteId_" + uniqueid);
- var istagselect = false;
- if ($("#txtAutoComplete_" + uniqueid).data("istagselect") == true) {
- istagselect = true;
- }
- var showtotalreportdata = $(Container).data("showtotalreportdata");
- if (showtotalreportdata) {
- if (Parameters != null && Parameters != "") {
- Parameters.map(function (item) {
- var reportfilterobj = { ParameterName: item.ColumnName, ParameterValue: item.Value.toString(), ExpOp: Unibase.Platform.Core.Enums.ExpressionOperator.Equals };
- reportfilter.push(reportfilterobj);
- });
- }
- var autoContainer = "autocomplete_" + FormPropertyId;
- Unibase.Forms.Controls.AutoComplete.localInstance(autoContainer).totalreportdatafilter = reportfilter;
- }
- var bindedData = undefined;
- var url = _appsettings.server_url() + '/apis/v4/unibase/platform/forms/autocomplete/docpropertyid/' + DocPropertyId + '/columnname/' + ColumnName + '/value/' + Value + '/formpropertyid/' + FormPropertyId + '/formid/' + FormId + '/bindeddata/' + bindedData;
- AutoCompleteHelper.getHelper().Create(textCol, idCol, url, function (response) {
- var data = response;
- }, istagselect);
- $(textCol).on('select2:open', function () {
- var id = $(textCol).attr("id");
- let searchField = $('#select2-' + id + '-results').parents('.select2-container').find('.select2-search__field');
- if (istagselect == true && searchField.val() == "") {
- searchField.val($("#" + id + " option:selected").text());
- }
- });
- $(textCol).on('select2:select', function () {
- if (istagselect == true) {
- var id = $(textCol).attr("id");
- var isFreeText = $("#" + id + " option:selected").attr('data-select2-tag');
- if (isFreeText == "true") {
- $(textCol).attr('data-addldata', "");
- }
- }
- });
- var autocompleteid1 = $(".txtAutoComplete_" + DocPropertyName).attr('id');
- });
- }
- loadPropertySettings(propertysettings, formpropertyid) {
- return ``;
- }
- bindEditFormDetails(formpropertyid, propval, DocPropertyName) {
- if (propval != "null") {
- var instance = this;
- var autojson = JSON.parse(propval);
- var IdValue = autojson.AutoCompleteIdColumn;
- var TextValue = autojson.AutoCompleteTextColumn;
- var selectedOptions = new Option(TextValue, IdValue, true);
- if (IdValue != "0") {
- $("#txtAutoComplete_" + formpropertyid).append(selectedOptions);
- instance.loadCascading = false;
- jQuery("#txtAutoComplete_" + formpropertyid).val(IdValue).trigger("change");
- }
- }
- }
- GetOrAddCurrentAutoCompleteInstance(ContainerId) {
- if (ContainerId != undefined && ContainerId != null && ContainerId != "") {
- let isInstance = false;
- let formControlInstance = Unibase.Platform.Forms.Components.FormViewer.formControlInstances;
- if (formControlInstance.length > 0)
- isInstance = formControlInstance.find(fv => fv.containerid == ContainerId) ? true : false;
- var viewerInstance = new Unibase.Forms.Controls.AutoComplete();
- var currentinstance = {
- instance: viewerInstance,
- containerid: ContainerId,
- };
- if (isInstance == true) {
- viewerInstance = formControlInstance.find(fv => fv.containerid == ContainerId).instance;
- }
- if (!isInstance)
- formControlInstance.push(currentinstance);
- return viewerInstance;
- }
- }
- static localInstance(ContainerId) {
- var formobj = new Unibase.Forms.Controls.AutoComplete();
- this.instance = formobj.GetOrAddCurrentAutoCompleteInstance(ContainerId);
- return this.instance;
- }
- static Instance() {
- if (this.instance === undefined) {
- this.instance = new AutoComplete();
- }
- return this.instance;
- }
- }
- Controls.AutoComplete = AutoComplete;
- })(Controls = Forms.Controls || (Forms.Controls = {}));
- })(Forms = Unibase.Forms || (Unibase.Forms = {}));
- })(Unibase || (Unibase = {}));
|