Skip to content

Commit 0b346e4

Browse files
author
Samuel Zeitler
committed
minor fixes
1 parent 982ebf6 commit 0b346e4

File tree

11 files changed

+401
-300
lines changed

11 files changed

+401
-300
lines changed

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -272,13 +272,14 @@ The following will give you an overview how to configure the VueQuintable for yo
272272

273273
##### Property *cells* for property *rows* properties
274274

275-
| Key | Type | Pre-condition | Description |
276-
| --------- | ------ | ---------------------------------------------------------- |------------------------------------------------------------------------------------------------------|
277-
| text | String | non of the following are set: *html*, *component* | Content string |
278-
| html | String | non of the following are set: *text*, *component* | HTML content string |
279-
| component | String | non of the following are set: *text*, *html* | Custom component object, see code example below. Should not be used, use slot *cell-content* instead |
280-
| classes | String | - | Additional CSS classes for cell |
281-
| align | String | - | Text alignment for whole column, this will overwrite *columns* and *rows* align values |
275+
| Key | Type | Pre-condition | Description |
276+
| --------- | ------- | --------------------------------------------------------- | ------------------------------------------------------------ |
277+
| text | String | non of the following are set: *html*, *component* | Content string |
278+
| html | String | non of the following are set: *text*, *component* | HTML content string |
279+
| component | String | non of the following are set: *text*, *html* | Custom component object, see code example below. Should not be used, use slot *cell-content* instead |
280+
| classes | String | - | Additional CSS classes for cell |
281+
| align | String | - | Text alignment for whole column, this will overwrite *columns* and *rows* align values |
282+
| isEmpty | Boolean | non of the following are set: *text*, *html*, *component* | Flag for custom cells (e.g for slot generation). This is checked for hiding empty cells and the flag will overwrite potential content of *text* and *html* if set to true |
282283

283284
Lets have a look on an example for *rows* and *cells*
284285

dist/vue-quintable.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/vue-quintable.es.js

Lines changed: 261 additions & 251 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/vue-quintable.es.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/vue-quintable.umd.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/vue-quintable.umd.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sensetence/vue-quintable",
3-
"version": "2.3.4",
3+
"version": "2.3.5",
44
"private": false,
55
"scripts": {
66
"dev": "vite --config vite.build.config.js",

src/components/VueQuintable.vue

Lines changed: 61 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
<div
7373
class="cell-inner"
7474
:class="options.path + ' ' + options.path + '--html'"
75-
v-else-if="cell.html"
75+
v-else-if="valueToString(cell.html)"
7676
v-html="cell.html"
7777
></div>
7878
<div
@@ -630,6 +630,9 @@
630630
"
631631
@click="setSortColumn(cIndex)"
632632
:class="configFinal.columnClasses[cIndex]"
633+
v-if="
634+
showHeadlines[cIndex] || configFinal.sorts[cIndex]
635+
"
633636
>
634637
<strong
635638
v-html="configFinal.headlines[cIndex]"
@@ -689,6 +692,12 @@
689692
</span>
690693
</td>
691694
<td
695+
:colspan="
696+
!showHeadlines[cIndex] &&
697+
!configFinal.sorts[cIndex]
698+
? 2
699+
: 1
700+
"
692701
:class="
693702
configFinal.columnClasses[cIndex] +
694703
' ' +
@@ -786,6 +795,9 @@
786795
"
787796
@click="setSortColumn(cIndex)"
788797
:class="configFinal.columnClasses[cIndex]"
798+
v-if="
799+
showHeadlines[cIndex] || configFinal.sorts[cIndex]
800+
"
789801
>
790802
<strong
791803
v-html="configFinal.headlines[cIndex]"
@@ -846,6 +858,12 @@
846858
</td>
847859

848860
<td
861+
:colspan="
862+
!showHeadlines[cIndex] &&
863+
!configFinal.sorts[cIndex]
864+
? 2
865+
: 1
866+
"
849867
:class="
850868
configFinal.columnClasses[cIndex] +
851869
' ' +
@@ -2990,7 +3008,17 @@ export default {
29903008
*
29913009
*/
29923010
valueToString: function (value) {
2993-
return String(value);
3011+
switch (value) {
3012+
case "":
3013+
case null:
3014+
case false:
3015+
case undefined:
3016+
return "";
3017+
case 0:
3018+
case "0":
3019+
default:
3020+
return String(value);
3021+
}
29943022
},
29953023
29963024
/**
@@ -2999,20 +3027,36 @@ export default {
29993027
*/
30003028
isColEmpty(i, rowIndex = -1) {
30013029
const rowIndexes = rowIndex > -1 ? [rowIndex] : this.visibleRowIndexes;
3002-
return (
3003-
rowIndexes
3004-
.map((index) => {
3005-
return this.rowsFinal[index];
3006-
})
3007-
.filter((row) => {
3008-
const cells = row.cells ? row.cells : row;
3009-
return (
3010-
this.valueToString(cells[i].text) ||
3011-
cells[i].html ||
3012-
cells[i].component
3013-
);
3014-
}).length <= 0
3015-
);
3030+
const visibleCells = rowIndexes
3031+
.map((index) => {
3032+
return this.rowsFinal[index];
3033+
})
3034+
.filter((row) => {
3035+
const cells = row.cells ? row.cells : row;
3036+
3037+
if (
3038+
typeof cells[i].isEmpty === "boolean" &&
3039+
cells[i].isEmpty === true
3040+
) {
3041+
return false;
3042+
}
3043+
3044+
if (
3045+
typeof cells[i].text !== "undefined" &&
3046+
this.valueToString(cells[i].text)
3047+
) {
3048+
return true;
3049+
}
3050+
3051+
if (
3052+
typeof cells[i].html !== "undefined" &&
3053+
this.valueToString(cells[i].html)
3054+
) {
3055+
return true;
3056+
}
3057+
return false;
3058+
});
3059+
return visibleCells.length <= 0;
30163060
},
30173061
30183062
/**
@@ -3055,7 +3099,7 @@ export default {
30553099
return formatted;
30563100
}
30573101
3058-
return cell.html
3102+
return this.valueToString(cell.html)
30593103
? cell.html
30603104
: this.valueToString(cell.text)
30613105
? cell.text

src/examples/BreakpointsAdvancedExample.vue

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ export default {
116116
sticky: true,
117117
sort: true,
118118
},
119+
{
120+
headline: "Description",
121+
hideHeadlineBreakpoint: "xxl",
122+
sticky: true,
123+
},
119124
{
120125
headline: "Job",
121126
breakpoint: "all",
@@ -142,6 +147,9 @@ export default {
142147
{
143148
text: chance.city(),
144149
},
150+
{
151+
text: [...Array(50).keys()].map(() => chance.word()).join(" "),
152+
},
145153
{
146154
text: chance.profession(),
147155
},

src/examples/HiddenExample.vue

Lines changed: 54 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@
2626
></v-select>
2727
</div>
2828
</template>
29+
<template #cell-content="{ cell }">
30+
<div v-if="cell.type === 'word'">
31+
{{ cell.value }}
32+
</div>
33+
</template>
2934
</VueQuintable>
3035

3136
<button
@@ -42,23 +47,35 @@
4247
<!-- @formatter:off -->
4348
<pre
4449
data-toolbar-order="copy-to-clipboard"
45-
><code class="language-markup">&lt;template&gt;
50+
><code class="language-markup" v-pre>&lt;template&gt;
4651
&lt;VueQuintable :dynamicConfig=&quot;dynamicConfig&quot; :config=&quot;config&quot; :rows=&quot;rows&quot;&gt;
4752
&lt;template v-slot:header&gt;
48-
&lt;div class=&quot;mb-3&quot;&gt;
49-
&lt;p-check class=&quot;p-switch&quot; v-model=&quot;hideAge&quot;&gt;Hide Age Column&lt;/p-check&gt;
50-
&lt;/div&gt;
51-
&lt;div class=&quot;mb-3&quot;&gt;
52-
&lt;p-check class=&quot;p-switch&quot; v-model=&quot;hideJob&quot;&gt;Hide Job Column&lt;/p-check&gt;
53-
&lt;/div&gt;
54-
&lt;div class=&quot;mb-3&quot;&gt;
55-
&lt;p-check class=&quot;p-switch&quot; v-model=&quot;hideColumns&quot;&gt;Hide empty columns automatically&lt;/p-check&gt;
56-
&lt;/div&gt;
57-
&lt;div class=&quot;mb-3&quot;&gt;
58-
&lt;v-select v-model=&quot;ignoreSortingColumns&quot; :reduce=&quot;option=&gt;option.value&quot; :options=&quot;ignoreOptions&quot; :clearable=&quot;false&quot;&gt;&lt;/v-select&gt;
59-
&lt;/div&gt;
53+
&lt;div class=&quot;mb-3&quot;&gt;
54+
&lt;p-check class=&quot;p-switch&quot; v-model=&quot;hideAge&quot;&gt;Hide Age Column&lt;/p-check&gt;
55+
&lt;/div&gt;
56+
&lt;div class=&quot;mb-3&quot;&gt;
57+
&lt;p-check class=&quot;p-switch&quot; v-model=&quot;hideJob&quot;&gt;Hide Job Column&lt;/p-check&gt;
58+
&lt;/div&gt;
59+
&lt;div class=&quot;mb-3&quot;&gt;
60+
&lt;p-check class=&quot;p-switch&quot; v-model=&quot;hideColumns&quot;
61+
&gt;Hide empty columns automatically&lt;/p-check
62+
&gt;
63+
&lt;/div&gt;
64+
&lt;div class=&quot;mb-3&quot;&gt;
65+
&lt;v-select
66+
v-model=&quot;ignoreSortingColumns&quot;
67+
:reduce=&quot;(option) =&gt; option.value&quot;
68+
:options=&quot;ignoreOptions&quot;
69+
:clearable=&quot;false&quot;
70+
&gt;&lt;/v-select&gt;
71+
&lt;/div&gt;
6072
&lt;/template&gt;
61-
&lt;/VueQuintable&gt;
73+
&lt;template #cell-content=&quot;{ cell }&quot;&gt;
74+
&lt;div v-if=&quot;cell.type === 'word'&quot;&gt;
75+
{{ cell.value }}
76+
&lt;/div&gt;
77+
&lt;/template&gt;
78+
&lt;/VueQuintable&gt;
6279
&lt;/template&gt;
6380
&lt;script&gt;
6481
import VueQuintable from &quot;../components/VueQuintable.vue&quot;;
@@ -113,6 +130,10 @@ export default {
113130
headline: &quot;Birth country&quot;,
114131
breakpoint: &quot;lg&quot;,
115132
},
133+
{
134+
headline: &quot;Random Word&quot;,
135+
breakpoint: &quot;xl&quot;,
136+
},
116137
{
117138
headline: &quot;Job&quot;,
118139
hidden: this.hideJob,
@@ -135,9 +156,10 @@ export default {
135156
const city = i &lt; 13 ? &quot;&quot; : chance.city();
136157
//last entry with a birth place will be the 9. row
137158
const country = i &gt;= 9 ? &quot;&quot; : chance.country();
138-
139159
//lase entry with name will be the 8. row
140160
const name = i &gt; 7 ? &quot;&quot; : chance.name({ nationality: &quot;en&quot; });
161+
//hide cell thought it has content
162+
const alwaysHide = i &lt; 15;
141163

142164
rows.push([
143165
{
@@ -152,6 +174,12 @@ export default {
152174
{
153175
text: country,
154176
},
177+
{
178+
type: &quot;word&quot;,
179+
text: &quot;asd&quot;,
180+
isEmpty: alwaysHide,
181+
value: chance.word(),
182+
},
155183
{
156184
text: chance.profession(),
157185
},
@@ -243,6 +271,10 @@ export default {
243271
headline: "Birth country",
244272
breakpoint: "lg",
245273
},
274+
{
275+
headline: "Random Word",
276+
breakpoint: "xl",
277+
},
246278
{
247279
headline: "Job",
248280
hidden: this.hideJob,
@@ -265,9 +297,10 @@ export default {
265297
const city = i < 13 ? "" : chance.city();
266298
//last entry with a birth place will be the 9. row
267299
const country = i >= 9 ? "" : chance.country();
268-
269300
//lase entry with name will be the 8. row
270301
const name = i > 7 ? "" : chance.name({ nationality: "en" });
302+
//hide cell thought it has content
303+
const alwaysHide = i < 15;
271304
272305
rows.push([
273306
{
@@ -282,6 +315,11 @@ export default {
282315
{
283316
text: country,
284317
},
318+
{
319+
type: "word",
320+
isEmpty: alwaysHide,
321+
value: chance.word(),
322+
},
285323
{
286324
text: chance.profession(),
287325
},

0 commit comments

Comments
 (0)