<template>
  <div>
    <div class="mb-n2 ml-10">
      <span class="text-caption">{{ $ay.t("Contract") }}</span>
    </div>

    <template>
      <div class="mb-6 mb-sm-0">
        <v-btn icon class="ml-n1 mr-2" @click="openDialog = true">
          <v-icon>$ayiEdit</v-icon>
        </v-btn>

        <span class="text-h6">{{ value.contractViz }}</span>
      </div>
    </template>

    <v-row justify="center">
      <v-dialog v-model="openDialog" max-width="600px">
        <v-card>
          <v-card-title>
            <span class="text-h5">{{ $ay.t("ContractList") }}</span>
          </v-card-title>
          <v-card-text>
            contract pick list here
          </v-card-text>
          <v-card-actions>
            <v-spacer></v-spacer>
            <v-btn color="blue darken-1" text @click="cancelDialog()">{{
              $ay.t("Cancel")
            }}</v-btn>
            <v-btn color="blue darken-1" text @click="save()">{{
              $ay.t("Save")
            }}</v-btn>
          </v-card-actions>
        </v-card>
      </v-dialog>
    </v-row>
  </div>
</template>
<script>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*  XXXeslint-disable    */
////////////////////////////////////////////////////////////////////////////////////////////////////////////

export default {
  data() {
    return {
      openDialog: false
    };
  },

  props: {
    value: {
      default: null,
      type: Object
    },
    pvm: {
      default: null,
      type: Object
    },

    formKey: { type: String, default: "" }, //used to grab template from store
    readonly: Boolean,
    disabled: Boolean
  },

  methods: {
    form() {
      return window.$gz.form;
    },

    handleEditStateClick: function() {
      window.$gz.eventBus.$emit("openobject", {
        type: window.$gz.type.Contract,
        id: this.value.contractId
      });
    },
    save() {
      //TODO: save entire workorder
      this.pvm.submit();
      this.openDialog = false;
    },
    cancelDialog() {
      this.openDialog = false;
    },
    fieldValueChanged(ref) {
      if (!this.pvm.formState.loading && !this.pvm.formState.readonly) {
        window.$gz.form.fieldValueChanged(this.pvm, ref);
      }
    }
  },
  computed: {}
};
</script>
