Built files from Bizgaze WebServer
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

comments.js 43KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510
  1. var Unibase;
  2. (function (Unibase) {
  3. let Platform;
  4. (function (Platform) {
  5. let Automation;
  6. (function (Automation) {
  7. let Components;
  8. (function (Components) {
  9. class Comments extends Unibase.Platform.Core.BaseComponent {
  10. constructor() {
  11. super();
  12. this.commentcount = 0;
  13. }
  14. cssFiles() {
  15. return [""];
  16. }
  17. jsFiles() {
  18. return [""];
  19. }
  20. html(id, containerid) {
  21. let html = `<div class="card card-default shadow-none border-0 mb-0" id="Form_Comments">
  22. <div class="card-header card-header-action"><span id="WidgetTitle" class="biz-highlight-bg-color">Comments (<span class="comments_count">0</span>)</h4></div>
  23. <div class="card-body"><div class="row"><div class="col-sm-12"><div class="divComments" id="divComments"></div></div></div></div>
  24. </div>
  25. <div class="divallcomments comment-list block" id="admincomments">
  26. <div class="allcomment-block"></div>
  27. <div class="row"><div class="form-group col-sm-12 ml-lg-10"><a href="/#/welcome" id="btnrefreshComments" class="btn btn-default hidden btn-sm"><i class="fa fa-plus icon-muted"></i> more</a></div></div>
  28. </div>`;
  29. $("." + containerid).html(html);
  30. return "";
  31. }
  32. init(containerId) {
  33. var instance = this;
  34. instance.html("", containerId);
  35. var id = "";
  36. var InstalledAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
  37. instance.InstalledAppId = InstalledAppId;
  38. for (let obj of Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters) {
  39. if (obj.Key === "hf_" + InstalledAppId + "_recordid") {
  40. id = obj.Value;
  41. }
  42. }
  43. instance.load(id, containerId, null);
  44. }
  45. load(id, containerid, callback) {
  46. var instance = this;
  47. instance.currentuser = Unibase.Platform.Membership.Infos.Identity.currentUser;
  48. instance.showComments();
  49. }
  50. showComments() {
  51. var instance = this;
  52. $('.allComments_').remove();
  53. var commentshtml = '<div class="divComments panel-default mb-2" id="divComments_">' +
  54. '<div class="allComments_ allcomment-block bg-light"></div> <div id="divComment_items" class="comment-item_ mr-35">' +
  55. '<div class="input-group form-group"><input type="text" id="commentTextBox_0" class="form-control commentTextBox txtnewComment_ " placeholder="Type Comments here...." onchange="Unibase.Platform.Automation.Components.Comments.Instance().enableSendbtn(event,0)">' +
  56. '<a href="javascript:(0)" id="commentPostButton_0" class="list-group-anchor btn btn-sm py-1 border-bottom rounded-0 input-group-addon" onclick="Unibase.Platform.Automation.Components.Comments.Instance().saveComment();"><span class="btn-icon-wrap"><button class="btn btn-white fa fa-paper-plane-o p-0 text-disabled "></button></span></a></span></a>' +
  57. '</div></div></div>';
  58. $("#divComments").html(commentshtml);
  59. instance.loadComments();
  60. instance.addComments();
  61. }
  62. loadComments() {
  63. var instance = this;
  64. var InstalledAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
  65. var refGuid = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_versionguid").Value;
  66. var jsfiles = ['platform/automation/managers/commentmanager.js', 'platform/automation/infos/comment.js', 'platform/automation/requests/comment.js', 'platform/automation/enums/commenttype.js'];
  67. instance.fileCacheHelper.loadJsFiles(jsfiles, function () {
  68. Unibase.Platform.Automation.Managers.CommentManager.Instance().getMyCommentsByGuid(refGuid).then(function (response) {
  69. var CommentId = 0;
  70. var ParentCommentCount = 0;
  71. $('.commentsCount_').text(response.result.length);
  72. $('.comments_count').text(response.result.length);
  73. var html = "";
  74. $(".comment-addItem").remove();
  75. $(".comment-item_").remove();
  76. var commentClosed = true;
  77. let photoUrl = "";
  78. if (instance.currentUser.photoUrl != "" && instance.currentUser.photoUrl != null) {
  79. photoUrl = instance.currentUser.photoUrl;
  80. let srcSplit = photoUrl.split('/');
  81. if (srcSplit[srcSplit.length - 1] == 'unnamed.png') {
  82. photoUrl = "tenants/themes/compact/imgs/avatar.jpg";
  83. }
  84. }
  85. else {
  86. photoUrl = "tenants/themes/compact/imgs/avatar.jpg";
  87. }
  88. html += `<form><div id="divComment_items" class="mb-2 d-flex comment-item_">
  89. <div class="comment-right-wrapper m-0 d-flex align-items-center w-100 border-bottom border-light-50"><input type="text" id="commentTextBox_0" class="w-100 border-0 outline-0 commentTextBox txtnewComment_" placeholder="Type Comments here...." oninput="Unibase.Platform.Automation.Components.Comments.Instance().enableSendbtn(event,0)">
  90. <div class="comment-btn-wrapper" id="add-comment-btn">
  91. <a href="javascript:(0)" id="commentPostButton_0" class="list-group-anchor btn btn-icon btn-sm rounded" onclick="Unibase.Platform.Automation.Components.Comments.Instance().saveComment();"><span class="btn-icon-wrap"><button class="btn btn-white fa fa-paper-plane-o mt-5 p-0 text-disabled commentSendBtn"></button></span></a>
  92. </div></div></div></form>`;
  93. for (var i = 0; i < response.result.length; i++) {
  94. var model = response.result[i];
  95. var deletehtml = '';
  96. if (model.CreatedBy == instance.currentuser.userId) {
  97. deletehtml = '<div class="d-flex align-items-center"><span class="mr-10"><a href="javascript:(0)" onclick="Unibase.Platform.Automation.Components.Comments.Instance().deleteComment(' + model.CommentId + ', 0, 0, 0);"><span class="btn-icon-wrap"><i class="fa fa-trash-o text-danger font-16"> </i></span> </a>' +
  98. '</span></div>';
  99. }
  100. var CreatedByImage = " ";
  101. if (model.FromUserPhotoUrl == null || model.FromUserPhotoUrl == "") {
  102. if (model.ImageUrl == null) {
  103. let avatarTxt = "";
  104. let headingTxt = model.FromUserName;
  105. let matches = headingTxt.match(/\b(\w)/g);
  106. if (matches.length == 1) {
  107. avatarTxt = $.trim(headingTxt).substr(0, 2);
  108. }
  109. else {
  110. avatarTxt = matches.join('').slice(0, 2);
  111. }
  112. CreatedByImage = `<h5 class="biz-primary-text-color font-12">${avatarTxt}</h5>`;
  113. }
  114. else {
  115. CreatedByImage = `<img src="${model.ImageUrl}" data-dynamic="1" onerror="ReloadImage(event)" class="avatar-img img-fluid rounded-circle font-11" alt="img">`;
  116. }
  117. }
  118. else {
  119. CreatedByImage = model.FromUserPhotoUrl;
  120. let srcSplit = CreatedByImage.split('/');
  121. if (srcSplit[srcSplit.length - 1] == 'unnamed.png' || CreatedByImage == null || CreatedByImage == "") {
  122. let avatarTxt = "";
  123. let headingTxt = model.FromUserName;
  124. let matches = headingTxt.match(/\b(\w)/g);
  125. if (matches.length == 1) {
  126. avatarTxt = $.trim(headingTxt).substr(0, 2);
  127. }
  128. else {
  129. avatarTxt = matches.join('').slice(0, 2);
  130. }
  131. CreatedByImage = `<h5 class="biz-primary-text-color font-12">${avatarTxt}</h5>`;
  132. }
  133. else {
  134. CreatedByImage = `<img src="${model.FromUserPhotoUrl}" data-dynamic="1" onerror="ReloadImage(event)" class="avatar-img img-fluid rounded-circle font-11" alt="img">`;
  135. }
  136. }
  137. var attachImage = "";
  138. if (model.ImageUrl == null || model.ImageUrl == "")
  139. attachImage = '';
  140. else {
  141. attachImage = "<img src='" + model.ImageUrl + "' class='w-100 h-100'>";
  142. }
  143. var commentIcon = "";
  144. var commentName = "";
  145. var IsEvent = "";
  146. var bgcolor = "";
  147. var parentCount = `<span class="pr-1 toGetReplyCountByParentId${model.CommentId}">Replies</span>`;
  148. parentCount += `<span id="Reply_${model.CommentId}"> (${model.ParentCommentCount}) </span>`;
  149. if (model.ParentCommentCount == 0) {
  150. parentCount = `<span class="pr-1 toGetReplyCountByParentId${model.CommentId}">Reply</span>`;
  151. parentCount += `<span id="Reply_${model.CommentId}"></span>`;
  152. }
  153. if (model.CommentType == Unibase.Platform.Automation.Enums.CommentType.Comment) {
  154. }
  155. else if (model.CommentType == Unibase.Platform.Automation.Enums.CommentType.Call) {
  156. commentIcon = "fa fa-phone text-info";
  157. commentName = "Call";
  158. }
  159. else if (model.CommentType == Unibase.Platform.Automation.Enums.CommentType.Mail) {
  160. commentIcon = "fa fa-envelope-o text-info";
  161. commentName = "Mail";
  162. }
  163. else if (model.CommentType == Unibase.Platform.Automation.Enums.CommentType.Meeting) {
  164. commentIcon = "fa fa-users text-info ";
  165. commentName = "Meeting";
  166. }
  167. else if (model.CommentType == Unibase.Platform.Automation.Enums.CommentType.Follow) {
  168. commentIcon = "fa fa-flash text-info";
  169. commentName = "Event";
  170. IsEvent = "hidden";
  171. }
  172. if ($("#hfCommentids").val() != model.CommentId) {
  173. if ($("#hfCommentids").val() != "0")
  174. html += '</section></article></div>';
  175. $("#hfCommentids").val(model.CommentId);
  176. if (model.ParentCommentCount > 0) {
  177. html += '<div class="block allComments_ allcomment-block comment-addItem pt-1 d-none"><article id="comment-' + model.CommentId + '" class="comment-item clear">' +
  178. '<input type="hidden" id="hfAssignedFollowers_' + model.CommentId + '" value="' + model.AssignedFollowers + '" />' +
  179. '<section class="comment-body"><div class="comment-body-wrapper d-flex justify-content-between">' +
  180. '<div class="comment-user-img"><div class="avatar biz-detail-avatar biz-highlight-color" style="width: 25px !important;height: 25px !important;">' + CreatedByImage + '</div>' +
  181. '</span></div>' +
  182. '<div class="comment-details-wrapper ml-1" style="flex-grow:2"><div class="comment-user-details d-flex align-items-center justify-content-between flex-wrap w-100"><div class="comment-username d-flex align-items-center"><h6 class="font-14 biz-highlight-bg-color mr-5 commentusername_' + CommentId + '"> ' + model.FromUserName + '</h6></div><input type="hidden" id="hf_ParentCmtVersionGuid_' + model.CommentId + '" value="' + model.VersionGuid + '"/>';
  183. }
  184. else {
  185. html += '<div class="block allComments_ allcomment-block comment-addItem pt-1 d-none"><article id="comment-' + model.CommentId + '" class="comment-item clear">' +
  186. '<input type="hidden" id="hfAssignedFollowers_' + model.CommentId + '" value="' + model.AssignedFollowers + '" />' +
  187. '<section class="comment-body"><div class="comment-body-wrapper d-flex justify-content-between">' +
  188. '<div class="comment-user-img"><div class="avatar biz-detail-avatar biz-highlight-color" style="width: 25px !important;height: 25px !important;">' + CreatedByImage + '</div>' +
  189. '</span></div>' +
  190. '<div class="comment-details-wrapper ml-1" style="flex-grow:2"><div class="comment-user-details d-flex align-items-center justify-content-between flex-wrap w-100"><div class="comment-username d-flex align-items-center"><h6 class="font-14 biz-highlight-bg-color mr-5 commentusername_' + CommentId + '"> ' + model.FromUserName + '</h6></div><input type="hidden" id="hf_ParentCmtVersionGuid_' + model.CommentId + '" value="' + model.VersionGuid + '"/>';
  191. }
  192. if (model.IsSystemGenerated != true) {
  193. if (window.innerWidth <= 1198) {
  194. html += deletehtml + '</div>' +
  195. '<div class="comment-text mt-1 w-sm-95 mb-5 text-dark font-11 word-break"><span>' + model.CommentSubject + ' </span></div>';
  196. }
  197. else {
  198. html += deletehtml + '</div>' +
  199. '<div class="comment-text mt-1 w-sm-95 mb-5 text-dark font-14 word-break"><span>' + model.CommentSubject + ' </span></div>';
  200. }
  201. }
  202. }
  203. html += '<div class="stats_container d-flex align-items-center mb-2 justify-content-between"><div class="comment-reply-wrapper"><span><a href="/#/welcome" class="list-group-anchor" onclick="Unibase.Platform.Automation.Components.Comments.Instance().details(' + model.CommentId + ');"><i class="' + commentIcon + '"></i> ' + commentName + '</a></span>';
  204. if (model.IsSystemGenerated != true) {
  205. if (window.innerWidth <= 1198) {
  206. html += '<span class="panel-default"><a href="/#/welcome" data-parent="divcomment 4" class="list-group-anchor text-dark d-flex mr-3 font-11 list-item-main-title" onclick="Unibase.Platform.Automation.Components.Comments.Instance().childComments(' + model.CommentId + ');"> ' + parentCount + '</a>' +
  207. '</span></div> <span class="comment-time font-11 text-dark">' + Unibase.Platform.Helpers.DateTimeHelper.Instance().commentsdateformat(model.CreatedDate) + '</span></div>' +
  208. ' <div class="bg-white hidden" id = "comments-' + model.CommentId + '" > ' +
  209. '<div id="childcomment-list_' + model.CommentId + '" class="childcomment-list_' + model.CommentId + '"></div>' +
  210. '</div></div></div></section></article></div>';
  211. }
  212. else {
  213. html += '<span class="panel-default"><a href="/#/welcome" data-parent="divcomment 4" class="list-group-anchor text-dark d-flex mr-3 font-12 list-item-main-title" onclick="Unibase.Platform.Automation.Components.Comments.Instance().childComments(' + model.CommentId + ');"> ' + parentCount + '</a>' +
  214. '</span></div> <span class="comment-time font-12 text-dark">' + Unibase.Platform.Helpers.DateTimeHelper.Instance().commentsdateformat(model.CreatedDate) + '</span></div>' +
  215. ' <div class="bg-white hidden" id = "comments-' + model.CommentId + '" > ' +
  216. '<div id="childcomment-list_' + model.CommentId + '" class="childcomment-list_' + model.CommentId + '"></div>' +
  217. '</div></div></div></section></article></div>';
  218. }
  219. }
  220. CommentId = model.CommentId;
  221. ParentCommentCount = model.ParentCommentCount;
  222. }
  223. $('.allComments_').after(html);
  224. let size_li = $("#divComments_ .comment-addItem").length;
  225. if (size_li >= 5) {
  226. $('#loadMore-Comments').removeClass("d-none");
  227. }
  228. else {
  229. $('#loadMore-Comments').addClass("d-none");
  230. }
  231. instance.commentcount = 5;
  232. $('#divComments_ .comment-addItem:lt(' + instance.commentcount + ')').removeClass("d-none");
  233. $('#loadMore-Comments').click(function () {
  234. instance.commentcount = (instance.commentcount + 5 <= size_li) ? instance.commentcount + 5 : size_li;
  235. $('#divComments_ .comment-addItem:lt(' + instance.commentcount + ')').removeClass("d-none");
  236. debugger;
  237. if (instance.commentcount == size_li) {
  238. $('#loadMore-Comments').addClass("d-none");
  239. instance.commentcount = 0;
  240. }
  241. });
  242. instance.toGetReplyCountByParentId(CommentId, ParentCommentCount);
  243. }, function (response) {
  244. });
  245. });
  246. }
  247. addComments() {
  248. var html = "";
  249. $('#divComments_').append(html);
  250. $('#divComments_').append(`<div class="d-flex align-items-center justify-content-center click-more-btn"><div id="loadMore-Comments" class="btn btn-sm btn-success d-none">More</div></div>`);
  251. }
  252. toGetReplyCountByParentId(Id, Count) {
  253. var ParentId = Id;
  254. var ParentCommentCount = Count;
  255. if (ParentId != 0) {
  256. Unibase.Platform.Automation.Managers.CommentManager.Instance().getCommentsByParentId(ParentId).then(function (response) {
  257. for (var i = 0; i < response.result.length; i++) {
  258. ParentCommentCount = ParentCommentCount + response.result[i].ParentCommentCount;
  259. if (ParentCommentCount != 0) {
  260. $('.toGetReplyCountByParentId' + ParentId).text('Replies');
  261. $('#Reply_' + ParentId).text(`(${ParentCommentCount})`);
  262. }
  263. else {
  264. $('.toGetReplyCountByParentId' + ParentId).text('Reply');
  265. $('#Reply_' + ParentId).text(``);
  266. }
  267. }
  268. });
  269. }
  270. }
  271. saveComment() {
  272. var instance = this;
  273. let size_li = $("#divComments_ .comment-addItem").length;
  274. if (size_li >= 5) {
  275. $('#loadMore-Comments').removeClass("d-none");
  276. }
  277. if ($('.txtnewComment_').val().toString().trim() == null || $('.txtnewComment_').val().toString().trim() == "") {
  278. MessageHelper.Instance().showError("Please Enter Something...", "div_message");
  279. return false;
  280. }
  281. var InstalledAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
  282. var refGuid = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_versionguid").Value;
  283. var postData = {
  284. CommentId: 0,
  285. RefGuid: refGuid,
  286. CommentSubject: $(".txtnewComment_").val().toString().trim(),
  287. CommentType: Unibase.Platform.Automation.Enums.CommentType.Comment,
  288. Followers: null,
  289. InstallPageId: Unibase.Themes.Providers.DetailHelper.installedAppId,
  290. ParentId: 0
  291. };
  292. Unibase.Platform.Automation.Managers.CommentManager.Instance().saveComment(postData).then(function (response) {
  293. var CommentId = response.result.CommentId;
  294. $(".txtnewComment_").val(" ");
  295. $("#Notifications_txtActivities").val(' ');
  296. $("#childcomment-list_" + CommentId).html(' ');
  297. instance.loadComments();
  298. instance.childComments(CommentId, undefined, true);
  299. });
  300. }
  301. childComments(commentId, parentid, fromsendbtn) {
  302. Unibase.Platform.Automation.Managers.CommentManager.Instance().getCommentsByParentId(commentId).then(function (response) {
  303. if (parentid == undefined) {
  304. var html = '<div class="wrapper-sm childcomment-item_' + commentId + '">' +
  305. '<form><div class="d-flex border-bottom border-light-50 bg-white w-85 ">' +
  306. '<input type="text" id="commentTextBox_' + commentId + '" class="w-100 border-0 outline-0 commentTextBox txtnewComment_' + commentId + '" placeholder="Type Comments here...." oninput="Unibase.Platform.Automation.Components.Comments.Instance().enableSendbtn(event,' + commentId + ')">' +
  307. '<div class="comment-btn-wrapper mb-1">' +
  308. '<a href="/#/welcome" id="commentPostButton_' + commentId + '"class="list-group-anchor btn btn-icon btn-xs rounded" onclick="Unibase.Platform.Automation.Components.Comments.Instance().addChildCommentsforChildComments(' + commentId + ',' + commentId + ',true);"><span class="btn-icon-wrap"><button class="btn btn-white fa fa-paper-plane-o mt-5 p-0 text-disabled commentSendBtn"></button></span></a></span></div>' +
  309. '</div></form>' +
  310. '</div>';
  311. }
  312. else {
  313. if (!fromsendbtn || fromsendbtn && $('.childcomment-item_' + commentId + '').hasClass('ml-35')) {
  314. var html = '<div class="ml-35 childcomment-item wrapper-sm childcomment-item_' + commentId + '">';
  315. }
  316. else if (fromsendbtn && !$('.childcomment-item_' + commentId + '').hasClass('ml-35')) {
  317. var html = '<div class="childcomment-item wrapper-sm childcomment-item_' + commentId + '">';
  318. }
  319. html += '<form><div class="d-flex border-bottom border-light-50 bg-white w-85 ml-35">' +
  320. '<input type="text" id="commentTextBox_' + commentId + '" class="w-100 border-0 outline-0 commentTextBox txtnewComment_' + commentId + '" placeholder="Type Comments here...." oninput="Unibase.Platform.Automation.Components.Comments.Instance().enableSendbtn(event,' + commentId + ')">' +
  321. '<div class="comment-btn-wrapper mb-1">' +
  322. '<a href="/#/welcome" id="commentPostButton_' + commentId + '"class="btn btn-icon btn-xs rounded" onclick=" Unibase.Platform.Automation.Components.Comments.Instance().addChildCommentsforChildComments(' + commentId + ',' + parentid + ',true);"><span class="btn-icon-wrap"><button class="btn btn-white fa fa-paper-plane-o mt-5 p-0 text-disabled commentSendBtn"></button></span></a></span></div>' +
  323. '</div></form>' +
  324. '</div>';
  325. }
  326. if (response.result != null)
  327. for (var i = response.result.length - 1; i >= 0; i--) {
  328. var model = response.result[i];
  329. var parentCount = `<span class="pr-1 toGetReplyCountByParentId${model.CommentId}">Replies</span>`;
  330. parentCount += `<span id="Reply_${model.CommentId}"> (${model.ParentCommentCount}) </span>`;
  331. if (model.ParentCommentCount == 0) {
  332. parentCount = `<span class="pr-1 toGetReplyCountByParentId${model.CommentId}">Reply</span>`;
  333. parentCount += `<span id="Reply_${model.CommentId}"></span>`;
  334. }
  335. var commentIcon = "";
  336. var bgcolor = "";
  337. var CommImage = "";
  338. if (model.FromUserPhotoUrl == null || model.FromUserPhotoUrl == "") {
  339. let avatarTxt = "";
  340. let headingTxt = model.FromUserName;
  341. let matches = headingTxt.match(/\b(\w)/g);
  342. if (matches.length == 1) {
  343. avatarTxt = $.trim(headingTxt).substr(0, 2);
  344. }
  345. else {
  346. avatarTxt = matches.join('').slice(0, 2);
  347. }
  348. CommImage = `<h5 class="biz-primary-text-color font-12">${avatarTxt}</h5>`;
  349. }
  350. else {
  351. let imgsrc = model.FromUserPhotoUrl;
  352. let srcSplit = imgsrc.split('/');
  353. if (srcSplit[srcSplit.length - 1] == 'unnamed.png') {
  354. let avatarTxt = "";
  355. let headingTxt = model.FromUserName;
  356. let matches = headingTxt.match(/\b(\w)/g);
  357. if (matches.length == 1) {
  358. avatarTxt = $.trim(headingTxt).substr(0, 2);
  359. }
  360. else {
  361. avatarTxt = matches.join('').slice(0, 2);
  362. }
  363. CommImage = `<h5 class="biz-primary-text-color font-12">${avatarTxt}</h5>`;
  364. }
  365. else {
  366. CommImage = `<img src="${model.FromUserPhotoUrl}" data-dynamic="1" onerror="ReloadImage(event)" class="avatar-img img-fluid rounded-circle font-11" alt="img">`;
  367. }
  368. }
  369. var deletehtml = '';
  370. if (model.CreatedBy == Unibase.Platform.Automation.Components.Comments.Instance().currentuser.userId) {
  371. deletehtml = '<div class="d-flex align-items-center"> <span class="mr-10"><a href="/#/welcome" onclick="Unibase.Platform.Automation.Components.Comments.Instance().deleteComment(' + model.CommentId + ',' + commentId + ',' + parentid + ',1);"> <span class="btn-icon-wrap"> <i class="fa fa-trash-o text-danger font-16"> </i></span> </a>' +
  372. '</span></div>';
  373. }
  374. bgcolor = "text-warning";
  375. $("#hfAssignedFollowers").val(model.AssignedFollowers);
  376. if (window.innerWidth <= 1198) {
  377. var innerhtml = '<div class="wrapper-sm mt-10 childcomment-item_' + commentId + '">' +
  378. '<section class="comment-body"><div class="comment-body-wrapper d-flex justify-content-between">' +
  379. '<div class="comment-user-img"><div class="avatar biz-detail-avatar biz-highlight-color" style="width: 25px !important;height: 25px !important;">' + CommImage + '</div></div>' +
  380. '<div class="comment-details-wrapper ml-1" style="flex-grow:2"><div class="comment-user-details"><div class="comment-username"><div class="d-flex align-items-center justify-content-between"><h6 class="font-12 biz-highlight-bg-color mr-5 commentusername_' + commentId + '">' + model.FromUserName + '</h6>' + deletehtml + '</div><div class="comment-text mt-1 w-sm-80 mb-5 text-dark font-11"><span>' + model.CommentSubject + '</span></div><div class="commentChild-statsContainer d-flex align-items-center text-dark justify-content-end flex-row-reverse"> ' +
  381. '<div class="comment-extra-details">' +
  382. '<span class="comment-time font-11 1"> ' + Unibase.Platform.Helpers.DateTimeHelper.Instance().commentsdateformat(model.CreatedDate) + '</span>' +
  383. '</div>';
  384. }
  385. else {
  386. var innerhtml = '<div class="wrapper-sm mt-10 childcomment-item_' + commentId + '">' +
  387. '<section class="comment-body"><div class="comment-body-wrapper d-flex justify-content-between">' +
  388. '<div class="comment-user-img"><div class="avatar biz-detail-avatar biz-highlight-color" style="width: 25px !important;height: 25px !important;">' + CommImage + '</div></div>' +
  389. '<div class="comment-details-wrapper ml-1" style="flex-grow:2"><div class="comment-user-details"><div class="comment-username"><div class="d-flex align-items-center justify-content-between"><h6 class="font-14 biz-highlight-bg-color mr-5 commentusername_' + commentId + '">' + model.FromUserName + '</h6>' + deletehtml + '</div><div class="comment-text mt-1 w-sm-80 mb-5 text-dark font-14"><span>' + model.CommentSubject + '</span></div><div class="commentChild-statsContainer d-flex align-items-center text-dark justify-content-end flex-row-reverse"> ' +
  390. '<div class="comment-extra-details">' +
  391. '<span class="comment-time font-12 1"> ' + Unibase.Platform.Helpers.DateTimeHelper.Instance().commentsdateformat(model.CreatedDate) + '</span>' +
  392. '</div>';
  393. }
  394. if (parentid == undefined) {
  395. innerhtml += '<div class="comment-reply-wrapper mr-3"><span class="panel-default"><a href="/#/welcome" data-parent="divcomment" class="list-group-anchor text-dark d-flex p-0 font-12 list-item-main-title repli_data" onclick=" Unibase.Platform.Automation.Components.Comments.Instance().childComments(' + model.CommentId + ',' + commentId + ');"> ' + parentCount + '</a>' +
  396. '</span></div>' +
  397. '</div> </div></section><div class="bg-white hidden" id = "comments-' + model.CommentId + '" > ' +
  398. '<div id="childcomment-list_' + model.CommentId + '" class="childcomment-list_' + model.CommentId + '"></div>' +
  399. '</div></</div>';
  400. }
  401. else {
  402. innerhtml += '<div class="comment-reply-wrapper mr-3"><span class="panel-default"><a href="/#/welcome" data-parent="divcomment" class="p-0 list-group-anchor text-dark d-flex pl-0 font-12 list-item-main-title repli_data" onclick=" Unibase.Platform.Automation.Components.Comments.Instance().childComments(' + model.CommentId + ',' + parentid + ')"> ' + parentCount + '</a>' +
  403. '</span></div>' +
  404. '</div> </div></section><div class="bg-white hidden" id = "comments-' + model.CommentId + '" > ' +
  405. '<div id="childcomment-list_' + model.CommentId + '" class="childcomment-list_' + model.CommentId + '"></div>' +
  406. '</div></</div>';
  407. }
  408. html = html + innerhtml;
  409. }
  410. if (fromsendbtn != true) {
  411. if ($('#comments-' + commentId).hasClass('hidden')) {
  412. $('#comments-' + commentId).removeClass('hidden').addClass('show');
  413. }
  414. else {
  415. $('#comments-' + commentId).removeClass('show').addClass('hidden');
  416. }
  417. }
  418. $("#childcomment-list_" + commentId).html(html);
  419. let userName;
  420. if ($('.toGetReplyCountByParentId' + commentId).parents('.stats_container').length > 0) {
  421. userName = $('.toGetReplyCountByParentId' + commentId).parents('.stats_container').siblings('.comment-user-details').find('.comment-username h6').text().trim();
  422. }
  423. else if ($('.toGetReplyCountByParentId' + commentId).parents('.comment-username').length > 0) {
  424. userName = $('.toGetReplyCountByParentId' + commentId).parents('.comment-username').find('h6').text().trim();
  425. }
  426. $('.txtnewComment_' + commentId).val('@' + userName + ' ');
  427. });
  428. }
  429. addChildCommentsforChildComments(commentId, parentid, fromsendbtn) {
  430. var instance = this;
  431. if ($('.txtnewComment_' + commentId).val() == null || $('.txtnewComment_' + commentId).val() == "") {
  432. MessageHelper.Instance().showError("Please Enter Something...", "bizgaze_SpiltErrorMessages");
  433. return false;
  434. }
  435. var assgflwrs = null;
  436. if ($('#hfAssignedFollowers_' + commentId).val() != null) {
  437. assgflwrs = $('#hfAssignedFollowers_' + commentId).val();
  438. }
  439. var postData = {
  440. CommentId: 0,
  441. RefGuid: $('#hf_ParentCmtVersionGuid_' + parentid).val().toString(),
  442. CommentSubject: $(".txtnewComment_" + commentId).val().toString(),
  443. CommentType: Unibase.Platform.Automation.Enums.CommentType.Comment,
  444. Followers: assgflwrs,
  445. InstallPageId: $("#hfBizgaze_InstalledPageId").val(),
  446. ParentId: commentId,
  447. };
  448. Unibase.Platform.Automation.Managers.CommentManager.Instance().saveComment(postData).then(function (response) {
  449. $(".txtnewComment_" + commentId).val(" ");
  450. instance.childComments(commentId, parentid, fromsendbtn);
  451. instance.toGetReplyCount(commentId, parentid);
  452. });
  453. }
  454. deleteComment(commentId, parentCommentId, SuperParentCmtId, IsChild) {
  455. var instance = this;
  456. bootbox.confirm("Are you sure want to delete?", function (result) {
  457. if (result) {
  458. Unibase.Platform.Automation.Managers.CommentManager.Instance().deleteComment(commentId).then(function (response) {
  459. MessageHelper.Instance().showSuccess(response.message, '');
  460. if (IsChild == 0) {
  461. instance.loadComments();
  462. }
  463. else {
  464. instance.childComments(parentCommentId, SuperParentCmtId, true);
  465. }
  466. instance.toGetReplyCount(parentCommentId);
  467. });
  468. }
  469. });
  470. }
  471. toGetReplyCount(Id, parentId) {
  472. var CommentId = Id;
  473. var ParentCommentCount = 0;
  474. if (CommentId != 0) {
  475. Unibase.Platform.Automation.Managers.CommentManager.Instance().getCommentByCommentId(CommentId).then(function (response) {
  476. ParentCommentCount = ParentCommentCount + response.result.ParentCommentCount;
  477. if (ParentCommentCount != 0) {
  478. $('.toGetReplyCountByParentId' + CommentId).text('Replies');
  479. $('#Reply_' + CommentId).text(`(${ParentCommentCount})`);
  480. }
  481. else {
  482. $('.toGetReplyCountByParentId' + CommentId).text('Reply');
  483. $('#Reply_' + CommentId).text(``);
  484. }
  485. CommentId = response.result.ParentId;
  486. });
  487. }
  488. }
  489. enableSendbtn(e, id) {
  490. let input = $('#commentTextBox_' + id);
  491. let btn = $('#commentPostButton_' + id).find('.commentSendBtn');
  492. if (input.val().length > 0) {
  493. btn.removeClass('text-disabled').addClass('text-primary');
  494. }
  495. else {
  496. btn.removeClass('text-primary').addClass('text-disabled');
  497. }
  498. }
  499. static Instance() {
  500. if (this.instance == undefined) {
  501. this.instance = new Comments();
  502. }
  503. return this.instance;
  504. }
  505. }
  506. Components.Comments = Comments;
  507. })(Components = Automation.Components || (Automation.Components = {}));
  508. })(Automation = Platform.Automation || (Platform.Automation = {}));
  509. })(Platform = Unibase.Platform || (Unibase.Platform = {}));
  510. })(Unibase || (Unibase = {}));