-
Notifications
You must be signed in to change notification settings - Fork 474
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change-Id: I4e9c044bdaa6981515ed16032e55725ea81500b7
- Loading branch information
1 parent
8b028a2
commit c24650f
Showing
15 changed files
with
298 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright (C) 2024 Checkmk GmbH - License: GNU General Public License v2 | ||
# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and | ||
# conditions defined in the file COPYING, which is part of this source code package. | ||
from dataclasses import asdict | ||
|
||
from cmk.gui.form_specs.vue import shared_type_defs | ||
from cmk.gui.form_specs.vue.visitors.multiline_text import MultilineTextVisitor | ||
from cmk.gui.i18n import _ | ||
from cmk.gui.logged_in import user | ||
|
||
from ._type_defs import EmptyValue, Value | ||
|
||
|
||
class CommentTextAreaVisitor(MultilineTextVisitor): | ||
def _to_vue( | ||
self, raw_value: object, parsed_value: str | EmptyValue | ||
) -> tuple[shared_type_defs.CommentTextArea, Value]: | ||
multiline_text, value = super()._to_vue(raw_value, parsed_value) | ||
multiline_text_args = asdict(multiline_text) | ||
multiline_text_args["type"] = "comment_text_area" | ||
return ( | ||
shared_type_defs.CommentTextArea( | ||
**multiline_text_args, | ||
user_name=user.id or "", | ||
i18n=shared_type_defs.CommentTextAreaI18n( | ||
prefix_date_and_comment=_("Prefix date and your name to the comment") | ||
), | ||
), | ||
value, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
packages/cmk-frontend-vue/src/form/components/forms/FormCommentTextArea.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<script setup lang="ts"> | ||
import '@/assets/variables.css' | ||
import FormMultilineText from './FormMultilineText.vue' | ||
import type * as FormSpec from '@/form/components/vue_formspec_components' | ||
import { type ValidationMessages } from '@/form/components/utils/validation' | ||
const props = defineProps<{ | ||
spec: FormSpec.CommentTextArea | ||
backendValidation: ValidationMessages | ||
}>() | ||
const data = defineModel('data', { type: String, required: true }) | ||
const prependDateAndUsername = (): void => { | ||
const date = new Date() | ||
const formattedDate = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}` | ||
data.value = `${formattedDate} ${props.spec.user_name || ''}:\n${data.value}` | ||
} | ||
</script> | ||
<template> | ||
<div style="display: flex"> | ||
<FormMultilineText v-model:data="data" :backend-validation="backendValidation" :spec="spec" /> | ||
<img | ||
:alt="props.spec.i18n.prefix_date_and_comment" | ||
:title="props.spec.i18n.prefix_date_and_comment" | ||
:style="{ content: 'var(--icon-insertdate)', cursor: 'pointer' }" | ||
@click="prependDateAndUsername()" | ||
/> | ||
</div> | ||
</template> | ||
|
||
<style scoped> | ||
img { | ||
width: 20px; | ||
height: 20px; | ||
margin-left: 10px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.