@@ -29,13 +29,65 @@ export default {
2929	data () { 
3030		return  { 
3131			identifier:  this .heartbeatManager .generateId (32 ), 
32+ 			confirmed:  false , 
3233		}; 
3334	}, 
3435
36+ 	methods:  { 
37+ 		propagateLostLock () { 
38+ 			const  lockedBy  =  this .$page .props .locked ? .locked_by ? .name ; 
39+ 			const  message  =  this .$page .props .locked ? .model_msg_prefix  +  '  wurde von ***' +  lockedBy +  ' *** übernommen. Ungespeicherte Änderungen sind ggf. verloren.'  
40+ 			window .alert (message); 
41+ 
42+ 			return  window .location  =  this .route (this .$page .props .locked ? .redirect_route_name ); 
43+ 		}, 
44+ 
45+ 		handleLockState () { 
46+ 			//  redirect if it's a claim call 
47+ 			if  (this .$page .url .includes (' claimLock=' return  window .location  =  this .$page .url .split (' ?' 0 ]; 
48+ 			//  ignore the logic if there is no lock 
49+ 			if  (! this .$page .props ? .locked ) return ; 
50+ 
51+ 			if  (this .route ().params ? .lostLock ) return  this .propagateLostLock (); 
52+ 
53+ 			return  this .handleLockedState (); 
54+ 		}, 
55+ 
56+ 		handleLostLock () { 
57+ 			if  (this .route ().params ? .lostLock ) return ; 
58+ 			const  params  =  this .route ().params ; 
59+ 			params .lostLock  =  true ; 
60+ 
61+ 			return  window .location  =  this .route (this .route ().current (), params); 
62+ 		}, 
63+ 
64+ 		handleLockedState () { 
65+ 			const  lockedBy  =  this .$page .props .locked ? .locked_by ? .name ; 
66+ 			const  message  =  this .$page .props .locked ? .model_msg_prefix  +  '  ist aktuell durch ***' +  lockedBy +  ' *** in Bearbeitung.\n\n Möchtest du die Bearbeitung erzwingen?\n\n Ungespeicherte Inhalte des anderen Benutzers gehen dabei ggf. verloren.'  
67+ 
68+ 			//  if the claim is not forced, the user is redirected redirect route 
69+ 			if  (window .confirm (message) !==  true ) { 
70+ 				//  this.$inertia.visit does not work here 
71+ 				return  window .location  =  this .route (this .$page .props .locked ? .redirect_route_name ); 
72+ 			} 
73+ 
74+ 			const  params  =  this .route ().params ; 
75+ 			params .claimLock  =  true ; 
76+ 
77+ 			return  this .$inertia .visit (this .route (this .route ().current (), params)); 
78+ 		}, 
79+ 	}, 
80+ 
3581	mounted () { 
82+ 		this .handleLockState (); 
83+ 
3684		const  refreshCallback  =  lockStateData  =>  { 
37- 			if  (lockStateData .locked_by  &&  ! lockStateData .locked_by .is_current_user ) { 
85+ 			if  (this .confirmed  &&  lockStateData .locked_by  &&  ! lockStateData .locked_by .is_current_user ) { 
86+ 				this .handleLostLock (); 
87+ 
3888				return  this .$emit (' lost'  
89+ 			} else  if  (lockStateData .locked_by  &&  lockStateData .locked_by .is_current_user ) { 
90+ 				this .confirmed  =  true ; 
3991			} 
4092
4193			this .identifier  =  this .heartbeatManager .generateId (32 ); 
0 commit comments