[BUGFIX] js errors
This commit is contained in:
		@@ -20,46 +20,51 @@ document.addEventListener('DOMContentLoaded', function() {
 | 
			
		||||
 | 
			
		||||
function selectBoatChange() {
 | 
			
		||||
  const boatSelect = <HTMLSelectElement>document.querySelector('#boat_id');
 | 
			
		||||
  const boatChoice = new Choices(boatSelect, {
 | 
			
		||||
    loadingText: 'Wird geladen...',
 | 
			
		||||
    noResultsText: 'Keine Ergebnisse gefunden',
 | 
			
		||||
    noChoicesText: 'Keine Ergebnisse gefunden',
 | 
			
		||||
    itemSelectText: 'Zum Auswählen klicken',
 | 
			
		||||
    callbackOnCreateTemplates: function () {
 | 
			
		||||
      return {
 | 
			
		||||
          option: ({ label, value, customProperties, active, disabled, }: any) => {
 | 
			
		||||
              const opt: HTMLOptionElement = Choices.defaults.templates.option.call(
 | 
			
		||||
                  this,
 | 
			
		||||
                  { label, value, customProperties, active, disabled }
 | 
			
		||||
              );
 | 
			
		||||
 | 
			
		||||
              // We get the original <option> from choicejs
 | 
			
		||||
              const originalOption: HTMLOptionElement = this._presetOptions.filter(
 | 
			
		||||
                  (option: HTMLOptionElement) => option.value === value
 | 
			
		||||
              )[0];
 | 
			
		||||
              
 | 
			
		||||
              const rowers = Number(originalOption.dataset.amount_seats) - 1;
 | 
			
		||||
              
 | 
			
		||||
	      setMaxAmountRowers(rowers);
 | 
			
		||||
              
 | 
			
		||||
        
 | 
			
		||||
              return opt;
 | 
			
		||||
          }
 | 
			
		||||
  if(boatSelect) {
 | 
			
		||||
    const boatChoice = new Choices(boatSelect, {
 | 
			
		||||
      loadingText: 'Wird geladen...',
 | 
			
		||||
      noResultsText: 'Keine Ergebnisse gefunden',
 | 
			
		||||
      noChoicesText: 'Keine Ergebnisse gefunden',
 | 
			
		||||
      itemSelectText: 'Zum Auswählen klicken',
 | 
			
		||||
      callbackOnCreateTemplates: function () {
 | 
			
		||||
        return {
 | 
			
		||||
            option: ({ label, value, customProperties, active, disabled, }: any) => {
 | 
			
		||||
                const opt: HTMLOptionElement = Choices.defaults.templates.option.call(
 | 
			
		||||
                    this,
 | 
			
		||||
                    { label, value, customProperties, active, disabled }
 | 
			
		||||
                );
 | 
			
		||||
  
 | 
			
		||||
                // We get the original <option> from choicejs
 | 
			
		||||
                const originalOption: HTMLOptionElement = this._presetOptions.filter(
 | 
			
		||||
                    (option: HTMLOptionElement) => option.value === value
 | 
			
		||||
                )[0];
 | 
			
		||||
                
 | 
			
		||||
                const rowers = Number(originalOption.dataset.amount_seats) - 1;
 | 
			
		||||
                
 | 
			
		||||
          setMaxAmountRowers(rowers);
 | 
			
		||||
                
 | 
			
		||||
          
 | 
			
		||||
                return opt;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  } as any);
 | 
			
		||||
 | 
			
		||||
  choiceObjects[boatSelect.id] = boatChoice;
 | 
			
		||||
    } as any);
 | 
			
		||||
  
 | 
			
		||||
    choiceObjects[boatSelect.id] = boatChoice;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  const shipmasterSelect = <HTMLSelectElement>document.querySelector('#shipmaster');
 | 
			
		||||
  const shipmasterChoice = new Choices(shipmasterSelect, {
 | 
			
		||||
    loadingText: 'Wird geladen...',
 | 
			
		||||
    noResultsText: 'Keine Ergebnisse gefunden',
 | 
			
		||||
    noChoicesText: 'Keine Ergebnisse gefunden',
 | 
			
		||||
    itemSelectText: 'Zum Auswählen klicken',
 | 
			
		||||
  });
 | 
			
		||||
  
 | 
			
		||||
  choiceObjects[shipmasterSelect.id] = shipmasterChoice;
 | 
			
		||||
  if(shipmasterSelect) {
 | 
			
		||||
    const shipmasterChoice = new Choices(shipmasterSelect, {
 | 
			
		||||
      loadingText: 'Wird geladen...',
 | 
			
		||||
      noResultsText: 'Keine Ergebnisse gefunden',
 | 
			
		||||
      noChoicesText: 'Keine Ergebnisse gefunden',
 | 
			
		||||
      itemSelectText: 'Zum Auswählen klicken',
 | 
			
		||||
    });
 | 
			
		||||
    
 | 
			
		||||
    choiceObjects[shipmasterSelect.id] = shipmasterChoice;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function setMaxAmountRowers(rowers: number){
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user