(function(){const b=new VueJsAsyncComponentTemplateRepository(webContext+"/processManager/jsp/javaScript/vuejs/reassignment-templates.jsp");const a={mixins:[VuejsI18nTemplateMixin],inject:["context","commonService"],data:function(){return{reassignmentData:{incumbent:{},substitute:{}},roleManager:undefined}},created:function(){this.commonService.promiseRoleManager().then(function(c){this.roleManager=c}.bind(this))},methods:{resetMixinData:function(){this.reassignmentData={incumbent:{},substitute:{}}},formatRoles:function(c){return this.$filters.joinWith(this.$filters.mapRoleLabel(c),{separator:", ",lastSeparator:" "+this.messages.andLabel+" "})}},computed:{incumbentUserId:function(){return this.reassignmentData.incumbent&&this.reassignmentData.incumbent.id},substituteUserId:function(){return this.reassignmentData.substitute&&this.reassignmentData.substitute.id},workflowRoleFilter:function(){if(this.roleManager){return this.$filters.mapRoleName(this.roleManager.getRolesOfComponentInstance())}},incumbentRoles:function(){if(this.incumbentUserId){return this.roleManager.getRolesOfUser(this.incumbentUserId)}},formattedIncumbentRoles:function(){return this.formatRoles(this.incumbentRoles)},substituteRoleFilter:function(){if(this.incumbentUserId){return this.$filters.mapRoleName(this.roleManager.getRolesOfUser(this.incumbentUserId))}},substituteRoles:function(){if(this.substituteUserId){return this.roleManager.getRolesOfUser(this.substituteUserId)}},formattedSubstituteRoles:function(){return this.formatRoles(this.substituteRoles)},notMatchingRoles:function(){if(this.incumbentRoles&&this.substituteRoles){return this.roleManager.getNotMatchingRoles(this.incumbentUserId,this.substituteUserId)}},notMatchingFormattedRoles:function(){return this.formatRoles(this.notMatchingRoles)}}};SpVue.component("workflow-reassignment-management",b.get("management",{mixins:[VuejsApiMixin,VuejsI18nTemplateMixin,VuejsProgressMessageMixin],inject:["context"],data:function(){return{reassignmentPopinApi:undefined}},created:function(){this.extendApiWith({openReassignment:this.openReassignment})},methods:{openReassignment:function(){this.reassignmentPopinApi.open()}}}));SpVue.component("workflow-reassignment-popin",b.get("popin",{mixins:[VuejsDefaultFormPanePopinApiMixin,VuejsI18nTemplateMixin,VuejsProgressMessageMixin],emits:["reassignment-applied"],inject:["context"],created:function(){this.extendApiWith({open:this.open})},methods:{open:function(){this.formApi.initFormData();this.$super(VuejsDefaultFormPanePopinApiMixin).open()},validate:function(){return this.formPaneApi.validate().then(this.applyReassignment)},applyReassignment:function(c){this.showProgressMessage();const d=sp.form.toFormData({sourceUserId:c.incumbent.id,destinationUserId:c.substitute.id});return sp.ajaxRequest("adminReplaceInAllTasks").byPostMethod().send(d).then(function(){this.$emit("reassignment-applied");this.hideProgressMessage()}.bind(this))["catch"](function(){SilverpeasError.add(sp.i18n.get("GML.error.help")).show();this.hideProgressMessage()}.bind(this))}}}));SpVue.component("workflow-reassignment-form",b.get("form",{mixins:[VuejsFormApiMixin,VuejsI18nTemplateMixin,a],inject:["context","rootFormMessages"],data:function(){return{selectIncumbentApi:undefined,selectSubstituteApi:undefined,substituteRoleFilterItems:undefined}},created:function(){this.extendApiWith({initFormData:this.initFormData,validateForm:function(){const c=this.reassignmentData;if(c.substitute.id===c.incumbent.id){this.rootFormApi.errorMessage().add(this.formatMessage(this.rootFormMessages.mustBeDifferentFrom,[this.messages.substituteLabel,this.messages.incumbentLabel]))}if(this.notMatchingRoles&&this.notMatchingRoles.length>0){this.rootFormApi.errorMessage().add(this.formatMessage(this.messages.mustHaveSameRoles))}return this.rootFormApi.errorMessage().none()},updateFormData:function(c){c.incumbent=extendsObject({},this.reassignmentData.incumbent);c.substitute=extendsObject({},this.reassignmentData.substitute)}})},methods:{initFormData:function(){this.resetMixinData();this.selectIncumbentApi.refresh();this.selectSubstituteApi.refresh()},applyUserFullName:function(c){c.fullName="";if(c.id){User.get(c.id).then(function(d){c.fullName=d.fullName})}},incumbentChanged:function(c){this.reassignmentData.incumbent.id=c.length?c[0]:""},substituteChanged:function(c){this.reassignmentData.substitute.id=c.length?c[0]:"";this.applyUserFullName(this.reassignmentData.substitute)}}}))})();