@policystudio/policy-studio-ui-vue 1.0.73 → 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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@policystudio/policy-studio-ui-vue",
3
- "version": "1.0.73",
3
+ "version": "1.0.74",
4
4
  "description": "Policy Studio UI",
5
5
  "main": "src/index.js",
6
6
  "author": "Policy Studio Team",
@@ -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,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
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>
105
+
106
+ <PsProgressBar
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
+ />
92
111
 
93
112
  <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"
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,11 +212,45 @@ 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
+ },
199
252
  getIconClasses(item) {
200
- return this.checkItemIsVisible(item) ? 'psui-text-gray-40' : 'psui-text-blue-60'
253
+ return this.checkRowIsVisible(item) ? 'psui-text-gray-40' : 'psui-text-blue-60'
201
254
  },
202
255
  addRow(item, deep = 0, index, rows) {
203
256
  item.deep = deep
@@ -213,13 +266,13 @@ export default {
213
266
  }
214
267
  }
215
268
  },
216
- checkItemIsVisible(item) {
217
- return this.hiddenItems.indexOf(item) < 0
269
+ checkRowIsVisible(item) {
270
+ return this.collapsedRows.indexOf(item.index) < 0
218
271
  },
219
- checkIndexIsHidden(item) {
272
+ checkRowIsCollapsed(item) {
220
273
  let isHidden = false
221
- for (let index = 0; index < this.itemsHiddenIndexes.length; index++) {
222
- const item_hidden = this.itemsHiddenIndexes[index]
274
+ for (let index = 0; index < this.collapsedRows.length; index++) {
275
+ const item_hidden = this.collapsedRows[index]
223
276
  if (item.index.startsWith(`${item_hidden}-`)) {
224
277
  isHidden = true
225
278
  break
@@ -228,21 +281,15 @@ export default {
228
281
  return isHidden
229
282
  },
230
283
  onCollapse(item) {
231
- const index = this.itemsHiddenIndexes.indexOf(item)
284
+ const index = this.collapsedRows.indexOf(item.index)
232
285
  if(index > -1) {
233
- this.itemsHiddenIndexes.splice(index, 1)
286
+ this.collapsedRows.splice(index, 1)
234
287
  } else {
235
- this.itemsHiddenIndexes.push(item)
236
- }
237
- this.$emit('click')
238
- },
239
- progressBarBreakEven(columnKey) {
240
- const data = this.formatFunction(columnKey, this.item.data[columnKey], this.item.data)
241
- if (Number(data) === 0 || data === '--') {
242
- return this.item.data[columnKey]
288
+ this.collapsedRows.push(item.index)
243
289
  }
244
- return 1
245
- },
290
+ this.$forceUpdate()
291
+ this.$emit('collapse-row', item)
292
+ }
246
293
  }
247
294
  }
248
295
  </script>