spark-grid-vue3 0.0.39 → 0.0.41

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spark-grid-vue3",
3
- "version": "0.0.39",
3
+ "version": "0.0.41",
4
4
  "description": "",
5
5
  "files": [
6
6
  "src"
@@ -43,6 +43,7 @@ export default {
43
43
  fetch: DataFetcher.fetch,
44
44
  refresh: EventHandler.refresh,
45
45
  setRows: EventHandler.setRows,
46
+ clearRows: EventHandler.clearRows,
46
47
  getRows: EventHandler.getRows,
47
48
  getCheckedRows: EventHandler.getCheckedRows,
48
49
  clearCheckedRows: EventHandler.clearCheckedRows,
@@ -21,7 +21,7 @@
21
21
  Exibindo {{ beginningRows() }} a {{ endingRows() }} de {{ grid.totalRows }} registro(s)
22
22
  </span>
23
23
 
24
- <span class="spark-grid-selected-rows">
24
+ <span class="spark-grid-selected-rows" v-if="grid.config.checkboxEnabled">
25
25
  <span v-if="selectedRowsLength > 0">{{ selectedRowsLength }} registro(s) selecionado(s)</span>
26
26
  </span>
27
27
 
@@ -7,6 +7,7 @@
7
7
  :name="grid.uuid"
8
8
  @input="onChange($event.target.value)"
9
9
  class="styled"
10
+ :disabled="isCheckboxHeaderDisabled"
10
11
  :value="hasAnyChecked"
11
12
  :checked="hasAnyChecked"
12
13
  />
@@ -17,7 +18,7 @@
17
18
 
18
19
  <script setup lang="ts">
19
20
  import {GridStyler} from "../utils/GridStyler"
20
- import type {GridComponent, Row} from "../types/types"
21
+ import {GridComponent, IsCheckboxHeaderDisabled, Row} from "../types/types"
21
22
  import {computed} from "vue"
22
23
 
23
24
  const props = defineProps<{
@@ -37,11 +38,21 @@ const onChange = function (value: any) {
37
38
  props.grid.getRows().forEach((row: Row) => {
38
39
  row._isChecked = isNotChecked
39
40
 
40
- if (row._isChecked) {
41
- props.grid.config.onRowChecked && props.grid.config.onRowChecked(row, 'checkbox');
42
- } else {
43
- props.grid.config.onRowUnchecked && props.grid.config.onRowUnchecked(row, 'checkbox');
41
+ if (row._isCheckboxDisabled !== true) {
42
+ if (row._isChecked) {
43
+ props.grid.config.onRowChecked && props.grid.config.onRowChecked(row, 'checkbox');
44
+ } else {
45
+ props.grid.config.onRowUnchecked && props.grid.config.onRowUnchecked(row, 'checkbox');
46
+ }
44
47
  }
45
48
  })
46
49
  }
50
+
51
+ const isCheckboxHeaderDisabled = computed(() => {
52
+ if (props.grid.config.isCheckboxHeaderDisabled) {
53
+ return props.grid.config.isCheckboxHeaderDisabled(props.grid)
54
+ }
55
+
56
+ return false
57
+ })
47
58
  </script>
@@ -27,6 +27,7 @@ export type OnRequestFinished = (response: any, grid: GridComponent) => void
27
27
  export type OnRequestStarted = (grid: GridComponent) => void
28
28
  export type IsRowChecked = (row: Row) => boolean
29
29
  export type IsCheckboxDisabled = (row: Row) => boolean
30
+ export type IsCheckboxHeaderDisabled = (grid: GridComponent) => boolean
30
31
  export type OnRowEvent = (row: Row, grid: GridComponent) => void
31
32
  export type OnCellEvent = (value: any, column: Column, row: Row, grid: GridComponent) => any
32
33
  export type OnContextMenu = (value: any, column: Column, row: Row, grid: GridComponent) => ContextMenItem[]
@@ -107,7 +108,8 @@ export type SparkGridConfig = {
107
108
  disableFilterWhenPresentOnInitialFilters?: boolean,
108
109
 
109
110
  isRowChecked?: IsRowChecked,
110
- isCheckboxDisabled?: IsCheckboxDisabled,
111
+ isCheckboxRowDisabled?: IsCheckboxDisabled,
112
+ isCheckboxHeaderDisabled?: IsCheckboxHeaderDisabled,
111
113
  onRowChecked?: (row: Row, type: 'checkbox' | 'radio') => void,
112
114
  onRowUnchecked?: (row: Row, type: 'checkbox' | 'radio') => void,
113
115
  onRequestStarted?: OnRequestStarted,
@@ -154,6 +156,7 @@ export type Methods = {
154
156
  refresh: () => void,
155
157
  fetch: () => void,
156
158
  setRows: (rows: Row[]) => Rows[],
159
+ clearRows: () => void,
157
160
  getRows: () => Rows[],
158
161
  getCheckedRows: () => Rows[],
159
162
  getColumns: () => Column[],
@@ -165,6 +168,7 @@ export type Methods = {
165
168
  getSummarizedValue: (column: Column, onlyIsChecked: boolean = true) => any,
166
169
  getSelectedRadioRow: () => Row | null,
167
170
  clearRadioRowSelection: () => void,
171
+ clearCheckedRows: () => void,
168
172
  setSelectedRadioRow: (row: Row) => void,
169
173
  }
170
174
 
@@ -6,8 +6,8 @@ export class CheckboxSelectedMapper {
6
6
  row._isChecked = grid.config.isRowChecked(row);
7
7
  }
8
8
 
9
- if (typeof grid.config.isCheckboxDisabled == "function") {
10
- row._isCheckboxDisabled = grid.config.isCheckboxDisabled(row);
9
+ if (typeof grid.config.isCheckboxRowDisabled == "function") {
10
+ row._isCheckboxDisabled = grid.config.isCheckboxRowDisabled(row);
11
11
  }
12
12
 
13
13
  return row;
@@ -33,6 +33,10 @@ export class EventHandler {
33
33
  return rows
34
34
  }
35
35
 
36
+ static clearRows(this: GridComponent): void {
37
+ this.rows = []
38
+ }
39
+
36
40
  static getRows(this: GridComponent): Row[] {
37
41
  return this.rows
38
42
  }