Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Convert DpTableHeader.vue to a template #205

Merged
merged 24 commits into from
May 15, 2023

Conversation

elmasdemos
Copy link
Contributor

@elmasdemos elmasdemos commented May 5, 2023

Ticket:: https://yaits.demos-deutschland.de/T19784

Description:

  • convert functional component DpTableHeader.vue into a template
  • convert ResizableColumns.js to a vue file and template
  • fix the error e.getBoundingClientRect() is not a function which is caused of the changes (see commit message and comment on code for the fix)

@elmasdemos elmasdemos self-assigned this May 5, 2023
…sizableColumns component

there was an error about e.getBoundingClientRect()
this error exists because the dom structure of the component DpTableHeader changed
so that there are not only HTML elements in tableHeader
here needs to be a check if tableHeader.nodeName is 'TH'
@elmasdemos elmasdemos requested review from spiess-demos and removed request for muellerdemos May 8, 2023 11:40
@elmasdemos elmasdemos added enhancement New feature or request review:frontend labels May 8, 2023
@elmasdemos elmasdemos marked this pull request as ready for review May 8, 2023 11:41
@elmasdemos elmasdemos changed the title Feat: convert tableheader into template Feat: convert DpTableHeader.vue to a template May 8, 2023
@elmasdemos elmasdemos changed the title Feat: convert DpTableHeader.vue to a template Feat: Convert DpTableHeader.vue to a template May 8, 2023
Copy link
Contributor

@salisdemos salisdemos left a comment

Choose a reason for hiding this comment

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

First of all thanks for all the effort

Comment on lines 378 to 388
/**
* The convert of the component DpTableHeader.vue from a functional component to a template indicates,
* that the DOM Element structure changed, so that the tableHeaders doesnt just contains HTML elements,
* it contains other code parts which are not HTML elements.
* So you get an error, that the method getBoundingClientRect is not a function,
* because it needs the same dom structure as before and the belonging HTML elements.
* So here needs to be a check if the tableHeader.nodeName is a 'th' element for this case.
* A general check if the tableHeader.nodeName is an HTML element here is inconvenient,
* so here its okay to do the check with directly with the 'th' element.
*/
if(tableHeader.nodeName === "TH") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Are You sure You have to check if its a TH? Isn't it enough to check if its a node?
if(tableHeader.nodeName) ?

And also its good to know where the bug came from right now, I think the depth of detail don't helps anyone in the feature. I suggest to shorten the comment.

And aside from that. Did You find out why There are none-TH elements in the Array?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

replacing node instead of nodeName didnt work. But it works with nodeTyoe, so I changed the check this way. done 9c36b6e

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the reason why there are other elements are because of the v-if structure in the template. see comment in the code

@@ -0,0 +1,104 @@
<template>
<th
:class="`c-data-table__resizable ${isLast? 'u-pr-0' : ''}`"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
:class="`c-data-table__resizable ${isLast? 'u-pr-0' : ''}`"
class="c-data-table__resizable"
:class="{ 'u-pr-0' : isLast }"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done 4c37717


methods: {
initResize (e, idx) {
this.resize = document.querySelector(`th[data-col-idx='${idx}']`)
Copy link
Contributor

Choose a reason for hiding this comment

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

We can make this more vue-ish and use refs instead

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done 4c37717

Comment on lines 98 to 100
document.getElementsByTagName('body')[0].removeEventListener('mousemove', this.namedFunc)
document.getElementsByTagName('body')[0].removeEventListener('mouseup', this.stopResize)
document.getElementsByTagName('body')[0].classList.remove('resizing')
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick to make it a bit shorter

Suggested change
document.getElementsByTagName('body')[0].removeEventListener('mousemove', this.namedFunc)
document.getElementsByTagName('body')[0].removeEventListener('mouseup', this.stopResize)
document.getElementsByTagName('body')[0].classList.remove('resizing')
document.querySelector('body').removeEventListener('mousemove', this.namedFunc)
document.querySelector('body').removeEventListener('mouseup', this.stopResize)
document.querySelector('body').classList.remove('resizing')

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks. done 4c37717

v-if="isResizable"
:is-last="headerFields.length === idx"
:header-field="hf"
:idx="idx">
Copy link
Contributor

Choose a reason for hiding this comment

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

does v-text works here too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

v-text doesnt work in combination with slots. thanks for the question to think about and to try it

{{ hf.label }}
</template>
</th>
<th v-if="isTruncatable"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<th v-if="isTruncatable"
<th
v-if="isTruncatable"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done 853e2c7

@click="listeners.toggleWrapAll()">
<dp-wrap-trigger :title="translations.headerExpandHint" />
</th>
<th v-if="isExpandable"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<th v-if="isExpandable"
<th
v-if="isExpandable"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks. done 853e2c7

otherwise the slot doesnt know that it has a reference to the text
…der_into_template

# Conflicts:
#	CHANGELOG.md
Copy link
Contributor

@spiess-demos spiess-demos left a comment

Choose a reason for hiding this comment

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

lgtm (code review)

thanks for taking this on!

Copy link
Contributor

@salisdemos salisdemos left a comment

Choose a reason for hiding this comment

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

just two noneblocking nitpicks


computed: {
isResizableColumn () {
return hasOwnProp(this.headerField, 'resizeable')? this.headerField.resizeable : true
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return hasOwnProp(this.headerField, 'resizeable')? this.headerField.resizeable : true
return hasOwnProp(this.headerField, 'resizeable') ? this.headerField.resizeable : true

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done 7ea8c56

Comment on lines 88 to 89
const newNextWidth = this.nextWidth - mouseMoved
if (newWidth > 25 && newNextWidth > 25) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const newNextWidth = this.nextWidth - mouseMoved
if (newWidth > 25 && newNextWidth > 25) {
const newNextWidth = this.nextWidth - mouseMoved
if (newWidth > 25 && newNextWidth > 25) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done 7ea8c56

add line break if new if condition
add space before the question mark in ternary
@elmasdemos elmasdemos merged commit 1eccbcd into main May 15, 2023
@elmasdemos elmasdemos deleted the feat_convert_tableheader_into_template branch May 15, 2023 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request review:frontend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants