<template>
  <div class="d-flex justify-content-center">
    <div class="col-8">
      <form name="editForm" novalidate @submit.prevent="save()">
        <h2 id="smartbookingApp.liberatoria.home.createOrEditLabel" data-cy="LiberatoriaCreateUpdateHeading">
          {{ t$('smartbookingApp.liberatoria.home.createOrEditLabel') }}
        </h2>
        <div>
          <div class="mb-3" v-if="liberatoria.id">
            <label for="id">{{ t$('global.field.id') }}</label>
            <input type="text" class="form-control" id="id" name="id" v-model="liberatoria.id" readonly />
          </div>
          <div class="mb-3">
            <label class="form-control-label" for="liberatoria">{{ t$('smartbookingApp.liberatoria.accettata') }}</label>
            <div class="d-flex">
              <input
                id="liberatoria-accettata"
                data-cy="accettata"
                type="datetime-local"
                class="form-control"
                name="accettata"
                :class="{ valid: !v$.accettata.$invalid, invalid: v$.accettata.$invalid }"
                :value="convertDateTimeFromServer(v$.accettata.$model)"
                @change="updateInstantField('accettata', $event)"
              />
            </div>
          </div>
          <div class="mb-3">
            <label class="form-control-label" for="liberatoria">{{ t$('smartbookingApp.liberatoria.utente') }}</label>
            <select class="form-control" id="liberatoria-utente" data-cy="utente" name="utente" v-model="liberatoria.utente">
              <option :value="null"></option>
              <option
                :value="liberatoria.utente && utenteAppOption.id === liberatoria.utente.id ? liberatoria.utente : utenteAppOption"
                v-for="utenteAppOption in utenteApps"
                :key="utenteAppOption.id"
              >
                {{ utenteAppOption.username }}
              </option>
            </select>
          </div>
          <div class="mb-3">
            <label class="form-control-label" for="liberatoria">{{ t$('smartbookingApp.liberatoria.modelloLiberatoria') }}</label>
            <select
              class="form-control"
              id="liberatoria-modelloLiberatoria"
              data-cy="modelloLiberatoria"
              name="modelloLiberatoria"
              v-model="liberatoria.modelloLiberatoria"
            >
              <option :value="null"></option>
              <option
                :value="
                  liberatoria.modelloLiberatoria && modelloLiberatoriaOption.id === liberatoria.modelloLiberatoria.id
                    ? liberatoria.modelloLiberatoria
                    : modelloLiberatoriaOption
                "
                v-for="modelloLiberatoriaOption in modelloLiberatorias"
                :key="modelloLiberatoriaOption.id"
              >
                {{ modelloLiberatoriaOption.id }}
              </option>
            </select>
          </div>
        </div>
        <div>
          <button type="button" id="cancel-save" data-cy="entityCreateCancelButton" class="btn btn-secondary" @click="previousState()">
            <font-awesome-icon icon="ban"></font-awesome-icon>&nbsp;<span>{{ t$('entity.action.cancel') }}</span>
          </button>
          <button
            type="submit"
            id="save-entity"
            data-cy="entityCreateSaveButton"
            :disabled="v$.$invalid || isSaving"
            class="btn btn-primary"
          >
            <font-awesome-icon icon="save"></font-awesome-icon>&nbsp;<span>{{ t$('entity.action.save') }}</span>
          </button>
        </div>
      </form>
    </div>
  </div>
</template>
<script lang="ts" src="./liberatoria-update.component.ts"></script>
