import { FileManagerVue } from '../../../../admin/view/javascript/changefiles.js';

export default {
  name: 'BaseThumbnail',
  props: {
    noimage: {
      type: String,
      required: true,
    },
    image: {
      type: Object,
    },
    onclose: {
      type: Function,
      default: function() {},
    },
    inputid: {
      type: String,
    },
    thumbKey: {
      type: String,
      default: 'thumb',
    },
    error: {
      type: Array,
      default: () => [],
    },
  },
  mounted() {
    // console.log(this);
  },
  methods: {
    callFileManager(row) {
      const $IMAGE = row ? this.$refs.imagem[row] : this.$refs.imagem,
        $INPUT = row ? this.$refs.inputimage[row] : this.$refs.inputimage,
        $OPTIONS = {
          onClose: this.onclose.bind(this, $INPUT, $IMAGE),
        };

      const FileManager = new FileManagerVue($IMAGE, $INPUT, $OPTIONS);
      FileManager.displayFileManager.call(FileManager);
    },
    removeImage(row) {
      const $IMAGE = row ? this.$refs.imagem[row] : this.$refs.imagem,
        $INPUT = row ? this.$refs.inputimage[row] : this.$refs.inputimage,
        $OPTIONS = {
          nameFile: $INPUT,
        };

      const FileManager = new FileManagerVue($IMAGE, $INPUT, $OPTIONS);
      FileManager.removeFile.call(FileManager);
    },

  },
};
