123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- 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 Apps;
- (function (Apps) {
- let Collaboration;
- (function (Collaboration) {
- let Controls;
- (function (Controls) {
- class UserSelect2 extends Unibase.Platform.Core.BaseComponent {
- constructor() {
- super(...arguments);
- this.data = [];
- }
- init(formpropertyid, prop, callback) {
- var instance = UserSelect2.Instance();
- var container = $(".select2_" + prop.FormPropertyId);
- Unibase.Apps.Collaboration.Controls.UserSelect2.Instance().loadControlSettings(container, null).then(function () {
- if (callback != null)
- callback();
- });
- }
- loadControl(containerid, prop) {
- var instance = this;
- var IsTagSelect = false;
- var text;
- debugger;
- if (prop.ControlJsonText != "" && prop.ControlJsonText != null && prop.ControlJsonText != undefined) {
- var text = JSON.parse(prop.ControlJsonText);
- if (text["IsTagSelect"] == true) {
- IsTagSelect = true;
- }
- }
- var html = '<div id="div_' + prop.DocPropertyName + '" class="floating-label-form-group-with-value floating-validate" style="border-bottom:0;"><label for= "lbl" id = "lbl_' + prop.DocPropertyName + '" >' + prop.LabelName + '<span class="text-danger hide " id="spnIsRequired_' + prop.DocPropertyName + '"> *</span></label >' +
- '<input type="hidden" id="hdnselect2_' + prop.FormPropertyId + '" class="" value="0">' +
- '<select id="select2_' + prop.FormPropertyId + '" class="value-control select2_' + prop.FormPropertyId + ' type-control select2_' + prop.DocPropertyName + ' form-control text-control " multiple="multiple" data-isdynamic="' + prop.IsDefault + '" data-istagselect="' + IsTagSelect + '" style="width:100%;" data-propdoctypename="' + prop.DocTypeName + '" data-propertyid="' + prop.DocPropertyId + '" data-propertyname="' + prop.DocPropertyName + '" data-formpropertyid="' + prop.FormPropertyId + '" data-regularexp="" data-validatemsg="" data-textformpropertyid=""><option>Select</option></select>' +
- '</div>';
- $("#" + containerid).html(html);
- }
- loadControlSettings(Container, Parameters) {
- return __awaiter(this, void 0, void 0, function* () {
- var ColumnName = "0";
- var Value = "0";
- var DocPropertyId = Container.data('propertyid');
- var DocPropertyName = Container.data('propertyname');
- var FormPropertyId = Container.data('formpropertyid');
- if (Parameters != null && Parameters != "") {
- ColumnName = Parameters.map(function (item) { return item.ColumnName; }).toString();
- Value = Parameters.map(function (item) { return item.Value + "|"; }).toString();
- }
- var userinfo = Unibase.Platform.Membership.Infos.Identity.getCurrentUser();
- var url = _appsettings.server_url() + '/apis/v4/unibase/platform/membership/getallusers';
- var data = UserSelect2.instance.data.find(x => x.formpropertyid == FormPropertyId);
- $(".select2_" + FormPropertyId).select2({
- tags: true,
- multiple: true,
- allowClear: false,
- data: UserSelect2.instance.data,
- placeholder: 'Select',
- ajax: {
- url: function (request) {
- var reqUrl = url;
- var term = request.term;
- if (term == undefined || term == "")
- reqUrl = reqUrl + "/term/" + term + "/authtoken/" + userinfo.sessionId;
- else
- reqUrl = reqUrl + "/term/" + term + "/authtoken/" + userinfo.sessionId;
- return reqUrl;
- },
- contentType: 'application/json',
- type: "GET",
- delay: 250,
- data: function (params) {
- var query = {
- term: params.term,
- type: 'GET'
- };
- return query;
- },
- beforeSend: function (xhr) {
- if (userinfo !== undefined && userinfo !== null) {
- xhr.setRequestHeader("Authorization", "Basic " + userinfo.sessionId);
- xhr.setRequestHeader('geoposition', userinfo.latd + ':' + userinfo.lgId);
- }
- },
- processResults: function (data, params) {
- return {
- results: jQuery.map(JSON.parse(data.result), function (item) {
- return {
- id: item.Value,
- text: item.DisplayText
- };
- })
- };
- }
- },
- templateResult: function (item) { debugger; return item.text; },
- templateSelection: function (item) { return item.text; },
- });
- });
- }
- loadPropertySettings(propertysettings, formpropertyid) {
- return ``;
- }
- bindEditFormDetails(formpropertyid, propval, DocPropertyName) {
- return ``;
- }
- static Instance() {
- if (this.instance === undefined) {
- this.instance = new UserSelect2();
- }
- return this.instance;
- }
- }
- Controls.UserSelect2 = UserSelect2;
- })(Controls = Collaboration.Controls || (Collaboration.Controls = {}));
- })(Collaboration = Apps.Collaboration || (Apps.Collaboration = {}));
- })(Apps = Unibase.Apps || (Unibase.Apps = {}));
- })(Unibase || (Unibase = {}));
|