Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions app/javascript/vue/repository/modals/text_cell.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<textarea v-model="textValue" ref="input" class="sci-input-field w-full "></textarea>
</div>
<div v-else ref="textContainer" class="[&_.atwho-user-container]:!whitespace-normal whitespace-pre-wrap">
<span v-html="textValue"></span>
<span v-html="viewValue"></span>
</div>
</div>
<div class="modal-footer">
Expand All @@ -38,10 +38,12 @@ export default {
row: Object
},
data: () => ({
textValue: ''
textValue: '',
viewValue: ''
}),
mounted() {
this.textValue = this.row[this.colDef.field]?.value?.edit || '';
this.viewValue = this.row[this.colDef.field]?.value?.view || '';

this.$nextTick(() => {
if (this.$refs.textContainer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
<div class="group relative flex items-center group-hover:marker text-xs h-full w-full leading-[unset]">
<div ref="descripitonBox" class="flex gap-2 w-full items-center text-sm leading-[unset]">
<span v-if="textValue && textValue.length > 0" class="cursor-pointer line-clamp-1 leading-[unset]"
@click.stop="showTextCellModal">
{{ textValue}}
@click.stop="showTextCellModal" v-html="textValue">

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really want to always use v-html?

</span>
<span v-if="textValue && textValue.length > 0"
@click.stop="showTextCellModal"
Expand Down Expand Up @@ -34,14 +33,15 @@ export default {
},
computed: {
textValue() {
return this.params?.value?.value?.edit || '';
return this.params?.value?.value?.view || '';
},
canManage() {
return this.params?.data?.permissions?.manage || false;
}
},
methods: {
showTextCellModal() {
if (event.target.closest('a')) return; // do not open modal if value is a link

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it is really reliable way to check that

this.params.dtComponent.$emit('showTextCell', null, [this.params.data], this.params.colDef);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
</div>
<div v-if="canEdit || colVal?.edit.length > 0" class="w-full contents">
<text-area :initialValue="colVal?.edit"
:viewValue="colVal?.view"
:noContentPlaceholder="i18n.t('repositories.item_card.repository_text_value.placeholder')"
:placeholder="i18n.t('repositories.item_card.repository_text_value.placeholder')"
:unEditableRef="`textRef`"
Expand Down
5 changes: 4 additions & 1 deletion app/javascript/vue/shared/legacy/Textarea.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
'text-sn-dark-grey': value, 'text-sn-grey': !value
}"
@click="enableEdit">
<span>{{ value || noContentPlaceholder }}</span>
<span v-if="viewValue" v-html="viewValue"></span>
<span v-else>{{ value || noContentPlaceholder }}</span>
</div>
</template>

Expand All @@ -41,6 +42,7 @@ export default {
expandable: { type: Boolean, required: true },
collapsed: { type: Boolean, required: true },
initialValue: String,
viewValue: { type: String, default: null },
noContentPlaceholder: String,
placeholder: String,
canEdit: { type: Boolean, default: false },
Expand Down Expand Up @@ -114,6 +116,7 @@ export default {
enableEdit(e) {
if (!this.canEdit) return;

if (e && e.target.closest('a')) return;
if (e && $(e.target).hasClass('atwho-user-popover')) return;
if (e && $(e.target).hasClass('sa-name')) return;
if (e && $(e.target).hasClass('sa-link')) return;
Expand Down