Add "contact update request" workflow for new custorder batch
if user checks "please add phone to customer record" etc. then this preference is stored in the batch params, and when batch is executed that will "happen" (which may just mean someone gets email about it)
This commit is contained in:
		
							parent
							
								
									2fa7857daf
								
							
						
					
					
						commit
						9b40096bb7
					
				
					 3 changed files with 41 additions and 18 deletions
				
			
		|  | @ -127,8 +127,7 @@ | |||
|                                            @input="contactChanged"> | ||||
|                     </tailbone-autocomplete> | ||||
|                   </b-field> | ||||
|                   <div v-if="contactUUID" | ||||
|                        class="buttons"> | ||||
|                   <div v-if="contactUUID"> | ||||
|                     <b-button v-if="contactProfileURL" | ||||
|                               type="is-primary" | ||||
|                               tag="a" target="_blank" | ||||
|  | @ -137,6 +136,7 @@ | |||
|                               icon-left="external-link-alt"> | ||||
|                       View Profile | ||||
|                     </b-button> | ||||
|                       | ||||
|                     <b-button @click="refreshContact" | ||||
|                               icon-pack="fas" | ||||
|                               icon-left="redo"> | ||||
|  | @ -157,7 +157,10 @@ | |||
|                         </div> | ||||
|                         % if allow_contact_info_choice: | ||||
|                             <div class="level-item" | ||||
|                                  v-if="contactPhones.length > 1"> | ||||
|                                  % if restrict_contact_info: | ||||
|                                  v-if="contactPhones.length > 1" | ||||
|                                  % endif | ||||
|                                  > | ||||
|                               <b-button type="is-primary" | ||||
|                                         @click="editPhoneNumberInit()" | ||||
|                                         icon-pack="fas" | ||||
|  | @ -199,8 +202,7 @@ | |||
|                                                  grouped> | ||||
|                                           <b-input v-model="otherPhoneNumber"> | ||||
|                                           </b-input> | ||||
|                                           <b-checkbox v-model="addOtherPhoneNumber" | ||||
|                                                       disabled> | ||||
|                                           <b-checkbox v-model="addOtherPhoneNumber"> | ||||
|                                             add this phone number to customer record | ||||
|                                           </b-checkbox> | ||||
|                                         </b-field> | ||||
|  | @ -243,7 +245,10 @@ | |||
|                         </div> | ||||
|                         % if allow_contact_info_choice: | ||||
|                             <div class="level-item" | ||||
|                                  v-if="contactEmails.length > 1"> | ||||
|                                  % if restrict_contact_info: | ||||
|                                  v-if="contactEmails.length > 1" | ||||
|                                  % endif | ||||
|                                  > | ||||
|                               <b-button type="is-primary" | ||||
|                                         @click="editEmailAddressInit()" | ||||
|                                         icon-pack="fas" | ||||
|  | @ -284,8 +289,7 @@ | |||
|                                                  grouped> | ||||
|                                           <b-input v-model="otherEmailAddress"> | ||||
|                                           </b-input> | ||||
|                                           <b-checkbox v-model="addOtherEmailAddress" | ||||
|                                                       disabled> | ||||
|                                           <b-checkbox v-model="addOtherEmailAddress"> | ||||
|                                             add this email address to customer record | ||||
|                                           </b-checkbox> | ||||
|                                         </b-field> | ||||
|  | @ -593,13 +597,13 @@ | |||
| 
 | ||||
|                     existingPhoneUUID: null, | ||||
|                     otherPhoneNumber: null, | ||||
|                     addOtherPhoneNumber: false, | ||||
|                     addOtherPhoneNumber: ${json.dumps(add_phone_number)|n}, | ||||
|                     editPhoneNumberShowDialog: false, | ||||
|                     editPhoneNumberSaving: false, | ||||
| 
 | ||||
|                     existingEmailUUID: null, | ||||
|                     otherEmailAddress: null, | ||||
|                     addOtherEmailAddress: false, | ||||
|                     addOtherEmailAddress: ${json.dumps(add_email_address)|n}, | ||||
|                     editEmailAddressShowDialog: false, | ||||
|                     editEmailAddressSaving: false, | ||||
| 
 | ||||
|  | @ -915,6 +919,8 @@ | |||
|                     % endif | ||||
|                     that.orderPhoneNumber = response.data.phone_number | ||||
|                     that.orderEmailAddress = response.data.email_address | ||||
|                     that.addOtherPhoneNumber = response.data.add_phone_number | ||||
|                     that.addOtherEmailAddres = response.data.add_email_address | ||||
|                     that.contactProfileURL = response.data.contact_profile_url | ||||
|                     that.contactPhones = response.data.contact_phones | ||||
|                     that.contactEmails = response.data.contact_emails | ||||
|  | @ -959,9 +965,11 @@ | |||
|                         } | ||||
|                     } | ||||
| 
 | ||||
|                     if (!params.phone_number) { | ||||
|                     if (params.phone_number) { | ||||
|                         params.add_phone_number = false | ||||
|                     } else { | ||||
|                         params.phone_number = this.otherPhoneNumber | ||||
|                         // params.add_phone_number = this.addOtherPhoneNumber | ||||
|                         params.add_phone_number = this.addOtherPhoneNumber | ||||
|                     } | ||||
| 
 | ||||
|                     this.submitBatchData(params, response => { | ||||
|  | @ -1012,9 +1020,11 @@ | |||
|                         } | ||||
|                     } | ||||
| 
 | ||||
|                     if (!params.email_address) { | ||||
|                     if (params.email_address) { | ||||
|                         params.add_email_address = false | ||||
|                     } else { | ||||
|                         params.email_address = this.otherEmailAddress | ||||
|                         // params.add_email_address = this.addOtherEmailAddress | ||||
|                         params.add_email_address = this.addOtherEmailAddress | ||||
|                     } | ||||
| 
 | ||||
|                     this.submitBatchData(params, response => { | ||||
|  |  | |||
|  | @ -63,6 +63,7 @@ class CustomerOrderBatchView(BatchMasterView): | |||
|         'person', | ||||
|         'phone_number', | ||||
|         'email_address', | ||||
|         'params', | ||||
|         'created', | ||||
|         'created_by', | ||||
|         'rowcount', | ||||
|  |  | |||
|  | @ -260,6 +260,8 @@ class CustomerOrderView(MasterView): | |||
|                    'contact_display': self.handler.get_contact_display(batch), | ||||
|                    'contact_phones': self.handler.get_contact_phones(batch), | ||||
|                    'contact_emails': self.handler.get_contact_emails(batch), | ||||
|                    'add_phone_number': bool(batch.get_param('add_phone_number')), | ||||
|                    'add_email_address': bool(batch.get_param('add_email_address')), | ||||
|                    'contact_profile_url': None, | ||||
|                    'contact_notes': self.handler.get_contact_notes(batch), | ||||
|                    'order_items': items, | ||||
|  | @ -405,6 +407,8 @@ class CustomerOrderView(MasterView): | |||
|             'contact_phones': self.handler.get_contact_phones(batch), | ||||
|             'contact_emails': self.handler.get_contact_emails(batch), | ||||
|             'contact_notes': self.handler.get_contact_notes(batch), | ||||
|             'add_phone_number': bool(batch.get_param('add_phone_number')), | ||||
|             'add_email_address': bool(batch.get_param('add_email_address')), | ||||
|         } | ||||
| 
 | ||||
|         # maybe add profile URL | ||||
|  | @ -426,9 +430,13 @@ class CustomerOrderView(MasterView): | |||
|         app = self.get_rattail_app() | ||||
| 
 | ||||
|         batch.phone_number = app.format_phone_number(data['phone_number']) | ||||
|         self.Session.flush() | ||||
|         self.Session.refresh(batch) | ||||
| 
 | ||||
|         if data.get('add_phone_number'): | ||||
|             batch.set_param('add_phone_number', True) | ||||
|         else: | ||||
|             batch.clear_param('add_phone_number') | ||||
| 
 | ||||
|         self.Session.flush() | ||||
|         return { | ||||
|             'success': True, | ||||
|             'phone_number': batch.phone_number, | ||||
|  | @ -437,9 +445,13 @@ class CustomerOrderView(MasterView): | |||
|     def update_email_address(self, batch, data): | ||||
| 
 | ||||
|         batch.email_address = data['email_address'] | ||||
|         self.Session.flush() | ||||
|         self.Session.refresh(batch) | ||||
| 
 | ||||
|         if data.get('add_email_address'): | ||||
|             batch.set_param('add_email_address', True) | ||||
|         else: | ||||
|             batch.clear_param('add_email_address') | ||||
| 
 | ||||
|         self.Session.flush() | ||||
|         return { | ||||
|             'success': True, | ||||
|             'email_address': batch.email_address, | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Lance Edgar
						Lance Edgar