@@ -378,24 +378,29 @@ class="collapse show"
378378 </b-col >
379379 <b-col >
380380 <div class =" retention-body retention-period" >
381- <h5 class =" retention-header pb-1" >{{ __ (' Retention Period' )} } <h5 >
381+ <h5 class =" retention-header pb-1" >{{ __ (' Retention Period' ) } } </ h5 >
382382 <p class =" retention-text" >{{ __ (' Retention periods over one year must be handled by Technical Support. Please contact Technical Support for assistance.' ) } } </p >
383383 </div >
384384 <div class =" form-group p-0 mb-4" >
385385 {{ html ()-> label (__ (' Select a Retention Period' ), ' selectRetentionPeriod' ) } }
386386 <multiselect
387387 id =" selectRetentionPeriod"
388- :value =" canSelectRetentionPeriod"
389- @input = " onRetentionPeriodSelect "
390- :options = " retentionPeriodOptions "
388+ v-model =" canSelectRetentionPeriod"
389+ :options = " retentionPeriodSelectOptions "
390+ @input = " onRetentionPeriodSelect($event) "
391391 :multiple =" false"
392392 :show-labels =" false"
393393 placeholder =" {{ __ (' Select a Retention Period' )} }"
394394 track-by =" id"
395395 label =" fullname"
396396 >
397- <template slot =" option" slot-scope =" props" >
398- <span :class =" { 'font-italic': props.option.id === 'two_years' || props.option.id === 'three_years' }" >@ {{ props.option.fullname }}</span >
397+ <template slot =" option" slot-scope =" { option }" >
398+ <span v-if =" !option.$isDisabled" >
399+ @ {{ option.fullname }}
400+ </span >
401+ <span v-else >
402+ @ {{ option.fullname }} ({{ __ (' Available on Support request' ) } } )
403+ </span >
399404 </template >
400405 </multiselect >
401406 </div >
@@ -671,15 +676,18 @@ class="custom-control-input">
671676 },
672677 maxManagers: 10 ,
673678 retentionPeriodOptions: [
679+ { id: ' six_months' , fullname: ' Six months after case creation' },
674680 { id: ' one_year' , fullname: ' One year after case creation' },
675- { id: ' two_years ' , fullname: ' Two years after case creation (Available on Support request) ' },
676- { id: ' three_years ' , fullname: ' Three years after case creation (Available on Support request) ' }
681+ { id: ' three_years ' , fullname: ' Three years after case creation' },
682+ { id: ' five_years ' , fullname: ' Five years after case creation' }
677683 ],
678684 canSelectRetentionPeriod: { id: ' one_year' , fullname: ' One year after case creation' },
685+ allowedRetentionPeriods: @json (config (' app.case_retention_tier_options' )[config (' app.case_retention_tier' )] ?? [' six_months' , ' one_year' ] ),
679686 showRetentionConfirmModal: false ,
680687 retentionModalStep: ' confirm' ,
681688 pendingRetentionPeriod: null ,
682- caseRetentionPolicyEnabled: @json (config (' app.case_retention_policy_enabled' ) )
689+ caseRetentionPolicyEnabled: @json (config (' app.case_retention_policy_enabled' ) ),
690+ lastConfirmedRetentionPeriod: null ,
683691 }
684692 },
685693 mounted () {
@@ -702,16 +710,29 @@ class="custom-control-input">
702710 this .activeTab = target[1 ];
703711 }
704712
705- if (this .caseRetentionPolicyEnabled && _ .get (this .formData , ' properties.retention_period' )) {
706- const id = this .formData .properties .retention_period ;
707- const option = this .retentionPeriodOptions .find (opt => opt .id === id);
708- if (option) {
713+ if (this .caseRetentionPolicyEnabled ) {
714+ const savedId = _ .get (this .formData , ' properties.retention_period' );
715+ const allowed = this .allowedRetentionPeriods || [];
716+ const option = this .retentionPeriodOptions .find (opt => opt .id === savedId);
717+ if (option && allowed .includes (savedId)) {
709718 this .canSelectRetentionPeriod = option;
719+ } else {
720+ const defaultId = allowed .includes (' one_year' ) ? ' one_year' : allowed[0 ];
721+ this .canSelectRetentionPeriod = this .retentionPeriodOptions .find (opt => opt .id === defaultId) || null ;
710722 }
711723 }
712724
725+ this .lastConfirmedRetentionPeriod = this .canSelectRetentionPeriod ;
713726 },
714727 computed: {
728+ retentionPeriodSelectOptions () {
729+ const allowed = this .allowedRetentionPeriods || [];
730+
731+ return this .retentionPeriodOptions .map (opt => ({
732+ ... opt,
733+ $isDisabled: ! allowed .includes (opt .id )
734+ }));
735+ },
715736 activeUsersAndGroupsWithManager () {
716737 const usersAndGroups = _ .cloneDeep (this .activeUsersAndGroups );
717738 usersAndGroups[0 ][' items' ].unshift (this .processManagerOption ());
@@ -843,25 +864,34 @@ class="custom-control-input">
843864 this .$refs [" listReassignment" ].add ();
844865 },
845866 onRetentionPeriodSelect (newVal ) {
846- if (! newVal || ( this .canSelectRetentionPeriod && newVal . id === this . canSelectRetentionPeriod . id ) ) {
867+ if (! newVal || ! this .lastConfirmedRetentionPeriod ) {
847868 return ;
848869 }
870+
871+ if (newVal .id === this .lastConfirmedRetentionPeriod .id ) {
872+ return ;
873+ }
874+
849875 this .pendingRetentionPeriod = newVal;
850876 this .retentionModalStep = ' confirm' ;
851877 this .showRetentionConfirmModal = true ;
852878 },
853879 confirmRetentionChange () {
854- if (this .pendingRetentionPeriod ) {
855- this .canSelectRetentionPeriod = this .pendingRetentionPeriod ;
856- this .formData .properties = this .formData .properties || {};
857- this .formData .properties .retention_period = this .pendingRetentionPeriod .id ;
858- }
859- this .retentionModalStep = ' success' ;
880+ if (this .pendingRetentionPeriod ) {
881+ this .canSelectRetentionPeriod = this .pendingRetentionPeriod ;
882+ this .lastConfirmedRetentionPeriod = this .pendingRetentionPeriod ;
883+
884+ this .formData .properties = this .formData .properties || {};
885+ this .formData .properties .retention_period = this .pendingRetentionPeriod .id ;
886+ }
887+
888+ this .retentionModalStep = ' success' ;
860889 },
861890 cancelRetentionChange () {
862- this .showRetentionConfirmModal = false ;
891+ this .canSelectRetentionPeriod = this . lastConfirmedRetentionPeriod ;
863892 this .pendingRetentionPeriod = null ;
864893 this .retentionModalStep = ' confirm' ;
894+ this .showRetentionConfirmModal = false ;
865895 },
866896 closeRetentionSuccessModal () {
867897 this .showRetentionConfirmModal = false ;
0 commit comments