diff --git a/resources/views/processes/edit.blade.php b/resources/views/processes/edit.blade.php index 531db91a92..efe5ffb8ec 100644 --- a/resources/views/processes/edit.blade.php +++ b/resources/views/processes/edit.blade.php @@ -405,7 +405,9 @@ class="collapse show"
- {{ __('The default retention period is in effect.')}} + {{ __('The default retention period is in effect.')}} + + {{ __('Last modified by: ') }}@{{ retentionUpdatedBy.fullname.trim() }}{{ __(', at') }} @{{formatDateUser(retentionUpdatedBy.date) }}
pendingRetentionPeriod: null, caseRetentionPolicyEnabled: @json(config('app.case_retention_policy_enabled')), lastConfirmedRetentionPeriod: null, + originalRetentionPeriodId: null, + retentionUpdatedBy: { + id: null, + fullname: null, + date: null, + }, } }, mounted() { @@ -723,6 +731,12 @@ class="custom-control-input"> } this.lastConfirmedRetentionPeriod = this.canSelectRetentionPeriod; + this.originalRetentionPeriodId = this.canSelectRetentionPeriod ? this.canSelectRetentionPeriod.id : null; + this.retentionUpdatedBy = { + id: _.get(this.formData, 'properties.retention_updated_by.id'), + fullname: _.get(this.formData, 'properties.retention_updated_by.fullname'), + date: _.get(this.formData, 'properties.retention_updated_at'), + }; }, computed: { retentionPeriodSelectOptions() { @@ -835,6 +849,23 @@ class="custom-control-input"> ? this.canSelectRetentionPeriod.id : this.getDefaultRetentionPeriodId(); this.formData.properties.retention_period = retentionPeriod; + // Log retention period update only if the retention period is changed from the original value + if (this.formData.properties.retention_period !== this.originalRetentionPeriodId) { + // The logged in user is the one who updated the retention period + const userID = document.head.querySelector("meta[name=\"user-id\"]"); + const userFullName = document.head.querySelector("meta[name=\"user-full-name\"]"); + this.formData.properties.retention_updated_by = { + id: userID.content, + fullname: userFullName.content, + }; + const updatedAt = new Date().toISOString(); + this.formData.properties.retention_updated_at = updatedAt; + this.retentionUpdatedBy = { + id: parseInt(userID?.content ?? 0), + fullname: userFullName?.content ?? '', + date: updatedAt, + }; + } } ProcessMaker.apiClient.put('processes/' + that.formData.id, that.formData) @@ -871,7 +902,7 @@ class="custom-control-input"> return allowed.includes('one_year') ? 'one_year' : (allowed[0] || null); }, onRetentionPeriodSelect(newVal) { - if (!newVal || !this.lastConfirmedRetentionPeriod) { + if (!newVal || !this.lastConfirmedRetentionPeriod) { return; } @@ -884,15 +915,15 @@ class="custom-control-input"> this.showRetentionConfirmModal = true; }, confirmRetentionChange() { - if (this.pendingRetentionPeriod) { - this.canSelectRetentionPeriod = this.pendingRetentionPeriod; - this.lastConfirmedRetentionPeriod = this.pendingRetentionPeriod; + if (this.pendingRetentionPeriod) { + this.canSelectRetentionPeriod = this.pendingRetentionPeriod; + this.lastConfirmedRetentionPeriod = this.pendingRetentionPeriod; - this.formData.properties = this.formData.properties || {}; - this.formData.properties.retention_period = this.pendingRetentionPeriod.id; - } + this.formData.properties = this.formData.properties || {}; + this.formData.properties.retention_period = this.pendingRetentionPeriod.id; + } - this.retentionModalStep = 'success'; + this.retentionModalStep = 'success'; }, cancelRetentionChange() { this.canSelectRetentionPeriod = this.lastConfirmedRetentionPeriod; @@ -908,11 +939,26 @@ class="custom-control-input"> if (this.retentionModalStep === 'confirm') { this.cancelRetentionChange(); } + }, + formatDateUser(value) { + let config = ""; + if (typeof ProcessMaker !== "undefined" && ProcessMaker.user && ProcessMaker.user.datetime_format) { + config = ProcessMaker.user.datetime_format; + } + + if (value) { + if (moment(value).isValid()) { + return window.moment(value) + .format(config); + } + return value; + } + return "n/a"; } }, + }); }); - @endsection @@ -1095,7 +1141,6 @@ class="custom-control-input"> } .default-retention { - font-style: italic; background-color: #F1F2F4; border-radius: 8px; }