mirror of
				https://github.com/Fabio286/antares.git
				synced 2025-06-05 21:59:22 +02:00 
			
		
		
		
	feat: aliases support
This commit is contained in:
		| @@ -124,8 +124,15 @@ export default { | |||||||
|             }; |             }; | ||||||
|  |  | ||||||
|             const { status, response } = await Tables.getTableColumns(params); |             const { status, response } = await Tables.getTableColumns(params); | ||||||
|  |  | ||||||
|             if (status === 'success') { |             if (status === 'success') { | ||||||
|                const fields = response.filter(field => this.selectedFields.includes(field.name)); |                let fields = response.filter(field => this.selectedFields.includes(field.name)); | ||||||
|  |                if (this.selectedFields.length) { | ||||||
|  |                   fields = fields.map((field, index) => { | ||||||
|  |                      return { ...field, alias: this.results.fields[index].name }; | ||||||
|  |                   }); | ||||||
|  |                } | ||||||
|  |  | ||||||
|                this.setTabFields({ cUid: this.connection.uid, tUid: this.tabUid, fields }); |                this.setTabFields({ cUid: this.connection.uid, tUid: this.tabUid, fields }); | ||||||
|             } |             } | ||||||
|             else |             else | ||||||
|   | |||||||
| @@ -57,7 +57,7 @@ | |||||||
|                   class="tr" |                   class="tr" | ||||||
|                   :class="{'selected': selectedRows.includes(row._id)}" |                   :class="{'selected': selectedRows.includes(row._id)}" | ||||||
|                   @select-row="selectRow($event, row._id)" |                   @select-row="selectRow($event, row._id)" | ||||||
|                   @update-field="updateField($event, row[primaryField.name])" |                   @update-field="updateField($event, row[primaryField.alias || primaryField.name])" | ||||||
|                   @contextmenu="contextMenu" |                   @contextmenu="contextMenu" | ||||||
|                /> |                /> | ||||||
|             </template> |             </template> | ||||||
|   | |||||||
| @@ -7,15 +7,14 @@ | |||||||
|          class="td p-0" |          class="td p-0" | ||||||
|          tabindex="0" |          tabindex="0" | ||||||
|          @contextmenu.prevent="$emit('contextmenu', $event, {id: row._id, field: cKey})" |          @contextmenu.prevent="$emit('contextmenu', $event, {id: row._id, field: cKey})" | ||||||
|          @update-field="updateField($event, row[primaryField.name])" |  | ||||||
|       > |       > | ||||||
|          <template v-if="cKey !== '_id'"> |          <template v-if="cKey !== '_id'"> | ||||||
|             <span |             <span | ||||||
|                v-if="!isInlineEditor[cKey]" |                v-if="!isInlineEditor[cKey]" | ||||||
|                class="cell-content px-2" |                class="cell-content px-2" | ||||||
|                :class="`${isNull(col)} type-${fieldType(cKey)}`" |                :class="`${isNull(col)} type-${getFieldType(cKey)}`" | ||||||
|                @dblclick="editON($event, col, cKey)" |                @dblclick="editON($event, col, cKey)" | ||||||
|             >{{ col | typeFormat(fieldType(cKey), fieldPrecision(cKey)) | cutText }}</span> |             >{{ col | typeFormat(getFieldType(cKey), getFieldPrecision(cKey)) | cutText }}</span> | ||||||
|             <ForeignKeySelect |             <ForeignKeySelect | ||||||
|                v-else-if="foreignKeys.includes(cKey)" |                v-else-if="foreignKeys.includes(cKey)" | ||||||
|                class="editable-field" |                class="editable-field" | ||||||
| @@ -218,7 +217,7 @@ export default { | |||||||
|  |  | ||||||
|          if (TIME.includes(this.editingType)) { |          if (TIME.includes(this.editingType)) { | ||||||
|             let timeMask = '##:##:##'; |             let timeMask = '##:##:##'; | ||||||
|             const precision = this.fieldPrecision(this.editingField); |             const precision = this.getFieldPrecision(this.editingField); | ||||||
|  |  | ||||||
|             for (let i = 0; i < precision; i++) |             for (let i = 0; i < precision; i++) | ||||||
|                timeMask += i === 0 ? '.#' : '#'; |                timeMask += i === 0 ? '.#' : '#'; | ||||||
| @@ -231,7 +230,7 @@ export default { | |||||||
|  |  | ||||||
|          if (DATETIME.includes(this.editingType)) { |          if (DATETIME.includes(this.editingType)) { | ||||||
|             let datetimeMask = '####-##-## ##:##:##'; |             let datetimeMask = '####-##-## ##:##:##'; | ||||||
|             const precision = this.fieldPrecision(this.editingField); |             const precision = this.getFieldPrecision(this.editingField); | ||||||
|  |  | ||||||
|             for (let i = 0; i < precision; i++) |             for (let i = 0; i < precision; i++) | ||||||
|                datetimeMask += i === 0 ? '.#' : '#'; |                datetimeMask += i === 0 ? '.#' : '#'; | ||||||
| @@ -260,22 +259,25 @@ export default { | |||||||
|       }); |       }); | ||||||
|    }, |    }, | ||||||
|    methods: { |    methods: { | ||||||
|       fieldType (cKey) { |       getFieldType (cKey) { | ||||||
|          let type = 'unknown'; |          let type = 'unknown'; | ||||||
|          const field = this.fields.filter(field => field.name === cKey)[0]; |          const field = this.getFieldObj(cKey); | ||||||
|          if (field) |          if (field) | ||||||
|             type = field.type; |             type = field.type; | ||||||
|  |  | ||||||
|          return type; |          return type; | ||||||
|       }, |       }, | ||||||
|       fieldPrecision (cKey) { |       getFieldPrecision (cKey) { | ||||||
|          let length = 0; |          let length = 0; | ||||||
|          const field = this.fields.filter(field => field.name === cKey)[0]; |          const field = this.getFieldObj(cKey); | ||||||
|          if (field) |          if (field) | ||||||
|             length = field.datePrecision; |             length = field.datePrecision; | ||||||
|  |  | ||||||
|          return length; |          return length; | ||||||
|       }, |       }, | ||||||
|  |       getFieldObj (cKey) { | ||||||
|  |          return this.fields.filter(field => field.name === cKey || field.alias === cKey)[0]; | ||||||
|  |       }, | ||||||
|       isNull (value) { |       isNull (value) { | ||||||
|          return value === null ? ' is-null' : ''; |          return value === null ? ' is-null' : ''; | ||||||
|       }, |       }, | ||||||
| @@ -283,7 +285,7 @@ export default { | |||||||
|          return bufferToBase64(val); |          return bufferToBase64(val); | ||||||
|       }, |       }, | ||||||
|       editON (event, content, field) { |       editON (event, content, field) { | ||||||
|          const type = this.fieldType(field); |          const type = this.getFieldType(field); | ||||||
|          this.originalContent = content; |          this.originalContent = content; | ||||||
|          this.editingType = type; |          this.editingType = type; | ||||||
|          this.editingField = field; |          this.editingField = field; | ||||||
| @@ -316,7 +318,7 @@ export default { | |||||||
|          } |          } | ||||||
|  |  | ||||||
|          // Inline editable fields |          // Inline editable fields | ||||||
|          this.editingContent = this.$options.filters.typeFormat(this.originalContent, type, this.fieldPrecision(field)); |          this.editingContent = this.$options.filters.typeFormat(this.originalContent, type, this.getFieldPrecision(field)); | ||||||
|          this.$nextTick(() => { // Focus on input |          this.$nextTick(() => { // Focus on input | ||||||
|             event.target.blur(); |             event.target.blur(); | ||||||
|  |  | ||||||
| @@ -347,7 +349,7 @@ export default { | |||||||
|          } |          } | ||||||
|  |  | ||||||
|          this.$emit('update-field', { |          this.$emit('update-field', { | ||||||
|             field: this.editingField, |             field: this.getFieldObj(this.editingField).name, | ||||||
|             type: this.editingType, |             type: this.editingType, | ||||||
|             content |             content | ||||||
|          }); |          }); | ||||||
| @@ -385,9 +387,6 @@ export default { | |||||||
|          }; |          }; | ||||||
|          this.willBeDeleted = true; |          this.willBeDeleted = true; | ||||||
|       }, |       }, | ||||||
|       updateField (event, id) { |  | ||||||
|          this.$emit('update-field', event, id); |  | ||||||
|       }, |  | ||||||
|       contextMenu (event, cell) { |       contextMenu (event, cell) { | ||||||
|          this.$emit('update-field', event, cell); |          this.$emit('update-field', event, cell); | ||||||
|       }, |       }, | ||||||
|   | |||||||
| @@ -133,12 +133,12 @@ body { | |||||||
| } | } | ||||||
|  |  | ||||||
| .form-select, | .form-select, | ||||||
| .form-select:not([multiple]):not([size]), |  | ||||||
| .form-input, | .form-input, | ||||||
|  | .form-select:not([multiple]):not([size]), | ||||||
| .form-checkbox .form-icon, | .form-checkbox .form-icon, | ||||||
| .form-radio .form-icon { | .form-radio .form-icon { | ||||||
|   border-color: $bg-color-light; |   border-color: $bg-color-light; | ||||||
|   background: $bg-color-gray; |   background-color: $bg-color-gray; | ||||||
| } | } | ||||||
|  |  | ||||||
| .form-input:not(:placeholder-shown):invalid:focus { | .form-input:not(:placeholder-shown):invalid:focus { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user