Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions resources/jscomposition/base/table/BaseTable.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<template>
<div
class="tw-w-full tw-relative tw-text-gray-600 tw-text-sm
tw-border tw-rounded-xl tw-border-gray-300 tw-overflow-hidden tw-overflow-x-auto tw-overflow-y-auto"
>
tw-border tw-rounded-xl tw-border-gray-300 tw-overflow-hidden tw-overflow-x-auto tw-overflow-y-auto">
<table
class="tw-w-full tw-border-collapse"
:class="{
Expand Down Expand Up @@ -86,7 +85,7 @@ import TCell from "./TCell.vue";
import ContainerRow from "./ContainerRow.vue";

const defaultConfig = () => ({
tableFixed: true,
tableFixed: false,
});

export default defineComponent({
Expand Down
19 changes: 16 additions & 3 deletions resources/jscomposition/base/table/TCell.vue
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
<template>
<td
class="tw-relative tw-p-0"
:style="{ width: `${column.width}px` }">
:style="{ width: width }">
<template v-if="!column.cellRenderer">
<slot
:columns="columns"
:column="column"
:row="row">
<div class="tw-p-3 tw-text-ellipsis tw-text-nowrap tw-overflow-hidden">
<div
:style="{ width: width }"
class="tw-p-3 tw-text-ellipsis tw-text-nowrap tw-overflow-hidden">
{{ getValue() }}
</div>
</slot>
</template>
<component
:is="getComponent()"
v-else
:style="{ width: width }"
v-bind="getParams()"
:columns="columns"
:column="column"
Expand All @@ -24,7 +27,7 @@
</template>

<script>
import { defineComponent } from "vue";
import { defineComponent, computed } from "vue";
import { isFunction, get } from "lodash";

export default defineComponent({
Expand Down Expand Up @@ -56,11 +59,21 @@ export default defineComponent({

const collapseContainer = (value) => emit("toogleContainer", value);

const index = computed(() => props.columns.findIndex((column) => column.field === props.column.field));

const width = computed(() => {
if (index.value === props.columns.length - 1) {
return "auto";
}
return `${props.column.width || 200}px`;
});

return {
getComponent,
getParams,
getValue,
collapseContainer,
width,
};
},
});
Expand Down
15 changes: 12 additions & 3 deletions resources/jscomposition/base/table/THeader.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<template>
<th
class="tw-relative thead-resizable tw-p-0"
:style="{ width: width + 'px' }">
:style="{ width: width }">
<div
:style="{ width: width }"
class="tw-py-3 tw-px-3 tw-text-left tw-text-nowrap tw-whitespace-nowrap tw-overflow-hidden tw-text-ellipsis">
<slot>
{{ $t(getValue()) }}
Expand All @@ -22,7 +23,7 @@

<script>
import { isFunction } from "lodash";
import { defineComponent, computed } from "vue";
import { defineComponent, computed, ref } from "vue";
import { columnResizeComposable } from "./composables/columnComposable";

export default defineComponent({
Expand All @@ -39,7 +40,14 @@ export default defineComponent({
setup(props, { emit }) {
const columnResize = columnResizeComposable(props.column);

const width = computed(() => props.column.width || 200);
const index = computed(() => props.columns.findIndex((column) => column.field === props.column.field));

const width = computed(() => {
if (index.value === props.columns.length - 1) {
return "auto";
}
return `${props.column.width || 200}px`;
});

const getValue = () => {
if (isFunction(props.column?.headerFormatter)) {
Expand All @@ -50,6 +58,7 @@ export default defineComponent({
};
return {
getValue,
index,
width,
columnResize,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@ export const columnResizeComposable = (column) => {
const startWidth = ref(0);
const isResizing = ref(false);

//Resize the column value
const minWidth = 144;

// Resize the column value
const doResize = (event) => {
if (isResizing.value) {
const diff = event.pageX - startX.value;
const min = 30;
const min = minWidth;
const currentWidth = Math.max(min, startWidth.value + diff);

console.log("doResize", currentWidth);

column.width = currentWidth;
}
};
Expand All @@ -35,7 +39,8 @@ export const columnResizeComposable = (column) => {
const startResize = (event, index) => {
isResizing.value = true;
startX.value = event.pageX;
startWidth.value = column.width || 200;
startWidth.value = column.width || minWidth;
console.log("startResize", startWidth.value);

document.addEventListener("mousemove", doResize);
document.addEventListener("mouseup", stopResize);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
:columns="columnsConfig"
:data="data"
:placeholder="showPlaceholder"
@changeFilter="onChangeFilter"
>
@changeFilter="onChangeFilter">
<template #placeholder>
<TablePlaceholder
:placeholder="placeholderType"
Expand Down
6 changes: 3 additions & 3 deletions resources/jscomposition/cases/casesDetail/config/columns.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const taskNumberColumn = () => ({
field: "id",
header: "Tasks #",
resizable: true,
width: 100,
width: 144,
filter: true,
formatter: (row, column, columns) => `#${row.id}`,
cellRenderer: () => ({
Expand Down Expand Up @@ -68,7 +68,7 @@ const dueDateColumn = () => ({
field: "due_at",
header: "Due Date",
resizable: true,
width: 200,
width: "auto",
filter: true,
formatter: (row, column, columns) => formatDate(row.due_at, "datetime"),
});
Expand Down Expand Up @@ -127,7 +127,7 @@ const startedColumn = () => ({
header: "Started",
filter: true,
resizable: true,
width: 200,
width: "auto",
formatter: (row, column, columns) => formatDate(row.initiated_at, "datetime"),
});

Expand Down
12 changes: 4 additions & 8 deletions resources/jscomposition/cases/casesMain/CasesDataSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,17 @@
<CaseFilter @enter="onChangeSearch" />
<BadgesSection
v-model="badgesData"
@remove="onRemoveBadge"
/>
@remove="onRemoveBadge" />
<FilterableTable
ref="table"
:columns="columnsConfig"
:data="data"
:placeholder="showPlaceholder"
@changeFilter="onChangeFilter"
>
@changeFilter="onChangeFilter">
<template #placeholder>
<TablePlaceholder
:placeholder="placeholderType"
class="tw-grow"
/>
class="tw-grow" />
</template>
</FilterableTable>
<Pagination
Expand All @@ -28,8 +25,7 @@
:page="dataPagination.page"
:pages="dataPagination.pages"
@perPage="onPerPage"
@go="onGo"
/>
@go="onGo" />
</div>
</template>
<script setup>
Expand Down
4 changes: 2 additions & 2 deletions resources/jscomposition/cases/casesMain/config/columns.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const caseNumberColumn = () => ({
field: "case_number",
header: "Case #",
resizable: true,
width: 100,
width: 144,
filter: {
dataType: "string",
operators: ["=", ">", ">=", "in", "between"],
Expand Down Expand Up @@ -162,7 +162,7 @@ export const completedColumn = () => ({
field: "completed_at",
header: "Completed",
resizable: true,
width: 200,
width: "auto",
formatter: (row, column, columns) => formatDate(row.completed_at, "datetime"),
filter: {
dataType: "datetime",
Expand Down
10 changes: 7 additions & 3 deletions resources/jscomposition/system/table/FilterableTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
:columns="columns"
:data="data"
:placeholder="placeholder"
class="tw-grow"
>
:config="config"
class="tw-grow">
<template
v-for="(column, index) in columns"
#[`theader-filter-${column.field}`]>
<FilterColumn
:id="column.field"
v-if="column.filter"
:id="column.field"
:key="`default-${index}-${hasFilter(index,column)}`"
:filter="column.filter"
:value="getFilter(index, column)"
Expand Down Expand Up @@ -42,6 +42,10 @@ const props = defineProps({
type: Boolean,
default: () => false,
},
config: {
type: Object,
default: () => {},
},
});

const filters = ref([]);
Expand Down
3 changes: 1 addition & 2 deletions resources/jscomposition/system/table/SortTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
:data="data"
:config="config"
:placeholder="placeholder"
class="tw-grow"
>
class="tw-grow">
<template
v-for="(column, index) in columns"
#[`theader-filter-${column.field}`]>
Expand Down