|
9 | 9 | <div class="table-responsive"> |
10 | 10 | <table class="table table-striped table-bordered"> |
11 | 11 | <thead> |
12 | | - <tr> |
| 12 | + <tr v-if="showToolsRow"> |
13 | 13 | <th :colspan="headerColSpan"> |
14 | | - <div class="row" v-if="global_search.visibility"> |
15 | | - <!-- global search text starts here --> |
16 | | - <div class="input-group col-md-2"> |
17 | | - <input ref="global_search" type="text" class="form-control" :placeholder="global_search.placeholder" @keyup.stop="updateGlobalSearch($event)"> |
18 | | - <div class="input-group-append vbt-global-search-clear" @click="clearGlobalSearch"> |
19 | | - <span class="input-group-text"> |
20 | | - <slot name="clear-global-search-icon"> |
21 | | - ⓧ |
22 | | - </slot> |
23 | | - </span> |
| 14 | + <div class="row"> |
| 15 | + <div class="col-md-4"> |
| 16 | + <div class=row> |
| 17 | + <!-- global search text starts here --> |
| 18 | + <div class="col-md-6 input-group" v-if="global_search.visibility"> |
| 19 | + <input ref="global_search" type="text" class="form-control" :placeholder="global_search.placeholder" @keyup.stop="updateGlobalSearch($event)"> |
| 20 | + <div class="input-group-append vbt-global-search-clear" @click="clearGlobalSearch"> |
| 21 | + <span class="input-group-text"> |
| 22 | + <slot name="clear-global-search-icon"> |
| 23 | + ⓧ |
| 24 | + </slot> |
| 25 | + </span> |
| 26 | + </div> |
| 27 | + </div> |
| 28 | + <!-- global search text ends here --> |
| 29 | + |
| 30 | + <!-- refresh & reset button starts here --> |
| 31 | + <div class="col-md-6"> |
| 32 | + <div class="btn-group" role="group" aria-label="Basic example"> |
| 33 | + <button v-if="show_refresh_button" type="button" class="btn btn-secondary" @click="$emit('refresh-data')"> |
| 34 | + <slot name="refresh-button-text"> |
| 35 | + Refresh |
| 36 | + </slot> |
| 37 | + </button> |
| 38 | + <button type="button" v-if="show_reset_button" class="btn btn-secondary" @click="resetQuery"> |
| 39 | + <slot name="reset-button-text"> |
| 40 | + Reset Query |
| 41 | + </slot> |
| 42 | + </button> |
| 43 | + </div> |
| 44 | + </div> |
| 45 | + <!-- refresh & reset button ends here --> |
24 | 46 | </div> |
25 | 47 | </div> |
26 | | - <!-- global search text ends here --> |
27 | | - |
28 | | - <!-- refresh & reset button starts here --> |
29 | | - <div class="btn-group col-md-2" role="group" aria-label="Basic example"> |
30 | | - <button v-if="show_refresh_button" type="button" class="btn btn-secondary" @click="$emit('refresh-data')"> |
31 | | - <slot name="refresh-button-text"> |
32 | | - Refresh |
33 | | - </slot> |
34 | | - </button> |
35 | | - <button type="button" v-if="show_reset_button" class="btn btn-secondary" @click="resetQuery"> |
36 | | - <slot name="reset-button-text"> |
37 | | - Reset Query |
38 | | - </slot> |
39 | | - </button> |
40 | | - </div> |
41 | | - <!-- refresh & reset button ends here --> |
42 | 48 |
|
43 | 49 | <!-- action buttons starts here --> |
44 | 50 | <div class="btn-group col-md-8 justify-content-end" role="group" aria-label="Basic example"> |
|
61 | 67 | </th> |
62 | 68 |
|
63 | 69 | <slot name="columns" :columns="vbt_columns"> |
64 | | - <th v-for="(column, key, index) in vbt_columns" :key="index" v-on="isSortableColumn(column) ? { click: () => updateSortQuery(column) } : {}" class="text-center vbt-column-header" v-bind:class="{'vbt-sort-cursor':isSortableColumn(column)}"> |
| 70 | + <th v-for="(column, key, index) in vbt_columns" :key="index" v-on="isSortableColumn(column) ? { click: () => updateSortQuery(column) } : {}" class="vbt-column-header" :class="columnClasses(column)"> |
65 | 71 | <slot :name="'column_' + getCellSlotName(column)" :column="column"> |
66 | 72 | {{column.label}} |
67 | 73 | </slot> |
|
83 | 89 | <!-- data rows stars here --> |
84 | 90 | <tr v-for="(row, key, index) in vbt_rows" :key="index" ref="vbt_row" v-bind:style='{"background": (canHighlightHover(row,row_hovered)) ? rowHighlightColor : ""}' @mouseover="rowHovered(row)" @mouseleave="rowHoveredOut()" v-on="rows_selectable ? { click: () => selectCheckboxByRow(row) } : {}"> |
85 | 91 | <CheckBox :checkboxRows="checkbox_rows" :selectedItems="selected_items" :rowsSelectable="rows_selectable" :row="row" @add-selected-item="addSelectedItem" @remove-selected-item="removeSelectedItem"></CheckBox> |
86 | | - <td v-for="(column, key, hindex) in vbt_columns" :key="hindex" class="text-center"> |
| 92 | + <td v-for="(column, key, hindex) in vbt_columns" :key="hindex" :class="rowClasses(column)"> |
87 | 93 | <slot :name="getCellSlotName(column)" :row="row" :column="column" :cell_value="getValueFromRow(row,column.name)"> |
88 | 94 | {{getValueFromRow(row,column.name)}} |
89 | 95 | </slot> |
@@ -805,7 +811,60 @@ export default { |
805 | 811 |
|
806 | 812 | this.$emit('on-change-query',payload); |
807 | 813 | } |
| 814 | + }, |
| 815 | +
|
| 816 | + rowClasses(column) { |
| 817 | + let classes = ""; |
| 818 | +
|
| 819 | + let default_text_alignment = "text-center"; |
| 820 | +
|
| 821 | + //decide text alignment class - starts here |
| 822 | + let alignments = ["text-justify","text-right","text-left","text-center"]; |
| 823 | + if (_.has(column, "row_text_alignment") && _.includes(alignments, column.row_text_alignment)) { |
| 824 | + classes = classes + " " + column.row_text_alignment; |
| 825 | + } else { |
| 826 | + classes = classes + " " + default_text_alignment; |
| 827 | + } |
| 828 | + //decide text alignment class - ends here |
| 829 | +
|
| 830 | + // adding user defined classes to rows - starts here |
| 831 | + if (_.has(column, "row_classes")) { |
| 832 | + classes = classes + " " + column.row_classes; |
| 833 | + } |
| 834 | + // adding user defined classes to rows - ends here |
| 835 | +
|
| 836 | + return classes; |
| 837 | + }, |
| 838 | +
|
| 839 | + columnClasses(column) { |
| 840 | + let classes = ""; |
| 841 | +
|
| 842 | + let default_text_alignment = "text-center"; |
| 843 | +
|
| 844 | + //decide text alignment class - starts here |
| 845 | + let alignments = ["text-justify","text-right","text-left","text-center"]; |
| 846 | + if (_.has(column, "column_text_alignment") && _.includes(alignments, column.column_text_alignment)) { |
| 847 | + classes = classes + " " + column.column_text_alignment; |
| 848 | + } else { |
| 849 | + classes = classes + " " + default_text_alignment; |
| 850 | + } |
| 851 | + //decide text alignment class - ends here |
| 852 | +
|
| 853 | + // adding user defined classes to rows - starts here |
| 854 | + if (_.has(column, "column_classes")) { |
| 855 | + classes = classes + " " + column.column_classes; |
| 856 | + } |
| 857 | + // adding user defined classes to rows - ends here |
| 858 | +
|
| 859 | + // adding classes for sortable column - starts here |
| 860 | + if (this.isSortableColumn(column)) { |
| 861 | + classes = classes + " vbt-sort-cursor"; |
| 862 | + } |
| 863 | + // adding classes for sortable column - ends here |
| 864 | +
|
| 865 | + return classes; |
808 | 866 | } |
| 867 | +
|
809 | 868 | }, |
810 | 869 | computed: { |
811 | 870 | // pagination computed properties -start |
@@ -900,6 +959,10 @@ export default { |
900 | 959 | count += this.vbt_columns.length; |
901 | 960 |
|
902 | 961 | return count; |
| 962 | + }, |
| 963 | +
|
| 964 | + showToolsRow() { |
| 965 | + return (this.global_search.visibility == true || this.show_refresh_button == true || this.show_reset_button == true || this.actions.length > 0); |
903 | 966 | } |
904 | 967 |
|
905 | 968 | }, |
|
0 commit comments