| 
									
										
										
										
											2021-04-21 15:38:00 +08:00
										 |  |  | import { isArray } from 'lodash'; | 
					
						
							| 
									
										
										
										
											2022-04-22 21:33:13 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-09 15:37:16 +08:00
										 |  |  | import coreModule from './core_module'; | 
					
						
							| 
									
										
										
										
											2015-09-11 16:54:56 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-12 17:49:14 +08:00
										 |  |  | export function arrayJoin() { | 
					
						
							| 
									
										
										
										
											2017-12-20 19:33:33 +08:00
										 |  |  |   'use strict'; | 
					
						
							| 
									
										
										
										
											2015-09-12 03:04:02 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-11 16:54:56 +08:00
										 |  |  |   return { | 
					
						
							| 
									
										
										
										
											2017-12-20 19:33:33 +08:00
										 |  |  |     restrict: 'A', | 
					
						
							|  |  |  |     require: 'ngModel', | 
					
						
							| 
									
										
										
										
											2019-04-28 15:58:12 +08:00
										 |  |  |     link: (scope: any, element: any, attr: any, ngModel: any) => { | 
					
						
							|  |  |  |       function split_array(text: string) { | 
					
						
							| 
									
										
										
										
											2017-12-20 19:33:33 +08:00
										 |  |  |         return (text || '').split(','); | 
					
						
							| 
									
										
										
										
											2015-09-11 16:54:56 +08:00
										 |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-28 15:58:12 +08:00
										 |  |  |       function join_array(text: string) { | 
					
						
							| 
									
										
										
										
											2021-04-21 15:38:00 +08:00
										 |  |  |         if (isArray(text)) { | 
					
						
							| 
									
										
										
										
											2019-04-15 18:11:52 +08:00
										 |  |  |           return ((text || '') as any).join(','); | 
					
						
							| 
									
										
										
										
											2015-09-11 16:54:56 +08:00
										 |  |  |         } else { | 
					
						
							|  |  |  |           return text; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       ngModel.$parsers.push(split_array); | 
					
						
							|  |  |  |       ngModel.$formatters.push(join_array); | 
					
						
							| 
									
										
										
										
											2017-12-20 19:33:33 +08:00
										 |  |  |     }, | 
					
						
							| 
									
										
										
										
											2015-09-11 16:54:56 +08:00
										 |  |  |   }; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-20 19:33:33 +08:00
										 |  |  | coreModule.directive('arrayJoin', arrayJoin); |