You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					39 lines
				
				836 B
			
		
		
			
		
	
	
					39 lines
				
				836 B
			| 
								 
											3 years ago
										 
									 | 
							
								"use strict";
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								Object.defineProperty(exports, "__esModule", {
							 | 
						||
| 
								 | 
							
								  value: true
							 | 
						||
| 
								 | 
							
								});
							 | 
						||
| 
								 | 
							
								exports.actionHref = void 0;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								var _viewHelpers = require("../../../backend/utils/view-helpers");
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								const h = new _viewHelpers.ViewHelpers();
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								const actionHref = (action, params) => {
							 | 
						||
| 
								 | 
							
								  const actionName = action.name;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								  if (!action.component && !action.hasHandler) {
							 | 
						||
| 
								 | 
							
								    return null;
							 | 
						||
| 
								 | 
							
								  }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								  const hrefMap = {
							 | 
						||
| 
								 | 
							
								    record: () => h.recordActionUrl({ ...params,
							 | 
						||
| 
								 | 
							
								      actionName
							 | 
						||
| 
								 | 
							
								    }),
							 | 
						||
| 
								 | 
							
								    resource: () => h.resourceActionUrl({
							 | 
						||
| 
								 | 
							
								      resourceId: params.resourceId,
							 | 
						||
| 
								 | 
							
								      actionName
							 | 
						||
| 
								 | 
							
								    }),
							 | 
						||
| 
								 | 
							
								    bulk: () => h.bulkActionUrl({ ...params,
							 | 
						||
| 
								 | 
							
								      actionName
							 | 
						||
| 
								 | 
							
								    })
							 | 
						||
| 
								 | 
							
								  };
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								  if (hrefMap[action.actionType]) {
							 | 
						||
| 
								 | 
							
								    return hrefMap[action.actionType]();
							 | 
						||
| 
								 | 
							
								  }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								  throw new Error('"actionType" should be either record, resource or bulk');
							 | 
						||
| 
								 | 
							
								};
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								exports.actionHref = actionHref;
							 |