@policystudio/policy-studio-ui-vue 1.0.71 → 1.0.74

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.
@@ -18527,6 +18527,13 @@ html {
18527
18527
  font-size: 24px;
18528
18528
  }
18529
18529
 
18530
+ .psui-el-table-results-wrapper {
18531
+ width: 100%;
18532
+ white-space: nowrap;
18533
+ display: flex;
18534
+ overflow: auto;
18535
+ }
18536
+
18530
18537
  .psui-el-table-results {
18531
18538
  position: relative;
18532
18539
  vertical-align: top;
@@ -18620,6 +18627,13 @@ html {
18620
18627
  border-color: rgba(230, 236, 242, var(--border-opacity));
18621
18628
  }
18622
18629
 
18630
+ .psui-el-table-results tbody tr.is-first .title {
18631
+ font-weight: 700;
18632
+ --text-opacity: 1;
18633
+ color: #28323B;
18634
+ color: rgba(40, 50, 59, var(--text-opacity));
18635
+ }
18636
+
18623
18637
  .psui-el-table-results tbody tr td {
18624
18638
  padding-left: 2rem;
18625
18639
  --text-opacity: 1;
@@ -19373,6 +19387,13 @@ html {
19373
19387
  border-bottom: 1px solid #e6ecf2;
19374
19388
  }
19375
19389
 
19390
+ .psui-el-accordion-item.disabled .psui-el-accordion-item-header .psui-el-accordion-item-header-wrapper {
19391
+ --text-opacity: 1;
19392
+ color: #798490;
19393
+ color: rgba(121, 132, 144, var(--text-opacity));
19394
+ pointer-events: none;
19395
+ }
19396
+
19376
19397
  .psui-el-accordion-item-header {
19377
19398
  display: flex;
19378
19399
  justify-content: space-between;
@@ -19451,7 +19472,8 @@ html {
19451
19472
  transform: rotate(180deg);
19452
19473
  }
19453
19474
 
19454
- .psui-el-accordion .psui-el-accordion-item.status-opened .psui-el-accordion-item-header, .psui-el-accordion .psui-el-accordion-item-header:hover {
19475
+ .psui-el-accordion .psui-el-accordion-item.status-opened .psui-el-accordion-item-header,
19476
+ .psui-el-accordion .psui-el-accordion-item-header:hover {
19455
19477
  --text-opacity: 1;
19456
19478
  color: #318FAC;
19457
19479
  color: rgba(49, 143, 172, var(--text-opacity));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@policystudio/policy-studio-ui-vue",
3
- "version": "1.0.71",
3
+ "version": "1.0.74",
4
4
  "description": "Policy Studio UI",
5
5
  "main": "src/index.js",
6
6
  "author": "Policy Studio Team",
@@ -3,8 +3,18 @@
3
3
  .psui-el-accordion {
4
4
 
5
5
  &-item {
6
- border-bottom: 1px solid #e6ecf2;
7
-
6
+ border-bottom: 1px solid #e6ecf2;
7
+
8
+
9
+ &.disabled {
10
+ .psui-el-accordion-item-header {
11
+ .psui-el-accordion-item-header-wrapper {
12
+ @apply psui-text-gray-50 pointer-events-none;
13
+
14
+ }
15
+ }
16
+ }
17
+
8
18
  &-header {
9
19
  @apply psui-flex psui-justify-between psui-items-center;
10
20
  padding-top: 16px;
@@ -61,8 +71,10 @@
61
71
  }
62
72
 
63
73
  .psui-el-accordion-item {
64
- &.status-opened .psui-el-accordion-item-header, &-header:hover {
74
+ &.status-opened .psui-el-accordion-item-header,
75
+ &-header:hover {
65
76
  @apply psui-text-blue-60;
77
+
66
78
  .psui-el-accordion-item-icon {
67
79
  @apply psui-text-blue-60;
68
80
  }
@@ -1,4 +1,7 @@
1
1
  @layer components{
2
+ .psui-el-table-results-wrapper {
3
+ @apply .psui-w-full .psui-whitespace-no-wrap .psui-flex .psui-overflow-auto;
4
+ }
2
5
 
3
6
  .psui-el-table-results {
4
7
  @apply .psui-relative .psui-align-top .psui-w-full .psui-max-w-full .psui-text-p;
@@ -57,6 +60,12 @@
57
60
  tr {
58
61
  @apply .psui-border-b .psui-border-gray-20;
59
62
 
63
+ &.is-first {
64
+ .title {
65
+ @apply .psui-font-bold .psui-text-gray-80;
66
+ }
67
+ }
68
+
60
69
  td {
61
70
  @apply .psui-pl-8 .psui-text-gray-80 .psui-h-10 .psui-text-right .psui-text-small;
62
71
  padding-top: 11px;
@@ -1,11 +1,11 @@
1
1
  <template>
2
- <div class="psui-el-accordion-item" :class="`status-${isOpen ? 'opened' : 'closed'}`">
2
+ <div class="psui-el-accordion-item" :class="{'status-opened':isOpen, 'disabled':disabled}">
3
3
  <div class="psui-el-accordion-item-header">
4
4
  <slot name='custom-header' :toggle="toggle" :isOpen="isOpen">
5
5
  <div @click="toggle" class="psui-el-accordion-item-header-wrapper" v-if="!hasCustomHeader">
6
6
  <h2 v-if="title" class="psui-el-accordion-item-title">{{ title }}</h2>
7
7
  <slot name='header-additionals'></slot>
8
- <i class="psui-el-accordion-item-icon">{{ getIcon }}</i>
8
+ <i v-if="!disabled" class="psui-el-accordion-item-icon">{{ getIcon }}</i>
9
9
  </div>
10
10
  </slot>
11
11
  </div>
@@ -49,11 +49,18 @@ export default {
49
49
  type: String
50
50
  },
51
51
  /**
52
- * It sets if it has a custom header
52
+ * It sets if it has a custom header.
53
53
  */
54
54
  hasCustomHeader: {
55
55
  type: Boolean,
56
56
  default: false
57
+ },
58
+ /**
59
+ * It sets the disabled status.
60
+ */
61
+ disabled: {
62
+ type: Boolean,
63
+ default: false
57
64
  }
58
65
  },
59
66
  data() {
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div class="psui-w-full psui-whitespace-no-wrap psui-flex psui-overflow-auto">
2
+ <div class="psui-el-table-results-wrapper">
3
3
  <table
4
4
  ref="table"
5
5
  class="psui-el-table-results"
@@ -14,9 +14,8 @@
14
14
  :key="index"
15
15
  :class="[
16
16
  {
17
- 'psui-font-bold psui-text-gray-80' : item.type == 'total',
18
- 'psui-hidden' : checkIndexIsHidden(item),
19
- 'cell-pb-20 psui-text-red-70' : item.type == 'vintage' && !checkItemIsVisible(item) || item.type == 'study_data' && item.is_last,
17
+ 'is-first' : item.deep == 0,
18
+ 'psui-hidden' : checkRowIsCollapsed(item),
20
19
  'is-last' : item.is_last
21
20
  },
22
21
  `type-${item.type}`
@@ -29,14 +28,14 @@
29
28
  :style="{ paddingLeft: `${item.deep * 20}px` }"
30
29
  >
31
30
  <PsIcon
32
- v-if="item.deep > 0 && !item.last_deep || item.type === 'total'"
31
+ v-if="!item.last_deep || item.type === 'total'"
33
32
  icon="expand_more"
34
33
  size="24"
35
34
  class="psui-cursor-pointer psui-transform psui-transition"
36
- icon-classes="psui-text-gray-40 psui-leading-none"
35
+ :icon-classes="getIconClasses(item)"
37
36
  :style="{ display: 'flex' }"
38
- :class="checkItemIsVisible(item) ? 'psui-rotate-0' : 'psui--rotate-90'"
39
- @click.native="$emit('collapse-row', item)"
37
+ :class="checkRowIsVisible(item) ? 'psui-rotate-0' : 'psui--rotate-90'"
38
+ @click.native="onCollapse(item)"
40
39
  />
41
40
  <PsRichTooltip
42
41
  v-if="item.is_disabled"
@@ -48,7 +47,16 @@
48
47
  <p class="title psui-text-gray-50">{{ item.title }}</p>
49
48
  </template>
50
49
  <template v-slot:content>
51
- <p class="psui-font-bold psui-text-gray-80 psui-text-xsmall">
50
+ <p
51
+ v-if="item.disabled_text"
52
+ class="psui-font-bold psui-text-gray-80 psui-text-xsmall"
53
+ >
54
+ {{ item.disabled_text }}
55
+ </p>
56
+ <p
57
+ v-else
58
+ class="psui-font-bold psui-text-gray-80 psui-text-xsmall"
59
+ >
52
60
  {{ item.title }} buildings are <br>not allowed.
53
61
  </p>
54
62
  </template>
@@ -81,19 +89,30 @@
81
89
  @click.native="$emit('policy-selected', { item, column })"
82
90
  />
83
91
 
84
- <p v-if="formatFunction && !item.is_disabled">{{ formatFunction(column.key, item.data[column.key], item.data) }}</p>
92
+ <p v-if="formatFunction && !item.is_disabled">
93
+ {{ formatFunction(column.key, item.data[column.key], item.data) }}
94
+ </p>
95
+
85
96
  <p
86
97
  v-else-if="item.is_disabled"
87
98
  class="psui-text-gray-50"
88
99
  >
89
100
  --
90
101
  </p>
91
- <p v-else>{{ item.data[column.key] }}</p>
102
+ <p v-else>
103
+ {{ item.data[column.key] }}
104
+ </p>
92
105
 
93
106
  <PsProgressBar
94
- v-if="column.isChart"
95
- :value="!item.is_disabled ? item.data[column.key] : 0"
96
- :force-break-even="item.is_disabled ? true : false"
107
+ v-if="column.isChart && formatFunction"
108
+ :value="formatFunction(column.key, item.data[column.key], item.data) == '--' ? 0 : item.data[column.key]"
109
+ :force-break-even="item.is_disabled || formatFunction(column.key, item.data[column.key], item.data) === '--' ? true : false"
110
+ />
111
+
112
+ <PsProgressBar
113
+ v-else-if="column.isChart"
114
+ :value="item.data[column.key] == '--' ? 0 : item.data[column.key]"
115
+ :force-break-even="item.is_disabled || item.data[column.key] === '--' ? true : false"
97
116
  />
98
117
  </div>
99
118
  </td>
@@ -110,10 +129,18 @@
110
129
  import PsRichTooltip from '../tooltip/PsRichTooltip.vue'
111
130
  import PsIcon from '../ui/PsIcon.vue'
112
131
  import PsProgressBar from '../badges-and-tags/PsProgressBar.vue'
132
+
113
133
  export default {
114
134
  name: 'PsTableResults',
115
135
  components: { PsProgressBar, PsIcon, PsRichTooltip },
116
136
  props: {
137
+ /**
138
+ * It sets if the lines should start collapsed.
139
+ */
140
+ showRowsCollapsed: {
141
+ type: Boolean,
142
+ default: true
143
+ },
117
144
  /**
118
145
  * It sets the format function to display values.
119
146
  */
@@ -121,6 +148,12 @@ export default {
121
148
  type: Function
122
149
  },
123
150
  /**
151
+ * It sets the format function to display values.
152
+ */
153
+ disabledText: {
154
+ type: String
155
+ },
156
+ /**
124
157
  * It sets the hidden items.
125
158
  */
126
159
  hiddenItems: {
@@ -133,10 +166,8 @@ export default {
133
166
  * It sets the hidden items index.
134
167
  */
135
168
  itemsHiddenIndexes: {
136
- type: Array,
137
- default() {
138
- return []
139
- }
169
+ type: [Array, undefined],
170
+ default: undefined
140
171
  },
141
172
  /**
142
173
  * It sets the values which will be use to render the body.
@@ -165,27 +196,15 @@ export default {
165
196
  return []
166
197
  }
167
198
  },
168
- /**
169
- * It sets a close button if needed.
170
- */
171
199
  isCollapsible: {
172
200
  type: Boolean,
173
201
  default: true
174
202
  },
175
- /**
176
- * It sets additional styling if needed.
177
- */
178
- cssStyle: {
179
- type: String,
180
- default: 'psui-text-gray-60'
181
- },
182
203
  },
204
+ data: () => ({
205
+ collapsedRows : []
206
+ }),
183
207
  computed: {
184
- cssAlign() {
185
- if (this.align === 'right') return `psui-text-right ${this.cssStyle}`
186
- if (this.align === 'center') return `psui-text-center ${this.cssStyle}`
187
- return `psui-text-left ${this.cssStyle}`
188
- },
189
208
  getRows() {
190
209
  const rows = []
191
210
  for (let index = 0; index < this.summaryData.length; index++) {
@@ -193,9 +212,46 @@ export default {
193
212
  this.addRow(item, 0, `${index}`, rows)
194
213
  }
195
214
  return rows
215
+ },
216
+ },
217
+ watch: {
218
+ getRows: {
219
+ deep: true,
220
+ immediate: true,
221
+ handler: function () {
222
+ this.setCollapsedRows()
223
+ }
224
+ },
225
+ itemsHiddenIndexes() {
226
+ this.setCollapsedRows()
227
+ },
228
+ showRowsCollapsed() {
229
+ this.setCollapsedRows()
196
230
  }
197
231
  },
232
+ mounted () {
233
+ this.setCollapsedRows()
234
+ },
198
235
  methods: {
236
+ setCollapsedRows() {
237
+ if ( this.itemsHiddenIndexes ) {
238
+ this.collapsedRows = [...this.itemsHiddenIndexes]
239
+ return
240
+ }
241
+
242
+ const newRowsCollpased = []
243
+ if ( this.showRowsCollapsed ) {
244
+ this.getRows.forEach(element => {
245
+ if ( element?.items?.length ) {
246
+ newRowsCollpased.push(element.index)
247
+ }
248
+ })
249
+ }
250
+ this.collapsedRows = newRowsCollpased
251
+ },
252
+ getIconClasses(item) {
253
+ return this.checkRowIsVisible(item) ? 'psui-text-gray-40' : 'psui-text-blue-60'
254
+ },
199
255
  addRow(item, deep = 0, index, rows) {
200
256
  item.deep = deep
201
257
  item.index = index
@@ -210,13 +266,13 @@ export default {
210
266
  }
211
267
  }
212
268
  },
213
- checkItemIsVisible(item) {
214
- return this.hiddenItems.indexOf(item) < 0
269
+ checkRowIsVisible(item) {
270
+ return this.collapsedRows.indexOf(item.index) < 0
215
271
  },
216
- checkIndexIsHidden(item) {
272
+ checkRowIsCollapsed(item) {
217
273
  let isHidden = false
218
- for (let index = 0; index < this.itemsHiddenIndexes.length; index++) {
219
- const item_hidden = this.itemsHiddenIndexes[index]
274
+ for (let index = 0; index < this.collapsedRows.length; index++) {
275
+ const item_hidden = this.collapsedRows[index]
220
276
  if (item.index.startsWith(`${item_hidden}-`)) {
221
277
  isHidden = true
222
278
  break
@@ -225,22 +281,15 @@ export default {
225
281
  return isHidden
226
282
  },
227
283
  onCollapse(item) {
228
- const index = this.itemsHiddenIndexes.indexOf(item)
284
+ const index = this.collapsedRows.indexOf(item.index)
229
285
  if(index > -1) {
230
- this.itemsHiddenIndexes.splice(index, 1)
286
+ this.collapsedRows.splice(index, 1)
231
287
  } else {
232
- this.itemsHiddenIndexes.push(item)
233
- }
234
- this.$emit('click')
235
- },
236
- progressBarBreakEven(columnKey) {
237
- const data = this.formatFunction(columnKey, this.item.data[columnKey], this.item.data)
238
- console.log('data:', data)
239
- if (Number(data) === 0 || data === '--') {
240
- return this.item.data[columnKey]
288
+ this.collapsedRows.push(item.index)
241
289
  }
242
- return 1
243
- },
290
+ this.$forceUpdate()
291
+ this.$emit('collapse-row', item)
292
+ }
244
293
  }
245
294
  }
246
295
  </script>