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 Themes; (function (Themes) { let Compact; (function (Compact) { let Components; (function (Components) { class Details extends Unibase.Platform.Core.BaseComponent { constructor() { super(); this.model = []; this.jsindex = 0; this.htmlindex = 0; this.evalExecuted = 0; this._recordId = 0; this._installedAppId = 0; this.changestagedata = ""; this.unibase_core_activeportletid = 0; this.unibase_ActiveInstalledAppId = 0; this.layoutIndex = Unibase.Themes.Compact.Components.Index.Instance().layoutIndex; this.detailsViewIndex = Unibase.Themes.Compact.Components.Index.Instance().detailsViewIndex; this.IsCustomDetailHeader = false; this.desktopMode = Unibase.Themes.Compact.Components.Index.Instance().desktopMode; this.mobileLMode = Unibase.Themes.Compact.Components.Index.Instance().mobileLMode; this.isSystemLock = false; this.isPortletModified = false; this.isDetailsUpdated = false; this.isPortletEdit = false; this.isDashboardWidgetDetail = false; var instance = this; var jsfiles = ["platform/portlets/managers/portletmanager.js", "platform/widgets/managers/widgetmanager.js", "/platform/apps/managers/stagemanager.js", "platform/apps/managers/appmanager.js"]; } jsFiles() { return ["platform/bundle/index.details.min.js"]; } cssFiles() { return []; } init() { } html(id, containerid) { var instance = this; this._containerId = containerid; var margin_padding = 20, hidden = 'd-flex'; if (instance.IsCustomDetailHeader == true) { hidden = "d-none"; } var html = ``; return html; } load(id, containerid, callback) { var instance = this; Unibase.Platform.Helpers.FileCacheHelper.Instance().addCacheFiles(["platform/apps/managers/stagemanager.js", "platform/datasources/managers/doctypemanager.js", "tenants/themes/compact/components/notifications/TaskParams.js", "platform/communications/managers/tasks/taskmanager.js", "platform/apps/components/stages/stagereason.js", "platform/apps/managers/interfaces/iappmanager.js", "platform/forms/managers/interfaces/iformmanager.js", "platform/permission/managers/interfaces/ipermissionmanager.js", "platform/dashboards/components/managedashboards.js", "platform/dashboards/components/import.js"]); Unibase.Themes.Providers.DetailHelper.isListStages = false; Unibase.Themes.Providers.Detail_Settings.Instance().isListStages = false; instance.lastContinerId = ""; instance.lastReportInstance = null; instance.isDetailsUpdated = false; Compact.CollapsedTabs.Instance().autoCollapse($("#" + containerid).find("#layout-detail-tabs")); instance.portletmanager = Unibase.Platform.Portlets.Managers.PortletManager.Instance(); instance.widgetmanager = Unibase.Platform.Widgets.Managers.WidgetManager.Instance(); instance.stagemanager = Unibase.Platform.Apps.Managers.StageManager.Instance(); instance.appmanager = Unibase.Platform.Apps.Managers.AppManager.Instance(); instance.doctypemanager = Unibase.Platform.DataSources.Managers.DocTypeManager.Instance(); $("#" + containerid).find(".detail-close").click(function () { if (!Unibase.Themes.Compact.Components.Index.Instance().isIframeObj.isListDetailPage) { window.parent.postMessage('List-Details-page', '*'); } else { window.parent.postMessage('clickToBack', '*'); } $('.txt_global_search').show(); $('.search_icon').removeClass("hidden"); $(this).removeClass("hidden"); Unibase.Themes.Providers.DetailHelper.installedAppId = 0; Unibase.Themes.Providers.DetailHelper.recordId = 0; Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters = []; Unibase.Themes.Providers.Detail_Settings.Instance().RecordId = 0; var ModalContainers = Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds; let rv_instance = Unibase.Platform.Helpers.NavigationHelper.reportViewerInstance; for (var i = 0; i < rv_instance.length; i++) { if (rv_instance[i].parentcontainerid == ModalContainers[$.inArray(containerid, ModalContainers)]) { rv_instance.splice(i, 1); i--; } } ModalContainers.splice($.inArray(containerid, ModalContainers), 1); var ContainerId = ModalContainers[ModalContainers.length - 1]; instance.lastContinerId = ContainerId; var DetailContainer = $("#" + ContainerId).find("#div_detail_profile"); var FormContainer = $("#" + ContainerId).attr("class") == undefined ? "" : $("#" + ContainerId).attr("class"); var IsListRefresh = Unibase.Platform.Helpers.NavigationHelper.IsListRefresh; IsListRefresh = instance.evaluateDefaultWidgetCallback("#" + containerid, true, IsListRefresh); if (DetailContainer.length != 0) { var installedappid = Unibase.Themes.Providers.Detail_Settings.Instance().DetailParameters["#" + ContainerId].InstalledAppId; Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters = Unibase.Themes.Providers.Detail_Settings.Instance().DetailParameters["#" + ContainerId].InputParameters; instance._installedAppId = installedappid; Unibase.Themes.Providers.DetailHelper.installedAppId = installedappid; instance.unibase_ActiveInstalledAppId = installedappid; var recordid = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + installedappid + "_recordid").Value); instance._recordId = recordid; Unibase.Themes.Providers.DetailHelper.recordId = recordid; instance._containerId = ContainerId; var portletid = Number(Unibase.Themes.Providers.Detail_Settings.Instance().DetailParameters["#" + ContainerId].ActivePortletId); if (isNaN(portletid)) { portletid = 0; } instance.unibase_core_activeportletid = portletid; if (IsListRefresh) { var detailInstance = Unibase.Themes.Compact.Components.Details.Instance(); var panel = "#" + ContainerId; var obj = Themes.Compact.Components.Details.Instance(); obj._recordId = recordid; obj._installedAppId = installedappid; Unibase.Themes.Providers.DetailHelper.recordId = recordid; detailInstance.loadAppDefaultWidget(obj, panel, ContainerId, function () { Unibase.Themes.Compact.Components.Details.Instance().loadWidgets(installedappid, portletid, panel); }); } else { $("#" + ContainerId).find(".tabid-" + portletid).find(".nav-link").addClass("active"); } } else if (FormContainer.includes("_bizgaze_popup_container")) { $("#" + ContainerId).modal("show"); } else { Unibase.Platform.Helpers.NavigationHelper.IsListRefresh = false; var installedappid = Unibase.Themes.Providers.Detail_Settings.Instance().DetailParameters["#" + containerid].InstalledAppId; $("#" + ContainerId).find('.txt_global_search').show(); if (IsListRefresh) { Unibase.Themes.Compact.Components.List.Instance().isListRefresh = IsListRefresh; if (!instance.isDashboardWidgetDetail) { instance.navigationHelper.loadList(installedappid, null); } else { const portletid = +$("#hf_DashboardPortletId").val(); Unibase.Themes.Compact.Components.Nav.Instance().loadDashboard(portletid, ''); } } } instance.isDashboardWidgetDetail = false; var containerClass = $("#" + containerid).attr("class") == undefined ? "" : $("#" + containerid).attr("class"); if (containerClass.includes("_bizgaze_popup_container")) { $("#" + containerid).modal("hide"); $('#' + containerid).remove(); } else { Unibase.Platform.Helpers.NavigationHelper.Instance().close(containerid, null); } }); $('.db-setting-dp-item').addClass('d-none'); if (isMobileApp()) { eval(`jquerySwipeHandler.handleSwipe(".detail-container-content-outer", [jquerySwipeHandler.SWIPE_LEFT, jquerySwipeHandler.SWIPE_RIGHT], function (direction) { console.log("swipe Diredction: ", direction); if(direction == 'SWIPE_LEFT' || direction == 'SWIPE_RIGHT'){ Unibase.Themes.Compact.Components.Details.Instance().swipe(direction); } });`); } } resize1(containerid) { var panel = containerid; if (panel === "" || panel === undefined) panel = '_modal_bizgaze_edit_' + moment().unix(); var deductHeight = 202; if ($(document).outerWidth() < 1200) { deductHeight = 266; $("#" + panel).find(".modal-body").addClass("px-0").removeClass("pa-15"); } if (this.desktopMode && this.detailsViewIndex != 2 && (this.layoutIndex == 2 || this.layoutIndex == 3)) { deductHeight = 256; } $("#" + panel).find(".modal-body").height($(window).outerHeight() - deductHeight); } loadPortlets(obj) { var instance = this; let skelhtml = '
'; skelhtml += Unibase.Themes.Compact.Components.Nav_Template.Instance().skelTonDetailsHDRPage(); skelhtml += Unibase.Themes.Compact.Components.Nav_Template.Instance().skelTonDetailsbBDYPage(); skelhtml += '
'; $('#' + obj._containerId).find('#div_detail_profile').addClass('invisible').before(skelhtml); if (this.unibase_ActiveInstalledAppId != obj._installedAppId) { this.unibase_core_activeportletid = 0; this.unibase_ActiveInstalledAppId = obj._installedAppId; } var panel; if (Unibase.Platform.Helpers.NavigationHelper.Instance().getLastContainerId().includes('_viewall')) { panel = Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds[Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds.length - 2]; } else { panel = "#" + instance._containerId; } var image_src = $("#hf_AppImage").val(); if (image_src == '') { image_src = 'tenants/themes/compact/images/avatar_default.jpg'; } $(panel).find("#bizgaze_AppImage").attr("src", 'image_src'); var id1 = $("#hf_AppTitle").val(); $(panel).find("#bizgaze_AppTitle").text('id1'); var hiddenhtml = ""; $(panel).find("#div_detail_notifications").attr("id", "div_detail_notifications_" + obj._recordId); instance.loadAppDefaultWidget(obj, panel, instance._containerId, function () { return __awaiter(this, void 0, void 0, function* () { if (instance.IsCustomDetailHeader != true) { instance.getPortlets(obj._installedAppId, panel); } yield instance.loadDefaultWidgets(obj._installedAppId, panel); yield instance.LoadApprovals(obj._recordId, obj._installedAppId); }); }); $(panel).find(".tab-addeditem").remove(); } getPortlets(installedappid, panel) { var instance = this; var currentstageid = 0; var userinfo = Unibase.Platform.Membership.Infos.Identity.getCurrentUser(); if (installedappid != null && installedappid != 0 && installedappid != undefined) { if (!userinfo.isAdmin && Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters. find(x => x.Key == "hf_" + installedappid + "_stageid") != undefined) { currentstageid = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters. find(x => x.Key == "hf_" + installedappid + "_stageid").Value); } instance.portletmanager.getPortletsByInstalledApp(installedappid, currentstageid).then(function (response) { var data = response.result; var html = ""; var firstportletid = 0; var activePortletIndex = Unibase.Themes.Providers.Detail_Settings.Instance().ActivePortlets.findIndex(x => x.InstalledAppId == installedappid); if (activePortletIndex != -1) { firstportletid = Unibase.Themes.Providers.Detail_Settings.Instance().ActivePortlets[activePortletIndex].ActivePortletId; } if (data.length > 0) { for (var i = 0; i < data.length; i++) { var portletName = data[i].PortletName; var portletId = data[i].PortletId; if (firstportletid == 0) { firstportletid = portletId; } Details.Instance().unibase_core_activeportletid = firstportletid; html += ''; } $(panel).find("#layout-detail-tabs").find('.detail-tab:first').prevAll().remove(); $(panel).find("#layout-detail-tabs").find('.detail-tab:first').before(html); $(panel).find(".tab-addeditem").removeClass("active"); $(panel).find(".tabid-" + firstportletid).find(".nav-link").addClass("active"); $("#managePortletBtn .portlet-title-span").text($(`#portletName_${firstportletid}`).text()); if (Unibase.Themes.Providers.Detail_Settings.Instance().DetailParameters["" + panel] == undefined) { Unibase.Themes.Providers.Detail_Settings.Instance().DetailParameters["" + panel] = []; } Unibase.Themes.Providers.Detail_Settings.Instance().DetailParameters[panel]["ActivePortletId"] = firstportletid; Unibase.Themes.Providers.Detail_Settings.Instance().DetailParameters.length++; if ($(window).width() > 768) { Unibase.Themes.Compact.CollapsedTabs.Instance().autoCollapse($(panel).find("#layout-detail-tabs")); } else { let activePortletEl = $(panel).find(`.tabid-${firstportletid} .nav-link.active`); activePortletEl.parents('#layout-detail-tabs').scrollLeft(activePortletEl.parent().position().left - 30); } $(panel).find(".tabid-" + firstportletid).find(".collapsedPortlet").addClass("nav-link active"); } else { $(panel).find('#divAddWidgetAndPortletMenu').css('display', 'none'); $(panel).find('#divMsgAddWidgetAndPortletMenu').css('display', 'block'); } }, null); } } loadAppDefaultWidget(obj, panel, containerId, callback) { var instance = this; var configurations = []; var detailsettingjs = []; var settingurl = []; instance.fileCacheHelper.loadJsFile("platform/core/helpers/token/tokenhelper.js", null); let lastContainerId = instance.navigationHelper.getLastContainerId(); $('.div_detailconfigurations_headerbtns').last().html(''); var userinfo = Unibase.Platform.Membership.Infos.Identity.getCurrentUser(); var fromDate = ""; var toDate = ""; var cf_fromDate = Unibase.Platform.Helpers.NavigationHelper.commonFilter_FromDate; var cf_toDate = Unibase.Platform.Helpers.NavigationHelper.commonFilter_ToDate; if (cf_fromDate != null && cf_toDate != null) { fromDate = cf_fromDate.toString(); toDate = cf_toDate.toString(); } else { fromDate = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDateformat(new Date(Unibase.Platform.Helpers.DateTimeHelper.Instance().currentDate()), "YYYY/MM/DD"); toDate = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDateformat(new Date(Unibase.Platform.Helpers.DateTimeHelper.Instance().currentDate()), "YYYY/MM/DD"); } var expObj = { InstalledAppId: obj._installedAppId, RecordId: obj._recordId, FromDate: fromDate, ToDate: toDate }; Unibase.Platform.Widgets.Managers.WidgetManager.Instance().getDefaultWidget(expObj).then(function (response) { if (response.status != Unibase.Data.Status.Error) { if (response.result != null) { var data = response.result.Data; instance.isSystemLock = response.result._IsSystemLock; var templatetext = response.result.TemplateText; var stages = response.result.Stages; var installedappinfo = response.result.InstalledApp; var statusinfo = response.result.Status; var permission = response.result.EditScreenPermission; if (data != null && data != "") { var model = ""; if (data != null) { model = JSON.parse(data); } var info = Object.keys(model[0]).map(function (key) { return [key, model[0][key]]; }); Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters = []; for (var i = 0; i < info.length; i++) { Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.push({ Key: "hf_" + obj._installedAppId + "_" + info[i][0].toLowerCase(), Value: info[i][1], DataType: typeof (info[i][1]) }); } Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.push({ Key: "hf_" + obj._installedAppId + "_" + "recordid", Value: obj._recordId.toString(), DataType: typeof (obj._recordId) }); if (Unibase.Themes.Providers.Detail_Settings.Instance().DetailParameters["" + panel] == undefined) { Unibase.Themes.Providers.Detail_Settings.Instance().DetailParameters["" + panel] = []; Unibase.Themes.Providers.Detail_Settings.Instance().DetailParameters.length++; } Unibase.Themes.Providers.Detail_Settings.Instance().DetailParameters[panel]["InputParameters"] = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters; Unibase.Themes.Providers.Detail_Settings.Instance().DetailParameters[panel]["InstalledAppId"] = obj._installedAppId; if (templatetext != null) { var html = Unibase.Core.Helpers.TokenHelper.Instance().replace(response.result.TemplateText, model[0]); var icon = ''; if (response.result.AppConfigurations.length > 0) { var confightml = ""; var appconfigurations = response.result.AppConfigurations; for (var i = 0; i < appconfigurations.length; i++) { if (appconfigurations[i].AppConfigType == Unibase.Platform.Apps.Enums.AppConfigeType.DetailSetting) { var onclickurl = ""; var settingname = appconfigurations[i].SettingName; var description = appconfigurations[i].Description; var sname = settingname.replace(/ /g, ''); if (description != null && description != "" && description != undefined) { description = appconfigurations[i].Description; } else { description = appconfigurations[i].SettingName; } if (appconfigurations[i].JsFunction != null && appconfigurations[i].JsFunction != "") { detailsettingjs.push(appconfigurations[i].JsFunction); } ; if (appconfigurations[i].SettingUrl != null && appconfigurations[i].SettingUrl != "") { settingurl.push(appconfigurations[i].SettingUrl); } icon = appconfigurations[i].Icon; if (appconfigurations[i].SettingUrlType == Unibase.Platform.Apps.Enums.SettingUrlType.Form && appconfigurations[i].AppConfigType == Unibase.Platform.Apps.Enums.AppConfigeType.DetailSetting) { onclickurl = "onclick='Unibase.Platform.Helpers.NavigationHelper.Instance().loadDetailSettingForm(" + appconfigurations[i].FormId + ", " + obj._recordId + ", " + appconfigurations[i].AppConfigurationId + ")'"; } if (appconfigurations[i].SettingUrlType == Unibase.Platform.Apps.Enums.SettingUrlType.JsFunction) { onclickurl = ""; } if (appconfigurations[i].Icon != null && appconfigurations[i].Icon != "null" && appconfigurations[i].Icon != "") { confightml += '
  • ' + ' ' + settingname + '
  • '; } else { confightml += '
  • ' + settingname + '
  • '; } } else { if (!Unibase.Platform.Membership.Infos.Identity.getCurrentUser().isAdmin) { appconfigurations[i].IsOwner = response.result.IsOwner; appconfigurations[i].IsManager = response.result.IsManager; } configurations.push(appconfigurations[i]); } } } $(`#${lastContainerId}`).find('.div_detailconfigurations_headerbtns').html('').append(confightml); if ($(`#${lastContainerId}`).find('.div_detailconfigurations_headerbtns li').length > 0 || $(`#${lastContainerId}`).find('#div_detail_notification_list .task').length > 0) { $(`#detailActionsWidget_${lastContainerId}`).removeClass('d-none'); } else { $(`#detailActionsWidget_${lastContainerId}`).addClass('d-none'); } $('.detail-close').removeClass('d-none'); if (obj._detailsHeader != true) { $(panel).find("#div_App_DefaultWidget").html(html); } else { $(panel).find(".app_defaultwidget").addClass("hidden"); $(panel).find("#div_App_DefaultWidget").html(html); instance.evaluateDefaultWidgetCallback(panel, false, false); } instance.loadHeaderAvatar(panel); instance.toggleAppDefaultWidget(panel); } } } if (settingurl.length > 0 && detailsettingjs.length > 0) { instance.fileCacheHelper.loadJsFiles(settingurl, function (resp) { for (var i = 0; i < detailsettingjs.length; i++) { eval(detailsettingjs[i]); } }); } if (callback != null) callback(); if (configurations.length > 0) { instance.loadAppConfigurations(configurations, containerId); } else { let checkEditsScreen = $("#DetailsProperties_" + containerId).find(".editscreen_view").length; if (checkEditsScreen == 0) { $("#DetailsProperties_" + containerId).append('Edit Screen'); } if (!userinfo.isAdmin) { $("#DetailsProperties_" + containerId).find("#editscreen").addClass('hidden'); $(".div_configurationsetting").addClass('hidden'); } } let isStageOrStatusPresent = false; if (stages != null && stages.length > 0) { $(".div_details_stages").removeClass('hidden'); instance.loadStages(stages, obj._installedAppId, panel); isStageOrStatusPresent = true; instance.toggleStagesOnMobileScroll(panel); } if (statusinfo != null || statusinfo != undefined) { statusinfo = Object.keys(statusinfo).map(function (key) { return [key, statusinfo[key]]; }); if (statusinfo.length > 0) { instance.loadRowStatusList(panel, statusinfo); isStageOrStatusPresent = true; instance.toggleStagesOnMobileScroll(panel); } if (($(".btnChangeStage").contents().length) == 0) { $(".div_details_stages").removeClass('d-none d-sm-block'); $(".div_details_stages").addClass('hidden'); $(".btnstagemobileview").addClass('hidden').removeClass("d-flex"); } } if (!installedappinfo.IsDynamic) { $(".div_details_stages").removeClass('d-none d-sm-block'); } if (instance.isSystemLock) { $(".div_details_lock").removeClass("d-none"); } } else { let VisibleContainerId = instance.navigationHelper.getLastContainerId(); $('#' + VisibleContainerId).find('#div_message').addClass('w-95 ml-35 mt-2'); $('#' + VisibleContainerId).find('#detail-close').removeClass('d-none'); $('#' + VisibleContainerId).find('.block-on-mobile').removeClass('d-flex').addClass('d-none'); instance.navigationHelper.hideLoading(); MessageHelper.Instance().showError(response.message, 'div_message', VisibleContainerId); $('#' + VisibleContainerId).find('#detail-close').off('click').on('click', function () { if ($(`#${VisibleContainerId}`).hasClass('_bizgaze_popup_container')) { instance.navigationHelper.closePopUp(); } else { Unibase.Platform.Helpers.NavigationHelper.Instance().close(VisibleContainerId, null); } }); } }); } div_App_DefaultWidgetSettings_toggle(e) { if ($(e.currentTarget).find('#div_App_DefaultWidgetSettings_angledown').hasClass('div_App_DefaultWidgetSettings_toggle_down')) { $(e.currentTarget).find('#div_App_DefaultWidgetSettings_angledown').removeClass('div_App_DefaultWidgetSettings_toggle_down').addClass('div_App_DefaultWidgetSettings_toggle_right'); } else { $(e.currentTarget).find('#div_App_DefaultWidgetSettings_angledown').removeClass('div_App_DefaultWidgetSettings_toggle_right').addClass('div_App_DefaultWidgetSettings_toggle_down'); } $(e.currentTarget).parents('.detail-container-content').find('.ApprovalTasks').toggleClass('hidden'); $('.ActionsApprovalError').toggleClass('hidden'); } updateToOldStageIdInMobileMode(installedappid, inputParam) { const instance = this; if (!instance.mobileLMode) { const oldId = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == `hf_${installedappid}_${inputParam}`).Value); const containerId = instance.navigationHelper.getLastContainerId(); $(`#${containerId}`).find('.stage-change-select').val(oldId); } } loadAppConfigurations(Configurations, containerid) { var instance = this; var filecachehelper = this.fileCacheHelper; var html = ""; var updatehtml = ""; var recordid = Unibase.Themes.Providers.DetailHelper.recordId; var installedappid = Unibase.Themes.Providers.DetailHelper.installedAppId; var userinfo = Unibase.Platform.Membership.Infos.Identity.getCurrentUser(); var detailConfigjs = []; var detailSettingUrl = []; let VisibleContainerId = Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds[Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds.length - 1]; $("#DetailsProperties_" + containerid).empty(); if ($(".Detail_Configurations_" + containerid).find(".update").length > 0) { $(".Detail_Configurations_" + containerid).find(".update").empty(); } let checkEditsScreen = $("#DetailsProperties_" + containerid).find(".editscreen_view").length; if (checkEditsScreen == 0) { $("#DetailsProperties_" + containerid).append('Edit Screen'); } Unibase.Platform.Apps.Managers.AppManager.Instance().getInstallApp(recordid).then(function (appResponse) { for (let i = 0; i < Configurations.length; i++) { var response = Configurations[i]; if (!userinfo.isAdmin) { var createdbyid = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + installedappid + "_createdby").Value); if (createdbyid == userinfo.userId) { response.IsOwner = true; } } if (instance.isSystemLock == false) { if (Number(response.SettingUrlType) == Unibase.Platform.Apps.Enums.SettingUrlType.Form && Number(response.AppConfigType) == Unibase.Platform.Apps.Enums.AppConfigeType.Details && response.Ungrouped == true) { var onclickhtml = "Unibase.Platform.Helpers.NavigationHelper.Instance().loadForm(" + response.FormId + ", " + recordid + ", " + response.AppConfigurationId + ")"; if (userinfo.isAdmin || response.PermissionName == "Admin" || response.PermissionName == "Allow") { updatehtml += ' Edit'; } else if (response.PermissionName == "Owner") { if (response.IsOwner) { updatehtml += 'Edit '; } } else if (response.PermissionName == "Manager") { if (response.IsManager || response.IsOwner) { updatehtml += ' Edit'; } } if (response.JsFunction != "" && response.JsFunction != null) { detailConfigjs.push(response.JsFunction); } if (response.SettingUrl != "" && response.SettingUrl != null) { detailSettingUrl.push(response.SettingUrl); } } if (Number(response.SettingUrlType) == Unibase.Platform.Apps.Enums.SettingUrlType.JsFunction && Number(response.AppConfigType) == Unibase.Platform.Apps.Enums.AppConfigeType.Details && response.Ungrouped == true) { var jsfunction = response.JsFunction; filecachehelper.loadJsFile(response.SettingUrl == null ? "" : response.SettingUrl, function () { }); if (userinfo.isAdmin || response.PermissionName == "Admin") { updatehtml += ' '; } else if (response.PermissionName == "Owner") { if (response.IsOwner) { updatehtml += ' '; } } else if (response.PermissionName == "Manager") { if (response.IsManager || response.IsOwner) { updatehtml += ' '; } } } if (Number(response.SettingUrlType) == Unibase.Platform.Apps.Enums.SettingUrlType.JsFunction && Number(response.AppConfigType) == Unibase.Platform.Apps.Enums.AppConfigeType.Details && response.Ungrouped == false) { var jsfunction = response.JsFunction; filecachehelper.loadJsFile(response.SettingUrl == null ? "" : response.SettingUrl, function () { }); if (userinfo.isAdmin || response.PermissionName == "Admin") { html += "" + response.SettingName + ""; } else if (response.PermissionName == "Owner") { if (response.IsOwner) { html += "" + response.SettingName + ""; } } else if (response.PermissionName == "Manager") { if (response.IsManager || response.IsOwner) { html += "" + response.SettingName + ""; } } } if (Number(response.SettingUrlType) == Unibase.Platform.Apps.Enums.SettingUrlType.Form && Number(response.AppConfigType) == Unibase.Platform.Apps.Enums.AppConfigeType.Details && response.Ungrouped == false) { var onclickhtml = "Unibase.Platform.Helpers.NavigationHelper.Instance().loadForm(" + response.FormId + ", " + recordid + ", " + response.AppConfigurationId + ")"; if (userinfo.isAdmin || response.PermissionName == "Admin" || response.PermissionName == "Allow") { html += "" + response.SettingName + ""; } else if (response.PermissionName == "Owner") { if (response.IsOwner) { html += "" + response.SettingName + ""; } } else if (response.PermissionName == "Manager") { if (response.IsManager || response.IsOwner) { html += "" + response.SettingName + ""; } } } if (Number(response.SettingUrlType) == Unibase.Platform.Apps.Enums.SettingUrlType.Status && Number(response.AppConfigType) == Unibase.Platform.Apps.Enums.AppConfigeType.Details) { var jsfunction = response.JsFunction; filecachehelper.loadJsFile(response.SettingUrl == null ? "" : response.SettingUrl, function () { }); var statusid = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + installedappid + "_statusid").Value); if (userinfo.isAdmin || response.PermissionName == "Admin") { if (statusid != undefined) { if (statusid != 0 && statusid != 1) { var onclickurl = 'Unibase.Themes.Compact.Components.Details.Instance().changeStatus(1,' + recordid + ')'; html += "Activate"; } else { var onclickurl = 'Unibase.Themes.Compact.Components.Details.Instance().changeStatus(2,' + recordid + ')'; html += "" + response.SettingName + ""; } } else { MessageHelper.Instance().showError("Please select statusid column in report", "div_message", VisibleContainerId); } } else if (response.PermissionName == "Owner") { if (response.IsOwner) { if (statusid != 0 && statusid != 1) { var onclickurl = 'Unibase.Themes.Compact.Components.Details.Instance().changeStatus(1,' + recordid + ')'; html += "Activate"; } else { var onclickurl = 'Unibase.Themes.Compact.Components.Details.Instance().changeStatus(2,' + recordid + ')'; html += "" + response.SettingName + ""; } } } else if (response.PermissionName == "Manager") { if (response.IsManager || response.IsOwner) { if (statusid != 0 && statusid != 1) { var onclickurl = 'Unibase.Themes.Compact.Components.Details.Instance().changeStatus(1,' + recordid + ')'; html += "Activate"; } else { var onclickurl = 'Unibase.Themes.Compact.Components.Details.Instance().changeStatus(2,' + recordid + ')'; html += "" + response.SettingName + ""; } } } } if (Number(response.SettingUrlType) == Unibase.Platform.Apps.Enums.SettingUrlType.JsFunction && Number(response.AppConfigType) == Unibase.Platform.Apps.Enums.AppConfigeType.Status) { var jsfunction = response.JsFunction; filecachehelper.loadJsFile(response.SettingUrl == null ? "" : response.SettingUrl, function () { }); if (appResponse.result.StatusId == 1) { html += "Uninstall"; } else { html += "Install"; } } } } if (html != "") { $("#DetailsProperties_" + containerid).find("#editscreen").before(html); } $(".Detail_Configurations_" + containerid).contents().not(".div_configurationsetting").remove(); $(".Detail_Configurations_" + containerid).find(".div_configurationsetting").before(updatehtml); if (detailSettingUrl.length > 0) { instance.fileCacheHelper.loadJsFiles(detailSettingUrl, function (resp) { for (var i = 0; i < detailConfigjs.length; i++) { eval(detailConfigjs[i]); } }); } if ($(window).width() < 576) { $("#DetailsProperties_" + containerid).find("#editscreen").remove(); if ($('.div_configurationsetting').find("#DetailsProperties_" + containerid).children().length == 0) { $('.div_configurationsetting').addClass("d-none"); } } if (!userinfo.isAdmin) { let detailsPropContainer = $("#DetailsProperties_" + containerid); detailsPropContainer.find("#editscreen").addClass('hidden'); if (detailsPropContainer.children().length == 1) { if (!($(window).width() < 576)) { detailsPropContainer.parent().addClass('d-none'); } if (detailsPropContainer.children().length == 0) { detailsPropContainer.closest('.div_configurationsetting').addClass('hidden'); } } } }); } loadRowStatusList(panel, statuslist) { const instance = this; var recordid = Unibase.Themes.Providers.DetailHelper.recordId; var installedappid = Unibase.Themes.Providers.DetailHelper.installedAppId; $(panel).find(".layout-details-stages,.stage-change-select").empty(); if (statuslist != null && statuslist.length > 0) { var currentstatusid = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + installedappid + "_statusid").Value); $(".div_details_stages").removeClass('hidden'); $(panel).find(".stage-change-select").addClass('row-status-select'); for (var i = 0; i < statuslist.length; i++) { var statusid = statuslist[i][1]; var statusname = statuslist[i][0]; var color; if (statusname == "Active") { color = "green"; } else if (statusname == "InActive") { color = "orange"; } else { color = "red"; } let html = ''; if (instance.mobileLMode) { html = ' ' + statusname + ''; $(panel).find(".layout-details-stages").append(html); } else { html = ``; $(panel).find(".stage-change-select").append(html); if ($(panel).find(".stage-change-select option").length == 0) { $(panel).find(".stage-change-select").addClass("d-none").removeClass("d-flex"); } } if (statusid == currentstatusid) { $(panel).find(".btnChangeStage").html('' + statusname + ''); $('.btnChangeStage').removeAttr("style"); $('.btnChangeStage').attr("style", "border:solid 1px " + color + ""); $("#StatusId_" + statusid + "").addClass('disabled'); $("#StatusId_" + statusid + "").removeAttr('onclick'); $(panel).find(".stage-change-select").val(statusid); } } } } changeStatus(statusid, recordid) { var instance = this; var installedAppId = Unibase.Themes.Providers.DetailHelper.installedAppId; let VisibleContainerId = Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds[Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds.length - 1]; var versionGuid = ""; var index = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.findIndex(x => x.Key == "hf_" + installedAppId + "_versionguid"); if (index > 0) { versionGuid = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + installedAppId + "_versionguid").Value; } else { MessageHelper.Instance().showError("Need to add versionguid column to your report", 'div_message', VisibleContainerId); return false; } if (statusid == 2) var msg = "Are you sure you want to De-Activate ?"; else if (statusid == 1) var msg = "Are you sure you want to Activate ?"; else var msg = "Are you sure you want to Delete ?"; bootbox.confirm({ message: msg, closeButton: false, buttons: { confirm: { label: 'Yes', className: 'btn-success' }, cancel: { label: 'No', className: 'btn-defualt' } }, callback: function (result) { if (result) { instance.appmanager.getInstallApp(installedAppId).then(function (appresponse) { if (appresponse.result != null) { var doctypeid = appresponse.result.DefaultDocTypeId; if (doctypeid != 0 && doctypeid != undefined) { instance.appmanager.saveStatus(statusid, doctypeid, recordid, versionGuid).then(function (statusresponse) { Unibase.Platform.Helpers.NavigationHelper.IsListRefresh = true; if (statusresponse.status == Unibase.Data.Status.Error) { MessageHelper.Instance().showError(appresponse.result.AppTitle + " " + statusresponse.message, "div_message", VisibleContainerId); instance.updateToOldStageIdInMobileMode(installedAppId, 'statusid'); } else { MessageHelper.Instance().showSuccess(appresponse.result.AppTitle + " " + statusresponse.message, "div_message"); var obj = Unibase.Themes.Compact.Components.Details.Instance(); obj._recordId = Unibase.Themes.Compact.Components.Details.Instance()._recordId; obj._installedAppId = Unibase.Themes.Compact.Components.Details.Instance()._installedAppId; instance.loadPortlets(obj); Unibase.Platform.Helpers.NavigationHelper.IsListRefresh = true; instance.isDetailsUpdated = true; } }); } else { MessageHelper.Instance().showError("Please Select Doctype", "div_message", VisibleContainerId); } } }); } else { instance.updateToOldStageIdInMobileMode(installedAppId, 'statusid'); } } }); } loadStages(response, InstalledAppId, panel) { var instance = this; Details.Instance().changestagedata = ""; var html = ""; let shortcodes = []; var userinfo = Unibase.Platform.Membership.Infos.Identity.getCurrentUser(); $(panel).find(".layout-details-stages,.stage-change-select").empty(); if (response != null && response.length > 0) { $(panel).find(".layout-details-stages").find(".content").html(html); $(panel).find(".list-group-stages").html(''); var currentstageid = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_stageid").Value); let currentstageindex = 0; let disableStages = ""; for (var i = 0; i < response.length; i++) { shortcodes.push(response[i].ShortCode); if (response[i].StageId == currentstageid) { $(panel).find(".btnChangeStage").html(' ' + response[i].StageName + ''); $(panel).find(".btnChangeStageshort").html('' + response[i].ShortCode + ''); $(panel).find('.btnChangeStage').removeAttr("style"); $(panel).find('.btnChangeStage .statuscircle').css({ "color": "" + response[i].ColorCode + "" }); $(panel).find('.btnChangeStage').css({ "padding": "0px 15px" }); $(panel).find('.btnChangeStageshort').removeAttr("style"); $(panel).find('.btnChangeStageshort').css({ "border": "solid 1px #000000" }); $(panel).find('.btnChangeStageshort .statuscircle').css({ "color": "" + response[i].ColorCode + "" }); } if (userinfo.isAdmin == true) { instance.loadstagedesign(panel, response[i], InstalledAppId); } else { if (response[i].ChangeAll && response[i].StageRoles == null) { instance.loadstagedesign(panel, response[i], InstalledAppId); } if (response[i].StageRoles != null && response[i].StageRoles.length != 0) { for (var j = 0; j < response[i].StageRoles.length; j++) { if (response[i].ChangeAll && (!response[i].StageRoles[j].ExcludeChangeRole)) { instance.loadstagedesign(panel, response[j], InstalledAppId); } } } if (response[i].ChangeAll == false && response[i].StageRoles != null && response[i].StageRoles.length > 0) { instance.loadstagedesign(panel, response[i], InstalledAppId); } } if (response[i].StageId == currentstageid) { $(panel).find(".layout-details-stages").find("#StageId_" + response[i].StageId).addClass("disabled"); $(panel).find(".layout-details-stages").find("#StageId_" + response[i].StageId).removeAttr("onclick"); let containerId = Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds[Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds.length - 1]; const stageSelectEl = $(panel).find(".stage-change-select"); const selectEl = $(`#stageChangeSelect_${containerId}`).find('option').length; if ($(".stage-change-select option[value='" + currentstageid + "']").length == 0) { stageSelectEl.append(``); } if (selectEl == 1) { $(`#stageChangeSelect_${containerId}`).attr('style', '-webkit-appearance: none;-moz-appearance: none;'); } stageSelectEl.val(response[i].StageId); } } } if (($(".layout-details-stages").contents().length) == 0) { $(".layout-details-stages").addClass('d-none').siblings('.btnChangeStage').find('.fa-angle-down').addClass('d-none'); } } loadstagedesign(panel, response, installedappid) { const instance = this; var currentstagename = ""; if (response.IsDefault) { currentstagename = response.StageName; } var html = ''; if (instance.mobileLMode) { html = ' ' + response.StageName + ''; $(panel).find(".layout-details-stages").append(html); } else { html = ``; $(panel).find(".stage-change-select").append(html); if ($(panel).find(".stage-change-select option").length == 0) { $(panel).find(".stage-change-select").addClass("d-none").removeClass("d-flex"); } } } change(StageId, InstalledAppId, id) { var instance = this; var stagemanager = Unibase.Platform.Apps.Managers.StageManager.Instance(); var oldstageid; if (Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.length > 0) { oldstageid = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_stageid").Value); } else { let stagename; oldstageid = Number($('#' + id).attr('data-oldstageid')); if ($('#' + id + '[data-kanban2view="stagechange"][data-stagechange="true"]').length > 0) { stagename = $('#' + id + '[data-kanban2view="stagechange"][data-stagechange="true"]').attr('data-stagename'); oldstageid = Number(StageId); StageId = Number($('#' + id + '[data-kanban2view="stagechange"][data-stagechange="true"]').parent().siblings().find('[data-kanban2view="stagechange"]').attr('data-oldstageid')); } else { stagename = $('#' + id).text(); oldstageid = Number($('#' + id).attr('data-oldstageid')); } } stagemanager.getStage(oldstageid).then(function (oldstageresp) { stagemanager.getStage(StageId).then(function (stageresp) { if (stageresp.result.ReasonMandatory == 1) { var reasons = false; stagemanager.getStageReasons(StageId).then(function (response) { if (response.result.length > 0) { reasons = true; } if (stageresp.result.IsForward == true && stageresp.result.IsBackward == false && (stageresp.result.StageIndex > oldstageresp.result.StageIndex)) { Unibase.Platform.Apps.Components.StageReason.Instance().loaddesign(0, StageId, InstalledAppId, reasons, "Forward"); } else if (stageresp.result.IsForward == false && stageresp.result.IsBackward == true && (oldstageresp.result.StageIndex > stageresp.result.StageIndex)) { Unibase.Platform.Apps.Components.StageReason.Instance().loaddesign(0, StageId, InstalledAppId, reasons, "Backward"); } else if (stageresp.result.IsForward == true && stageresp.result.IsBackward == true) { Unibase.Platform.Apps.Components.StageReason.Instance().loaddesign(0, StageId, InstalledAppId, reasons, "Both"); } else { Details.Instance().changeStage(StageId, InstalledAppId, 0, '', 0, id); } }); } else { Details.Instance().changeStage(StageId, InstalledAppId, 0, '', 0, id); } }); }); } changeStage(StageId, InstalledAppId, reasonid = 0, reason = '', refstatusid = 0, id) { var instance = this, oldstageid, VersionGuid, recordid; let VisibleContainerId = Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds[Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds.length - 1]; var userinfo = Unibase.Platform.Membership.Infos.Identity.getCurrentUser(); if (Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.length > 0) { VersionGuid = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_versionguid").Value; oldstageid = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_stageid").Value); recordid = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_recordid").Value); } else { if (id == undefined || id == null) { id = $('[data-stage2event="true"][data-click2event="active"]').attr('id'); } VersionGuid = $('#' + id).attr('data-versionguid'); oldstageid = Number($('#' + id).attr('data-oldstageid')); recordid = Number($('#' + id).attr('data-record2id')); } if (oldstageid != 0 && recordid != 0 && InstalledAppId != 0) { if (StageId != 0 || refstatusid != 0) { Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.push({ Key: "hf_" + InstalledAppId + "_" + "newstageid", Value: StageId.toString(), DataType: typeof (StageId) }); let postData = { VersionGuid: VersionGuid, StageId: Number(StageId), InstalledAppId: Number(InstalledAppId), OldStageId: Number(oldstageid), RefStatusId: refstatusid }; if (reasonid != 0 && reasonid != undefined) { postData.StageReasonId = reasonid; } if (reason != null && reason != undefined && reason != "") { postData.Description = reason; } Unibase.Themes.Compact.Components.Details.Instance().PostData = postData; var FormId = 0; if (StageId != 0) { Unibase.Platform.Apps.Managers.StageManager.Instance().getStage(StageId).then(function (response) { FormId = response.result.FormId; if (FormId != 0) { Unibase.Platform.Helpers.NavigationHelper.Instance().loadForm(FormId, recordid, 0, 0, function () { Unibase.Themes.Compact.Components.Details.Instance().StageChange(Unibase.Themes.Compact.Components.Details.Instance().PostData, Unibase.Themes.Providers.DetailHelper.installedAppId); }); } else { Unibase.Themes.Compact.Components.Details.Instance().StageChange(postData, InstalledAppId); } }); } else { Unibase.Themes.Compact.Components.Details.Instance().StageChange(postData, InstalledAppId); } } else { MessageHelper.Instance().showError("Newstageid or refstatusid should not be 0", "div_message", VisibleContainerId); } } else { MessageHelper.Instance().showError("Installedappid,Recordid,Oldstageid,Newstageid should not be 0", "div_message", VisibleContainerId); } } StageChange(postData, InstalledAppId) { var instance = this; let VisibleContainerId = Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds[Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds.length - 1]; var stagemanager = Unibase.Platform.Apps.Managers.StageManager.Instance(); instance.navigationHelper.showLoading(); stagemanager.changeStage(postData).then(function (response) { return __awaiter(this, void 0, void 0, function* () { if (response.status == Unibase.Data.Status.Error) { if ($('#' + VisibleContainerId).find('#div_message').length != 0) { MessageHelper.Instance().showError(response.message, 'div_message', VisibleContainerId); } if (($('#' + VisibleContainerId).find('.portletwidget-item #div_ErrorMessage').length == 0) && ($('#' + VisibleContainerId).find('#div_ErrorMessage').length != 0)) { MessageHelper.Instance().showError(response.message, 'div_ErrorMessage', VisibleContainerId); } instance.updateToOldStageIdInMobileMode(InstalledAppId, 'stageid'); } else { MessageHelper.Instance().showSuccess(response.message, ''); var newstageid = response.result.StageId.toString(); if (Unibase.Themes.Providers.DetailHelper.installedAppId != 0) { Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == 'hf_' + InstalledAppId + '_stageid').Value = newstageid; var obj = Unibase.Themes.Compact.Components.Details.Instance(); obj._recordId = Unibase.Themes.Compact.Components.Details.Instance()._recordId; obj._installedAppId = Unibase.Themes.Compact.Components.Details.Instance()._installedAppId; instance.loadPortlets(obj); Unibase.Platform.Helpers.NavigationHelper.IsListRefresh = true; instance.isDetailsUpdated = true; } else { Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.pop(); let fitername = $(`#filters-list${VisibleContainerId} .filter-item.active`).attr('data-filtername'); $(`#filters-list${VisibleContainerId} .filter-item[data-filtername="${fitername}"] a`).click(); } } instance.navigationHelper.hideLoading(); }); }); } mobileStageChange(containerId) { const instance = this; const selectEl = $(`#stageChangeSelect_${containerId}`); if (selectEl.hasClass('row-status-select')) { const statusId = +selectEl.val(); const recordId = +selectEl.find('option:selected').attr('data-recordid'); instance.changeStatus(statusId, recordId); } else { const stageId = +selectEl.val(); const installedAppId = +selectEl.find('option:selected').attr('data-installedappid'); instance.change(stageId, installedAppId); } } loadDefaultWidgets(InstalledAppId, panel) { return __awaiter(this, void 0, void 0, function* () { var instance = this; var currentstageid = 0; var userinfo = Unibase.Platform.Membership.Infos.Identity.getCurrentUser(); var detailSettingInstance = Unibase.Themes.Providers.Detail_Settings.Instance(); if (!userinfo.isAdmin && detailSettingInstance.InputParameters. find(x => x.Key == "hf_" + InstalledAppId + "_stageid") != undefined) { currentstageid = Number(detailSettingInstance.InputParameters. find(x => x.Key == "hf_" + InstalledAppId + "_stageid").Value); } var activeportletid; let ActivePortletIndex = detailSettingInstance.ActivePortlets.findIndex(x => x.InstalledAppId == InstalledAppId); if (ActivePortletIndex != -1) { activeportletid = detailSettingInstance.ActivePortlets[ActivePortletIndex].ActivePortletId; } else { activeportletid = 0; } yield this.getportletlayout(InstalledAppId, activeportletid, panel); if ($(panel).find('#tab-container').hasClass('ui-sortable') && (Unibase.Themes.Compact.Components.Index.Instance().isAppStructureEnable)) { Unibase.Platform.Widgets.Components.Widget.Instance().EditScreen(InstalledAppId); } }); } loadWidgets(installedappid, portletid, panel) { if ($(panel).find('#details-edit-header').not('.d-none').length != 0) { $(panel).find('#details-edit-header').find('.portlet-title-span').text($(panel).find('#portletName_' + portletid).text()); } var instance = this; let isAppStructure = Unibase.Themes.Compact.Components.Index.Instance().isAppStructureEnable; if (instance.isPortletModified) { if ((isAppStructure == true && instance.isAppStructEnable == true)) { instance.savedChanges(installedappid, portletid, panel); } else { instance.confirmPortletChangesModal(installedappid, portletid, panel); } } else { $(panel).find('.tab-container').empty(); this.unibase_core_activeportletid = portletid; var currentstageid = 0; var userinfo = Unibase.Platform.Membership.Infos.Identity.getCurrentUser(); if (!userinfo.isAdmin && Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters. find(x => x.Key == "hf_" + installedappid + "_stageid") != undefined) { currentstageid = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters. find(x => x.Key == "hf_" + installedappid + "_stageid").Value); } if (portletid != 0) { this.unibase_core_activeportletid = portletid; this.reloadWidgetReport(panel); let containerId = Unibase.Platform.Helpers.NavigationHelper.Instance().getLastContainerId(); try { Unibase.Themes.Providers.Detail_Settings.Instance().DetailParameters[panel]["ActivePortletId"] = portletid; } catch (_a) { if (containerId.includes('_viewall')) { containerId = Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds[Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds.length - 2]; if (Unibase.Themes.Providers.Detail_Settings.Instance().DetailParameters[containerId] != undefined) { Unibase.Themes.Providers.Detail_Settings.Instance().DetailParameters[containerId]["ActivePortletId"] = portletid; } } } var activePortletIndex = Unibase.Themes.Providers.Detail_Settings.Instance().ActivePortlets.findIndex(x => x.InstalledAppId == installedappid); if (activePortletIndex != -1) { Unibase.Themes.Providers.Detail_Settings.Instance().ActivePortlets[activePortletIndex].ActivePortletId = portletid; } else { Unibase.Themes.Providers.Detail_Settings.Instance().ActivePortlets.push({ InstalledAppId: Number(installedappid), ActivePortletId: Number(portletid) }); } $("#managePortletBtn .portlet-title-span").text($(`#portletName_${portletid}`).text()); this.portletmanager.getPortletWidgets(portletid, currentstageid).then(function (response) { return __awaiter(this, void 0, void 0, function* () { var data = response.result; if ($("#" + Unibase.Platform.Helpers.NavigationHelper.Instance().getLastContainerId()).find('#portletTab_' + portletid + ' .findportlets_' + portletid).attr('data_isappstructenable') == 'true') { instance.isAppStructEnable = true; } else { instance.isAppStructEnable = false; } if ((isAppStructure == true && instance.isAppStructEnable == true)) { if ($("#" + Unibase.Platform.Helpers.NavigationHelper.Instance().getLastContainerId()).find("#tab-container").hasClass('ui-sortable')) { $("#bizgaze_body").addClass("edit-dashboard-mode"); $("#" + Unibase.Platform.Helpers.NavigationHelper.Instance().getLastContainerId()).find("#addWidgetContainer").addClass('hidden'); instance.savedChanges(installedappid, portletid, panel); } else { yield instance.btnchange(installedappid, portletid, panel); yield instance.getportletlayout(installedappid, portletid, panel); } } else { $("#bizgaze_body").removeClass("edit-dashboard-mode"); yield instance.btnchange(installedappid, portletid, panel); yield instance.getportletlayout(installedappid, portletid, panel); } }); }); } } } savedChanges(installedappid, portletid, panel) { return __awaiter(this, void 0, void 0, function* () { let instance = this; var msg = 'Are You Want Save Layout ?'; if ($("#tab-container").hasClass('ui-sortable') && instance.isPortletModified) { bootbox.confirm({ message: msg, closeButton: false, buttons: { confirm: { label: 'OK', className: 'btn-success' }, cancel: { label: 'Cancel', className: 'btn-danger' } }, callback: function (result) { return __awaiter(this, void 0, void 0, function* () { if (result) { yield Unibase.Platform.Widgets.Components.Widget.Instance().parentStructures('tab-container', 'portletwidget-item'); yield Unibase.Platform.Widgets.Components.Widget.Instance().SaveStructureLayout(); yield instance.btnchange(installedappid, portletid, panel); $(panel).find('.tab-container').empty(); yield instance.getportletlayout(installedappid, portletid, panel); yield Unibase.Themes.Compact.Components.Details.Instance().addWidget(); } else { yield instance.btnchange(installedappid, portletid, panel); yield instance.getportletlayout(installedappid, portletid, panel); yield Unibase.Themes.Compact.Components.Details.Instance().addWidget(); } }); } }); } else { yield instance.btnchange(installedappid, portletid, panel); yield instance.getportletlayout(installedappid, portletid, panel); yield Unibase.Themes.Compact.Components.Details.Instance().addWidget(); } instance.isPortletModified = false; }); } btnchange(installedappid, portletid, panel) { $(".nav-link").removeClass("active"); $(".collapsedPortlet").removeClass("nav-link active"); $(".tabid-" + portletid).find(".nav-link").addClass("active"); $(".tabid-" + portletid).find(".collapsedPortlet").addClass("nav-link active"); } reloadWidgetReport(panel) { if (panel.includes('_viewall')) { const containerId = panel.replace('#', ''); const reportInstance = Unibase.Platform.Analytics.Components.ReportViewer.Instance(); const rv_instance = reportInstance.getReportViewerInstance(containerId); Unibase.Platform.Analytics.Components.ReportViewer.Instance().getReportData(rv_instance.ReportId, containerId, rv_instance.reportWidgetData, null); return; } } getportletlayout(InstalledAppId, activeportletid, panel) { return __awaiter(this, void 0, void 0, function* () { let instance = this; var currentstageid = 0; let VisibleContainerId = Unibase.Platform.Helpers.NavigationHelper.Instance().getLastContainerId(); if (VisibleContainerId.includes('_viewall')) { let wdgtContainerId = VisibleContainerId.replace("_viewall", ""); let rprtId = Number($(`[class^="${wdgtContainerId}"]`).parent().siblings('#hf_ReportId').val()); Unibase.Platform.Analytics.Components.ReportViewer.Instance().refreshReportData(rprtId, VisibleContainerId, null); VisibleContainerId = Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds[Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds.length - 2]; } var userinfo = Unibase.Platform.Membership.Infos.Identity.getCurrentUser(); var detailSettingInstance = Unibase.Themes.Providers.Detail_Settings.Instance(); if (!userinfo.isAdmin && detailSettingInstance.InputParameters. find(x => x.Key == "hf_" + InstalledAppId + "_stageid") != undefined) { currentstageid = Number(detailSettingInstance.InputParameters. find(x => x.Key == "hf_" + InstalledAppId + "_stageid").Value); } if (Unibase.Themes.Compact.Components.Index.Instance().isAppStructureEnable) { yield instance.portletmanager.getdefaultAppsPortletWidgetStruct(InstalledAppId, currentstageid, activeportletid).then(function (response) { return __awaiter(this, void 0, void 0, function* () { let data = response.result; instance.isAppStructEnable = data.isAppStructEnable; if (data.isAppStructEnable) { let isStructure = true; let divStructure = 'divStructure_' + Math.floor(Math.random() * Date.now()); let boxId = 'structureId_' + Math.floor(Math.random() * Date.now()); if ((data.portletstructure != null) && (data.portletstructure != undefined)) { if (data.portletstructure.length > 0) { yield $(panel).find(".tab-container").empty(); $(panel).find(".tab-container").removeClass('row'); yield Unibase.Themes.Compact.Components.Dashboard.Instance().filterStructures(data.portletstructure, "tab-container"); $('#' + VisibleContainerId).find('.structureDiv[data-parentindex="0"]').each(function () { $(this).find('.droppablePlaceCol[data-parentindex="0"]:first').removeClass('px-lg-10 px-md-10').addClass('pl-lg-0'); }); } else { if (data.portletwidget != null) { if (data.portletwidget.length) { isStructure = false; let html = `
    `; $('#' + VisibleContainerId).find('#tab-container').html(html); } } } } if (data.portletwidget != null && data.portletwidget != undefined && data.portletwidget.length > 0) { yield instance.loadWidgetData(InstalledAppId, data.portletwidget, panel, isStructure, boxId); } else { instance.navigationHelper.hideLoading(); } } else { yield instance.portletmanager.getDefaultWidgets(InstalledAppId, currentstageid, activeportletid).then(function (response) { instance.loadWidgetData(InstalledAppId, response.result, panel, false); }); } }); }); } else { yield instance.portletmanager.getDefaultWidgets(InstalledAppId, currentstageid, activeportletid).then(function (response) { instance.loadWidgetData(InstalledAppId, response.result, panel, false); }); } }); } loadWidgetData(installedappid, widgetdata, panel, isStructure, boxId) { var instance = this; let data; if (widgetdata != "" && widgetdata != null && widgetdata.length > 0) { if (Unibase.Themes.Compact.Components.Index.Instance().isAppStructureEnable) { data = widgetdata.sort(Unibase.Themes.Compact.Components.Dashboard.Instance().sortStructureWidgets); instance.reloadWidgetReport(panel); } else { data = widgetdata; } if (data.length != 0) { let skelhtml = '
    '; skelhtml += Unibase.Themes.Compact.Components.Nav_Template.Instance().skelTonDetailsbBDYPage(); skelhtml += '
    '; $('.detail-container-content').before(skelhtml); let sorting = 'widgetdataHere', plus = ''; if (!Unibase.Themes.Compact.Components.Index.Instance().isAppStructureEnable) { sorting = '', plus = "+"; $(panel).find("#tab-container").empty(); } $(panel).find('.detail-container-content').addClass('invisible'); var html = ""; for (var i = 0; i < data.length; i++) { var model = data[i]; let elem; try { elem = $(panel).find('#portletTab_' + model.PortletId + ' .findportlets_' + model.PortletId).attr('data_isappstructenable').toString(); } catch (_a) { elem = ''; } if (elem != undefined && elem != null && elem != '') { if (elem == 'true') { instance.isAppStructEnable = true; $(panel).find('.tab-container').removeClass('row'); } else { instance.isAppStructEnable = false; $(panel).find('.tab-container').addClass('row'); } } else { if (isStructure) { instance.isAppStructEnable = true; $(panel).find('.tab-container').removeClass('row'); } else { instance.isAppStructEnable = false; $(panel).find('.tab-container').addClass('row'); } } var widgetUrl = model.WidgetUrl; var WidgetName = ""; if (model.DisplayText == null || model.DisplayText == "") { WidgetName = model.WidgetName; } else { WidgetName = model.DisplayText; } var IsFiltarable = model.IsFilterable; var filterhtml = ""; if (IsFiltarable == null || IsFiltarable == false || IsFiltarable == "") { filterhtml = "hidden"; } var Width = ''; if (isStructure == false) { if (model.WidgetLayoutName == "List") { Width = 'mb-2 col-lg-' + 12; } else { if (model.PortletWidgetCss != null && model.PortletWidgetCss != undefined && model.CssProperty != null && model.CssProperty != undefined && model.CssProperty != '' && model.PortletWidgetCss != '') { if (JSON.parse(model.PortletWidgetCss)[0].Width != null && JSON.parse(model.PortletWidgetCss)[0].Width != undefined) { Width = 'mb-2 col-lg-' + Number(JSON.parse(model.PortletWidgetCss)[0].Width); } else if (JSON.parse(model.CssProperty)[0].Width != null && JSON.parse(model.CssProperty)[0].Width != undefined) { Width = 'mb-2 col-lg-' + Number(JSON.parse(model.CssProperty)[0].Width); } else { Width = 'mb-2 col-lg-' + model.Width; } } else { Width = 'mb-2 col-lg-' + model.Width; } } } let hidden = ''; if (instance.IsCustomDetailHeader == true) { hidden = 'hidden'; } if (Unibase.Themes.Compact.Components.Index.Instance().isAppStructureEnable == true && instance.isAppStructEnable == true) { html = ''; } if (Unibase.Themes.Compact.Components.Index.Instance().isAppStructureEnable == true && instance.isAppStructEnable == true) { let afterchild, beforechild; if (model.StrctWidgetIndex == 1 || model.StrctWidgetIndex == 0) { if (isStructure != false) { $(panel).find('#structureId_' + model.StructureDesignId).find('.widgetplace').first().prepend(html); } else { $(panel).find('#' + boxId + ' .widgetplace').append(html); } } else { if (isStructure != false) { afterchild = model.StrctWidgetIndex - 1; beforechild = model.StrctWidgetIndex + 1; if (($(panel).find('#structureId_' + model.StructureDesignId + ' .widgetplace').find('[data-strctwidgetindex="' + afterchild + '"][data-boxid="' + model.StructureDesignId + '"]').length) > 0) { $(panel).find('#structureId_' + model.StructureDesignId + ' .widgetplace').find('[data-strctwidgetindex="' + afterchild + '"][data-boxid="' + model.StructureDesignId + '"]').after(html); } else if (($(panel).find('#structureId_' + model.StructureDesignId + ' .widgetplace').find('[data-strctwidgetindex="' + beforechild + '"][data-boxid="' + model.StructureDesignId + '"]').length) > 0) { $(panel).find('#structureId_' + model.StructureDesignId + ' .widgetplace').find('[data-strctwidgetindex="' + beforechild + '"][data-boxid="' + model.StructureDesignId + '"]').before(html); } else if (model.StrctWidgetIndex < Number($(panel).find('#structureId_' + model.StructureDesignId + ' [data-boxid="' + model.StructureDesignId + '"]').attr('data-strctwidgetindex'))) { $(panel).find('#structureId_' + model.StructureDesignId + ' [data-boxid="' + model.StructureDesignId + '"]').before(html); } else if (model.StrctWidgetIndex > Number($(panel).find('#structureId_' + model.StructureDesignId + ' [data-boxid="' + model.StructureDesignId + '"]').attr('data-strctwidgetindex'))) { $(panel).find('#structureId_' + model.StructureDesignId + ' [data-boxid="' + model.StructureDesignId + '"]').after(html); } else { $(panel).find('#structureId_' + model.StructureDesignId + ' .widgetplace').append(html); } } else { $(panel).find('#' + boxId + ' .widgetplace').append(html); } } } var StrWidgetID = '.widgetdataHere.widgetid-' + model.WidgetId + ''; var FindStrutreLength = $(StrWidgetID).length; if (FindStrutreLength >= 2) { $(panel).find('#tab-container .widgetdataHere.widgetid-' + model.WidgetId + '').not(':last').remove(); } } if ($("body").hasClass('background-image')) { $(panel).find(".simple-scroll-bar.scrollable").css("background", "rgb(255,255,255,0.8)"); $(panel).find(".simple-scroll-bar.tab-content").css({ "background": "rgb(255,255,255,0)", "height": "calc(100% - 100px) !important" }); } if (instance.isAppStructEnable == false || Unibase.Themes.Compact.Components.Index.Instance().isAppStructureEnable == false) { $(panel).find("#tab-container").html(html); } else { $(panel).find('#addWidgetContainer').addClass('hidden'); } instance.navigationHelper.hideLoading(); if ($(panel).find('#addWidgetContainer').is(':visible') || instance.isPortletEdit == true) { if (!instance.isAppStructEnable) { $(panel).find('#addWidgetContainer').removeClass('hidden'); } $(panel).find(".Border").addClass('card'); $(panel).find(".Border1").addClass('card-header').removeClass('hidden'); } var checklistcount = $(".portletwidget-item").find(".list-group-item").length; if (checklistcount >= 2) { $(".portletwidget-item").find(".list-group-item:not(:last)").css({ "border-bottom": "solid 1px rgb(204,204,204,0.6) !important;" }); } if ($(window).width() <= 1198) { let VisibleContainerId = Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds[Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds.length - 1]; $("#" + VisibleContainerId).find('.app_defaultwidget').on('click', function () { let modalimgUrl, modalsubtext, modalmaintext, modalHtml, modalavatar = ''; modalavatar = $("#" + VisibleContainerId).find(this).find('.biz-detail-avatar').find('.biz-primary-text-color').html(); modalimgUrl = $("#" + VisibleContainerId).find(this).find('.avatar-img').attr('src'); modalsubtext = $("#" + VisibleContainerId).find(this).find('.biz-header-sub-text').text(); modalmaintext = $("#" + VisibleContainerId).find(this).find('.biz-header-main-text').text(); if (modalimgUrl != null) { modalHtml = `
    `; } else { modalHtml = `
    `; } $("#_bizgaze_modal").html(modalHtml); $('#detailHeaderModal').modal(); $('#bizgaze_body').click(function () { $('#detailHeaderModal').modal('hide'); }); }); $(`${panel} .portlet-detail-header`).find(".biz-header-main-text,.biz-header-sub-text").addClass("text-truncate w-170p"); } else { $(`${panel} .portlet-detail-header`).find(".biz-header-main-text,.biz-header-sub-text").removeClass("text-truncate w-170p"); } $(".heading-display-name").click(function () { $(".dropdown-menu-name").removeClass("show"); $(".heading-display-name").addClass("d-none"); }); var instance = this; instance.model = data; instance.jsindex = 0; instance.htmlindex = 0; instance.evalExecuted = 0; instance.evaluateJs(data, panel); $(".portletwidget-item").find(".card-header-right").find(".my-auto").find(".nav-link").removeClass("d-none"); } else { if (!Unibase.Themes.Compact.Components.Index.Instance().isAppStructureEnable) { $(panel).find("#tab-container").empty(); } instance.navigationHelper.hideLoading(); } } else instance.navigationHelper.hideLoading(); } toggleStagesOnMobileScroll(panel) { if ($(window).width() <= 576 && $(panel).find('.Mobile-mode .div_details_stages option').length > 0) { $(panel).find('.portlet-header-wrapper').addClass("h-80p").removeClass('h-55p'); $(panel).find('.portlet-header-wrapper').removeClass("align-items-center"); let scrollEl = $(panel).find('.biz-detail-page-view'); eval(`const simpleBar = new SimpleBar($(panel).find('.biz-detail-page-view')[0]); const wrapperEl = $(simpleBar.el).find('.simplebar-content-wrapper'); if (wrapperEl.length) { scrollEl = wrapperEl; }`); scrollEl.off('scroll').on('scroll', function () { var st = $(this).scrollTop(); var lastScrollTop = 0; if (st > lastScrollTop) { $(panel).find(".Mobile-mode .div_details_stages").addClass('d-none').removeClass("d-block d-sm-none"); $(panel).find(".sales_invoice_column_three").addClass('d-none').removeClass("d-block d-sm-none"); $(panel).find('.portlet-header-wrapper').removeClass('h-80p').addClass("h-55p"); } else { $(panel).find(".Mobile-mode .div_details_stages").removeClass('d-none').addClass("d-block d-sm-none"); $(panel).find(".sales_invoice_column_three").removeClass('d-none').addClass("d-block d-sm-none"); $(panel).find('.portlet-header-wrapper').addClass('h-80p').removeClass("h-55p"); } lastScrollTop = st; }); } } loadWidgetEditData(installedappid, data, panel) { let instance = this; if (data != null) { $(panel).find('.detail-container-content').addClass('invisible'); instance.navigationHelper.showLoading(); var DeletedWidgets = []; for (var i = 0; i < data.length; i++) { DeletedWidgets = Unibase.Platform.Widgets.WidgetHiddenFields.Instance().NewWidgets; for (var j = 0; j < DeletedWidgets.length; j++) { var _isDeleted = DeletedWidgets.find(x => x.PortletWidgetId == data[i].PortletWidgetId) ? true : false; if (_isDeleted) { data.splice(i, 1); } } } $(panel).find("#tab-container").empty(); var html = ""; var cWidth = 0; var cHeight = 0; for (var i = 0; i < data.length; i++) { var model = data[i]; var widgetUrl = model.WidgetUrl; var WidgetName = ""; if (model.DisplayText == null || model.DisplayText == "") { WidgetName = model.WidgetName; } else { WidgetName = model.DisplayText; } var IsFiltarable = model.IsFilterable; var filterhtml = ""; if (IsFiltarable == null || IsFiltarable == false || IsFiltarable == "") { filterhtml = "hidden"; } var Width = 0; if (model.WidgetLayoutName == "List") { Width = 12; } else { Width = model.Width; } let hidden = ''; if (instance.IsCustomDetailHeader == true) { hidden = 'hidden'; } html += ''; } $(panel).find("#tab-container").html(html); instance.navigationHelper.hideLoading(); instance.model = data; instance.jsindex = 0; instance.htmlindex = 0; instance.evalExecuted = 0; instance.evaluateJs(data, panel); } else { $(panel).find("#tab-container").empty(); } if (Unibase.Platform.Widgets.WidgetHiddenFields.Instance().NewWidgets.length != 0) { var html = ""; for (let i = 0; i < Unibase.Platform.Widgets.WidgetHiddenFields.Instance().NewWidgets.length; i++) { if (Unibase.Platform.Widgets.WidgetHiddenFields.Instance().NewWidgets[i].PortletId == $("#hf_PortletId").val()) { var html1 = '
    ' + Unibase.Platform.Widgets.WidgetHiddenFields.Instance().NewWidgets[i].WidgetName + '
    ' + '
    '; html += '
    ' + '
    ' + '' + '' + html1 + '
    '; } } $(panel).find("#tab-container .portletwidget-addeditem:last").after(html); } } evaluateJs(data, panel) { var currentinstance = this, url = []; var staticfileaarry = []; currentinstance.evalExecuted = 1; var staticwidetfiles = data.filter(function (o) { return o.WidgetUrl !== '' && o.WidgetUrl !== null; }); if (staticwidetfiles != null && staticwidetfiles != '') { for (var i = 0; i < staticwidetfiles.length; i++) { var staticjs = staticwidetfiles[i].WidgetUrl.split(','); staticfileaarry.push(staticjs[0]); } currentinstance.fileCacheHelper.loadJsFiles(staticfileaarry, function () { for (var i = 0; i < staticwidetfiles.length; i++) { var model = staticwidetfiles[i]; if (model.WidgetUrl != null && model.WidgetUrl != '') { let containerid = "div_portletwidget_" + model.PortletWidgetId + "_" + panel.replace("#", ""); var loadcurentjs = staticwidetfiles[i].WidgetUrl.split(','); eval(loadcurentjs[1] + '.init("' + containerid + '")'); } } }); } for (var i = 0; i < data.length; i++) { var model = data[i]; var wclist = []; let containerid = "div_portletwidget_" + model.PortletWidgetId + "_" + panel.replace("#", ""); if (model.WidgetUrl == null || model.WidgetUrl == '') { if (model != null) { if (model.StaticJsPath != null) { var instance1 = eval(model.StaticJsPath); } if (model.Js != null) { Unibase.Platform.Helpers.FileCacheHelper.Instance().addCacheFiles([model.JsPath]); let instance = eval(model.Js); var widgetsettingcomponent = instance; let containerid = "div_portletwidget_" + model.PortletWidgetId + "_" + panel.replace("#", ""); wclist.push({ PortletWidgetId: model.PortletWidgetId, WidgetId: model.WidgetId, WidgetParameters: model.Parameter, WidgetName: model.WidgetName, InstalledAppId: currentinstance._installedAppId, DetailContainerId: panel, StaticJsPath: model.StaticJsPath, ReportId: model.ReportId, CustomHtml: model.CustomHtml }); currentinstance.navigationHelper.loadSection(wclist, containerid, instance, null, null); } } } } $('.portletwidget-item').on('touchstart', function () { $('.portletwidget-item').attr('data-mobileSwipe', 'false'); }); } ShowWidgetPermissions(PortletWidgetId) { this.navigationHelper.popup(0, "", Unibase.Platform.Widgets.Components.WidgetPermission.Instance(), function () { $(".toplayout-structures-panel").css({ "z-index": "1040" }); $(".biz-layout-3-left-nav").css({ "z-index": "1040" }); $(".biz-submenu").css({ "z-index": "1040" }); Unibase.Platform.Widgets.Components.WidgetPermission.Instance().showPermissions(PortletWidgetId, 'widget', 0); }, Unibase.Platform.Helpers.Size.Medium); } addWidget() { var instance = this; this.fileCacheHelper.loadJsFile("platform/widgets/components/widget.js", function () { Unibase.Platform.Widgets.Components.Widget.Instance().EditScreen(instance._installedAppId); }); } LoadApprovals(id, InstalledAppId) { const instance = this; var notificationdiv = $("#div_detail_notifications_" + id); var approvalhtml = '
    ' + '
    ' + '' + '
    ' + '
    '; var VersionGuid = ""; for (let obj of Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters) { if (obj.Key === "hf_" + InstalledAppId + "_versionguid") { VersionGuid = obj.Value.toString(); } } Unibase.Platform.Communications.Managers.TaskManager.Instance().getTasksByRefId(VersionGuid).then(function (response) { var data = response.result; if (data != null && data.length != 0) { let lastContainerId = instance.navigationHelper.getLastContainerId(); $(`#${lastContainerId}`).find("#div_detail_notifications_" + id).html(approvalhtml); notificationdiv.find("#div_detail_notification_footer").show(); var html = ''; var confirmtext = ""; var rejecttext = ""; var rejectonclick = ""; for (var i = 0; i < data.length; i++) { var j = i + 1; confirmtext = "Confirm"; rejecttext = "Reject"; rejectonclick = 'Unibase.Themes.Compact.Components.Details.Instance().SaveTaskReason(' + data[i].TaskId + ',\'Reject\')'; if (data[i].ConfirmKeyText != null && data[i].ConfirmKeyText != undefined && data[i].ConfirmKeyText != "") { confirmtext = data[i].ConfirmKeyText; } if (data[i].RejectKeyText != null && data[i].RejectKeyText != undefined && data[i].RejectKeyText != "") { rejecttext = data[i].RejectKeyText; } if (Number(data[i].RejectFormId) != 0) { rejectonclick = 'Unibase.Themes.Compact.Components.Details.Instance().ChangeApprovalStatus(' + data[i].TaskId + ', \'Reject\',' + data[i].RejectFormId + ',' + data[i].RejectFormPkId + ')'; } html += '
  • ' + '
    ' + data[i].Subject + '' + '

    ' + data[i].Body + '

    ' + confirmtext + '' + '' + rejecttext + 'Close' + '
    ' + '
  • '; } $(`#${lastContainerId}`).find("#div_detail_notification_list_item:last").after(html); $(".span_notification_count").text(data.length); if ($(`#${lastContainerId}`).find('#div_detail_notification_list').find('li.task').length > 0) { $(`#${lastContainerId}`).find('#div_detail_notification_list').parents('.ApprovalTasks').parent().addClass('bg-white mb-20').removeClass('d-none'); } } else { notificationdiv.find(".fa-angle-down,.fa-angle-right,.card-body,#div_detail_notification_footer").toggleClass("hidden"); } }); } CloseApprovals(taskid) { var instance = this; $("#notification_list_" + taskid).remove(); var tasks = $(".task").each(function () { }); if (tasks.length == 0) { $(".ApprovalTasks").remove(); } if (instance = null) Unibase.Platform.Helpers.NavigationHelper.Instance().loadDetail(instance._recordId, instance._installedAppId, null); } confirmclosetask(taskid) { bootbox.confirm({ title: "Close Task?", message: "Are you sure? If you are deleting this task.Then work flow will override", buttons: { cancel: { label: ' Cancel' }, confirm: { label: ' Confirm' } }, callback: function (result) { if (result) { Unibase.Themes.Compact.Components.Details.Instance().CloseTask(taskid, "Completed"); } else { return; } } }); } CloseTask(taskid, status) { var username = Unibase.Platform.Membership.Infos.Identity.currentUser.name; let reason = "Task is Closed by " + username; var obj = { TaskId: taskid, Status: status, Reason: reason }; Unibase.Platform.Communications.Managers.TaskManager.Instance().changeApprovalStatus(obj).then(function (response) { Unibase.Themes.Compact.Components.Notification.Instance().removetask(taskid); }); } ToggleApprovals(id) { $("#div_detail_notifications_" + id).find(".fa-angle-down").toggleClass("hidden"); $("#div_detail_notifications_" + id).find(".fa-angle-right").toggleClass("hidden"); $("#div_detail_notifications_" + id).find(".card-body").toggleClass("hidden"); $("#div_detail_notifications_" + id).find(".card-footer").toggleClass("hidden"); } ChangeApprovalStatus(taskid, status, formid, formpkid) { var reason = status == "Reject" ? $("#textarea_Reason_" + taskid).val().toString() : "Accepted"; let lastContainerId = this.navigationHelper.getLastContainerId(); if (formid != 0) { Unibase.Themes.Compact.Components.TaskParms.Instance().SaveTaskParameters({ TaskId: taskid, Reason: reason, Status: status, ActivePortletId: Unibase.Themes.Compact.Components.Details.Instance().unibase_core_activeportletid, FormId: formid, }); Unibase.Platform.Helpers.NavigationHelper.Instance().loadForm(formid, formpkid, 0, 0, function (response) { var taskparameters = Unibase.Themes.Compact.Components.TaskParms.Instance().GetTaskParameters(taskid); Unibase.Themes.Compact.Components.TaskParms.Instance().RemoveTaskParameters(taskparameters.TaskId); if (response != null) { var obj = { TaskId: taskparameters.TaskId, Status: taskparameters.Status, Reason: taskparameters.Reason }; Unibase.Platform.Communications.Managers.TaskManager.Instance().changeApprovalStatus(obj).then(function (response) { if (response.status == Unibase.Data.Status.Success) { var refid = $('#notification_list_' + taskid).attr('data-refid'); Unibase.Themes.Compact.Components.Notification.Instance().reloadPage(refid); Unibase.Themes.Compact.Components.Notification.Instance().removetask(taskid); } }); } }); } else { var reqobj = { TaskId: taskid, Status: status, Reason: reason }; Unibase.Platform.Communications.Managers.TaskManager.Instance().changeApprovalStatus(reqobj).then(function (response) { if (response.status == Unibase.Data.Status.Success) { var refid = $('#notification_list_' + taskid).attr('data-refid'); Unibase.Themes.Compact.Components.Notification.Instance().reloadPage(refid); Unibase.Themes.Compact.Components.Notification.Instance().removetask(taskid); if ($(`#${lastContainerId}`).find('#div_detail_notification_list').find('li.task').length == 0) { $(`#detailActionsWidget_${lastContainerId}`).addClass('d-none'); } } }); } } SaveTaskReason(taskid, status) { let reason = $("#textarea_Reason_" + taskid).val().toString(); let lastContainerId = this.navigationHelper.getLastContainerId(); var obj = { TaskId: taskid, Status: status, Reason: reason }; Unibase.Platform.Communications.Managers.TaskManager.Instance().changeApprovalStatus(obj).then(function (response) { var refid = $('#notification_list_' + taskid).attr('data-refid'); Unibase.Themes.Compact.Components.Notification.Instance().reloadPage(refid); Unibase.Themes.Compact.Components.Notification.Instance().removetask(taskid); if ($(`#${lastContainerId}`).find('#div_detail_notification_list').find('li.task').length == 0) { $(`#detailActionsWidget_${lastContainerId}`).addClass('d-none'); } }); } ChangeRejectStatus(taskid) { $("#Reason_" + taskid).removeClass("d-none").addClass('d-flex'); $("#btn_Approve_" + taskid).addClass("hidden"); $("#btn_Reject_" + taskid).addClass("hidden"); $("#btn_close_" + taskid).addClass("hidden"); } loadHeaderAvatar(panel) { let avatarElement = $(panel).find('.app_defaultwidget .biz-detail-avatar'); if (avatarElement.length > 0) { let dataSrc = avatarElement.attr('data-src'); if (dataSrc == '' || dataSrc == 'NA' || dataSrc == undefined) { let dataIconName = avatarElement.attr('data-icon-name'); if (dataIconName == '' || dataIconName == 'NA' || dataIconName == undefined) { let avatarTxt = ""; let headingTxt = $(panel).find('.app_defaultwidget #Column1').text(); let matches = headingTxt.match(/\b(\w)/g); if (matches.length == 1) { avatarTxt = $.trim(headingTxt).substr(0, 1).toUpperCase() + $.trim(headingTxt).substr(1, 1); } else { avatarTxt = matches.join('').slice(0, 2).toUpperCase(); } avatarElement.html(`
    ${avatarTxt}
    `); } else { avatarElement.html(``); } } else { if (dataSrc && dataSrc.includes("~")) { dataSrc = dataSrc.slice(2); } avatarElement.html(`img`); } avatarElement.addClass('flex-shrink-0'); } else { $(panel).find(".div_details_stages.d-sm-none").removeClass("ml-35"); } } confirmPortletChangesModal(installedappid, portletid, panel) { var instance = this; $('#confirmPortletChangesModal').remove(); $('body').append(``); $("#confirmPortletChangesModal").modal({ keyboard: false, backdrop: 'static', show: true }); $('#confirmPortletChangesModal').attr('data-portletid', portletid); $("#discardChangesBtn").click(function (e) { instance.isPortletModified = false; instance.loadWidgets(installedappid, portletid, panel); }); $('#confirmPortletChangesModal').on('hide.bs.modal', function () { $('#confirmPortletChangesModal').remove(); }); } evaluateDefaultWidgetCallback(panel, IsDetailClose, IsListRefresh) { let closeCallbackfn = $(panel).find("#div_App_DefaultWidget").find("#defaultwidgetclosecallbackfn"); let Callbackfn = $(panel).find("#div_App_DefaultWidget").find("#defaultwidgetcallbackfn"); let callbck; let defaultcallbackfn = $(panel).find("#div_App_DefaultWidget").find("#defaultwidgetclosecallbackfn"); if (defaultcallbackfn.length > 0) { IsListRefresh = false; if (!IsDetailClose) { $(panel).find(".app_defaultwidget").html('').removeClass("hidden"); } } if (closeCallbackfn.length > 0 && IsDetailClose) { callbck = closeCallbackfn.val(); } if (Callbackfn.length > 0 && !IsDetailClose) { callbck = Callbackfn.val(); } if (callbck != null) { eval(callbck); } return IsListRefresh; } swipe(direction) { if ($('.portletwidget-item[data-mobileswipe="true"]').length == 0) { let VisibleContainerId = Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds[Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds.length - 1], instance = this, _installedAppId = Unibase.Themes.Providers.DetailHelper.installedAppId; let id = $('#' + VisibleContainerId).find("#div_detail_profile").attr('id'); if (_installedAppId != 0 && id == 'div_detail_profile') { let totalLength = $('#' + VisibleContainerId + ' .layout-detail-tabs .tab-item').not('.exclude-tab').find('a').length; let activeIndex = $('#' + VisibleContainerId + ' .layout-detail-tabs .tab-item').not('.exclude-tab').find('a.active').parent().index(), isClickEvent = direction, _activeIndex = activeIndex + 1, leftscrolling = _activeIndex - 1, rightscrolling = _activeIndex + 1; if (isClickEvent == 'SWIPE_RIGHT' && leftscrolling != 0) { $('#' + VisibleContainerId + ' .layout-detail-tabs .tab-item:nth-child(' + leftscrolling + ') a').not('.exclude-tab').click(); instance.scrollEvent(isClickEvent); } if ((isClickEvent == 'SWIPE_LEFT')) { $('#' + VisibleContainerId + ' .layout-detail-tabs .tab-item:nth-child(' + rightscrolling + ') a').not('.exclude-tab').click(); instance.scrollEvent(isClickEvent); } } } } scrollEvent(scroll) { let VisibleContainerId = Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds[Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds.length - 1]; let ActivePortletElement = $('#' + VisibleContainerId + ' .layout-detail-tabs .tab-item').not('.exclude-tab').find('a.active'); let IndividualWidth = [], index = ActivePortletElement.parent().index() + 1; for (let i = 1; i <= index; i++) { IndividualWidth.push($('#' + VisibleContainerId).find('.layout-detail-tabs .tab-item:nth-child(' + i + ') a').not('.exclude-tab').outerWidth()); } var sumWidth = IndividualWidth.reduce(function (a, b) { return a + b; }, 0); ActivePortletElement.parents('#layout-detail-tabs').scrollLeft(sumWidth - ActivePortletElement.parent().outerWidth()); } toggleAppDefaultWidget(panel) { const configHeaderBtnEl = $(panel).find('.div_detailconfigurations_headerbtns'); const containerId = panel.replace('#', ''); if (configHeaderBtnEl[0] !== undefined) { const observer = new window.MutationObserver(function (mutations) { let findableEl; if ($(mutations[0].target).hasClass('detail-setting-item')) { findableEl = '.detail-setting-item'; } else if ($(mutations[0].target).hasClass('detail-setting-btn')) { findableEl = '.detail-setting-btn'; } if (configHeaderBtnEl.find(findableEl).not('.hidden').length) { $(`#detailActionsWidget_${containerId}`).removeClass('d-none'); } else { $(`#detailActionsWidget_${containerId}`).addClass('d-none'); } }); observer.observe(configHeaderBtnEl[0], { subtree: true, attributes: true }); } } reloadActivePortlet() { var installedAppId = Unibase.Themes.Providers.DetailHelper.installedAppId; var containerId = "#" + Unibase.Platform.Helpers.NavigationHelper.Instance().getLastContainerId(); var portletId = 0; var activePortletsList = Unibase.Themes.Providers.Detail_Settings.Instance().ActivePortlets; if (activePortletsList.length > 0) { var activePortletIndex = activePortletsList.findIndex(x => x.InstalledAppId == installedAppId); if (activePortletIndex > -1) { portletId = activePortletsList[activePortletIndex].ActivePortletId; } } if (portletId == 0) { portletId = Number($("#hf_PortletId").val()); } Unibase.Themes.Compact.Components.Details.Instance().loadWidgets(installedAppId, portletId, containerId); } static Instance() { if (this.instance === undefined) { this.instance = new Details(); } return this.instance; } } Details.inputparameters = []; Components.Details = Details; })(Components = Compact.Components || (Compact.Components = {})); })(Compact = Themes.Compact || (Themes.Compact = {})); })(Themes = Unibase.Themes || (Unibase.Themes = {})); })(Unibase || (Unibase = {}));