Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QA Observation Bugfix/FOUR-14061: Saved search custom date columns showing wrong date/time #6187

Merged
merged 6 commits into from
Feb 8, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
44 changes: 5 additions & 39 deletions resources/js/components/shared/FilterTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,20 @@
v-for="(header, index) in headers"
:key="index"
>
<template v-if="containsHTML(getNestedPropertyValue(row, header.field))">
<template v-if="containsHTML(getNestedPropertyValue(row, header))">
<div
:id="`${tableName}-element-${rowIndex}-${index}`"
:class="{ 'pm-table-truncate': header.truncate }"
:style="{ maxWidth: header.width + 'px' }"
>
<div v-html="sanitize(getNestedPropertyValue(row, header.field))"></div>
<div v-html="sanitize(getNestedPropertyValue(row, header))"></div>
</div>
<b-tooltip
v-if="header.truncate"
:target="`${tableName}-element-${rowIndex}-${index}`"
custom-class="pm-table-tooltip"
>
{{ sanitizeTooltip(getNestedPropertyValue(row, header.field)) }}
{{ sanitizeTooltip(getNestedPropertyValue(row, header)) }}
</b-tooltip>
</template>
<template v-else>
Expand All @@ -92,13 +92,13 @@
:class="{ 'pm-table-truncate': header.truncate }"
:style="{ maxWidth: header.width + 'px' }"
>
{{ getNestedPropertyValue(row, header.field) }}
{{ getNestedPropertyValue(row, header) }}
<b-tooltip
v-if="header.truncate"
:target="`${tableName}-element-${rowIndex}-${index}`"
custom-class="pm-table-tooltip"
>
{{ getNestedPropertyValue(row, header.field) }}
{{ getNestedPropertyValue(row, header) }}
</b-tooltip>
</div>
</template>
Expand Down Expand Up @@ -157,21 +157,6 @@ export default {
resizingColumnIndex: -1,
};
},
watch: {
data() {
this.headers.forEach((column) => {
if (column.format) {
if (column.format === "datetime" || column.format === "date") {
if (this.data?.data?.forEach) {
this.data.data.forEach((element) => {
element[column.field] = this.formatDate(element[column.field], column.format);
});
}
}
}
});
},
},
mounted() {
this.$nextTick(() => {
this.calculateColumnWidth();
Expand Down Expand Up @@ -223,25 +208,6 @@ export default {
this.resizingColumnIndex = -1;
}
},
formatDate(value, format) {
let config = "";
if (typeof ProcessMaker !== "undefined" && ProcessMaker.user && ProcessMaker.user.datetime_format) {
if (format === "datetime") {
config = ProcessMaker.user.datetime_format;
}
if (format === "date") {
config = ProcessMaker.user.datetime_format.replace(/[\sHh:msaAzZ]/g, "");
}
}
if (value) {
if (moment(value).isValid()) {
return window.moment(value)
.format(config);
}
return value;
}
return "-";
},
handleRowClick(row) {
this.$emit("table-row-click", row);
},
Expand Down
26 changes: 24 additions & 2 deletions resources/js/components/shared/FilterTableBodyMixin.js
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can try replacing this line when the filter table formats the data on filtertable.vue

watch: {
data() {
this.headers.forEach((column) => {
if (column.format) {
if (column.format === "datetime" || column.format === "date") {
if (this.data?.data?.forEach) {
this.data.data.forEach((element) => {
//element[column.field] = this.formatDate(element[column.field], column.format);
set(element, column.field, this.formatDate(this.getNestedPropertyValue(element, column.field), column.format));
});
}
}
}
});
},
},

Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,30 @@ export default {
formatCategory(categories) {
return categories.map(item => item.name).join(', ');
},
getNestedPropertyValue(obj, path) {
return get(obj, path);
getNestedPropertyValue(obj, header) {
return this.format(get(obj, header.field), header);
},
format(value, header) {
let config = "";
if (header.format === "datetime") {
config = ProcessMaker.user.datetime_format;
value = this.convertUTCToLocal(value, config)
}
if (header.format === "date") {
config = ProcessMaker.user.datetime_format.replace(/[\sHh:msaAzZ]/g, "");
value = this.convertUTCToLocal(value, config)
}
return value;
},
convertUTCToLocal(value, config) {
if (value) {
if (moment(value).isValid()) {
return window.moment(value)
.format(config);
}
return value;
}
return "-";
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
<div
:style="{ maxWidth: header.width + 'px' }"
>
{{ row[header.field] }}
{{ getNestedPropertyValue(row, header) }}
</div>
</template>
</template>
Expand Down
2 changes: 1 addition & 1 deletion resources/js/processes/components/ArchivedProcessList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
<div
:style="{ maxWidth: header.width + 'px' }"
>
{{ row[header.field] }}
{{ getNestedPropertyValue(row, header) }}
</div>
</template>
</template>
Expand Down
2 changes: 1 addition & 1 deletion resources/js/processes/components/ProcessesListing.vue
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
<div
:style="{ maxWidth: header.width + 'px' }"
>
{{ row[header.field] }}
{{ getNestedPropertyValue(row, header) }}
</div>
</template>
</template>
Expand Down
10 changes: 5 additions & 5 deletions resources/js/requests/components/RequestsListing.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,20 @@
v-for="(header, colIndex) in tableHeaders"
:key="colIndex"
>
<template v-if="containsHTML(getNestedPropertyValue(row, header.field))">
<template v-if="containsHTML(getNestedPropertyValue(row, header))">
<div
:id="`element-${rowIndex}-${colIndex}`"
:class="{ 'pm-table-truncate': header.truncate }"
:style="{ maxWidth: header.width + 'px' }"
>
<span v-html="sanitize(getNestedPropertyValue(row, header.field))"></span>
<span v-html="sanitize(getNestedPropertyValue(row, header))"></span>
</div>
<b-tooltip
v-if="header.truncate"
:target="`element-${rowIndex}-${colIndex}`"
custom-class="pm-table-tooltip"
>
{{ sanitizeTooltip(getNestedPropertyValue(row, header.field)) }}
{{ sanitizeTooltip(getNestedPropertyValue(row, header)) }}
</b-tooltip>
</template>
<template v-else>
Expand All @@ -72,13 +72,13 @@
:class="{ 'pm-table-truncate': header.truncate }"
:style="{ maxWidth: header.width + 'px' }"
>
{{ getNestedPropertyValue(row, header.field) }}
{{ getNestedPropertyValue(row, header) }}
<b-tooltip
v-if="header.truncate"
:target="`element-${rowIndex}-${colIndex}`"
custom-class="pm-table-tooltip"
>
{{ getNestedPropertyValue(row, header.field) }}
{{ getNestedPropertyValue(row, header) }}
</b-tooltip>
</div>
</template>
Expand Down
12 changes: 6 additions & 6 deletions resources/js/tasks/components/TasksList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,20 @@
v-for="(header, colIndex) in tableHeaders"
:key="colIndex"
>
<template v-if="containsHTML(getNestedPropertyValue(row, header.field))">
<template v-if="containsHTML(getNestedPropertyValue(row, header))">
<div
:id="`element-${rowIndex}-${colIndex}`"
:class="{ 'pm-table-truncate': header.truncate }"
:style="{ maxWidth: header.width + 'px' }"
>
<span v-html="sanitize(getNestedPropertyValue(row, header.field))"></span>
<span v-html="sanitize(getNestedPropertyValue(row, header))"></span>
</div>
<b-tooltip
v-if="header.truncate"
:target="`element-${rowIndex}-${colIndex}`"
custom-class="pm-table-tooltip"
>
{{ sanitizeTooltip(getNestedPropertyValue(row, header.field)) }}
{{ sanitizeTooltip(getNestedPropertyValue(row, header)) }}
</b-tooltip>
</template>
<template v-else>
Expand All @@ -71,7 +71,7 @@
<template v-else>
<template v-if="header.field === 'due_at'">
<span :class="['badge', 'badge-'+row['color_badge'], 'due-'+row['color_badge']]">
{{ formatRemainingTime(getNestedPropertyValue(row, header.field)) }}
{{ formatRemainingTime(getNestedPropertyValue(row, header)) }}
</span>
<span>{{ row["due_date"] }}</span>
</template>
Expand All @@ -81,13 +81,13 @@
:class="{ 'pm-table-truncate': header.truncate }"
:style="{ maxWidth: header.width + 'px' }"
>
{{ getNestedPropertyValue(row, header.field) }}
{{ getNestedPropertyValue(row, header) }}
<b-tooltip
v-if="header.truncate"
:target="`element-${rowIndex}-${colIndex}`"
custom-class="pm-table-tooltip"
>
{{ getNestedPropertyValue(row, header.field) }}
{{ getNestedPropertyValue(row, header) }}
</b-tooltip>
</div>
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
<div
:style="{ maxWidth: header.width + 'px' }"
>
{{ row[header.field] }}
{{ getNestedPropertyValue(row, header) }}
</div>
</template>
</template>
Expand Down