Skip to content

Commit

Permalink
Merge pull request #974 from 3YOURMIND/970-force-internal-comments-in…
Browse files Browse the repository at this point in the history
…-kt-comment

feature(#970) : force internal comments for KtCommentInput (and KtComment)
  • Loading branch information
FlorianWendelborn authored Jul 24, 2024
2 parents 7f3c9cc + aec6e7b commit b8fe397
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
14 changes: 14 additions & 0 deletions packages/documentation/pages/usage/components/comment.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
:allowInternal="settings.allowInternal"
class="mb-block"
:dataTest="settings.dataTest"
:forceInternal="settings.forceInternal"
:isReadOnly="settings.isReadOnly"
:tabIndex="settings.tabIndex"
:userAvatar="currentUser.avatar"
Expand All @@ -30,6 +31,8 @@
<KtCommentInput
:allowInternal="settings.allowInternal"
:dataTest="settings.dataTest"
:forceInternal="settings.forceInternal"
:isInternal="settings.isInternal"
:placeholder="settings.placeholder"
:tabIndex="settings.tabIndex"
:userAvatar="currentUser.avatar"
Expand Down Expand Up @@ -63,6 +66,13 @@
label="allowInternal"
type="switch"
/>
<KtFieldToggle
formKey="forceInternal"
helpText="Force Internal Comments i.e. No public access (only meaningful if allowInternal is true)"
isOptional
label="forceInternal"
type="switch"
/>
<KtFieldToggle
formKey="isReadOnly"
helpText="Hides KtComment action buttons"
Expand Down Expand Up @@ -215,6 +225,7 @@
class="mb-block"
:dangerouslyOverrideParser="dangerouslyOverrideParser"
:dataTest="settings.dataTest"
:forceInternal="settings.forceInternal"
:isReadOnly="settings.isReadOnly"
:postEscapeParser="postEscapeParser"
:tabIndex="settings.tabIndex"
Expand All @@ -226,6 +237,7 @@
<KtCommentInput
:allowInternal="settings.allowInternal"
:dataTest="settings.dataTest"
:forceInternal="settings.forceInternal"
:placeholder="settings.placeholder"
:tabIndex="settings.tabIndex"
:userAvatar="currentUser.avatar"
Expand Down Expand Up @@ -340,13 +352,15 @@ export default defineComponent({
})
const settings = ref<{
allowInternal: Kotti.FieldToggle.Value
forceInternal: Kotti.FieldToggle.Value
dataTest: Kotti.FieldText.Value
isReadOnly: Kotti.FieldToggle.Value
locale: Kotti.I18n.SupportedLanguages
placeholder: Kotti.FieldText.Value
tabIndex: Kotti.FieldNumber.Value
}>({
allowInternal: true,
forceInternal: false,
dataTest: null,
isReadOnly: false,
locale: 'en-US',
Expand Down
8 changes: 7 additions & 1 deletion packages/kotti-ui/source/kotti-comment/KtComment.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@
/>
<KtCommentInput
v-if="userToReply"
v-bind="{ isInternal, placeholder, tabIndex, userAvatar }"
v-bind="{
forceInternal,
isInternal,
placeholder,
tabIndex,
userAvatar,
}"
autofocus
:dataTest="rootDataTest"
isReply
Expand Down
8 changes: 6 additions & 2 deletions packages/kotti-ui/source/kotti-comment/KtCommentInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,20 @@ export default defineComponent({
const payload: KottiComment.Events.Add = {
isInternal: localIsInternal.value,
message: localMessage.value,
replyToUserId: props.replyToUserId,
parentId: props.parentId,
replyToUserId: props.replyToUserId,
}
emit('add', payload)
localIsInternal.value = props.isInternal
localMessage.value = ''
},
onToggleInternal: () => (localIsInternal.value = !localIsInternal.value),
onToggleInternal: () => {
if (localIsInternal.value && props.allowInternal && props.forceInternal)
return
localIsInternal.value = !localIsInternal.value
},
}
},
})
Expand Down
2 changes: 2 additions & 0 deletions packages/kotti-ui/source/kotti-comment/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export module KottiComment {

const sharedSchema = commentSchema.extend({
allowInternal: z.boolean().default(false),
forceInternal: z.boolean().default(false),
dangerouslyOverrideParser: parseFunctionSchema.default(defaultParser),
isReadOnly: z.boolean().default(false),
postEscapeParser: parseFunctionSchema.default(defaultPostEscapeParser),
Expand Down Expand Up @@ -169,6 +170,7 @@ export module KottiCommentInput {
export const propsSchema = KottiComment.propsSchema
.pick({
allowInternal: true,
forceInternal: true,
dataTest: true,
isInternal: true,
tabIndex: true,
Expand Down

0 comments on commit b8fe397

Please sign in to comment.