Skip to content

Instantly share code, notes, and snippets.

@Macadoshis
Created October 18, 2018 10:22
Show Gist options
  • Save Macadoshis/f12a65c975a2194a6b996cb794493ece to your computer and use it in GitHub Desktop.
Save Macadoshis/f12a65c975a2194a6b996cb794493ece to your computer and use it in GitHub Desktop.
import { ServiceFolderStatusCategory } from '../../../../../Logiciels/workspaces/CMSS/CMSS.Client/src/app/enums/service-folder-management/service-folder-status-category';
private onChangeSelectedColumns(userPreference: IUserPreferenceType,
doWithWorkshopPreference: (workshopPreference: IWorkshopPreferenceType) => void,
doWithQuotationPreference: (quotationPreference: IQuotationPreferenceType) => void,
doWithInvoicingPreference: (invoicingPreference: IInvoicingPreferenceType) => void,
doWithEstimationPreference: (estimationPreference: IEstimationPreferenceType) => void,
doWithDeliveryPreference: (deliveryPreference: IDeliveryPreferenceType) => void,
doWithRegistrationPreference: (registrationPreference: IRegistrationPreferenceType) => void,
doWithAllPreference: (allPreference: IAllPreferenceType) => void
) : void {
switch (this.currentStatusCategory) {
case (ServiceFolderStatusCategory.Workshop):
doWithWorkshopPreference(userPreference.WorkshopPreference);
break;
case (ServiceFolderStatusCategory.Quotation):
doWithQuotationPreference(userPreference.QuotationPreference);
break;
case (ServiceFolderStatusCategory.Invoicing):
doWithInvoicingPreference(userPreference.InvoicingPreference);
break;
case (ServiceFolderStatusCategory.Estimation):
doWithEstimationPreference(userPreference.EstimationPreference);
break;
case (ServiceFolderStatusCategory.Delivery):
doWithDeliveryPreference(userPreference.DeliveryPreference);
break;
case (ServiceFolderStatusCategory.Registration):
doWithRegistrationPreference(userPreference.RegistrationPreference);
break;
default:
doWithAllPreference(this.userPreference[0].AllPreference);
break;
}
}
onChangeSelectedColumns(event): void {
let exist = this.selectedColumns.some(x => x.field == event.itemValue.field);
switch (event.itemValue.field) {
case ('id'):
this.onChangeSelectedColumns(this.userPreference[0],
(workshopPreference: IWorkshopPreferenceType) => {
workshopPreference.DisplayId = exist;
},
(quotationPreference: IQuotationPreferenceType) => {
quotationPreference.DisplayId = exist;
},
// etc..
);
break;
case('customerName'):
this.onChangeSelectedColumns(this.userPreference[0],
(workshopPreference: IWorkshopPreferenceType) => {
workshopPreference.DisplayCustomerName = exist;
},
(quotationPreference: IQuotationPreferenceType) => {
quotationPreference.DisplayCustomerName = exist;
},
// etc..
);
break;
// etc..
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment