<template>
  <div>
    <div v-if="formState.ready">
      <gz-error :error-box-message="formState.errorBoxMessage"></gz-error>
      <v-form ref="form">
        <v-row dense>
          <v-col cols="12">
            <div class="text-h4 primary--text">
              {{ $ay.t("BusinessSettings") }}
            </div>
          </v-col>

          <v-col cols="12" sm="6" lg="4" xl="3">
            <gz-pick-list
              ref="taxPartPurchaseId"
              v-model="obj.taxPartPurchaseId"
              :aya-type="ayaTypes().TaxCode"
              show-edit-icon
              :readonly="formState.readOnly"
              :label="$ay.t('GlobalTaxPartPurchaseID')"
              data-cy="taxPartPurchaseId"
              :error-messages="form().serverErrors(this, `taxPartPurchaseId`)"
              @input="fieldValueChanged(`taxPartPurchaseId`)"
            ></gz-pick-list>
          </v-col>

          <v-col cols="12" sm="6" lg="4" xl="3">
            <gz-pick-list
              ref="taxRateSaleId"
              v-model="obj.taxRateSaleId"
              :aya-type="ayaTypes().TaxCode"
              show-edit-icon
              :readonly="formState.readOnly"
              :label="$ay.t('GlobalTaxRateSaleID')"
              data-cy="taxRateSaleId"
              :error-messages="form().serverErrors(this, `taxRateSaleId`)"
              @input="fieldValueChanged(`taxRateSaleId`)"
            ></gz-pick-list>
          </v-col>

          <v-col cols="12" sm="6" lg="4" xl="3">
            <gz-pick-list
              ref="taxPartSaleId"
              v-model="obj.taxPartSaleId"
              :aya-type="ayaTypes().TaxCode"
              show-edit-icon
              :readonly="formState.readOnly"
              :label="$ay.t('GlobalTaxPartSaleID')"
              data-cy="taxPartSaleId"
              :error-messages="form().serverErrors(this, `taxPartSaleId`)"
              @input="fieldValueChanged(`taxPartSaleId`)"
            ></gz-pick-list>
          </v-col>

          <v-col cols="12" sm="6" lg="4" xl="3">
            <v-checkbox
              ref="filterCaseSensitive"
              v-model="obj.filterCaseSensitive"
              dense
              :readonly="formState.readOnly"
              :label="$ay.t('GlobalFilterCaseSensitive')"
              data-cy="filterCaseSensitive"
              @change="fieldValueChanged('filterCaseSensitive')"
            ></v-checkbox>
          </v-col>

          <v-col cols="12" sm="6" lg="4" xl="3">
            <v-checkbox
              ref="useInventory"
              v-model="obj.useInventory"
              dense
              :readonly="formState.readOnly"
              :label="$ay.t('GlobalUseInventory')"
              data-cy="useInventory"
              @change="fieldValueChanged('useInventory')"
            ></v-checkbox>
          </v-col>

          <v-col cols="12" sm="6" lg="4" xl="3">
            <gz-duration-picker
              ref="workOrderCompleteByAge"
              v-model="obj.workOrderCompleteByAge"
              :readonly="formState.readOnly"
              :label="$ay.t('GlobalWorkOrderCompleteByAge')"
              :show-seconds="false"
              data-cy="workOrderCompleteByAge"
              :error-messages="
                form().serverErrors(this, 'workOrderCompleteByAge')
              "
              @input="fieldValueChanged('workOrderCompleteByAge')"
            ></gz-duration-picker>
          </v-col>

          <v-col cols="12" sm="6" lg="4" xl="3">
            <v-checkbox
              ref="allowScheduleConflicts"
              v-model="obj.allowScheduleConflicts"
              dense
              :readonly="formState.readOnly"
              :label="$ay.t('GlobalAllowScheduleConflicts')"
              data-cy="allowScheduleConflicts"
              @change="fieldValueChanged('allowScheduleConflicts')"
            ></v-checkbox>
          </v-col>

          <v-col cols="12" sm="6" lg="4" xl="3">
            <v-text-field
              ref="workLaborScheduleDefaultMinutes"
              v-model="obj.workLaborScheduleDefaultMinutes"
              dense
              :readonly="formState.readOnly"
              :label="$ay.t('GlobalLaborSchedUserDfltTimeSpan')"
              data-cy="workLaborScheduleDefaultMinutes"
              :rules="[
                form().integerValid(this, 'workLaborScheduleDefaultMinutes'),
                form().required(this, 'workLaborScheduleDefaultMinutes')
              ]"
              :error-messages="
                form().serverErrors(this, 'workLaborScheduleDefaultMinutes')
              "
              @input="fieldValueChanged('workLaborScheduleDefaultMinutes')"
            ></v-text-field>
          </v-col>

          <v-col cols="12" sm="6" lg="4" xl="3">
            <v-text-field
              ref="workOrderTravelDefaultMinutes"
              v-model="obj.workOrderTravelDefaultMinutes"
              dense
              :readonly="formState.readOnly"
              :label="$ay.t('GlobalTravelDfltTimeSpan')"
              data-cy="workOrderTravelDefaultMinutes"
              :rules="[
                form().integerValid(this, 'workOrderTravelDefaultMinutes'),
                form().required(this, 'workOrderTravelDefaultMinutes')
              ]"
              :error-messages="
                form().serverErrors(this, 'workOrderTravelDefaultMinutes')
              "
              @input="fieldValueChanged('workOrderTravelDefaultMinutes')"
            ></v-text-field>
          </v-col>
          <v-col cols="12" sm="6" lg="4" xl="3">
            <v-btn to="adm-global-seeds">{{
              $ay.t("GlobalNextSeeds")
            }}</v-btn></v-col
          >

          <!-- --------------COMPANY ADDRESS ETC ---------------- -->

          <v-col cols="12">
            <div class="text-h4 primary--text">
              {{ $ay.t("CompanyInformation") }}
            </div>
          </v-col>
          <v-col cols="12" sm="6" lg="4" xl="3">
            <gz-url
              ref="webAddress"
              v-model="obj.webAddress"
              :readonly="formState.readOnly"
              :label="$ay.t('WebAddress')"
              data-cy="webAddress"
              :error-messages="form().serverErrors(this, 'webAddress')"
              @input="fieldValueChanged('webAddress')"
            ></gz-url>
          </v-col>

          <v-col cols="12" sm="6" lg="4" xl="3">
            <gz-email
              ref="emailAddress"
              v-model="obj.emailAddress"
              :readonly="formState.readOnly"
              :label="$ay.t('CompanyEmail')"
              data-cy="emailAddress"
              :error-messages="form().serverErrors(this, 'emailAddress')"
              @input="fieldValueChanged('emailAddress')"
            ></gz-email>
          </v-col>

          <v-col cols="12" sm="6" lg="4" xl="3">
            <gz-phone
              ref="phone1"
              v-model="obj.phone1"
              :readonly="formState.readOnly"
              :label="$ay.t('CompanyPhone1')"
              data-cy="phone1"
              :error-messages="form().serverErrors(this, 'phone1')"
              @input="fieldValueChanged('phone1')"
            ></gz-phone>
          </v-col>

          <v-col cols="12" sm="6" lg="4" xl="3">
            <gz-phone
              ref="phone2"
              v-model="obj.phone2"
              :readonly="formState.readOnly"
              :label="$ay.t('CompanyPhone2')"
              data-cy="phone2"
              :error-messages="form().serverErrors(this, 'phone2')"
              @input="fieldValueChanged('phone2')"
            ></gz-phone>
          </v-col>

          <v-col cols="12">
            <span class="text-subtitle-1">
              {{ $ay.t("AddressTypePhysical") }}</span
            >
          </v-col>
          <v-col cols="12" sm="6" lg="4" xl="3">
            <v-text-field
              ref="address"
              v-model="obj.address"
              dense
              :readonly="formState.readOnly"
              :label="$ay.t('AddressDeliveryAddress')"
              data-cy="address"
              :error-messages="form().serverErrors(this, 'address')"
              @input="fieldValueChanged('address')"
            ></v-text-field>
          </v-col>

          <v-col cols="12" sm="6" lg="4" xl="3">
            <v-text-field
              ref="city"
              v-model="obj.city"
              dense
              :readonly="formState.readOnly"
              :label="$ay.t('AddressCity')"
              data-cy="city"
              :error-messages="form().serverErrors(this, 'city')"
              @input="fieldValueChanged('city')"
            ></v-text-field>
          </v-col>

          <v-col cols="12" sm="6" lg="4" xl="3">
            <v-text-field
              ref="region"
              v-model="obj.region"
              dense
              :readonly="formState.readOnly"
              :label="$ay.t('AddressStateProv')"
              data-cy="region"
              :error-messages="form().serverErrors(this, 'region')"
              @input="fieldValueChanged('region')"
            ></v-text-field>
          </v-col>

          <v-col cols="12" sm="6" lg="4" xl="3">
            <v-text-field
              ref="country"
              v-model="obj.country"
              dense
              :readonly="formState.readOnly"
              :label="$ay.t('AddressCountry')"
              data-cy="country"
              :error-messages="form().serverErrors(this, 'country')"
              @input="fieldValueChanged('country')"
            ></v-text-field>
          </v-col>

          <v-col cols="12" sm="6" lg="4" xl="3">
            <v-text-field
              ref="addressPostal"
              v-model="obj.addressPostal"
              dense
              :readonly="formState.readOnly"
              :label="$ay.t('AddressPostal')"
              data-cy="addressPostal"
              :error-messages="form().serverErrors(this, 'addressPostal')"
              @input="fieldValueChanged('addressPostal')"
            ></v-text-field>
          </v-col>

          <v-col cols="12" sm="6" lg="4" xl="3">
            <gz-decimal
              ref="latitude"
              v-model="obj.latitude"
              :readonly="formState.readOnly"
              :label="$ay.t('AddressLatitude')"
              data-cy="latitude"
              :rules="[form().decimalValid(this, 'latitude')]"
              :error-messages="form().serverErrors(this, 'latitude')"
              :precision="6"
              @input="fieldValueChanged('latitude')"
            ></gz-decimal>
          </v-col>

          <v-col cols="12" sm="6" lg="4" xl="3">
            <gz-decimal
              ref="longitude"
              v-model="obj.longitude"
              :readonly="formState.readOnly"
              :label="$ay.t('AddressLongitude')"
              data-cy="longitude"
              :rules="[form().decimalValid(this, 'longitude')]"
              :error-messages="form().serverErrors(this, 'longitude')"
              :precision="6"
              @input="fieldValueChanged('longitude')"
            ></gz-decimal>
          </v-col>

          <v-col cols="12">
            <span class="text-subtitle-1">
              {{ $ay.t("AddressTypePostal") }}</span
            >
          </v-col>

          <v-col cols="12" sm="6" lg="4" xl="3">
            <v-text-field
              ref="postAddress"
              v-model="obj.postAddress"
              dense
              :readonly="formState.readOnly"
              :label="$ay.t('AddressPostalDeliveryAddress')"
              data-cy="postAddress"
              :error-messages="form().serverErrors(this, 'postAddress')"
              @input="fieldValueChanged('postAddress')"
            ></v-text-field>
          </v-col>

          <v-col cols="12" sm="6" lg="4" xl="3">
            <v-text-field
              ref="postCity"
              v-model="obj.postCity"
              dense
              :readonly="formState.readOnly"
              :label="$ay.t('AddressPostalCity')"
              data-cy="postCity"
              :error-messages="form().serverErrors(this, 'postCity')"
              @input="fieldValueChanged('postCity')"
            ></v-text-field>
          </v-col>

          <v-col cols="12" sm="6" lg="4" xl="3">
            <v-text-field
              ref="postRegion"
              v-model="obj.postRegion"
              dense
              :readonly="formState.readOnly"
              :label="$ay.t('AddressPostalStateProv')"
              data-cy="postRegion"
              :error-messages="form().serverErrors(this, 'postRegion')"
              @input="fieldValueChanged('postRegion')"
            ></v-text-field>
          </v-col>

          <v-col cols="12" sm="6" lg="4" xl="3">
            <v-text-field
              ref="postCountry"
              v-model="obj.postCountry"
              dense
              :readonly="formState.readOnly"
              :label="$ay.t('AddressPostalCountry')"
              data-cy="postCountry"
              :error-messages="form().serverErrors(this, 'postCountry')"
              @input="fieldValueChanged('postCountry')"
            ></v-text-field>
          </v-col>

          <v-col cols="12" sm="6" lg="4" xl="3">
            <v-text-field
              ref="postCode"
              v-model="obj.postCode"
              dense
              :readonly="formState.readOnly"
              :label="$ay.t('AddressPostalPostal')"
              data-cy="postCode"
              :error-messages="form().serverErrors(this, 'postCode')"
              @input="fieldValueChanged('postCode')"
            ></v-text-field>
          </v-col>

          <!-- -------------------- /ADDRESS CONTACT INFO ------------------------------ -->

          <v-col cols="12" class="mt-8">
            <span class="text-h4 primary--text">
              {{ $ay.t("UserInterfaceSettings") }}</span
            >
          </v-col>
          <v-col cols="12" sm="6" lg="4" xl="3">
            <v-btn to="adm-global-logo">{{ $ay.t("GlobalLogo") }}</v-btn>
          </v-col>
          <v-col cols="12" sm="6" lg="4" xl="3">
            <v-btn to="adm-global-select-templates">{{
              $ay.t("PickListTemplates")
            }}</v-btn></v-col
          >

          <v-col cols="12" class="mt-4">
            <div class="text-subtitle-1">
              {{ $ay.t("CustomerSignature") }}
            </div>
          </v-col>

          <v-col cols="12" sm="6" lg="4" xl="3">
            <v-text-field
              ref="signatureTitle"
              v-model="obj.signatureTitle"
              dense
              :readonly="formState.readOnly"
              :label="$ay.t('GlobalSignatureTitle')"
              data-cy="signatureTitle"
              :error-messages="form().serverErrors(this, 'signatureTitle')"
              @input="fieldValueChanged('signatureTitle')"
            ></v-text-field>
          </v-col>

          <v-col cols="12" sm="6" lg="4" xl="3">
            <v-text-field
              ref="signatureHeader"
              v-model="obj.signatureHeader"
              dense
              :readonly="formState.readOnly"
              :label="$ay.t('GlobalSignatureHeader')"
              data-cy="signatureHeader"
              :error-messages="form().serverErrors(this, 'signatureHeader')"
              @input="fieldValueChanged('signatureHeader')"
            ></v-text-field>
          </v-col>

          <v-col cols="12" sm="6" lg="4" xl="3">
            <v-text-field
              ref="signatureFooter"
              v-model="obj.signatureFooter"
              dense
              :readonly="formState.readOnly"
              :label="$ay.t('GlobalSignatureFooter')"
              data-cy="signatureFooter"
              :error-messages="form().serverErrors(this, 'signatureFooter')"
              @input="fieldValueChanged('signatureFooter')"
            ></v-text-field>
          </v-col>

          <v-col cols="12" class="mt-8">
            <div class="text-h4 primary--text">
              {{ $ay.t("CustomerAccessSettings") }}
            </div>
          </v-col>

          <!-- ######################################################## -->
          <v-col cols="12">
            <v-expansion-panels>
              <v-expansion-panel key="1">
                <v-expansion-panel-header>
                  <span class="text-h6">
                    {{ $ay.t("CustomerServiceRequestList") }}
                  </span>
                </v-expansion-panel-header>
                <v-expansion-panel-content>
                  <v-row dense>
                    <v-col cols="12" sm="6" lg="2">
                      <v-checkbox
                        ref="customerAllowCSR"
                        v-model="obj.customerAllowCSR"
                        dense
                        :readonly="formState.readOnly"
                        :label="$ay.t('Active')"
                        data-cy="customerAllowCSR"
                        :error-messages="
                          form().serverErrors(this, 'customerAllowCSR')
                        "
                        @change="fieldValueChanged('customerAllowCSR')"
                      ></v-checkbox>
                    </v-col>
                    <template v-if="obj.customerAllowCSR">
                      <v-col cols="12" sm="6" lg="10">
                        <gz-tag-picker
                          ref="customerAllowCSRInTags"
                          v-model="obj.customerAllowCSRInTags"
                          :readonly="formState.readOnly"
                          :label="$ay.t('ContactCustomerHeadOfficeTaggedWith')"
                          data-cy="customerAllowCSRInTags"
                          :error-messages="
                            form().serverErrors(this, 'customerAllowCSRInTags')
                          "
                          @input="fieldValueChanged('customerAllowCSRInTags')"
                        ></gz-tag-picker>
                      </v-col>

                      <v-col cols="12">
                        <v-textarea
                          ref="customerServiceRequestInfoText"
                          v-model="obj.customerServiceRequestInfoText"
                          dense
                          :readonly="formState.readOnly"
                          :label="$ay.t('CSRInfoText')"
                          :error-messages="
                            form().serverErrors(
                              this,
                              'customerServiceRequestInfoText'
                            )
                          "
                          data-cy="customerServiceRequestInfoText"
                          auto-grow
                          @input="
                            fieldValueChanged('customerServiceRequestInfoText')
                          "
                        ></v-textarea>
                      </v-col>

                      <v-col cols="12" sm="6" lg="2">
                        <v-checkbox
                          ref="customerAllowCreateUnit"
                          v-model="obj.customerAllowCreateUnit"
                          dense
                          :readonly="formState.readOnly"
                          :label="$ay.t('CustomerAllowCreateUnit')"
                          data-cy="customerAllowCreateUnit"
                          :error-messages="
                            form().serverErrors(this, 'customerAllowCreateUnit')
                          "
                          @change="fieldValueChanged('customerAllowCreateUnit')"
                        ></v-checkbox>
                      </v-col>
                      <template v-if="obj.customerAllowCreateUnit">
                        <v-col cols="12" sm="6" lg="10">
                          <gz-tag-picker
                            ref="customerAllowCreateUnitInTags"
                            v-model="obj.customerAllowCreateUnitInTags"
                            :readonly="formState.readOnly"
                            :label="
                              $ay.t('ContactCustomerHeadOfficeTaggedWith')
                            "
                            data-cy="customerAllowCreateUnitInTags"
                            :error-messages="
                              form().serverErrors(
                                this,
                                'customerAllowCreateUnitInTags'
                              )
                            "
                            @input="
                              fieldValueChanged('customerAllowCreateUnitInTags')
                            "
                          ></gz-tag-picker>
                        </v-col>
                      </template>
                    </template>
                  </v-row>
                </v-expansion-panel-content>
              </v-expansion-panel>
              <v-expansion-panel key="2">
                <v-expansion-panel-header>
                  <span class="text-h6">
                    {{ $ay.t("WorkOrderList") }}
                  </span>
                </v-expansion-panel-header>
                <v-expansion-panel-content>
                  <v-row dense>
                    <v-col cols="12" sm="6" lg="2">
                      <v-checkbox
                        ref="customerAllowViewWO"
                        v-model="obj.customerAllowViewWO"
                        dense
                        :readonly="formState.readOnly"
                        :label="$ay.t('Active')"
                        data-cy="customerAllowViewWO"
                        :error-messages="
                          form().serverErrors(this, 'customerAllowViewWO')
                        "
                        @change="fieldValueChanged('customerAllowViewWO')"
                      ></v-checkbox>
                    </v-col>
                    <template v-if="obj.customerAllowViewWO">
                      <v-col cols="12" sm="6" lg="10">
                        <gz-tag-picker
                          ref="customerAllowViewWOInTags"
                          v-model="obj.customerAllowViewWOInTags"
                          :readonly="formState.readOnly"
                          :label="$ay.t('ContactCustomerHeadOfficeTaggedWith')"
                          data-cy="customerAllowViewWOInTags"
                          :error-messages="
                            form().serverErrors(
                              this,
                              'customerAllowViewWOInTags'
                            )
                          "
                          @input="
                            fieldValueChanged('customerAllowViewWOInTags')
                          "
                        ></gz-tag-picker>
                      </v-col>
                      <v-expansion-panels>
                        <v-expansion-panel key="a">
                          <v-expansion-panel-header>
                            <span class="text-subtitle-1">
                              {{ $ay.t("CustomerAccessWorkOrderReport") }}
                            </span>
                          </v-expansion-panel-header>
                          <v-expansion-panel-content>
                            <v-row dense>
                              <v-col cols="12">
                                <gz-pick-list
                                  ref="customerDefaultWorkOrderReportId"
                                  v-model="obj.customerDefaultWorkOrderReportId"
                                  :aya-type="ayaTypes().Report"
                                  :variant="ayaTypes().WorkOrder.toString()"
                                  show-edit-icon
                                  :readonly="formState.readOnly"
                                  :label="$ay.t('DefaultReport')"
                                  data-cy="customerDefaultWorkOrderReportId"
                                  :error-messages="
                                    form().serverErrors(
                                      this,
                                      'customerDefaultWorkOrderReportId'
                                    )
                                  "
                                  @input="
                                    fieldValueChanged(
                                      'customerDefaultWorkOrderReportId'
                                    )
                                  "
                                ></gz-pick-list>
                              </v-col>

                              <!-- ------------ -->
                              <v-col cols="12" sm="6">
                                <gz-tag-picker
                                  ref="customerWorkOrderReport1Tags"
                                  v-model="obj.customerWorkOrderReport1Tags"
                                  :readonly="formState.readOnly"
                                  :label="$ay.t('WorkOrderCustomerTaggedWith')"
                                  data-cy="customerWorkOrderReport1Tags"
                                  :error-messages="
                                    form().serverErrors(
                                      this,
                                      'customerWorkOrderReport1Tags'
                                    )
                                  "
                                  @input="
                                    fieldValueChanged(
                                      'customerWorkOrderReport1Tags'
                                    )
                                  "
                                ></gz-tag-picker>
                              </v-col>

                              <v-col cols="12" sm="6">
                                <gz-pick-list
                                  ref="customerTagWorkOrderReport1Id"
                                  v-model="obj.customerTagWorkOrderReport1Id"
                                  :aya-type="ayaTypes().Report"
                                  :variant="ayaTypes().WorkOrder.toString()"
                                  show-edit-icon
                                  :readonly="formState.readOnly"
                                  :label="$ay.t('DefaultReport')"
                                  data-cy="customerTagWorkOrderReport1Id"
                                  :error-messages="
                                    form().serverErrors(
                                      this,
                                      'customerTagWorkOrderReport1Id'
                                    )
                                  "
                                  @input="
                                    fieldValueChanged(
                                      'customerTagWorkOrderReport1Id'
                                    )
                                  "
                                ></gz-pick-list>
                              </v-col>

                              <!-- ------------ -->
                              <v-col cols="12" sm="6">
                                <gz-tag-picker
                                  ref="customerWorkOrderReport2Tags"
                                  v-model="obj.customerWorkOrderReport2Tags"
                                  :readonly="formState.readOnly"
                                  :label="$ay.t('WorkOrderCustomerTaggedWith')"
                                  data-cy="customerWorkOrderReport2Tags"
                                  :error-messages="
                                    form().serverErrors(
                                      this,
                                      'customerWorkOrderReport2Tags'
                                    )
                                  "
                                  @input="
                                    fieldValueChanged(
                                      'customerWorkOrderReport2Tags'
                                    )
                                  "
                                ></gz-tag-picker>
                              </v-col>

                              <v-col cols="12" sm="6">
                                <gz-pick-list
                                  ref="customerTagWorkOrderReport2Id"
                                  v-model="obj.customerTagWorkOrderReport2Id"
                                  :aya-type="ayaTypes().Report"
                                  :variant="ayaTypes().WorkOrder.toString()"
                                  show-edit-icon
                                  :readonly="formState.readOnly"
                                  :label="$ay.t('DefaultReport')"
                                  data-cy="customerTagWorkOrderReport2Id"
                                  :error-messages="
                                    form().serverErrors(
                                      this,
                                      'customerTagWorkOrderReport2Id'
                                    )
                                  "
                                  @input="
                                    fieldValueChanged(
                                      'customerTagWorkOrderReport2Id'
                                    )
                                  "
                                ></gz-pick-list>
                              </v-col>

                              <!-- ------------ -->
                              <v-col cols="12" sm="6">
                                <gz-tag-picker
                                  ref="customerWorkOrderReport3Tags"
                                  v-model="obj.customerWorkOrderReport3Tags"
                                  :readonly="formState.readOnly"
                                  :label="$ay.t('WorkOrderCustomerTaggedWith')"
                                  data-cy="customerWorkOrderReport3Tags"
                                  :error-messages="
                                    form().serverErrors(
                                      this,
                                      'customerWorkOrderReport3Tags'
                                    )
                                  "
                                  @input="
                                    fieldValueChanged(
                                      'customerWorkOrderReport3Tags'
                                    )
                                  "
                                ></gz-tag-picker>
                              </v-col>

                              <v-col cols="12" sm="6">
                                <gz-pick-list
                                  ref="customerTagWorkOrderReport3Id"
                                  v-model="obj.customerTagWorkOrderReport3Id"
                                  :aya-type="ayaTypes().Report"
                                  :variant="ayaTypes().WorkOrder.toString()"
                                  show-edit-icon
                                  :readonly="formState.readOnly"
                                  :label="$ay.t('DefaultReport')"
                                  data-cy="customerTagWorkOrderReport3Id"
                                  :error-messages="
                                    form().serverErrors(
                                      this,
                                      'customerTagWorkOrderReport3Id'
                                    )
                                  "
                                  @input="
                                    fieldValueChanged(
                                      'customerTagWorkOrderReport3Id'
                                    )
                                  "
                                ></gz-pick-list>
                              </v-col>

                              <!-- ------------ -->
                              <v-col cols="12" sm="6">
                                <gz-tag-picker
                                  ref="customerWorkOrderReport4Tags"
                                  v-model="obj.customerWorkOrderReport4Tags"
                                  :readonly="formState.readOnly"
                                  :label="$ay.t('WorkOrderCustomerTaggedWith')"
                                  data-cy="customerWorkOrderReport4Tags"
                                  :error-messages="
                                    form().serverErrors(
                                      this,
                                      'customerWorkOrderReport4Tags'
                                    )
                                  "
                                  @input="
                                    fieldValueChanged(
                                      'customerWorkOrderReport4Tags'
                                    )
                                  "
                                ></gz-tag-picker>
                              </v-col>

                              <v-col cols="12" sm="6">
                                <gz-pick-list
                                  ref="customerTagWorkOrderReport4Id"
                                  v-model="obj.customerTagWorkOrderReport4Id"
                                  :aya-type="ayaTypes().Report"
                                  :variant="ayaTypes().WorkOrder.toString()"
                                  show-edit-icon
                                  :readonly="formState.readOnly"
                                  :label="$ay.t('DefaultReport')"
                                  data-cy="customerTagWorkOrderReport4Id"
                                  :error-messages="
                                    form().serverErrors(
                                      this,
                                      'customerTagWorkOrderReport4Id'
                                    )
                                  "
                                  @input="
                                    fieldValueChanged(
                                      'customerTagWorkOrderReport4Id'
                                    )
                                  "
                                ></gz-pick-list>
                              </v-col>

                              <!-- ------------ -->
                              <v-col cols="12" sm="6">
                                <gz-tag-picker
                                  ref="customerWorkOrderReport5Tags"
                                  v-model="obj.customerWorkOrderReport5Tags"
                                  :readonly="formState.readOnly"
                                  :label="$ay.t('WorkOrderCustomerTaggedWith')"
                                  data-cy="customerWorkOrderReport5Tags"
                                  :error-messages="
                                    form().serverErrors(
                                      this,
                                      'customerWorkOrderReport5Tags'
                                    )
                                  "
                                  @input="
                                    fieldValueChanged(
                                      'customerWorkOrderReport5Tags'
                                    )
                                  "
                                ></gz-tag-picker>
                              </v-col>

                              <v-col cols="12" sm="6">
                                <gz-pick-list
                                  ref="customerTagWorkOrderReport5Id"
                                  v-model="obj.customerTagWorkOrderReport5Id"
                                  :aya-type="ayaTypes().Report"
                                  :variant="ayaTypes().WorkOrder.toString()"
                                  show-edit-icon
                                  :readonly="formState.readOnly"
                                  :label="$ay.t('DefaultReport')"
                                  data-cy="customerTagWorkOrderReport5Id"
                                  :error-messages="
                                    form().serverErrors(
                                      this,
                                      'customerTagWorkOrderReport5Id'
                                    )
                                  "
                                  @input="
                                    fieldValueChanged(
                                      'customerTagWorkOrderReport5Id'
                                    )
                                  "
                                ></gz-pick-list>
                              </v-col>
                            </v-row>
                          </v-expansion-panel-content>
                        </v-expansion-panel>
                        <v-expansion-panel key="b">
                          <v-expansion-panel-header>
                            <span class="text-subtitle-1">
                              {{ $ay.t("CustomerAccessWorkOrderWiki") }}
                            </span>
                          </v-expansion-panel-header>
                          <v-expansion-panel-content>
                            <v-row dense>
                              <v-col cols="12" sm="6" lg="2">
                                <v-checkbox
                                  ref="customerAllowWOWiki"
                                  v-model="obj.customerAllowWOWiki"
                                  dense
                                  :readonly="formState.readOnly"
                                  :label="$ay.t('Active')"
                                  data-cy="customerAllowWOWiki"
                                  :error-messages="
                                    form().serverErrors(
                                      this,
                                      'customerAllowWOWiki'
                                    )
                                  "
                                  @change="
                                    fieldValueChanged('customerAllowWOWiki')
                                  "
                                ></v-checkbox>
                              </v-col>
                              <template v-if="obj.customerAllowWOWiki">
                                <v-col cols="12" sm="6" lg="10">
                                  <gz-tag-picker
                                    ref="customerAllowWOWikiInTags"
                                    v-model="obj.customerAllowWOWikiInTags"
                                    :readonly="formState.readOnly"
                                    :label="
                                      $ay.t(
                                        'WorkOrderContactCustomerHeadOfficeTaggedWith'
                                      )
                                    "
                                    data-cy="customerAllowWOWikiInTags"
                                    :error-messages="
                                      form().serverErrors(
                                        this,
                                        'customerAllowWOWikiInTags'
                                      )
                                    "
                                    @input="
                                      fieldValueChanged(
                                        'customerAllowWOWikiInTags'
                                      )
                                    "
                                  ></gz-tag-picker>
                                </v-col>
                              </template>
                            </v-row>
                          </v-expansion-panel-content>
                        </v-expansion-panel>
                        <v-expansion-panel key="c" class="mb-10">
                          <v-expansion-panel-header>
                            <span class="text-subtitle-1">
                              {{ $ay.t("CustomerAccessWorkOrderAttachments") }}
                            </span>
                          </v-expansion-panel-header>
                          <v-expansion-panel-content>
                            <v-row dense>
                              <v-col cols="12" sm="6" lg="2">
                                <v-checkbox
                                  ref="customerAllowWOAttachments"
                                  v-model="obj.customerAllowWOAttachments"
                                  dense
                                  :readonly="formState.readOnly"
                                  :label="$ay.t('Active')"
                                  data-cy="customerAllowWOAttachments"
                                  :error-messages="
                                    form().serverErrors(
                                      this,
                                      'customerAllowWOAttachments'
                                    )
                                  "
                                  @change="
                                    fieldValueChanged(
                                      'customerAllowWOAttachments'
                                    )
                                  "
                                ></v-checkbox>
                              </v-col>
                              <template v-if="obj.customerAllowWOAttachments">
                                <v-col cols="12" sm="6" lg="10">
                                  <gz-tag-picker
                                    ref="customerAllowWOAttachmentsInTags"
                                    v-model="
                                      obj.customerAllowWOAttachmentsInTags
                                    "
                                    :readonly="formState.readOnly"
                                    :label="
                                      $ay.t(
                                        'WorkOrderContactCustomerHeadOfficeTaggedWith'
                                      )
                                    "
                                    data-cy="customerAllowWOAttachmentsInTags"
                                    :error-messages="
                                      form().serverErrors(
                                        this,
                                        'customerAllowWOAttachmentsInTags'
                                      )
                                    "
                                    @input="
                                      fieldValueChanged(
                                        'customerAllowWOAttachmentsInTags'
                                      )
                                    "
                                  ></gz-tag-picker>
                                </v-col>
                              </template>
                            </v-row>
                          </v-expansion-panel-content>
                        </v-expansion-panel>
                      </v-expansion-panels>
                    </template>
                  </v-row>
                </v-expansion-panel-content>
              </v-expansion-panel>
              <v-expansion-panel key="3">
                <v-expansion-panel-header>
                  <span class="text-h6">
                    {{ $ay.t("UserSettings") }}
                  </span>
                </v-expansion-panel-header>
                <v-expansion-panel-content>
                  <v-row dense>
                    <v-col cols="12" sm="6" lg="2">
                      <v-checkbox
                        ref="customerAllowUserSettings"
                        v-model="obj.customerAllowUserSettings"
                        dense
                        :readonly="formState.readOnly"
                        :label="$ay.t('Active')"
                        data-cy="customerAllowUserSettings"
                        :error-messages="
                          form().serverErrors(this, 'customerAllowUserSettings')
                        "
                        @change="fieldValueChanged('customerAllowUserSettings')"
                      ></v-checkbox>
                    </v-col>
                    <template v-if="obj.customerAllowUserSettings">
                      <v-col cols="12" sm="6" lg="10">
                        <gz-tag-picker
                          ref="customerAllowUserSettingsInTags"
                          v-model="obj.customerAllowUserSettingsInTags"
                          :readonly="formState.readOnly"
                          :label="$ay.t('ContactCustomerHeadOfficeTaggedWith')"
                          data-cy="customerAllowUserSettingsInTags"
                          :error-messages="
                            form().serverErrors(
                              this,
                              'customerAllowUserSettingsInTags'
                            )
                          "
                          @input="
                            fieldValueChanged('customerAllowUserSettingsInTags')
                          "
                        ></gz-tag-picker>
                      </v-col>
                    </template>
                  </v-row>
                </v-expansion-panel-content>
              </v-expansion-panel>
              <v-expansion-panel key="4">
                <v-expansion-panel-header>
                  <span class="text-h6">
                    {{ $ay.t("NotifySubscriptionList") }}
                  </span>
                </v-expansion-panel-header>
                <v-expansion-panel-content>
                  <v-row dense>
                    <v-col cols="12" sm="6" lg="3">
                      <v-checkbox
                        ref="customerAllowNotifyServiceImminent"
                        v-model="obj.customerAllowNotifyServiceImminent"
                        dense
                        :readonly="formState.readOnly"
                        :label="$ay.t('NotifyEventCustomerServiceImminent')"
                        data-cy="customerAllowNotifyServiceImminent"
                        :error-messages="
                          form().serverErrors(
                            this,
                            'customerAllowNotifyServiceImminent'
                          )
                        "
                        @change="
                          fieldValueChanged(
                            'customerAllowNotifyServiceImminent'
                          )
                        "
                      ></v-checkbox>
                    </v-col>

                    <v-col
                      v-if="obj.customerAllowNotifyServiceImminent"
                      cols="12"
                      sm="6"
                      lg="9"
                    >
                      <gz-tag-picker
                        ref="customerAllowNotifyServiceImminentInTags"
                        v-model="obj.customerAllowNotifyServiceImminentInTags"
                        :readonly="formState.readOnly"
                        :label="$ay.t('ContactCustomerHeadOfficeTaggedWith')"
                        data-cy="customerAllowNotifyServiceImminentInTags"
                        :error-messages="
                          form().serverErrors(
                            this,
                            'customerAllowNotifyServiceImminentInTags'
                          )
                        "
                        @input="
                          fieldValueChanged(
                            'customerAllowNotifyServiceImminentInTags'
                          )
                        "
                      ></gz-tag-picker>
                    </v-col>

                    <!-- ######################################################## -->

                    <v-col cols="12" sm="6" lg="3">
                      <v-checkbox
                        ref="customerAllowNotifyCSRAccepted"
                        v-model="obj.customerAllowNotifyCSRAccepted"
                        dense
                        :readonly="formState.readOnly"
                        :label="$ay.t('NotifyEventCSRAccepted')"
                        data-cy="customerAllowNotifyCSRAccepted"
                        :error-messages="
                          form().serverErrors(
                            this,
                            'customerAllowNotifyCSRAccepted'
                          )
                        "
                        @change="
                          fieldValueChanged('customerAllowNotifyCSRAccepted')
                        "
                      ></v-checkbox>
                    </v-col>
                    <v-col
                      v-if="obj.customerAllowNotifyCSRAccepted"
                      cols="12"
                      sm="6"
                      lg="9"
                    >
                      <gz-tag-picker
                        ref="customerAllowNotifyCSRAcceptedInTags"
                        v-model="obj.customerAllowNotifyCSRAcceptedInTags"
                        :readonly="formState.readOnly"
                        :label="$ay.t('ContactCustomerHeadOfficeTaggedWith')"
                        data-cy="customerAllowNotifyCSRAcceptedInTags"
                        :error-messages="
                          form().serverErrors(
                            this,
                            'customerAllowNotifyCSRAcceptedInTags'
                          )
                        "
                        @input="
                          fieldValueChanged(
                            'customerAllowNotifyCSRAcceptedInTags'
                          )
                        "
                      ></gz-tag-picker>
                    </v-col>

                    <!-- ######################################################## -->

                    <v-col cols="12" sm="6" lg="3">
                      <v-checkbox
                        ref="customerAllowNotifyCSRRejected"
                        v-model="obj.customerAllowNotifyCSRRejected"
                        dense
                        :readonly="formState.readOnly"
                        :label="$ay.t('NotifyEventCSRRejected')"
                        data-cy="customerAllowNotifyCSRRejected"
                        :error-messages="
                          form().serverErrors(
                            this,
                            'customerAllowNotifyCSRRejected'
                          )
                        "
                        @change="
                          fieldValueChanged('customerAllowNotifyCSRRejected')
                        "
                      ></v-checkbox>
                    </v-col>
                    <v-col
                      v-if="obj.customerAllowNotifyCSRRejected"
                      cols="12"
                      sm="6"
                      lg="9"
                    >
                      <gz-tag-picker
                        ref="customerAllowNotifyCSRRejectedInTags"
                        v-model="obj.customerAllowNotifyCSRRejectedInTags"
                        :readonly="formState.readOnly"
                        :label="$ay.t('ContactCustomerHeadOfficeTaggedWith')"
                        data-cy="customerAllowNotifyCSRRejectedInTags"
                        :error-messages="
                          form().serverErrors(
                            this,
                            'customerAllowNotifyCSRRejectedInTags'
                          )
                        "
                        @input="
                          fieldValueChanged(
                            'customerAllowNotifyCSRRejectedInTags'
                          )
                        "
                      ></gz-tag-picker>
                    </v-col>

                    <!-- ######################################################## -->

                    <v-col cols="12" sm="6" lg="3">
                      <v-checkbox
                        ref="customerAllowNotifyWOCreated"
                        v-model="obj.customerAllowNotifyWOCreated"
                        dense
                        :readonly="formState.readOnly"
                        :label="$ay.t('NotifyEventWorkorderCreatedForCustomer')"
                        data-cy="customerAllowNotifyWOCreated"
                        :error-messages="
                          form().serverErrors(
                            this,
                            'customerAllowNotifyWOCreated'
                          )
                        "
                        @change="
                          fieldValueChanged('customerAllowNotifyWOCreated')
                        "
                      ></v-checkbox>
                    </v-col>
                    <v-col
                      v-if="obj.customerAllowNotifyWOCreated"
                      cols="12"
                      sm="6"
                      lg="9"
                    >
                      <gz-tag-picker
                        ref="customerAllowNotifyWOCreatedInTags"
                        v-model="obj.customerAllowNotifyWOCreatedInTags"
                        :readonly="formState.readOnly"
                        :label="$ay.t('ContactCustomerHeadOfficeTaggedWith')"
                        data-cy="customerAllowNotifyWOCreatedInTags"
                        :error-messages="
                          form().serverErrors(
                            this,
                            'customerAllowNotifyWOCreatedInTags'
                          )
                        "
                        @input="
                          fieldValueChanged(
                            'customerAllowNotifyWOCreatedInTags'
                          )
                        "
                      ></gz-tag-picker>
                    </v-col>

                    <!-- ######################################################## -->

                    <v-col cols="12" sm="6" lg="3">
                      <v-checkbox
                        ref="customerAllowNotifyWOCompleted"
                        v-model="obj.customerAllowNotifyWOCompleted"
                        dense
                        :readonly="formState.readOnly"
                        :label="$ay.t('NotifyEventWorkorderCompleted')"
                        data-cy="customerAllowNotifyWOCompleted"
                        :error-messages="
                          form().serverErrors(
                            this,
                            'customerAllowNotifyWOCompleted'
                          )
                        "
                        @change="
                          fieldValueChanged('customerAllowNotifyWOCompleted')
                        "
                      ></v-checkbox>
                    </v-col>
                    <v-col
                      v-if="obj.customerAllowNotifyWOCompleted"
                      cols="12"
                      sm="6"
                      lg="9"
                    >
                      <gz-tag-picker
                        ref="customerAllowNotifyWOCompletedInTags"
                        v-model="obj.customerAllowNotifyWOCompletedInTags"
                        :readonly="formState.readOnly"
                        :label="$ay.t('ContactCustomerHeadOfficeTaggedWith')"
                        data-cy="customerAllowNotifyWOCompletedInTags"
                        :error-messages="
                          form().serverErrors(
                            this,
                            'customerAllowNotifyWOCompletedInTags'
                          )
                        "
                        @input="
                          fieldValueChanged(
                            'customerAllowNotifyWOCompletedInTags'
                          )
                        "
                      ></gz-tag-picker>
                    </v-col>
                  </v-row>
                </v-expansion-panel-content>
              </v-expansion-panel>
            </v-expansion-panels>
          </v-col>
          <!-- **************************************************** -->
        </v-row>
      </v-form>
    </div>
    <v-overlay :value="!formState.ready || formState.loading">
      <v-progress-circular indeterminate :size="64" />
    </v-overlay>
  </div>
</template>
<script>
const FORM_KEY = "global-settings-edit";
const API_BASE_URL = "global-biz-setting/";
export default {
  data() {
    return {
      obj: {
        id: 0,
        concurrency: 0,
        filterCaseSensitive: false,
        useInventory: true,
        taxPartPurchaseId: null,
        taxPartSaleId: null,
        taxRateSaleId: null,
        workOrderCompleteByAge: "00:00:00",
        allowScheduleConflicts: false,
        workOrderTravelDefaultMinutes: 0,
        workLaborScheduleDefaultMinutes: 0,
        customerDefaultWorkOrderReportId: null,
        customerServiceRequestInfoText: null,
        signatureTitle: null,
        signatureHeader: null,
        signatureFooter: null,
        customerAllowCSR: false,
        customerAllowCSRInTags: [],
        customerAllowCreateUnit: false,
        customerAllowCreateUnitInTags: [],
        customerAllowViewWO: false,
        customerAllowViewWOInTags: [],
        customerAllowWOWiki: false,
        customerAllowWOWikiInTags: [],
        customerAllowWOAttachments: false,
        customerAllowWOAttachmentsInTags: [],
        customerAllowUserSettings: false,
        customerAllowUserSettingsInTags: [],
        customerAllowNotifyServiceImminent: false,
        customerAllowNotifyServiceImminentInTags: [],
        customerAllowNotifyCSRAccepted: false,
        customerAllowNotifyCSRAcceptedInTags: [],
        customerAllowNotifyCSRRejected: false,
        customerAllowNotifyCSRRejectedInTags: [],
        customerAllowNotifyWOCreated: false,
        customerAllowNotifyWOCreatedInTags: [],
        customerAllowNotifyWOCompleted: false,
        customerAllowNotifyWOCompletedInTags: [],
        customerTagWorkOrderReport1Id: null,
        customerWorkOrderReport1Tags: [],
        customerTagWorkOrderReport2Id: null,
        customerWorkOrderReport2Tags: [],
        customerTagWorkOrderReport3Id: null,
        customerWorkOrderReport3Tags: [],
        customerTagWorkOrderReport4Id: null,
        customerWorkOrderReport4Tags: [],
        customerTagWorkOrderReport5Id: null,
        customerWorkOrderReport5Tags: []
      },
      formState: {
        ready: false,
        dirty: false,
        valid: true,
        readOnly: false,
        loading: true,
        errorBoxMessage: null,
        appError: null,
        serverError: {}
      },
      rights: window.$gz.role.defaultRightsObject(),
      ayaType: window.$gz.type.Project,
      listgroupitems: []
    };
  },
  watch: {
    formState: {
      handler: function(val) {
        if (this.formState.loading) {
          return;
        }

        if (val.dirty && val.valid && !val.readOnly) {
          window.$gz.eventBus.$emit("menu-enable-item", FORM_KEY + ":save");
        } else {
          window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":save");
        }
      },
      deep: true
    }
  },
  async created() {
    const vm = this;
    try {
      await initForm();
      vm.rights = window.$gz.role.getRights(window.$gz.type.Global);
      vm.formState.readOnly = !vm.rights.change;
      window.$gz.eventBus.$on("menu-click", clickHandler);
      //NOTE: slightly different in this form as there is only ever a single global object so no need for a bunch of code
      //is there already an obj from a prior operation?
      if (this.$route.params.obj) {
        //yes, no need to fetch it
        this.obj = this.$route.params.obj;
        window.$gz.form.setFormState({
          vm: vm,
          loading: false
        });
      } else {
        await vm.getDataFromApi();
      }
      window.$gz.form.setFormState({
        vm: vm,
        dirty: false,
        valid: true
      });
      generateMenu(vm);
    } catch (error) {
      window.$gz.errorHandler.handleFormError(error, vm);
    } finally {
      vm.formState.ready = true;
    }
  },
  async beforeRouteLeave(to, from, next) {
    if (!this.formState.dirty) {
      next();
      return;
    }
    if ((await window.$gz.dialog.confirmLeaveUnsaved()) === true) {
      next();
    } else {
      next(false);
    }
  },
  beforeDestroy() {
    window.$gz.eventBus.$off("menu-click", clickHandler);
  },
  methods: {
    canSave: function() {
      return this.formState.valid && this.formState.dirty;
    },
    ayaTypes: function() {
      return window.$gz.type;
    },
    form() {
      return window.$gz.form;
    },
    fieldValueChanged(ref) {
      if (
        this.formState.ready &&
        !this.formState.loading &&
        !this.formState.readOnly
      ) {
        window.$gz.form.fieldValueChanged(this, ref);
      }
    },
    async getDataFromApi() {
      const vm = this;
      window.$gz.form.setFormState({
        vm: vm,
        loading: true
      });
      try {
        window.$gz.form.deleteAllErrorBoxErrors(vm);
        const res = await window.$gz.api.get(API_BASE_URL);
        if (res.error) {
          if (res.error.code == "2010") {
            window.$gz.form.handleObjectNotFound(vm);
          }
          vm.formState.serverError = res.error;
          window.$gz.form.setErrorBoxErrors(vm);
        } else {
          vm.obj = res.data;
          generateMenu(vm);
          window.$gz.form.setFormState({
            vm: vm,
            dirty: false,
            valid: true,
            loading: false
          });
        }
      } catch (error) {
        window.$gz.errorHandler.handleFormError(error, vm);
      } finally {
        window.$gz.form.setFormState({
          vm: vm,
          loading: false
        });
      }
    },
    async submit() {
      const vm = this;
      if (vm.canSave == false) {
        return;
      }
      try {
        window.$gz.form.setFormState({
          vm: vm,
          loading: true
        });
        window.$gz.form.deleteAllErrorBoxErrors(vm);
        const res = await window.$gz.api.put(API_BASE_URL, vm.obj);
        if (res.error) {
          vm.formState.serverError = res.error;
          window.$gz.form.setErrorBoxErrors(vm);
        } else {
          //PUT
          vm.obj.concurrency = res.data.concurrency;
          window.$gz.form.setFormState({
            vm: vm,
            dirty: false,
            valid: true
          });
          //refresh the local global settings cache so user can try their settings right away
          //get the client version of the global settings object values
          const gsets = await window.$gz.api.get("global-biz-setting/client");
          if (!gsets.error) {
            window.$gz.store.commit("setGlobalSettings", gsets.data);
          }
        }
      } catch (ex) {
        window.$gz.errorHandler.handleFormError(ex, vm);
      } finally {
        window.$gz.form.setFormState({
          vm: vm,
          loading: false
        });
      }
    }
  }
};

/////////////////////////////
//
//
async function clickHandler(menuItem) {
  if (!menuItem) {
    return;
  }
  const m = window.$gz.menu.parseMenuItem(menuItem);
  if (m.owner == FORM_KEY && !m.disabled) {
    switch (m.key) {
      case "save":
        m.vm.submit();
        break;
      default:
        window.$gz.eventBus.$emit(
          "notify-warning",
          FORM_KEY + "::context click: [" + m.key + "]"
        );
    }
  }
}

//////////////////////
//
//
function generateMenu(vm) {
  const menuOptions = {
    isMain: false,
    readOnly: vm.formState.readOnly,
    icon: "$ayiCogs",
    title: "AdministrationGlobalSettings",
    helpUrl: "adm-global-settings",
    formData: {
      ayaType: window.$gz.type.Project,
      recordId: vm.$route.params.recordid,
      recordName: vm.$ay.t("AdministrationGlobalSettings")
    },
    menuItems: []
  };
  if (vm.rights.change) {
    menuOptions.menuItems.push({
      title: "Save",
      icon: "$ayiSave",
      surface: true,
      key: FORM_KEY + ":save",
      vm: vm
    });
  }
  menuOptions.menuItems.push({ divider: true, inset: false });
  window.$gz.eventBus.$emit("menu-change", menuOptions);
}

/////////////////////////////////
//
//
async function initForm() {
  await fetchTranslatedText();
}

//////////////////////////////////////////////////////////
//
// Ensures UI translated text is available
//
async function fetchTranslatedText() {
  await window.$gz.translation.cacheTranslations([
    "DefaultReport",
    "ContactCustomerHeadOfficeTaggedWith",
    "WorkOrderCustomerTaggedWith",
    "WorkOrderContactCustomerHeadOfficeTaggedWith",
    "CustomerServiceRequestList",
    "WorkOrderList",
    "UserSettings",
    "UserInterfaceSettings",
    "BusinessSettings",
    "CustomerAccessSettings",
    "PickListTemplates",
    "GlobalLogo",
    "GlobalUseInventory",
    "GlobalFilterCaseSensitive",
    "GlobalTaxPartPurchaseID",
    "GlobalTaxPartSaleID",
    "GlobalTaxRateSaleID",
    "GlobalNextSeeds",
    "GlobalWorkOrderCompleteByAge",
    "GlobalLaborSchedUserDfltTimeSpan",
    "GlobalTravelDfltTimeSpan",
    "CustomerAccessWorkOrderWiki",
    "CustomerAccessWorkOrderAttachments",
    "NotifySubscriptionList",
    "NotifyEventCustomerServiceImminent",
    "NotifyEventCSRAccepted",
    "NotifyEventCSRRejected",
    "NotifyEventWorkorderCreatedForCustomer",
    "NotifyEventWorkorderCompleted",
    "CustomerAccessWorkOrderReport",
    "CSRInfoText",
    "CustomerAllowCreateUnit",
    "CustomerSignature",
    "GlobalSignatureFooter",
    "GlobalSignatureHeader",
    "GlobalSignatureTitle",
    "GlobalAllowScheduleConflicts",
    "CompanyInformation",
    "CompanyEmail",
    "CompanyPhone1",
    "CompanyPhone2",
    "WebAddress",
    "AddressTypePhysical",
    "AddressTypePostal",
    "Address",
    "AddressPostalDeliveryAddress",
    "AddressPostalCity",
    "AddressPostalStateProv",
    "AddressPostalCountry",
    "AddressPostalPostal",
    "AddressDeliveryAddress",
    "AddressCity",
    "AddressStateProv",
    "AddressCountry",
    "AddressPostal",
    "AddressLatitude",
    "AddressLongitude"
  ]);
}
</script>
