<template>
  <div>
    <h2 class="content-block">Lihat Profil</h2>

    <div class="content-block dx-card responsive-paddings">
      <DxForm :form-data="formData">
        <template #avatar-template="{}">
          <div class="form-avatar">
            <img :src="imageSrc" />
          </div>
        </template>
        <DxGroupItem :col-count="8" css-class="first-group">
          <DxSimpleItem :col-span="1" template="avatar-template" />
          <DxGroupItem :col-span="7">
            <DxGroupItem :col-count="1">
              <DxSimpleItem data-field="nama" />
            </DxGroupItem>
            <DxGroupItem :col-count="2">
              <DxSimpleItem data-field="bidang_id" editor-type="dxSelectBox" :editor-options="bidangOptions" css-class="bt-5" />
              <DxSimpleItem data-field="jabatan_id" editor-type="dxSelectBox" :editor-options="jabatanOptions" css-class="bt-5" />
            </DxGroupItem>
            <DxGroupItem :col-count="1">
              <DxSimpleItem data-field="role_id" editor-type="dxSelectBox" :editor-options="roleOptions" />
            </DxGroupItem>
            <DxGroupItem :col-count="2">
              <DxSimpleItem data-field="email" />
              <DxSimpleItem data-field="phone" />
            </DxGroupItem>
          </DxGroupItem>
        </DxGroupItem>

      </DxForm>
    </div>
  </div>
</template>

<script>
import {
  DxForm,
  DxSimpleItem,
  DxGroupItem,
  // DxLabel,
} from 'devextreme-vue/form';

export default {
  props: {
    picture: String
  },
  data() {
    return {
      bidangOptions: {
        items: ['Bidang 1', 'Bidang 2', 'Bidang 3'],
        searchEnabled: true,
        value: null,
      },
      jabatanOptions: {
        items: ['Jabatan 1', 'Jabatan 2', 'Jabatan 3'],
        searchEnabled: true,
        value: null,
      },
      roleOptions: {
        items: ['Role 1', 'Role 2', 'Role 3'],
        searchEnabled: true,
        value: null,
      }
    }
  },
  setup() {
    const picture = "images/employees/02.png";

    const imageSrc = `https://js.devexpress.com/Demos/WidgetsGallery/JSDemos/${picture}`;
    const formData = {
      nama: 'Sample Name',
      username: 'sample',
      email: 'sample@yopmail.com',
      role_id: 1,
      bidang_id: 1,
      jabatan_id: 1,
      instansi_id: 1,
      phone: '08123456789',
    };
    const colCountByScreen = {
      xs: 1,
      sm: 2,
      md: 3,
      lg: 4
    }

    return {
      imageSrc,
      formData,
      colCountByScreen
    };
  },
  components: {
    DxForm,
    DxSimpleItem,
    DxGroupItem,
  }
};
</script>

<style lang="scss">
.form-avatar {
  float: left;
  height: 120px;
  border-radius: 50%;
  width: 120px;
  margin-right: 20px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  background-color: #fff;
  overflow: hidden;

  img {
    height: 120px;
    display: block;
    margin: 0 auto;
  }
}
</style>
