Skip to content

Commit 356e831

Browse files
committed
hide all comments functionality
1 parent 2401ae6 commit 356e831

7 files changed

Lines changed: 283 additions & 92 deletions
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
quukRVQ3_05UlQ-_BHS8F5v-NapqcLjJRkM-znI6isiiUPoBuALbFi0EBUH5dzDuEI5IpOVjmsnq4YXXYEt9NUC4_6kas2CDek4qQZQrS8Y-nZ0BZPAS6ZYY1qdZfx4PeTys2irfag5SqMzbFon_zps346Kn06Jb7VaL5pvkp4NaJCskMCrh4lGLGpdhVZJXD58R22L-rYYraC2XxXGEyUsTd1fkN2mcNx1eSuRWyixEZxk67IGjT0uIrVixoJn7GrB5lWajK4Zx1qePycx1cmcSEWd10FjNNGlww8e-BhhW20LG1e5YwDTH7Vh1FgkKtE2_PJXF7Banjr545Uj4-rSZHHsAhzjxMeQu_7yOhayjgCaJELmmKz3aK4Fdo2kho7If5G_cy38ltEyBYs45AMEO9Am1ThvmTNpEROf6pYMW8X7ABbdhgPVkfy6-Ac2RIulFu1jjGpurZulzROMy-PGJ14dlvcKmQaWrVKzLX0m24-2ZEtW0O_hgT2EQD26ErsNlKYh0ZLEBeDXr1wFi8Pogry5Rz8C0pteTrYtB7BnIkI55kbdHAmkVmflUBaOkfUQ1JJikZO8HPh0sPLo_Aq1z1JyhZ6k9ClJYFaALBch41XKJJzDU24729-0_C6I2uAh-y1vj4QJWXMfcxOS3bdW9Evzu881pbvxT-k3S9AU
1+
xKdI2hRJtIJ9mGSdiohMHdxeUp0raPmpo2JDbcQCuzi6WG3F341uRwMm9YzUDu7ymUuHcbCX8e37SvrtIQ7-W-Qhv6qdXk99axn00BVEIplP73BjXWLSa-gBHC-vXHLeOXNaOcrmi3OG_yl0WzzpclJqQ-1K9LONmc15kFxN8vcCmTs1ssBYk0D5FbYctdOcLXeZ_wZtzqcaHs68CTlgVeaoqM1rcAS3hjkkezVRI7NEajeRTNrHVSza0Na6j6l_GMZ55ITdCRnSoWD7hLzO2agC1GU9lsh00fThiCSjT81Cx0lSkF2TuHVBnq5CL9wzw861AjLOnlhlLpOvd--Qva4rF4LRDaXNIuAXqjhJ0XgRcCEEGu80H82SgqyXTNNy5GMEIgpOJZO5M8lQ5NEozXj9bFRPrx8iTPN9OSQEecoBBhyD6MUsUj0wUvBNOeBjRt_l1FQ2apTtl-WvJUAWWl19roCBbzk6CEeoMemhElZoo-kDOtg7YjZIoddcd9NhV_L804PQx3d35xOQGUIwryOmwx2XvRiBY3MEpqeyMXxEnSm6u6blooSFCK_mZCNtvzn_QliUFUtIhQSz_Hh5SXAiVcL15mcOQvVTpUyXXZ3rlLhiEY-4W6eQcQRtgJ5OiuHLEgzAfq3f_ncvg11qku4NmhAGvctv6YBIt8xdf-w

ff61a00ac32a8610c9bcbe2bb00131da/dictionary/x_snc_ehd_servic_0_prompt.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?><database>
22
<element audit="true" db_object_id="1d107a66c3664a10c9bcbe2bb00131a0" extends="task" label="Prompt" max_length="40" name="x_snc_ehd_servic_0_prompt" type="collection">
3+
<element label="Hide comments" max_length="255" name="hide_comments" type="boolean"/>
34
<element label="Category" max_length="32" name="category" reference="x_snc_ehd_servic_0_category" type="reference"/>
45
<element default="0" label="Score" max_length="255" name="score" type="integer"/>
56
<element label="Prompt" max_length="2048" name="prompt" type="string"/>

ff61a00ac32a8610c9bcbe2bb00131da/update/sp_widget_0182c9d793ea0a10b653ffbd1dba10b1.xml

Lines changed: 48 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?><record_update table="sp_widget">
22
<sp_widget action="INSERT_OR_UPDATE">
33
<category>custom</category>
4-
<client_script><![CDATA[api.controller=function($uibModal, $scope, spUtil) {
4+
<client_script><![CDATA[api.controller=function($uibModal, $scope, spUtil, $uibModalStack) {
55
var c = this;
66
77
c.goToPrompt = function(sys_id){
@@ -59,12 +59,30 @@ For example: [INPUT YOUR NAME HERE]`;*/
5959
c.closeModal();
6060
});
6161
}
62+
63+
c.hideComments = function(prompt, event){
64+
if (event) event.stopPropagation();
65+
$scope.prompt = prompt;
66+
c.modalInstance = $uibModal.open({
67+
templateUrl: 'hideComments',
68+
scope: $scope,
69+
})
70+
}
71+
72+
c.hideCommentsConfirmed = function(prompt){
73+
c.data.hideAllComments = prompt;
74+
c.server.update().then(function(){
75+
$uibModalStack.dismissAll();
76+
c.data.hideAllComments = null;
77+
});
78+
}
6279
6380
c.addComment = function(prompt, event){
6481
if (event) event.stopPropagation();
6582
$scope.comments = prompt.comments;
6683
$scope.prompt = prompt.prompt;
6784
$scope.sys_id = prompt.sys_id;
85+
$scope.hideCommentsPrompt = prompt.hide_comments === 'true';
6886
c.modalInstance = $uibModal.open({
6987
templateUrl: 'commentModal',
7088
scope: $scope,
@@ -295,7 +313,7 @@ For example: [INPUT YOUR NAME HERE]`;*/
295313
//see all posts for this form
296314
297315
//configuration
298-
data.debug = false;
316+
data.debug = true;
299317
data.userId = gs.getUserID();
300318
data.isMod = gs.hasRole('x_snc_ehd_servic_0.moderator');
301319
data.thisUrl = gs.getProperty('glide.servlet.uri');
@@ -315,6 +333,7 @@ For example: [INPUT YOUR NAME HERE]`;*/
315333
'parent.number',
316334
'number',
317335
'sys_id',
336+
'hide_comments',
318337
];
319338
320339
//inputs
@@ -335,6 +354,14 @@ For example: [INPUT YOUR NAME HERE]`;*/
335354
deleteGr.update();
336355
}
337356
}
357+
358+
if (input?.hideAllComments){
359+
const hideCommentsGr = new GlideRecord('x_snc_ehd_servic_0_prompt');
360+
if (hideCommentsGr.get(input.hideAllComments)){
361+
hideCommentsGr.setValue('hide_comments', 'true');
362+
hideCommentsGr.update();
363+
}
364+
}
338365
339366
if (input?.voteClicked){
340367
const newVoteGr = new GlideRecord('x_snc_ehd_servic_0_vote');
@@ -538,14 +565,14 @@ For example: [INPUT YOUR NAME HERE]`;*/
538565
<sys_created_by>earl.duque</sys_created_by>
539566
<sys_created_on>2024-06-07 18:15:31</sys_created_on>
540567
<sys_id>0182c9d793ea0a10b653ffbd1dba10b1</sys_id>
541-
<sys_mod_count>625</sys_mod_count>
568+
<sys_mod_count>650</sys_mod_count>
542569
<sys_name>library</sys_name>
543570
<sys_package display_value="ServiceNow GenAI Prompt Library" source="x_snc_ehd_servic_0">ff61a00ac32a8610c9bcbe2bb00131da</sys_package>
544571
<sys_policy/>
545572
<sys_scope display_value="ServiceNow GenAI Prompt Library">ff61a00ac32a8610c9bcbe2bb00131da</sys_scope>
546573
<sys_update_name>sp_widget_0182c9d793ea0a10b653ffbd1dba10b1</sys_update_name>
547574
<sys_updated_by>earl.duque</sys_updated_by>
548-
<sys_updated_on>2024-06-26 19:11:49</sys_updated_on>
575+
<sys_updated_on>2024-06-27 16:59:01</sys_updated_on>
549576
<template><![CDATA[<div class="page-intro">
550577
<div ng-if="data.query || data.sort">
551578
<span class="icon-home home-button" ng-click="c.goHome()"> Go to Library home</span>
@@ -758,17 +785,17 @@ For example: [INPUT YOUR NAME HERE]`;*/
758785
</div>
759786
</script>
760787
761-
<!--script type="text/ng-template" id="deleteComment">
788+
<script type="text/ng-template" id="hideComments">
762789
<div class="panel panel-default">
763790
<div class="panel-heading">
764-
<h4 class="panel-title">Mods only: Delete comment?</h4>
791+
<h4 class="panel-title">Mods only: Hide comments?</h4>
765792
</div>
766793
<div class="panel-footer text-right">
767-
<button class="btn btn-primary" ng-click="c.deleteComment(comment)">${Delete}</button>
794+
<button class="btn btn-primary" ng-click="c.hideCommentsConfirmed(prompt)">${Hide all}</button>
768795
<button class="btn btn-info" ng-click="c.closeModal()">${Close}</button>
769796
</div>
770797
</div>
771-
</script-->
798+
</script>
772799
773800
<script type="text/ng-template" id="commentModal">
774801
<div class="panel panel-default">
@@ -778,23 +805,29 @@ For example: [INPUT YOUR NAME HERE]`;*/
778805
<div class="panel-body wrapper-xl">
779806
<div>
780807
{{prompt}}<br>
781-
<hr class="solid">
808+
<span class="icon-cross-circle" ng-click="c.hideComments(sys_id, $event)" ng-if="data.isMod === true && hideCommentsPrompt == false" style="float: right">
809+
Hide comments (Mod)
810+
</span>
811+
<hr class="solid">
812+
</div>
813+
<div ng-if="hideCommentsPrompt">
814+
Comments have been hidden by moderators<br>
782815
</div>
783-
<div ng-repeat="comment in comments">
816+
<div ng-if="comments.length == 0">
817+
Be the first to comment!<br><br>
818+
</div>
819+
<div ng-repeat="comment in comments" ng-if="!hideCommentsPrompt">
784820
<div>
785-
<!--span class="icon-cross-circle" ng-click="c.deleteCommentModal('', $event)" ng-if="data.isMod === true" style="float: right">
786-
Delete (Mod)
787-
</span-->
788821
{{comment[0]}}<br>
789822
{{comment[1]}}
790823
</div>
791824
<hr class="dashed">
792825
</div>
793-
<div class="form-group">
826+
<div class="form-group" ng-if="!hideCommentsPrompt">
794827
<label for="multiLineTextBox">Add a comment:</label>
795828
<textarea id="multiLineTextBox" class="form-control" rows="5" ng-model="userInput"></textarea>
796829
</div>
797-
<button class="btn btn-primary" ng-click="c.submitComment(sys_id, userInput)" ng-class="{disabled: !userInput}">Submit</button>
830+
<button class="btn btn-primary" ng-click="c.submitComment(sys_id, userInput)" ng-if="!hideCommentsPrompt" ng-class="{disabled: !userInput}">Submit</button>
798831
</div>
799832
<div class="panel-footer text-right">
800833
<button class="btn btn-primary" ng-click="c.closeModal()">${Close Comments}</button>

ff61a00ac32a8610c9bcbe2bb00131da/update/sp_widget_902d233bc336c610c9bcbe2bb00131a6.xml

Lines changed: 65 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,24 @@
4242
});
4343
}
4444
45+
c.hideComments = function(prompt, event){
46+
if (event) event.stopPropagation();
47+
$scope.prompt = prompt;
48+
c.modalInstance = $uibModal.open({
49+
templateUrl: 'hideComments',
50+
scope: $scope,
51+
})
52+
}
53+
54+
c.hideCommentsConfirmed = function(prompt){
55+
c.data.hideAllComments = prompt;
56+
c.server.update().then(function(){
57+
c.closeModal();
58+
$uibModalStack.dismissAll();
59+
c.data.hideAllComments = null;
60+
});
61+
}
62+
4563
c.submitComment = function (sys_id, userInput){
4664
c.data.newComment = {
4765
sys_id: sys_id,
@@ -284,6 +302,7 @@ For example: [INPUT YOUR NAME HERE]`;*/
284302
'parent.number',
285303
'number',
286304
'sys_id',
305+
'hide_comments',
287306
];
288307
289308
if (input?.newComment){
@@ -294,7 +313,7 @@ For example: [INPUT YOUR NAME HERE]`;*/
294313
}
295314
data.newComment = {};
296315
}
297-
316+
298317
if (input?.promptToDelete){
299318
const deleteGr = new GlideRecord('x_snc_ehd_servic_0_prompt');
300319
if (deleteGr.get(input.promptToDelete)){
@@ -303,6 +322,14 @@ For example: [INPUT YOUR NAME HERE]`;*/
303322
}
304323
}
305324
325+
if (input?.hideAllComments){
326+
const hideCommentsGr = new GlideRecord('x_snc_ehd_servic_0_prompt');
327+
if (hideCommentsGr.get(input.hideAllComments)){
328+
hideCommentsGr.setValue('hide_comments', 'true');
329+
hideCommentsGr.update();
330+
}
331+
}
332+
306333
if (input?.voteClicked){
307334
const newVoteGr = new GlideRecord('x_snc_ehd_servic_0_vote');
308335
newVoteGr.addQuery('prompt', input.voteClicked);
@@ -350,6 +377,7 @@ For example: [INPUT YOUR NAME HERE]`;*/
350377
351378
data.number = prompt.number;
352379
data.author = prompt['opened_by.name'];
380+
data.hide_comments = prompt.hide_comments === 'true';
353381
354382
//get parents
355383
prompt.parents = [];
@@ -410,14 +438,14 @@ For example: [INPUT YOUR NAME HERE]`;*/
410438
<sys_created_by>earl.duque</sys_created_by>
411439
<sys_created_on>2024-06-22 06:13:36</sys_created_on>
412440
<sys_id>902d233bc336c610c9bcbe2bb00131a6</sys_id>
413-
<sys_mod_count>85</sys_mod_count>
441+
<sys_mod_count>93</sys_mod_count>
414442
<sys_name>prompt</sys_name>
415443
<sys_package display_value="ServiceNow GenAI Prompt Library" source="x_snc_ehd_servic_0">ff61a00ac32a8610c9bcbe2bb00131da</sys_package>
416444
<sys_policy/>
417445
<sys_scope display_value="ServiceNow GenAI Prompt Library">ff61a00ac32a8610c9bcbe2bb00131da</sys_scope>
418446
<sys_update_name>sp_widget_902d233bc336c610c9bcbe2bb00131a6</sys_update_name>
419447
<sys_updated_by>earl.duque</sys_updated_by>
420-
<sys_updated_on>2024-06-26 19:09:52</sys_updated_on>
448+
<sys_updated_on>2024-06-27 16:58:46</sys_updated_on>
421449
<template><![CDATA[<div>
422450
<div class="page-intro">
423451
<div>
@@ -511,19 +539,27 @@ For example: [INPUT YOUR NAME HERE]`;*/
511539
</div>
512540
<div class="col-xs-12">
513541
<div class="section-block block-main">
514-
<div class="form-group">
515-
<label for="multiLineTextBox">Add a comment:</label>
516-
<textarea id="multiLineTextBox" class="form-control" rows="5" ng-model="data.userInput"></textarea>
517-
</div>
518-
<div class="prompt-button">
519-
<button class="btn btn-primary" ng-click="c.submitComment(data.sys_id, data.userInput)" ng-class="{disabled: !data.userInput}">Submit</button>
542+
<div ng-if="data.hide_comments">
543+
Comments have been hidden by moderators.
520544
</div>
521-
<div ng-repeat="comment in data.comments">
522-
<div>
523-
{{comment[0]}}<br>
524-
{{comment[1]}}
545+
<div ng-if="!data.hide_comments">
546+
<span class="icon-cross-circle" ng-click="c.hideComments(data.sys_id)" ng-if="data.isMod === true && data.hide_comments == false" style="float: right">
547+
Hide comments (Mod)
548+
</span>
549+
<div class="form-group">
550+
<label for="multiLineTextBox">Add a comment:</label>
551+
<textarea id="multiLineTextBox" class="form-control" rows="5" ng-model="data.userInput"></textarea>
552+
</div>
553+
<div class="prompt-button">
554+
<button class="btn btn-primary" ng-click="c.submitComment(data.sys_id, data.userInput)" ng-class="{disabled: !data.userInput}">Submit</button>
555+
</div>
556+
<div ng-repeat="comment in data.comments">
557+
<div>
558+
{{comment[0]}}<br>
559+
{{comment[1]}}
560+
</div>
561+
<hr class="dashed" ng-if="$index != data.comments.length-1">
525562
</div>
526-
<hr class="dashed" ng-if="$index != data.comments.length-1">
527563
</div>
528564
</div>
529565
</div>
@@ -565,8 +601,8 @@ For example: [INPUT YOUR NAME HERE]`;*/
565601
<li>S — Steps: Outline specific steps. (e.g., "Start with a user persona, describe the user's goal, list the tasks to achieve the goal, and define the acceptance criteria.")
566602
<li>E — End goal: State the goal and audience. (e.g., "Help team members understand how to write clear and effective agile stories.")
567603
<li>N — Narrowing: Add constraints. (e.g., "Max 800 words, avoid technical jargon, use practical examples.")
568-
</ul>
569-
</div>
604+
</ul>
605+
</div>
570606
</div>
571607
<div class="panel-footer text-right">
572608
<button class="btn btn-primary" ng-click="c.submitPrompt()" ng-class="{disabled: !data.newPromptText || !data.newPromptCategory || (data.oldPromptText == data.newPromptText)}">${Submit Prompt}</button>
@@ -613,7 +649,19 @@ For example: [INPUT YOUR NAME HERE]`;*/
613649
<button class="btn btn-primary" ng-click="c.deletePrompt(prompt)">${Delete}</button>
614650
<button class="btn btn-info" ng-click="c.closeModal()">${Close}</button>
615651
</div>
616-
</div>
652+
</div>
653+
</script>
654+
655+
<script type="text/ng-template" id="hideComments">
656+
<div class="panel panel-default">
657+
<div class="panel-heading">
658+
<h4 class="panel-title">Mods only: Hide comments?</h4>
659+
</div>
660+
<div class="panel-footer text-right">
661+
<button class="btn btn-primary" ng-click="c.hideCommentsConfirmed(prompt)">${Hide all}</button>
662+
<button class="btn btn-info" ng-click="c.closeModal()">${Close}</button>
663+
</div>
664+
</div>
617665
</script>]]></template>
618666
</sp_widget>
619667
</record_update>
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?xml version="1.0" encoding="UTF-8"?><record_update>
2+
<sys_dictionary action="INSERT_OR_UPDATE" element="hide_comments" table="x_snc_ehd_servic_0_prompt">
3+
<active>true</active>
4+
<array>false</array>
5+
<attributes/>
6+
<audit>false</audit>
7+
<calculation/>
8+
<choice>0</choice>
9+
<choice_field/>
10+
<choice_table/>
11+
<column_label>Hide comments</column_label>
12+
<comments/>
13+
<create_roles/>
14+
<default_value/>
15+
<defaultsort/>
16+
<delete_roles/>
17+
<dependent/>
18+
<dependent_on_field/>
19+
<display>false</display>
20+
<dynamic_creation>false</dynamic_creation>
21+
<dynamic_creation_script/>
22+
<dynamic_default_value/>
23+
<dynamic_ref_qual/>
24+
<element>hide_comments</element>
25+
<element_reference>false</element_reference>
26+
<foreign_database/>
27+
<formula/>
28+
<function_definition/>
29+
<function_field>false</function_field>
30+
<internal_type display_value="">boolean</internal_type>
31+
<mandatory>false</mandatory>
32+
<max_length>255</max_length>
33+
<name>x_snc_ehd_servic_0_prompt</name>
34+
<next_element/>
35+
<primary>false</primary>
36+
<read_only>false</read_only>
37+
<read_roles/>
38+
<reference/>
39+
<reference_cascade_rule/>
40+
<reference_floats>false</reference_floats>
41+
<reference_key/>
42+
<reference_qual/>
43+
<reference_qual_condition/>
44+
<reference_type/>
45+
<spell_check>false</spell_check>
46+
<staged>false</staged>
47+
<sys_class_name>sys_dictionary</sys_class_name>
48+
<sys_created_by>earl.duque</sys_created_by>
49+
<sys_created_on>2024-06-27 16:33:48</sys_created_on>
50+
<sys_name>Hide comments</sys_name>
51+
<sys_package display_value="ServiceNow GenAI Prompt Library" source="x_snc_ehd_servic_0">ff61a00ac32a8610c9bcbe2bb00131da</sys_package>
52+
<sys_policy/>
53+
<sys_scope display_value="ServiceNow GenAI Prompt Library">ff61a00ac32a8610c9bcbe2bb00131da</sys_scope>
54+
<sys_update_name>sys_dictionary_x_snc_ehd_servic_0_prompt_hide_comments</sys_update_name>
55+
<sys_updated_by>earl.duque</sys_updated_by>
56+
<sys_updated_on>2024-06-27 16:33:48</sys_updated_on>
57+
<table_reference>false</table_reference>
58+
<text_index>false</text_index>
59+
<unique>false</unique>
60+
<use_dependent_field>false</use_dependent_field>
61+
<use_dynamic_default>false</use_dynamic_default>
62+
<use_reference_qualifier>simple</use_reference_qualifier>
63+
<virtual>false</virtual>
64+
<virtual_type>script</virtual_type>
65+
<widget/>
66+
<write_roles/>
67+
<xml_view>false</xml_view>
68+
</sys_dictionary>
69+
</record_update>

0 commit comments

Comments
 (0)