123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458 |
- var Unibase;
- (function (Unibase) {
- let Forms;
- (function (Forms) {
- let Controls;
- (function (Controls) {
- class multiselectlist extends Unibase.Platform.Core.BaseComponent {
- constructor() {
- super(...arguments);
- this.count = 0;
- this.iddel = [];
- this.id = [];
- this.Isrow = false;
- this.page = 0;
- this.rows = 0;
- this.parameters = [];
- }
- init(formpropertyid, prop, callback) {
- multiselectlist.Instance().iddel = [];
- multiselectlist.Instance().id = [];
- multiselectlist.Instance().Isrow = false;
- Unibase.Forms.Controls.multiselectlist.Instance().loadControlSettings(prop, prop.FormPropertyId);
- Unibase.Forms.Controls.multiselectlist.Instance().binddetails(prop.DocPropertyName);
- }
- binddetails(docPropertyName) {
- var UserId = 0;
- var InstalledAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
- if (docPropertyName == "branchid" || docPropertyName == "roleid") {
- if (Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.length != 0) {
- UserId = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_userid").Value);
- }
- }
- else {
- if (Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.length != 0) {
- var OfferId = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_offerid").Value);
- }
- }
- if (docPropertyName == "branchid") {
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile('apps/crm/companies/managers/companymanager.js', function () {
- Bizgaze.Apps.CRM.Companies.Managers.CompanyManager.Instance().getUserBranches(UserId).then(function (response) {
- var remids = '';
- var ids = "";
- for (var i = 0; i < response.result.length; i++) {
- var id = $("#hdnchkmulti_" + docPropertyName).val();
- ids += response.result[i].BranchId + "|";
- $("#hdnchkmulti_" + docPropertyName).val(ids);
- }
- multiselectlist.Instance().Isrow = true;
- if (multiselectlist.Instance().iddel.length > 0) {
- for (var a = 0; a < multiselectlist.Instance().iddel.length; a++) {
- $("#ul_" + docPropertyName).find('.li_list').each(function () {
- if (multiselectlist.Instance().iddel[a] == $(this).find(".id_column").val()) {
- $(this).find(".id_column").prop("checked", false);
- $(this).find(".id_column").addClass("IsSaved");
- }
- });
- }
- }
- $("#hdnchkmultidel_branchid").val(remids);
- });
- });
- }
- else if (docPropertyName == "roleid") {
- UserId = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_userid").Value);
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile('platform/permission/managers/permissionmanager.js', function () {
- Unibase.Platform.Permissions.Managers.PermissionManager.Instance().getUserRoles(UserId).then(function (response) {
- var remids = '';
- var ids = "";
- for (var i = 0; i < response.result.length; i++) {
- var id = $("#hdnchkmulti_" + docPropertyName).val();
- ids += response.result[i].RoleId + "|";
- $("#hdnchkmulti_" + docPropertyName).val(ids);
- }
- multiselectlist.Instance().Isrow = true;
- if (multiselectlist.Instance().iddel.length > 0) {
- for (var a = 0; a < multiselectlist.Instance().iddel.length; a++) {
- $("#ul_" + docPropertyName).find('.li_list').each(function () {
- if (multiselectlist.Instance().iddel[a] == $(this).find(".id_column").val()) {
- $(this).find(".id_column").prop("checked", false);
- $(this).find(".id_column").addClass("IsSaved");
- }
- });
- }
- }
- $("#hdnchkmultidel_roleid").val(remids);
- });
- });
- }
- else if (docPropertyName == "planid") {
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile('apps/transact/managers/offers/offermanager.js', function () {
- Bizgaze.Apps.Transact.Managers.OfferManager.Instance().getofferplans(OfferId).then(function (response) {
- var remids = '';
- var ids = "";
- if (response.result != null) {
- for (var i = 0; i < response.result.length; i++) {
- ids += response.result[i].PlanId + "|";
- if (response.result[i].StatusId == 2) {
- $(this).find(".id_column").prop("checked", false);
- }
- }
- $("#hdnchkmultidel_roleid").val(remids);
- }
- });
- });
- }
- }
- loadControl(container, prop) {
- var html = '<div class="floating-label-form-group"><input class="form-control floating-label-control txt_global_search" id="text_multiselectsearch" type="search" placeholder="Search" aria-label="Search"></div>' +
- '<div class="" id = "div_' + prop.DocPropertyName + '" style="margin-top:5px;">' +
- '<input type="hidden" id="hdnchkmulti_' + prop.DocPropertyName + '" class="form-control value-control" data-isdefault="' + prop.IsDefault + '" data-required="' + prop.IsRequired + '" data-regularexp="" data-validatemsg="" placeholder = "' + prop.Placeholder + '" data-placeholder="' + prop.Placeholder + '" data-label="' + prop.LabelName + '" data-ismultiple="' + prop.IsMultiple + '" />' +
- '<input type="hidden" id="hdnchkmultidel_' + prop.DocPropertyName + '" class="form-control " data-isdefault="' + prop.IsDefault + '" data-required="' + prop.IsRequired + '" data-regularexp="" data-validatemsg="" placeholder = "' + prop.Placeholder + '" data-placeholder="' + prop.Placeholder + '" data-label="' + prop.LabelName + '" data-ismultiple="' + prop.IsMultiple + '" />' +
- '<ul id="ul_' + prop.DocPropertyName + '" class="text-center mt-10 type-control ul_' + prop.DocPropertyName + '" list-group no-radius m-b-none list-group-lg Ul-list"></ul>' +
- '<div class="Div_pagination row row mt-15">' +
- '<div class="col-sm-4" id="list_count"><span id="TotalRecords"class="text-muted">Total : <span id="lblItemTotalRecords" class="lblItemTotalRecords mr-30"></span></span>' +
- '</div><div class="col-sm-8">' +
- '<div id="divpagination" class="pagination custom-pagination pagination-rounded pull-right"></div></div></div>';
- $("#" + container).html(html);
- var Search = null;
- var instance = this;
- multiselectlist._instance.page = 0;
- $("#text_multiselectsearch").on("keyup", function () {
- var txt = $('#text_multiselectsearch').val();
- if (txt == '') {
- var value = $(this).val();
- Search = value;
- multiselectlist._instance.page = 0;
- let para = null;
- if (instance.parameters.find(x => x.formid == $("._bizgaze_popup_container:visible").find("#hf_FormId").val()) != null) {
- para = instance.parameters.find(x => x.formid == $("._bizgaze_popup_container:visible").find("#hf_FormId").val()).para;
- }
- Unibase.Forms.Controls.multiselectlist.Instance().LoadMultiSelectlist(prop.DocPropertyId, prop.DocPropertyName, value, 5, multiselectlist._instance.page, para, prop);
- }
- else {
- var value = $(this).val();
- let para = null;
- if (instance.parameters.find(x => x.formid == $("._bizgaze_popup_container:visible").find("#hf_FormId").val()) != null) {
- para = instance.parameters.find(x => x.formid == $("._bizgaze_popup_container:visible").find("#hf_FormId").val()).para;
- }
- Search = value;
- var res = Unibase.Forms.Controls.multiselectlist.Instance().LoadMultiSelectlist(prop.DocPropertyId, prop.DocPropertyName, value, 5, multiselectlist._instance.page, para, prop);
- var s;
- }
- });
- if ($(window).width() <= 800) {
- $("#" + container).find("#divpagination").addClass("font-11");
- $("#" + container).find("#list_count").addClass("mb-10");
- }
- }
- LoadMultiSelectlist(DocPropertyId, docPropertyName, value, rows, page, para, prop) {
- var instance = this;
- instance.loadMultSelectListWithParams(DocPropertyId, docPropertyName, value, rows, page, para, prop);
- }
- loadMultSelectListWithParams(DocPropertyId, docPropertyName, value, rows, page, Parameters, prop) {
- var instacnce = this;
- if (Parameters != null) {
- if (instacnce.parameters.find(x => x.formid == $("._bizgaze_popup_container:visible").find("#hf_FormId").val()) == null) {
- var obj = { formid: $("._bizgaze_popup_container:visible").find("#hf_FormId").val(), para: Parameters };
- instacnce.parameters.push(obj);
- }
- else {
- instacnce.parameters.find(x => x.formid == $("._bizgaze_popup_container:visible").find("#hf_FormId").val()).para = Parameters;
- }
- }
- if (DocPropertyId == 0 || DocPropertyId == "" || DocPropertyId == null || DocPropertyId == undefined) {
- DocPropertyId = $("#ul_" + docPropertyName).parents(".divCustomProperties").data('propertyid');
- }
- var ColumnName = "0";
- var Value = "0";
- if (Parameters != null && Parameters != "") {
- ColumnName = Parameters.map(function (item) { return item.ColumnName; }).toString();
- Value = Parameters.map(function (item) { return item.Value; }).toString();
- }
- var MultiSelectList = page;
- if (page < 1) {
- MultiSelectList = 0;
- }
- else {
- MultiSelectList = page;
- }
- if (value == undefined) {
- var text = $('#text_multiselectsearch').val();
- if (text != '') {
- value = text;
- }
- }
- if (value == "") {
- value = undefined;
- }
- var instance = this;
- var conjson = JSON.parse(prop.ControlJsonText);
- var formid = conjson.FormId;
- Unibase.Platform.Forms.Managers.FormManager.Instance().dynamicMultiSelectList(DocPropertyId, null, ColumnName, Value, value, rows, page, formid).then(function (response) {
- var ids = $("#hdnchk_" + docPropertyName).val();
- var data1 = JSON.stringify(response);
- var json = JSON.parse(prop.ControlJsonText);
- var IdColumn = json.AutoCompleteIdColumn;
- var TextColumn = json.AutoCompleteTextColumn;
- var data2 = JSON.parse(data1);
- if (data2 != "") {
- var data = JSON.parse(data2);
- var html = '';
- var Count = multiselectlist.Instance().count;
- for (var i = 0; i < data.length; i++) {
- var idcolumn = eval("data[i]." + IdColumn);
- var textcolumn = eval("data[i]." + TextColumn);
- html += '<li class="list-group-item pa-10 clear role-row added-row li_list ">' +
- '<div class="row"><div class="ml-20">';
- var a = multiselectlist.Instance().id.find(x => x == idcolumn) ? true : false;
- if (a == true) {
- html += '<input type="checkbox" class="id_column" value=' + idcolumn + ' id="chk_new_' + idcolumn + '" checked onclick="Unibase.Forms.Controls.multiselectlist.Instance().CheckBoxClick(' + "'" + textcolumn + "' ," + idcolumn + ',' + "'" + docPropertyName + "'" + ')"></div>';
- }
- else {
- html += '<input type="checkbox" class="id_column" value=' + idcolumn + ' id="chk_new_' + idcolumn + '" onclick="Unibase.Forms.Controls.multiselectlist.Instance().CheckBoxClick(' + "'" + textcolumn + "' ," + idcolumn + ',' + "'" + docPropertyName + "'" + ')"></div>';
- }
- html += '<div class="ml-40 text-left"><strong class="textcolumn">' + textcolumn + '</strong></div></div></li>';
- }
- $(".ul_" + docPropertyName).empty();
- $(".ul_" + docPropertyName).append(html);
- }
- else {
- $(".ul_" + docPropertyName).empty();
- $(".ul_" + docPropertyName).append("<span>No results found</span>");
- }
- var UserId = 0;
- var InstalledAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
- if (docPropertyName == "branchid" || docPropertyName == "roleid") {
- if (Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.length != 0) {
- UserId = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_userid").Value);
- }
- }
- if (docPropertyName == "branchid") {
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile('apps/crm/companies/managers/companymanager.js', function () {
- Bizgaze.Apps.CRM.Companies.Managers.CompanyManager.Instance().getUserBranches(UserId).then(function (response) {
- var remids = '';
- var ids = "";
- for (var i = 0; i < response.result.length; i++) {
- $("#ul_" + docPropertyName).find('.li_list').each(function () {
- if (response.result[i].BranchId == $(this).find(".id_column").val()) {
- $(this).find(".id_column").prop("checked", true);
- $(this).find(".id_column").addClass("IsSaved");
- }
- });
- }
- for (var j = 0; j < response.result.length; j++) {
- if (page == 0 && multiselectlist.Instance().Isrow == false) {
- ids += response.result[j].BranchId + "|";
- $("#hdnchkmulti_" + docPropertyName).val(ids);
- }
- }
- multiselectlist.Instance().Isrow = true;
- if (multiselectlist.Instance().iddel.length > 0) {
- for (var a = 0; a < multiselectlist.Instance().iddel.length; a++) {
- $("#ul_" + docPropertyName).find('.li_list').each(function () {
- if (multiselectlist.Instance().iddel[a] == $(this).find(".id_column").val()) {
- $(this).find(".id_column").prop("checked", false);
- $(this).find(".id_column").addClass("IsSaved");
- }
- });
- }
- }
- $("#hdnchkmultidel_branchid").val(remids);
- });
- });
- }
- else if (docPropertyName == "roleid") {
- UserId = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_userid").Value);
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile('platform/permission/managers/permissionmanager.js', function () {
- Unibase.Platform.Permissions.Managers.PermissionManager.Instance().getUserRoles(UserId).then(function (response) {
- var remids = '';
- var ids = "";
- for (var i = 0; i < response.result.length; i++) {
- $("#ul_" + docPropertyName).find('.li_list').each(function () {
- if (response.result[i].RoleId == $(this).find(".id_column").val()) {
- $(this).find(".id_column").prop("checked", true);
- $(this).find(".id_column").addClass("IsSaved");
- }
- });
- }
- for (var j = 0; j < response.result.length; j++) {
- if (page == 0 && multiselectlist.Instance().Isrow == false) {
- ids += response.result[j].RoleId + "|";
- $("#hdnchkmulti_" + docPropertyName).val(ids);
- }
- }
- multiselectlist.Instance().Isrow = true;
- if (multiselectlist.Instance().iddel.length > 0) {
- for (var a = 0; a < multiselectlist.Instance().iddel.length; a++) {
- $("#ul_" + docPropertyName).find('.li_list').each(function () {
- if (multiselectlist.Instance().iddel[a] == $(this).find(".id_column").val()) {
- $(this).find(".id_column").prop("checked", false);
- $(this).find(".id_column").addClass("IsSaved");
- }
- });
- }
- }
- $("#hdnchkmultidel_roleid").val(remids);
- });
- });
- }
- else if (docPropertyName == "planid") {
- var OfferId = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_offerid").Value);
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile('apps/transact/managers/offers/offermanager.js', function () {
- Bizgaze.Apps.Transact.Managers.OfferManager.Instance().getofferplans(OfferId).then(function (response) {
- var remids = '';
- $(".id_column").prop("checked", true);
- for (var i = 0; i < response.result.length; i++) {
- $("#ul_" + docPropertyName).find('.li_list').each(function () {
- if (response.result[i].StatusId == 2) {
- if (response.result[i].PlanId == Number($(this).find(".id_column").val())) {
- $(this).find(".id_column").prop("checked", false);
- }
- }
- });
- }
- $("#hdnchkmultidel_planid").val(remids);
- });
- });
- }
- if (data == undefined) {
- $(".Div_pagination").hide();
- }
- if (data.length <= 0) {
- $(".Div_pagination").hide();
- }
- else {
- $(".Div_pagination").show();
- var totalCount = data.length;
- var _page = MultiSelectList + 1;
- var st = 0;
- var _count = 0;
- var t = _page * 5;
- if (totalCount > 0) {
- st = 1;
- _count = totalCount;
- }
- if (totalCount > t)
- _count = t;
- if (MultiSelectList > 0) {
- st += t - 5;
- }
- var result = st + " - " + (st + (_count - 1)) + " of " + multiselectlist.Instance().count;
- var totalcount = multiselectlist.Instance().count;
- var ct = Count - 5;
- page = multiselectlist._instance.page + 1;
- if (Count <= 5) {
- $(".Div_pagination").hide();
- }
- $(".lblItemTotalRecords").text(result);
- var pageEle = $(".Div_pagination").find('#divpagination');
- instance.fileCacheHelper.loadJsFile('libs/jquery/pagination/jquery.pagination.js', function () {
- var ele;
- ele = $(".Div_pagination").find('#divpagination');
- ele.pagination(totalcount, 5, {
- current_page: MultiSelectList,
- callback: function (page, component) {
- MultiSelectList = page;
- var para = null;
- if (instance.parameters.find(x => x.formid == $("._bizgaze_popup_container:visible").find("#hf_FormId").val()) != null) {
- para = instance.parameters.find(x => x.formid == $("._bizgaze_popup_container:visible").find("#hf_FormId").val()).para;
- }
- Unibase.Forms.Controls.multiselectlist.Instance().LoadMultiSelectlist(DocPropertyId, docPropertyName, null, rows, page, para, prop);
- }
- });
- });
- }
- multiselectlist._instance.page = 0;
- });
- }
- loadControlSettings(controlsettingjson, formpropertyid) {
- var prop = controlsettingjson;
- Unibase.Forms.Controls.multiselectlist.Instance().LoadMultiSelectlist(prop.DocPropertyId, prop.DocPropertyName, null, 5, 0, null, prop);
- }
- loadPropertySettings(propertysettings, formpropertyid) {
- return ``;
- }
- bindEditFormDetails(formpropertyid, propval, DocPropertyName) {
- return ``;
- }
- CheckBoxClick(TextColumn, IdColumn, docPropertyName) {
- var ids;
- var ids1;
- ids = $("#hdnchkmulti_" + docPropertyName).val();
- ids1 = $("#hdnchkmultidel_" + docPropertyName).val();
- if (docPropertyName == "planid") {
- if ($("#chk_new_" + IdColumn).is(':checked')) {
- if (ids != 0 || ids == "") {
- ids += IdColumn + "|";
- }
- }
- else {
- if (ids != 0 || ids == "") {
- ids += IdColumn + "|";
- }
- }
- ;
- }
- else {
- if ($("#chk_new_" + IdColumn).is(':checked')) {
- if (ids != 0 || ids == "") {
- if ($("#chk_new_" + IdColumn).hasClass('IsSaved') == false) {
- ids += IdColumn + "|";
- }
- else {
- ids1 += IdColumn + "|";
- }
- }
- else {
- if ($("#chk_new_" + IdColumn).hasClass('IsSaved') == false) {
- ids = IdColumn + "|";
- }
- else {
- ids1 = IdColumn + "|";
- }
- }
- var ChckbxId = Unibase.Forms.Controls.multiselectlist.Instance().id.find(x => x == IdColumn) ? true : false;
- if (ChckbxId == false) {
- if ($("#chk_new_" + IdColumn).hasClass('IsSaved') == false) {
- multiselectlist.Instance().id.push(IdColumn);
- }
- }
- }
- else {
- var tg = ids.split('|');
- ids = "";
- for (var i = 0; i < tg.length; i++) {
- if (tg[i] != IdColumn && tg[i] != '') {
- ids += tg[i] + "|";
- }
- }
- if ($("#chk_new_" + IdColumn).hasClass('IsSaved') == false) {
- multiselectlist.Instance().id.splice(Unibase.Forms.Controls.multiselectlist.Instance().id.findIndex(p => p == IdColumn), 1);
- }
- var tg1 = ids1.split('|');
- ids1 = "";
- for (var i = 0; i < tg1.length; i++) {
- if (tg1[i] != IdColumn && tg1[i] != '') {
- ids1 += tg1[i] + "|";
- }
- }
- if ($("#chk_new_" + IdColumn).hasClass('IsSaved') == true) {
- multiselectlist.Instance().iddel.push(IdColumn);
- }
- $("#chk_new_" + IdColumn).removeClass('IsSaved');
- }
- }
- $("#hdnchkmulti_" + docPropertyName).val(ids);
- $("#hdnchkmultidel_" + docPropertyName).val(ids1);
- }
- static Instance() {
- if (this._instance === undefined)
- this._instance = new multiselectlist();
- return this._instance;
- }
- }
- Controls.multiselectlist = multiselectlist;
- })(Controls = Forms.Controls || (Forms.Controls = {}));
- })(Forms = Unibase.Forms || (Unibase.Forms = {}));
- })(Unibase || (Unibase = {}));
|