1
1
mirror of https://github.com/Fabio286/antares.git synced 2025-06-05 21:59:22 +02:00

feat: support to text blob fields

This commit is contained in:
2022-11-05 10:22:12 +01:00
parent 95bb41e9db
commit e6f6a022d1
8 changed files with 42 additions and 27 deletions

View File

@ -81,6 +81,7 @@
:fields="fieldsObj"
:key-usage="keyUsage"
:element-type="elementType"
:blob-as-text="blobAsText"
:class="{'selected': selectedRows.includes(row._antares_id)}"
:selected="selectedRows.includes(row._antares_id)"
:selected-cell="selectedRows.length === 1 && selectedRows.includes(row._antares_id) ? selectedField : null"
@ -182,6 +183,7 @@ const isEditingRow = ref(false);
const workspaceSchema = computed(() => getWorkspace(props.connUid).breadcrumbs.schema);
const workspaceClient = computed(() => getWorkspace(props.connUid).client);
const blobAsText = computed(() => getWorkspace(props.connUid).customizations.blobAsText);
const primaryField = computed(() => {
const primaryFields = fields.value.filter(field => field.key === 'pri');

View File

@ -243,7 +243,8 @@ const props = defineProps({
itemHeight: Number,
elementType: { type: String, default: 'table' },
selected: { type: Boolean, default: false },
selectedCell: { type: String, default: null }
selectedCell: { type: String, default: null },
blobAsText: { type: Boolean, default: false }
});
const emit = defineEmits(['update-field', 'select-row', 'contextmenu', 'start-editing', 'stop-editing']);
@ -318,7 +319,7 @@ const inputProps = computed(() => {
return { type: 'text', mask: datetimeMask };
}
if (BLOB.includes(editingType.value))
if (BLOB.includes(editingType.value) && !props.blobAsText)
return { type: 'file', mask: false };
if (BOOLEAN.includes(editingType.value))
@ -398,7 +399,7 @@ const editON = async (field: string) => {
editingField.value = field;
editingLength.value = props.fields[field].length;
if ([...LONG_TEXT, ...ARRAY, ...TEXT_SEARCH].includes(type)) {
if ([...LONG_TEXT, ...ARRAY, ...TEXT_SEARCH].includes(type) || (BLOB.includes(type) && props.blobAsText)) {
isTextareaEditor.value = true;
editingContent.value = typeFormat(content, type);
emit('start-editing', field);
@ -415,7 +416,7 @@ const editON = async (field: string) => {
return;
}
if (BLOB.includes(type)) {
if (BLOB.includes(type) && !props.blobAsText) {
isBlobEditor.value = true;
editingContent.value = content || '';
fileToUpload.value = null;
@ -454,7 +455,7 @@ const editOFF = () => {
isInlineEditor.value[editingField.value] = false;
let content;
if (!BLOB.includes(editingType.value)) {
if (!BLOB.includes(editingType.value) || (BLOB.includes(editingType.value) && props.blobAsText)) {
if ([...DATETIME, ...TIME].includes(editingType.value)) {
if (editingContent.value !== null && editingContent.value.substring(editingContent.value.length - 1) === '.')
editingContent.value = editingContent.value.slice(0, -1);
@ -588,7 +589,7 @@ const typeFormat = (val: string | number | Date | number[], type: string, precis
return moment(val).isValid() ? moment(val).format(`YYYY-MM-DD HH:mm:ss${datePrecision}`) : val;
}
if (BLOB.includes(type)) {
if (BLOB.includes(type) && !props.blobAsText) {
const buff = Buffer.from(val as string);
if (!buff.length) return '';