var Unibase; (function (Unibase) { let Platform; (function (Platform) { let Dashboards; (function (Dashboards) { let Components; (function (Components) { class CreateDashboard extends Platform.Core.BaseComponent { constructor() { super(); this.dashboardManager = Dashboards.Managers.DashboardManager.Instance(); } cssFiles() { return []; } jsFiles() { return ["platform/dashboards/managers/dashboardmanager.js", "platform/dashboards/requests/dashboards.js", "platform/dashboards/components/dashboardpermissions.js", "platform/portlets/managers/portletmanager.js"]; } html(id, containerid) { let html = `
Create Dashboard
Details
Pin Common Filters
Permissions
Is Trackable ?
Everyone can view?
`; return html; } load(id, containerid, callback) { var instance = this; instance.loadDashboardGroups(); $('#chkIsDashboardViewable').change(function () { var viewable = $("#chkIsDashboardViewable").prop('checked'); if (viewable) { $('#div_DashboardViewRoles').addClass("hidden"); $('#div_DashboardExcludeViewRoles').removeClass("hidden"); } else { $('#div_DashboardExcludeViewRoles').removeClass("hidden"); $('#div_DashboardViewRoles').removeClass("hidden"); } }); let IncludeRoles = []; let ExcludeRoles = []; $('#txtDashboardViewRoles').on("select2:select", function (e) { var result = e.params.data; if (Number(result.id) != 0) { var roleId = result.id; IncludeRoles.push(roleId); $(ExcludeRoles).each(function (i, value) { if (value == roleId) { var index = ExcludeRoles.indexOf(value); if (index > -1) { ExcludeRoles.splice(index, 1); } ExcludeRoles.splice(value, 1); jQuery("#txtDashboardExcludeViewRoles").val(ExcludeRoles).trigger('change'); return false; } }); } }); $('#txtDashboardViewRoles').on("select2:unselect", function (e) { var result = e.params.data; if (Number(result.id) != 0) { var roleId = Number(result.id); IncludeRoles.pop(roleId); } }); $('#txtDashboardExcludeViewRoles').on("select2:select", function (e) { var result = e.params.data; if (Number(result.id) != 0) { var roleId = result.id; ExcludeRoles.push(roleId); $(IncludeRoles).each(function (i, value) { if (value == roleId) { var index = IncludeRoles.indexOf(value); if (index > -1) { IncludeRoles.splice(index, 1); } jQuery("#txtDashboardViewRoles").val(IncludeRoles).trigger('change'); return false; } }); } }); $('#txtDashboardExcludeViewRoles').on("select2:unselect", function (e) { var result = e.params.data; if (Number(result.id) != 0) { var roleId = result.id; ExcludeRoles.pop(roleId); } }); $("#btn_SaveDashboard").click(function () { if ($("#Txt_EditDashboardName").val() == '') { MessageHelper.Instance().showError("Dashboard Name is required", 'Unibase_EditDashboardErrorMessages'); return false; } let reqObj = new Unibase.Platform.Dashboards.Requests.Dashboard(); reqObj.DashboardName = String($("#Txt_EditDashboardName").val()); reqObj.DashboardIndex = Number($("#Txt_EditDashboardIndex").val()); reqObj.DashboardGroupId = Number($("#ddl_DashboardGroups").val()); reqObj.ViewRoles = IncludeRoles; reqObj.ExcludeRoles = ExcludeRoles; reqObj.IsTrackable = $("#Ch_IsTrackable").is(":checked"); reqObj.ViewAllStages = true; reqObj.PinCommonFilters = $("#pinCmnFiltersChk").is(':checked'); instance.dashboardManager.saveDashboard(reqObj).then(function (response) { if (response.errors == null) { instance.navigationHelper.closePopUp(); MessageHelper.Instance().showSuccess('Dashboard Saved Successfully', ''); Unibase.Platform.Dashboards.Components.ManageDashboard.Instance().loadDashboardGroups(); } else MessageHelper.Instance().showError(response.errors[0], 'Unibase_EditDashboardErrorMessages'); }); }); $("#btn_CloseDashboard").click(function () { instance.navigationHelper.closePopUp(); }); var _Permissions_ViewRoles = []; var ExcludeViewRoles = []; var Ids = []; var ExludedIds = []; var ViewRoleElementId = "txtDashboardViewRoles"; var ExcludeRoleElementId = "txtDashboardExcludeViewRoles"; Unibase.Platform.Dashboards.Components.DashboardPermissions.Instance().select2dashboardbinding(0, false, _Permissions_ViewRoles, ExcludeViewRoles, Ids, ExludedIds, ViewRoleElementId, ExcludeRoleElementId); } loadDashboardGroups() { var instance = this; instance.dashboardManager.getDashboardGroups().then(function (response) { var indexhtml = ""; let html = ""; for (var i = 0; i < response.result.length; i++) { html += ''; indexhtml += ''; } var selectOpt = ''; $('#ddl_DashboardGroups').html(selectOpt + html).append(indexhtml); $('#ddl_DashboardGroups').change(function () { var portletscount = 0; var groupid = Number($('#ddl_DashboardGroups').val()); portletscount = Number($('.portletscount_' + groupid + '').val()); $('#Txt_EditDashboardIndex').val(portletscount); if (groupid != 0) { $('#Txt_EditDashboardIndex').attr('disabled', 'true'); } }); }); } static Instance() { return new CreateDashboard(); } } Components.CreateDashboard = CreateDashboard; })(Components = Dashboards.Components || (Dashboards.Components = {})); })(Dashboards = Platform.Dashboards || (Platform.Dashboards = {})); })(Platform = Unibase.Platform || (Unibase.Platform = {})); })(Unibase || (Unibase = {}));