@eturnity/eturnity_reusable_components 6.37.0-EPDM-8148.3 → 6.37.0-EPDM-8148.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,15 @@
1
1
  <template>
2
- <page-container>
2
+ <page-container
3
+ :tableHeight="tableHeight"
4
+ :shouldSetCustomHeight="doesTableContainDraggables"
5
+ >
3
6
  <table-title v-if="titleText">
4
7
  {{ titleText }}
5
8
  </table-title>
6
- <table-scroll>
9
+ <table-scroll
10
+ ref="tableRef"
11
+ :isPositionAbsolute="doesTableContainDraggables"
12
+ >
7
13
  <table-wrapper :fullWidth="fullWidth">
8
14
  <spinner-wrapper v-if="isLoading">
9
15
  <spinner />
@@ -26,7 +32,15 @@
26
32
  import styled from 'vue-styled-components'
27
33
  import Spinner from '../../spinner'
28
34
 
29
- const PageContainer = styled.div``
35
+ const pageContainerProps = {
36
+ tableHeight: String,
37
+ shouldSetCustomHeight: Boolean
38
+ }
39
+ const PageContainer = styled('div', pageContainerProps)`
40
+ position: relative;
41
+ height: ${(props) =>
42
+ props.shouldSetCustomHeight ? props.tableHeight : 'auto'};
43
+ `
30
44
 
31
45
  const TableTitle = styled.div`
32
46
  margin-bottom: 16px;
@@ -35,15 +49,27 @@ const TableTitle = styled.div`
35
49
  text-transform: uppercase;
36
50
  `
37
51
 
38
- const TableScroll = styled.div`
52
+ const tableScrollProps = {
53
+ isPositionAbsolute: Boolean
54
+ }
55
+
56
+ const TableScroll = styled('div', tableScrollProps)`
39
57
  max-width: 100%;
58
+ height: auto;
59
+ ${(props) =>
60
+ props.isPositionAbsolute &&
61
+ `
62
+ position: absolute;
63
+ left: -20px;
64
+ `}
40
65
  `
41
66
 
42
67
  const wrapperAttrs = { fullWidth: Boolean }
43
68
  const TableWrapper = styled('div', wrapperAttrs)`
44
69
  width: ${(props) => (props.fullWidth ? '100%' : 'fit-content')};
45
70
  max-width: 100%;
46
- overflow: auto;
71
+ overflow-x: auto;
72
+ overflow-y: hidden;
47
73
 
48
74
  ::-webkit-scrollbar {
49
75
  height: 5px; //height of the whole scrollbar area
@@ -67,7 +93,11 @@ const SpinnerWrapper = styled.div`
67
93
  justify-items: center;
68
94
  `
69
95
 
70
- const containerAttrs = { cellPaddings: String, tableCursor: String }
96
+ const containerAttrs = {
97
+ cellPaddings: String,
98
+ tableCursor: String
99
+ }
100
+
71
101
  const TableContainer = styled('table', containerAttrs)`
72
102
  width: 100%;
73
103
  border-collapse: collapse;
@@ -378,6 +408,39 @@ export default {
378
408
  tableCursor: {
379
409
  required: false
380
410
  }
411
+ },
412
+ data() {
413
+ return {
414
+ tableHeight: 'auto',
415
+ doesTableContainDraggables: false
416
+ }
417
+ },
418
+ mounted() {
419
+ this.observeTableHeight()
420
+ },
421
+ beforeDestroy() {
422
+ if (this.resizeObserver) {
423
+ this.resizeObserver.disconnect()
424
+ }
425
+ },
426
+ methods: {
427
+ observeTableHeight() {
428
+ if (!this.$refs.tableRef) return
429
+
430
+ const tableElement = this.$refs.tableRef.$el
431
+
432
+ this.resizeObserver = new ResizeObserver(() => {
433
+ const newTableHeight = this.titleText
434
+ ? tableElement.offsetHeight + 33
435
+ : tableElement.offsetHeight
436
+ this.tableHeight = `${newTableHeight}px`
437
+ this.doesTableContainDraggables = Boolean(
438
+ tableElement.querySelector('.drag-container')
439
+ )
440
+ })
441
+
442
+ this.resizeObserver.observe(tableElement)
443
+ }
381
444
  }
382
445
  }
383
446
  </script>
@@ -8,8 +8,6 @@
8
8
  <dropdown-container
9
9
  v-if="isOpen"
10
10
  @click.stop
11
- :top="getItemLocation('top')"
12
- :right="getItemLocation('right')"
13
11
  :containerWidth="childOpen ? 440 : 240"
14
12
  ref="dropdownContainer"
15
13
  >
@@ -130,6 +128,7 @@ const PageContainer = styled.div`
130
128
  justify-items: center;
131
129
  width: 30px;
132
130
  height: 30px;
131
+ position: relative;
133
132
 
134
133
  &:hover {
135
134
  background-color: ${(props) => props.theme.colors.grey5};
@@ -158,12 +157,15 @@ const DotItem = styled.div`
158
157
  border-radius: 50%;
159
158
  `
160
159
 
161
- const dropdownAttrs = { top: Number, right: Number, containerWidth: Number }
160
+ const dropdownAttrs = {
161
+ containerWidth: Number
162
+ }
162
163
  const DropdownContainer = styled('div', dropdownAttrs)`
163
164
  z-index: 99;
164
165
  height: 200px;
165
- top: ${(props) => props.top + 'px'};
166
- left: ${(props) => props.right - props.containerWidth + 'px'};
166
+ top: 0;
167
+ right: 27px;
168
+
167
169
  position: absolute;
168
170
  display: grid;
169
171
  grid-template-columns: auto auto;
@@ -299,14 +301,6 @@ export default {
299
301
  document.removeEventListener('click', this.clickOutside)
300
302
  }
301
303
  },
302
- getItemLocation(value) {
303
- let ref = this.$refs.dropdownItem
304
- let location = ref.$el.getBoundingClientRect()[value]
305
- if (value === 'top') {
306
- location = location + window.scrollY
307
- }
308
- return location
309
- },
310
304
  hasChildren(item) {
311
305
  return !!item.children && !!item.children.length
312
306
  },
@@ -1,12 +1,11 @@
1
+ import { langForLocaleString } from './translateLang'
2
+
1
3
  export const stringToNumber = ({
2
- value,
4
+ value = '',
3
5
  numberPrecision = false,
4
- allowNegative
6
+ allowNegative = false
5
7
  }) => {
6
8
  // This is for saving. It converts our input string to a readable number
7
- if (value === undefined) {
8
- value = ''
9
- }
10
9
  let newVal = value.toString()
11
10
  const selectedLang = localStorage.getItem('lang')
12
11
  // The first replace will replace not allowed characters with a blank
@@ -94,16 +93,8 @@ export const stringToNumber = ({
94
93
 
95
94
  export const numberToString = ({ value, numberPrecision, minDecimals }) => {
96
95
  const minimumRounding = minDecimals ? minDecimals : 0
97
- let selectedLang = localStorage.getItem('lang')
98
- ? localStorage.getItem('lang') === 'fr-lu'
99
- ? 'fr-fr'
100
- : localStorage.getItem('lang')
101
- : 'en-US'
102
- if (selectedLang == 'null') {
103
- selectedLang = 'en-US'
104
- }
105
96
  value = parseFloat(value)
106
- return value.toLocaleString(selectedLang, {
97
+ return value.toLocaleString(langForLocaleString(), {
107
98
  minimumFractionDigits: minimumRounding, // removing this for now. Why do we need this to be a minimum amount?
108
99
  maximumFractionDigits: numberPrecision
109
100
  })
@@ -70,12 +70,15 @@ export const datePickerLang = (lang) => {
70
70
  return 'fr'
71
71
  } else if (lang === 'it-it' || lang === 'it-ch') {
72
72
  return 'it'
73
+ } else if (lang === 'en-us' || lang === 'en-gb') {
74
+ return 'en'
73
75
  } else {
74
76
  return lang
75
77
  }
76
78
  }
77
79
 
78
80
  export const tinyLanguage = (lang) => {
81
+ // the function is used to pass correct language to Tiny MCE text editor https://www.tiny.cloud/docs/tinymce/6/ui-localization/#language
79
82
  if (
80
83
  lang === 'de' ||
81
84
  lang === 'de-de' ||
@@ -104,3 +107,14 @@ export const tinyLanguage = (lang) => {
104
107
  return langCode
105
108
  }
106
109
  }
110
+
111
+ export const langForLocaleString = () => {
112
+ const selectedLang = localStorage.getItem('lang')
113
+ ? localStorage.getItem('lang') === 'fr-lu'
114
+ ? 'fr-fr'
115
+ : localStorage.getItem('lang') === 'fr-ch'
116
+ ? 'de-ch'
117
+ : localStorage.getItem('lang')
118
+ : 'en-US'
119
+ return selectedLang !== 'null' ? selectedLang : 'en-US'
120
+ }