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
1 change: 1 addition & 0 deletions resources/jscomposition/cases/casesDetail/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const getData = async () => {
for (let i = 0; i <= 31; i += 1) {
const obj = {
id: `${i}`,
case_number: 100,
case_title: `Case Title ${i}`,
process_name: `Process ${i}`,
assigned: `Avatar ${i}`,
Expand Down
37 changes: 13 additions & 24 deletions resources/jscomposition/cases/casesDetail/components/TaskTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,23 @@
</div>
</template>

<script>
import { defineComponent, ref, onMounted } from "vue";
<script setup>
import { ref, onMounted } from "vue";
import { BaseTable, Pagination } from "../../../base";
import { getData } from "../api/index";
import { getColumns } from "../config/columns";

export default defineComponent({
components: { BaseTable, Pagination },
setup() {
const data = ref(null);
const columnsConfig = ref(null);
const dataPagination = ref({
total: 153,
page: 0,
pages: 10,
perPage: 15,
});

onMounted(async () => {
data.value = await getData();
columnsConfig.value = getColumns("tasks");
});
const data = ref(null);
const columnsConfig = ref(null);
const dataPagination = ref({
total: 153,
page: 0,
pages: 10,
perPage: 15,
});

return {
data,
dataPagination,
columnsConfig,
};
},
onMounted(async () => {
data.value = await getData();
columnsConfig.value = getColumns("tasks");
});
</script>
19 changes: 18 additions & 1 deletion resources/jscomposition/cases/casesDetail/config/columns.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,39 @@
import {
StatusCell,
LinkCell,
} from "../../../system/index";

export default {};

// Column for Task
const taskNumberColumn = () => ({
field: "id",
field: "case_number",
header: "Tasks #",
resizable: true,
width: 200,
cellRenderer: () => ({
component: LinkCell,
params: {
click: (row, column, columns) => {
window.document.location = `/tasks/${row.case_number}/edit`;
},
},
}),
});

const taskNameColumn = () => ({
field: "case_title",
header: "Task Name",
resizable: true,
width: 200,
cellRenderer: () => ({
component: LinkCell,
params: {
click: (row, column, columns) => {
window.document.location = `/tasks/${row.case_number}/edit`;
},
},
}),
});

const processNameColumn = () => ({
Expand Down
65 changes: 28 additions & 37 deletions resources/jscomposition/system/table/cell/LinkCell.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<template>
<div
v-if="row.case_title_formatted"
class="tw-text-nowrap tw-whitespace-nowrap tw-overflow-hidden tw-text-ellipsis"
:style="{ width: column.width + 'px' } ">
<a
Expand All @@ -11,45 +10,37 @@
</a>
</div>
</template>
<script>
import { defineComponent } from "vue";
<script setup>
import { defineProps } from "vue";
import { isFunction, get } from "lodash";

export default defineComponent({
props: {
columns: {
type: Array,
default: () => [],
},
column: {
type: Object,
default: () => ({}),
},
row: {
type: Object,
default: () => ({}),
},
click: {
type: Function,
default: new Function(),
},
const props = defineProps({
columns: {
type: Array,
default: () => [],
},
setup(props) {
const getValue = () => {
if (isFunction(props.column?.formatter)) {
return props.column?.formatter(props.row, props.column, props.columns);
}
return get(props.row, props.column?.field) || "";
};

const onClick = () => {
props.click && props.click(props.row, props.column, props.columns);
};

return {
onClick,
getValue,
};
column: {
type: Object,
default: () => ({}),
},
row: {
type: Object,
default: () => ({}),
},
click: {
type: Function,
default: new Function(),
},
});

const getValue = () => {
if (isFunction(props.column?.formatter)) {
return props.column?.formatter(props.row, props.column, props.columns);
}
return get(props.row, props.column?.field) || "";
};

const onClick = () => {
props.click && props.click(props.row, props.column, props.columns);
};
</script>