2023-11-22 17:06:55 +01:00
|
|
|
<script setup lang="ts">
|
feat: Add alternate mimetype support, enhance validation for alternate mimetypes, and improve script loading performance
- mime_type.ts: Added a new column `public alternate_mimetype: string;`
- MimetypeController.ts: Extended validation and storage logic to accommodate the new `alternate_mimetype` attribute
- adonisrc.ts: Integrated new validation rule to validate user-provided mimetypes
- vite.ts: Set `defer: true` for script attributes to improve loading performance
- update_1_to_mime_types.ts: Added migration for the new `alternate_mimetype` column in the database
- UI improvements: Updated components such as AsideMenuLayer.vue, FormCheckRadioGroup.vue, MimeTypeInput.vue, NavBar.vue (lime-green background), NavBarMenu.vue, SectionBannerStarOnGitea.vue, Admin/mimetype/Create.vue, Admin/mimetype/Delete.vue, Admin/mimetype/Index.vue
- allowed_extensions_mimetype.ts: Enhanced rule to also check for alternate mimetypes
- referenceValidation.ts: Improved validation to allow only ISBNs with a '-' delimiter
- package-lock.json: Updated npm dependencie
2025-02-13 15:49:09 +01:00
|
|
|
import { computed, ref } from 'vue';
|
2023-10-31 15:38:43 +01:00
|
|
|
import FormCheckRadio from '@/Components/FormCheckRadio.vue';
|
feat: Add alternate mimetype support, enhance validation for alternate mimetypes, and improve script loading performance
- mime_type.ts: Added a new column `public alternate_mimetype: string;`
- MimetypeController.ts: Extended validation and storage logic to accommodate the new `alternate_mimetype` attribute
- adonisrc.ts: Integrated new validation rule to validate user-provided mimetypes
- vite.ts: Set `defer: true` for script attributes to improve loading performance
- update_1_to_mime_types.ts: Added migration for the new `alternate_mimetype` column in the database
- UI improvements: Updated components such as AsideMenuLayer.vue, FormCheckRadioGroup.vue, MimeTypeInput.vue, NavBar.vue (lime-green background), NavBarMenu.vue, SectionBannerStarOnGitea.vue, Admin/mimetype/Create.vue, Admin/mimetype/Delete.vue, Admin/mimetype/Index.vue
- allowed_extensions_mimetype.ts: Enhanced rule to also check for alternate mimetypes
- referenceValidation.ts: Improved validation to allow only ISBNs with a '-' delimiter
- package-lock.json: Updated npm dependencie
2025-02-13 15:49:09 +01:00
|
|
|
import BaseButton from '@/Components/BaseButton.vue';
|
|
|
|
import FormControl from '@/Components/FormControl.vue';
|
|
|
|
import { mdiPlusCircle } from '@mdi/js';
|
2023-03-03 16:54:28 +01:00
|
|
|
const props = defineProps({
|
2023-10-31 15:38:43 +01:00
|
|
|
options: {
|
|
|
|
type: Object,
|
feat: Add alternate mimetype support, enhance validation for alternate mimetypes, and improve script loading performance
- mime_type.ts: Added a new column `public alternate_mimetype: string;`
- MimetypeController.ts: Extended validation and storage logic to accommodate the new `alternate_mimetype` attribute
- adonisrc.ts: Integrated new validation rule to validate user-provided mimetypes
- vite.ts: Set `defer: true` for script attributes to improve loading performance
- update_1_to_mime_types.ts: Added migration for the new `alternate_mimetype` column in the database
- UI improvements: Updated components such as AsideMenuLayer.vue, FormCheckRadioGroup.vue, MimeTypeInput.vue, NavBar.vue (lime-green background), NavBarMenu.vue, SectionBannerStarOnGitea.vue, Admin/mimetype/Create.vue, Admin/mimetype/Delete.vue, Admin/mimetype/Index.vue
- allowed_extensions_mimetype.ts: Enhanced rule to also check for alternate mimetypes
- referenceValidation.ts: Improved validation to allow only ISBNs with a '-' delimiter
- package-lock.json: Updated npm dependencie
2025-02-13 15:49:09 +01:00
|
|
|
default: () => { },
|
|
|
|
},
|
|
|
|
allowManualAdding: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
manualAddingPlaceholder: {
|
|
|
|
type: String,
|
|
|
|
default: 'Add manually',
|
|
|
|
required: false,
|
2023-10-31 15:38:43 +01:00
|
|
|
},
|
|
|
|
name: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
type: {
|
|
|
|
type: String,
|
|
|
|
default: 'checkbox',
|
2023-11-22 17:06:55 +01:00
|
|
|
validator: (value: string) => ['checkbox', 'radio', 'switch'].includes(value),
|
2023-10-31 15:38:43 +01:00
|
|
|
},
|
|
|
|
componentClass: {
|
|
|
|
type: String,
|
|
|
|
default: null,
|
|
|
|
},
|
|
|
|
isColumn: Boolean,
|
|
|
|
modelValue: {
|
|
|
|
type: [Array, String, Number, Boolean, Object],
|
|
|
|
default: null,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
const emit = defineEmits(['update:modelValue']);
|
2023-03-03 16:54:28 +01:00
|
|
|
const computedValue = computed({
|
2023-11-22 17:06:55 +01:00
|
|
|
// get: () => props.modelValue,
|
|
|
|
get: () => {
|
|
|
|
// const ids = props.modelValue.map((obj) => obj.id);
|
|
|
|
// return ids;
|
|
|
|
if (Array.isArray(props.modelValue)) {
|
|
|
|
if (props.modelValue.every((item) => typeof item === 'number')) {
|
|
|
|
return props.modelValue;
|
|
|
|
} else if (props.modelValue.every((item) => hasIdAttribute(item))) {
|
|
|
|
const ids = props.modelValue.map((obj) => obj.id.toString());
|
|
|
|
return ids;
|
|
|
|
}
|
|
|
|
return props.modelValue;
|
|
|
|
}
|
|
|
|
// return props.modelValue;
|
|
|
|
},
|
2023-10-31 15:38:43 +01:00
|
|
|
set: (value) => {
|
|
|
|
emit('update:modelValue', value);
|
|
|
|
},
|
|
|
|
});
|
2023-11-22 17:06:55 +01:00
|
|
|
|
|
|
|
// Define a type guard to check if an object has an 'id' attribute
|
|
|
|
// function hasIdAttribute(obj: any): obj is { id: any } {
|
|
|
|
// return typeof obj === 'object' && 'id' in obj;
|
|
|
|
// }
|
|
|
|
|
|
|
|
const hasIdAttribute = (obj: any): obj is { id: any } => {
|
|
|
|
return typeof obj === 'object' && 'id' in obj;
|
|
|
|
};
|
feat: Add alternate mimetype support, enhance validation for alternate mimetypes, and improve script loading performance
- mime_type.ts: Added a new column `public alternate_mimetype: string;`
- MimetypeController.ts: Extended validation and storage logic to accommodate the new `alternate_mimetype` attribute
- adonisrc.ts: Integrated new validation rule to validate user-provided mimetypes
- vite.ts: Set `defer: true` for script attributes to improve loading performance
- update_1_to_mime_types.ts: Added migration for the new `alternate_mimetype` column in the database
- UI improvements: Updated components such as AsideMenuLayer.vue, FormCheckRadioGroup.vue, MimeTypeInput.vue, NavBar.vue (lime-green background), NavBarMenu.vue, SectionBannerStarOnGitea.vue, Admin/mimetype/Create.vue, Admin/mimetype/Delete.vue, Admin/mimetype/Index.vue
- allowed_extensions_mimetype.ts: Enhanced rule to also check for alternate mimetypes
- referenceValidation.ts: Improved validation to allow only ISBNs with a '-' delimiter
- package-lock.json: Updated npm dependencie
2025-02-13 15:49:09 +01:00
|
|
|
|
|
|
|
const newOption = ref<string>('');
|
|
|
|
const addOption = () => {
|
|
|
|
if (newOption.value && !props.options[newOption.value]) {
|
|
|
|
props.options[newOption.value] = newOption.value;
|
|
|
|
newOption.value = '';
|
|
|
|
}
|
|
|
|
};
|
2023-03-03 16:54:28 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2023-10-31 15:38:43 +01:00
|
|
|
<div class="flex justify-start flex-wrap -mb-3" :class="{ 'flex-col': isColumn }">
|
|
|
|
<!-- :input-value="key" -->
|
|
|
|
<!-- :label="value" -->
|
|
|
|
<!-- :input-value="value.id"
|
2023-03-03 16:54:28 +01:00
|
|
|
:label="value.name" -->
|
feat: Add alternate mimetype support, enhance validation for alternate mimetypes, and improve script loading performance
- mime_type.ts: Added a new column `public alternate_mimetype: string;`
- MimetypeController.ts: Extended validation and storage logic to accommodate the new `alternate_mimetype` attribute
- adonisrc.ts: Integrated new validation rule to validate user-provided mimetypes
- vite.ts: Set `defer: true` for script attributes to improve loading performance
- update_1_to_mime_types.ts: Added migration for the new `alternate_mimetype` column in the database
- UI improvements: Updated components such as AsideMenuLayer.vue, FormCheckRadioGroup.vue, MimeTypeInput.vue, NavBar.vue (lime-green background), NavBarMenu.vue, SectionBannerStarOnGitea.vue, Admin/mimetype/Create.vue, Admin/mimetype/Delete.vue, Admin/mimetype/Index.vue
- allowed_extensions_mimetype.ts: Enhanced rule to also check for alternate mimetypes
- referenceValidation.ts: Improved validation to allow only ISBNs with a '-' delimiter
- package-lock.json: Updated npm dependencie
2025-02-13 15:49:09 +01:00
|
|
|
<div v-if="allowManualAdding && type === 'checkbox'" class="flex items-center mt-2 mb-2">
|
|
|
|
<FormControl v-model="newOption" :placeholder="manualAddingPlaceholder" class="mr-2" />
|
|
|
|
<BaseButton small rounded-full color="info" :icon="mdiPlusCircle" @click.prevent="addOption" />
|
|
|
|
</div>
|
|
|
|
<FormCheckRadio v-for="(value, key) in options" :key="key" v-model="computedValue" :type="type" :name="name"
|
|
|
|
:input-value="key" :label="value" :class="componentClass" />
|
2023-10-31 15:38:43 +01:00
|
|
|
</div>
|
|
|
|
</template>
|