spark-grid-vue3 0.0.74 → 0.0.76
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
|
@@ -20,10 +20,11 @@
|
|
|
20
20
|
</div>
|
|
21
21
|
</template>
|
|
22
22
|
|
|
23
|
-
<script setup lang="ts">
|
|
24
|
-
import { computed, onMounted, ref, watch } from "vue"
|
|
23
|
+
<script setup lang="ts">
|
|
24
|
+
import { computed, onMounted, onUnmounted, ref, watch } from "vue"
|
|
25
25
|
import { DataTableSearchType } from "../values/column"
|
|
26
26
|
import { SearchConfigListValue, DataTableSearchTypeDefinition } from "@/types";
|
|
27
|
+
import { EventEmitter } from "../utils/EventEmitter";
|
|
27
28
|
import MultiSelect from "./MultiSelect.vue";
|
|
28
29
|
import InputText from "./InputText.vue";
|
|
29
30
|
import InputDate from "./InputDate.vue";
|
|
@@ -103,9 +104,25 @@ const loadSearchConfig = async () => {
|
|
|
103
104
|
}
|
|
104
105
|
}
|
|
105
106
|
|
|
107
|
+
const onGridFilterChanged = (data: any) => {
|
|
108
|
+
if (data.name === props.name) {
|
|
109
|
+
filterValue.value = data.value
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
106
113
|
onMounted(() => {
|
|
107
114
|
filterValue.value = props.modelValue
|
|
108
115
|
loadSearchConfig()
|
|
116
|
+
|
|
117
|
+
if (props.emitsEvents) {
|
|
118
|
+
EventEmitter.on("grid-filter", onGridFilterChanged)
|
|
119
|
+
}
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
onUnmounted(() => {
|
|
123
|
+
if (props.emitsEvents) {
|
|
124
|
+
EventEmitter.off("grid-filter", onGridFilterChanged)
|
|
125
|
+
}
|
|
109
126
|
})
|
|
110
127
|
|
|
111
128
|
</script>
|
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="grid-row grid-search-row">
|
|
3
3
|
<div class="spark-grid-datatable-header-cell form-group-sm" v-if="props.grid.config.checkboxEnabled"
|
|
4
|
-
data-label="Selecionar"
|
|
5
|
-
:style="DataTableStyler.getCheckboxColumnStyles()"></div>
|
|
4
|
+
data-label="Selecionar" :style="DataTableStyler.getCheckboxColumnStyles()"></div>
|
|
6
5
|
<div class="spark-grid-datatable-header-cell form-group-sm" v-if="props.grid.config.radioButtonSelectionEnabled"
|
|
7
|
-
data-label="Selecionar"
|
|
8
|
-
:style="DataTableStyler.getCheckboxColumnStyles()"></div>
|
|
6
|
+
data-label="Selecionar" :style="DataTableStyler.getCheckboxColumnStyles()"></div>
|
|
9
7
|
|
|
10
|
-
<div class="spark-grid-datatable-header-cell form-group-sm" v-for="column in grid.getColumns()"
|
|
11
|
-
:data-label="column.label"
|
|
8
|
+
<div class="spark-grid-datatable-header-cell form-group-sm" v-for="column in grid.getColumns()"
|
|
9
|
+
:key="column.name" :data-label="column.label"
|
|
12
10
|
:style="DataTableStyler.getSearchRowColumnStyle(column, props.grid)">
|
|
13
11
|
<DataTableSearchField v-if="column.searchEnabled ?? true" :type="column.searchType"
|
|
14
12
|
:search-config="column.searchConfig" :name="column.filterName ?? column.name"
|
|
15
|
-
:disabled="isDisabled(column)" :uuid="grid.uuid"
|
|
13
|
+
:disabled="isDisabled(column)" :uuid="grid.uuid" :emits-events="true"
|
|
14
|
+
@change="value => onFilterChanged(column, value)" />
|
|
16
15
|
</div>
|
|
17
16
|
|
|
18
|
-
<div :style="DataTableStyler.getActionRowColumn(props.grid)" v-if="props.grid.config.actions"
|
|
19
|
-
data-label="Ações"
|
|
17
|
+
<div :style="DataTableStyler.getActionRowColumn(props.grid)" v-if="props.grid.config.actions" data-label="Ações"
|
|
20
18
|
class="spark-grid-datatable-header-cell form-group-sm"></div>
|
|
21
19
|
|
|
22
20
|
<!-- <th v-if="hasActions" class="text-center"></th>-->
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
<div class="grid-search-row-cell" v-for="column in columns" :key="column.name"
|
|
9
9
|
:style="GridStyler.getSearchRowColumnStyle(column, props.grid)">
|
|
10
|
-
<
|
|
10
|
+
<DataTableSearchField v-if="column.searchEnabled ?? true" :type="column.searchType"
|
|
11
11
|
:search-config="column.searchConfig" :name="column.filterName ?? column.name"
|
|
12
12
|
:disabled="isDisabled(column)" :uuid="grid.uuid" :emits-events="true"
|
|
13
13
|
@change="value => onFilterChanged(column, value)" />
|
|
@@ -15,14 +15,12 @@
|
|
|
15
15
|
|
|
16
16
|
<div :style="GridStyler.getActionRowColumn(props.grid)" v-if="props.grid.config.actions"
|
|
17
17
|
class="grid-search-row-cell"></div>
|
|
18
|
-
|
|
19
|
-
<!-- <th v-if="hasActions" class="text-center"></th>-->
|
|
20
18
|
</div>
|
|
21
19
|
</template>
|
|
22
20
|
|
|
23
21
|
<script setup lang="ts">
|
|
24
22
|
import type { GridComponent, Column } from "../types/types"
|
|
25
|
-
import
|
|
23
|
+
import DataTableSearchField from "./DataTableSearchField.vue"
|
|
26
24
|
import { computed } from "vue"
|
|
27
25
|
import { GridStyler } from "../utils/GridStyler"
|
|
28
26
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { DataTableComponent } from "../types"
|
|
2
|
+
import { GlobalConfig } from "./GlobalConfig"
|
|
2
3
|
|
|
3
4
|
export class EventEmitter {
|
|
4
5
|
static onRequestStarted(state: DataTableComponent) {
|
|
@@ -13,25 +14,16 @@ export class EventEmitter {
|
|
|
13
14
|
}
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
private static events: Record<string, Function[]> = {}
|
|
17
|
-
|
|
18
17
|
static emit(grid: DataTableComponent, name: string, data: any): void {
|
|
19
18
|
grid.$emit(name, data)
|
|
20
|
-
|
|
21
|
-
if (this.events[name]) {
|
|
22
|
-
this.events[name].forEach(cb => cb(data))
|
|
23
|
-
}
|
|
19
|
+
GlobalConfig.eventProxy?.emit(name, data)
|
|
24
20
|
}
|
|
25
21
|
|
|
26
22
|
static on(event: string, callback: Function) {
|
|
27
|
-
|
|
28
|
-
this.events[event] = []
|
|
29
|
-
}
|
|
30
|
-
this.events[event].push(callback)
|
|
23
|
+
GlobalConfig.eventProxy?.on(event, callback)
|
|
31
24
|
}
|
|
32
25
|
|
|
33
26
|
static off(event: string, callback: Function) {
|
|
34
|
-
|
|
35
|
-
this.events[event] = this.events[event].filter(cb => cb !== callback)
|
|
27
|
+
GlobalConfig.eventProxy?.off(event, callback)
|
|
36
28
|
}
|
|
37
29
|
}
|