PHP Classes

File: resources/js/Compositions/file-list.js

Recommend this page to a friend!
  Classes of Robert Devenyi   Iceburg CRM   resources/js/Compositions/file-list.js   Download  
File: resources/js/Compositions/file-list.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Iceburg CRM
CRM application to manage contacts
Author: By
Last change:
Date: 1 year ago
Size: 832 bytes
 

Contents

Class file image Download
import { ref } from 'vue' export default function () { const files = ref([]) function addFiles(newFiles) { let newUploadableFiles = [...newFiles].map((file) => new UploadableFile(file)).filter((file) => !fileExists(file.id)) files.value = files.value.concat(newUploadableFiles) } function fileExists(otherId) { return files.value.some(({ id }) => id === otherId) } function removeFile(file) { const index = files.value.indexOf(file) if (index > -1) files.value.splice(index, 1) } return { files, addFiles, removeFile } } class UploadableFile { constructor(file) { this.file = file this.id = `${file.name}-${file.size}-${file.lastModified}-${file.type}` this.url = URL.createObjectURL(file) this.status = null } }