Update filter button to look consistent and add double click to resize columns to default width
This commit is contained in:
parent
c1128618fb
commit
38a3ef0c34
|
@ -21,7 +21,7 @@
|
||||||
quiet
|
quiet
|
||||||
{disabled}
|
{disabled}
|
||||||
on:click={modal.show}
|
on:click={modal.show}
|
||||||
active={tempValue?.length > 0}
|
selected={tempValue?.length > 0}
|
||||||
>
|
>
|
||||||
Filter
|
Filter
|
||||||
</ActionButton>
|
</ActionButton>
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
class="resize-slider sticky"
|
class="resize-slider sticky"
|
||||||
class:visible={column === $stickyColumn.name}
|
class:visible={column === $stickyColumn.name}
|
||||||
on:mousedown={e => resize.actions.startResizing($stickyColumn, e)}
|
on:mousedown={e => resize.actions.startResizing($stickyColumn, e)}
|
||||||
|
on:dblclick={() => resize.actions.resetSize($stickyColumn)}
|
||||||
style="left:{40 + $stickyColumn.width}px;"
|
style="left:{40 + $stickyColumn.width}px;"
|
||||||
>
|
>
|
||||||
<div class="resize-indicator" />
|
<div class="resize-indicator" />
|
||||||
|
@ -37,6 +38,7 @@
|
||||||
class="resize-slider"
|
class="resize-slider"
|
||||||
class:visible={column === column.name}
|
class:visible={column === column.name}
|
||||||
on:mousedown={e => resize.actions.startResizing(column, e)}
|
on:mousedown={e => resize.actions.startResizing(column, e)}
|
||||||
|
on:dblclick={() => resize.actions.resetSize(column)}
|
||||||
style={getStyle(column, offset, scrollLeft)}
|
style={getStyle(column, offset, scrollLeft)}
|
||||||
>
|
>
|
||||||
<div class="resize-indicator" />
|
<div class="resize-indicator" />
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
import { derived, get, writable } from "svelte/store"
|
import { derived, get, writable } from "svelte/store"
|
||||||
|
|
||||||
|
export const DefaultColumnWidth = 200
|
||||||
|
|
||||||
export const createColumnsStores = context => {
|
export const createColumnsStores = context => {
|
||||||
const { schema } = context
|
const { schema } = context
|
||||||
const defaultWidth = 200
|
|
||||||
const columns = writable([])
|
const columns = writable([])
|
||||||
const stickyColumn = writable(null)
|
const stickyColumn = writable(null)
|
||||||
|
|
||||||
|
@ -49,7 +50,7 @@ export const createColumnsStores = context => {
|
||||||
const existing = currentColumns.find(x => x.name === field)
|
const existing = currentColumns.find(x => x.name === field)
|
||||||
return {
|
return {
|
||||||
name: field,
|
name: field,
|
||||||
width: existing?.width || defaultWidth,
|
width: existing?.width || DefaultColumnWidth,
|
||||||
schema: $schema[field],
|
schema: $schema[field],
|
||||||
visible: existing?.visible ?? true,
|
visible: existing?.visible ?? true,
|
||||||
}
|
}
|
||||||
|
@ -69,7 +70,7 @@ export const createColumnsStores = context => {
|
||||||
const same = primaryDisplay[0] === get(stickyColumn)?.name
|
const same = primaryDisplay[0] === get(stickyColumn)?.name
|
||||||
stickyColumn.set({
|
stickyColumn.set({
|
||||||
name: primaryDisplay[0],
|
name: primaryDisplay[0],
|
||||||
width: same ? existingWidth : defaultWidth,
|
width: same ? existingWidth : DefaultColumnWidth,
|
||||||
left: 40,
|
left: 40,
|
||||||
schema: primaryDisplay[1],
|
schema: primaryDisplay[1],
|
||||||
idx: "sticky",
|
idx: "sticky",
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
import { writable, get, derived } from "svelte/store"
|
import { writable, get, derived } from "svelte/store"
|
||||||
|
import { DefaultColumnWidth } from "./columns"
|
||||||
|
|
||||||
|
export const MinColumnWidth = 100
|
||||||
|
|
||||||
export const createResizeStores = context => {
|
export const createResizeStores = context => {
|
||||||
const { columns, stickyColumn } = context
|
const { columns, stickyColumn } = context
|
||||||
|
@ -12,7 +15,6 @@ export const createResizeStores = context => {
|
||||||
}
|
}
|
||||||
const resize = writable(initialState)
|
const resize = writable(initialState)
|
||||||
const isResizing = derived(resize, $resize => $resize.column != null)
|
const isResizing = derived(resize, $resize => $resize.column != null)
|
||||||
const MinColumnWidth = 100
|
|
||||||
|
|
||||||
// Starts resizing a certain column
|
// Starts resizing a certain column
|
||||||
const startResizing = (column, e) => {
|
const startResizing = (column, e) => {
|
||||||
|
@ -78,11 +80,28 @@ export const createResizeStores = context => {
|
||||||
document.removeEventListener("mouseup", stopResizing)
|
document.removeEventListener("mouseup", stopResizing)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Resets a column size back to default
|
||||||
|
const resetSize = column => {
|
||||||
|
let columnIdx = get(columns).findIndex(col => col.name === column.name)
|
||||||
|
if (columnIdx === -1) {
|
||||||
|
stickyColumn.update(state => ({
|
||||||
|
...state,
|
||||||
|
width: DefaultColumnWidth,
|
||||||
|
}))
|
||||||
|
} else {
|
||||||
|
columns.update(state => {
|
||||||
|
state[columnIdx].width = DefaultColumnWidth
|
||||||
|
return [...state]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
resize: {
|
resize: {
|
||||||
...resize,
|
...resize,
|
||||||
actions: {
|
actions: {
|
||||||
startResizing,
|
startResizing,
|
||||||
|
resetSize,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
isResizing,
|
isResizing,
|
||||||
|
|
|
@ -168,8 +168,7 @@ export const createRowsStore = context => {
|
||||||
|
|
||||||
// Refreshes all data
|
// Refreshes all data
|
||||||
const refreshData = () => {
|
const refreshData = () => {
|
||||||
filter.set([])
|
get(fetch)?.getInitialData()
|
||||||
sort.set(initialSortState)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Updates a value of a row
|
// Updates a value of a row
|
||||||
|
|
Loading…
Reference in New Issue