Skip to content

Commit

Permalink
- treefilter has height property
Browse files Browse the repository at this point in the history
- fix table state restoring
- fix datasource remove error
  • Loading branch information
wulff007 committed Mar 19, 2024
1 parent db3aa74 commit 075121c
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 18 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tabbled-web",
"private": true,
"version": "0.5.7",
"version": "0.5.8",
"type": "module",
"license": "MIT",
"scripts": {
Expand Down
8 changes: 6 additions & 2 deletions src/components/DialogView.vue
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<template>
<el-dialog class="dialog"
:model-value="visible"
style="padding: 0"
@close="emit('update:visible', false)"
:title="pageConfig ? pageConfig.title : 'Dialog'"
:modal="options && options.modal ? options.modal : true"
draggable
:width="options && options.width ? options.width : '60%'"
:fullscreen="screenSize === ScreenSize.mobile"
:append-to-body="true"

>
<el-form ref="grid" class="grid-wrap" :model="editEntity" label-position="top" style="padding: 0">
<el-form ref="grid" class="grid-wrap" :model="editEntity" label-position="top" style="padding: 0; height: 100%">

<el-form-item v-for="(element, idx) in elements"
:label="getLabelElement(element)"
Expand Down Expand Up @@ -72,6 +72,7 @@ let editDataSource: DataSourceInterface = null
let isNew = ref(false)
let elements = ref<Array<ElementInterface>>([])
let filters = ref<Filters>(null)
let maxHeight = ref('')
const emit = defineEmits(['update:visible', 'selected'])
Expand Down Expand Up @@ -100,6 +101,7 @@ async function init() {
elements.value = []
editDataSource = null
editEntity.value = null
maxHeight.value = '200px'
if (pageConfig.value.datasource) {
editDataSource = await dsService.create(pageConfig.value.datasource)
Expand Down Expand Up @@ -279,6 +281,8 @@ function selectedChanged(sl) {
.el-dialog__body {
padding: 0;
padding-bottom: 16px;
overflow: auto;
max-height: calc(100vh - 300px);
}
}
Expand Down
8 changes: 3 additions & 5 deletions src/components/Table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -565,9 +565,6 @@ async function addChild() {
return
}
if (actions.value.onAdd) {
await execAction(actions.value.onAdd)
return
Expand Down Expand Up @@ -669,10 +666,11 @@ async function onGridReady(params) {
}
await init()
restoreCols()
}
async function onFirstDataRendered(/*params*/) {
restoreCols()
}
function saveColumnState(e) {
Expand Down Expand Up @@ -1037,7 +1035,7 @@ let onItemInserted = async (params) => {
}
let onItemRemoved = async (params) => {
//console.log('onItemRemoved', params)
console.log('onItemRemoved', params)
gridApi.applyServerSideTransaction({
remove: [params.data],
route: isTree.value && params.route ? params.route.slice(0, params.route.length - 1) : null
Expand Down
5 changes: 3 additions & 2 deletions src/components/TreeFilter.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div v-if="fieldConfig" style="width: 100%;">
<el-card v-if="type === 'list'" shadow="never" body-style="padding: 0" style="width: 100%">
<el-card v-if="type === 'list'" shadow="never" body-style="padding: 0" :style="{width: '100%', height: height + 'px'}">
<el-tree ref="tree"
style="width: 100%"
:data="treeData"
Expand Down Expand Up @@ -60,7 +60,8 @@ interface Props {
rootItem: boolean,
keyProp?: string,
titleProp?: string,
childrenProp?: string
childrenProp?: string,
height?: string
}
const props = withDefaults(defineProps<Props>(), {
Expand Down
5 changes: 5 additions & 0 deletions src/components/configuration/tree.filter.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ export class Config implements ComponentInterface {
title: "Show root item",
alias: "rootItem",
type: "bool"
},{
title: "Height",
alias: "height",
type: 'number',
default: null
},
{
title: 'Visibility',
Expand Down
12 changes: 4 additions & 8 deletions src/model/datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,17 +250,11 @@ export class DataSource extends EventEmitter implements DataSourceInterface {

async removeById(id: string, route?: string[]): Promise<boolean> {
//let dt = new Date().getMilliseconds()
let res = await this.server.emit(`${this.type === 'config' ? 'config' : 'dataSources/data'}/removeById`, {
await this.server.emit(`${this.type === 'config' ? 'config' : 'dataSources/data'}/removeById`, {
alias: this.alias,
id: id
})
//console.log(this.alias, "removed; timing, ms: ", new Date().getMilliseconds() - dt)

this.emit('item-removed', {
data: res.data,
route: route
})

return true
}

Expand All @@ -279,6 +273,8 @@ export class DataSource extends EventEmitter implements DataSourceInterface {
if (!msg || msg.type !== 'data' || !msg.entity || msg.entity.alias !== this.alias)
return

console.log(msg)

switch (msg.action) {
case 'add':
this.emit('item-inserted', {
Expand All @@ -295,7 +291,7 @@ export class DataSource extends EventEmitter implements DataSourceInterface {
case 'remove':
this.emit('item-removed', {
data: {
id: msg.entity.data
id: msg.entity.id
},
route: []
})
Expand Down

0 comments on commit 075121c

Please sign in to comment.