Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ui/src/components/dynamics-form/items/upload/UploadInput.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<el-upload
style="width: 80%"
style="width: 100%"
v-loading="loading"
action="#"
v-bind="$attrs"
Expand Down Expand Up @@ -62,7 +62,7 @@ function formatSize(sizeInBytes: number) {
}

const deleteFile = (file: any) => {
if (inputDisabled) {
if (inputDisabled.value) {
return
}
fileArray.value = fileArray.value.filter((f: any) => f.uid != file.uid)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your code is generally clean and functional. However, there are a few minor improvements you can make:

  1. Template Literals: In the <template> part of your code, ensure that all template literals are properly closed with double quotes (").

  2. Consistent Use of .value Property: It's important to consistently use the .value property when dealing with reactivity properties in Vue.js.

  3. Function Naming Consistency: The function formatSize uses snake_case, while others like if, else if, etc., follow camelCase. Consider using consistent naming conventions throughout your codebase for clarity.

Here’s an optimized version of your code:

<template>
  <el-upload
    :style="{ width: '100%' }"
    v-loading="loading"
    action="#"
    v-bind="$attrs"
  ></el-upload>
</template>

<script lang="ts">
import { defineComponent, ref } from 'vue';
const formatSize = (sizeInBytes: number): string => {
  // Your implementation of formatting size goes here
};

const deleteFile = (file: any) => {
  if (!inputDisabled.value) {
    fileArray.value = fileArray.value.filter((f: any) => f.uid !== file.uid);
  }
};

export default defineComponent({
  name: 'YourComponentName',
  setup() {
    const loading = ref(true);
    const inputDisabled = ref(false); // Make sure this is also reactive
    const fileArray = ref([]); // Ensure this is reactive

    return {
      loading,
      inputDisabled,
      fileArray,
      formatSize,
      deleteFile,
    };
  },
});
</script>

<style scoped>
/* Your styles go here */
</style>

Key changes:

  • Ensured consistent template literal usage.
  • Used arrow functions where appropriate.
  • Properly defined constants and returned them inside script tags.
  • Made inputDisabled and fileArray reactive references by prefixing them with ref().

These changes should improve both readability and maintainability of your Vue component.

Expand Down
Loading