parent
							
								
									eb4537afb1
								
							
						
					
					
						commit
						6f01fbf00f
					
				
					 5 changed files with 42 additions and 0 deletions
				
			
		
							
								
								
									
										23
									
								
								app/components/confirm-button.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								app/components/confirm-button.js
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,23 @@ | ||||||
|  | import Component from '@ember/component'; | ||||||
|  | 
 | ||||||
|  | export default Component.extend({ | ||||||
|  |   tagName: 'span', | ||||||
|  |   showConfirm: false, | ||||||
|  |   initialLabel: 'LABEL', | ||||||
|  |   confirmLabel: 'CONFIRM LABEL', | ||||||
|  |   cancelLabel: 'Cancel', | ||||||
|  | 
 | ||||||
|  |   actions: { | ||||||
|  |     initial() { | ||||||
|  |       this.set('showConfirm', true); | ||||||
|  |     }, | ||||||
|  | 
 | ||||||
|  |     cancel() { | ||||||
|  |       this.set('showConfirm', false); | ||||||
|  |     }, | ||||||
|  | 
 | ||||||
|  |     confirm() { | ||||||
|  |       this.get('onClick')(); | ||||||
|  |     }, | ||||||
|  |   }, | ||||||
|  | }); | ||||||
|  | @ -5,5 +5,10 @@ export default Controller.extend({ | ||||||
|     editCollection() { |     editCollection() { | ||||||
|       this.transitionToRoute('collections.detail.edit', this.get('model')); |       this.transitionToRoute('collections.detail.edit', this.get('model')); | ||||||
|     }, |     }, | ||||||
|  |     deleteCollection() { | ||||||
|  |       this.get('model')[0].destroyRecord().then(() => { | ||||||
|  |         this.transitionToRoute('collections'); | ||||||
|  |       }); | ||||||
|  |     }, | ||||||
|   }, |   }, | ||||||
| }); | }); | ||||||
|  |  | ||||||
|  | @ -2,4 +2,5 @@ | ||||||
|   collection/detail-container |   collection/detail-container | ||||||
|   model=model |   model=model | ||||||
|   editCollection=(action 'editCollection') |   editCollection=(action 'editCollection') | ||||||
|  |   deleteCollection=(action 'deleteCollection') | ||||||
| }} | }} | ||||||
|  |  | ||||||
|  | @ -5,6 +5,13 @@ | ||||||
|   onClick=(action editCollection) |   onClick=(action editCollection) | ||||||
| }} | }} | ||||||
| 
 | 
 | ||||||
|  | {{ | ||||||
|  |   confirm-button | ||||||
|  |   initialLabel='Delete Collection' | ||||||
|  |   confirmLabel='Yes, Delete Collection' | ||||||
|  |   onClick=(action deleteCollection) | ||||||
|  | }} | ||||||
|  | 
 | ||||||
| <h3>Main Detail</h3> | <h3>Main Detail</h3> | ||||||
| <div class="row"> | <div class="row"> | ||||||
|   <div class="col-md-12"> |   <div class="col-md-12"> | ||||||
|  |  | ||||||
							
								
								
									
										6
									
								
								app/templates/components/confirm-button.hbs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								app/templates/components/confirm-button.hbs
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,6 @@ | ||||||
|  | {{#if showConfirm}} | ||||||
|  |   {{action-button isDanger=true label=cancelLabel onClick=(action 'cancel')}} | ||||||
|  |   {{action-button isSuccess=true label=confirmLabel onClick=(action 'confirm')}} | ||||||
|  | {{else}} | ||||||
|  |   {{action-button isDanger=true label=initialLabel onClick=(action 'initial')}} | ||||||
|  | {{/if}} | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 GitHub
							GitHub