IsDeleted sütunu eklendi
This commit is contained in:
parent
41c7d862dc
commit
6aa5e2b1ca
4 changed files with 57 additions and 4 deletions
|
|
@ -17588,6 +17588,12 @@
|
|||
"en": "Columns load after selecting a Select Command",
|
||||
"tr": "Select Command seçince sütunlar yüklenir"
|
||||
},
|
||||
{
|
||||
"resourceName": "Platform",
|
||||
"key": "ListForms.Wizard.Step3.SelectTable",
|
||||
"en": "Select Table",
|
||||
"tr": "Tablo Seç"
|
||||
},
|
||||
{
|
||||
"resourceName": "Platform",
|
||||
"key": "ListForms.Wizard.Step3.IncludeInEditingForm",
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import { number, object, string } from 'yup'
|
|||
import { cascadeFilterOperator, columnLookupDataSourceTypeListOptions } from '../options'
|
||||
import { FormFieldEditProps } from './FormFields'
|
||||
import { ColumnCascadeFilterOperatorEnum, UiLookupDataSourceTypeEnum } from '@/proxy/form/models'
|
||||
import { buildLookupQuery } from '../../lookupQuery'
|
||||
|
||||
const schema = object().shape({
|
||||
lookupDto: object()
|
||||
|
|
@ -190,7 +191,12 @@ function TablePickerModal({
|
|||
</div>
|
||||
{keyCol && nameCol && (
|
||||
<div className="rounded bg-gray-50 dark:bg-gray-800 px-2 py-1.5 text-[10px] font-mono text-gray-500 dark:text-gray-400 break-all">
|
||||
{`SELECT "${keyCol}" AS "Key", "${nameCol}" AS "Name" FROM "${pickerTable?.tableName}" ORDER BY "${nameCol}";`}
|
||||
{buildLookupQuery({
|
||||
keyColumn: keyCol,
|
||||
nameColumn: nameCol,
|
||||
tableName: pickerTable?.tableName,
|
||||
columns: pickerColumns,
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
<button
|
||||
|
|
@ -198,7 +204,12 @@ function TablePickerModal({
|
|||
disabled={!keyCol || !nameCol}
|
||||
onClick={() => {
|
||||
onSelect(
|
||||
`SELECT "${keyCol}" AS "Key", "${nameCol}" AS "Name" FROM "${pickerTable?.tableName}" ORDER BY "${nameCol}";`,
|
||||
buildLookupQuery({
|
||||
keyColumn: keyCol,
|
||||
nameColumn: nameCol,
|
||||
tableName: pickerTable?.tableName,
|
||||
columns: pickerColumns,
|
||||
}),
|
||||
)
|
||||
}}
|
||||
className="mt-1 w-full py-1.5 text-xs font-semibold rounded bg-indigo-600 text-white hover:bg-indigo-700 disabled:opacity-40 disabled:cursor-not-allowed transition-colors"
|
||||
|
|
|
|||
25
ui/src/views/admin/listForm/lookupQuery.ts
Normal file
25
ui/src/views/admin/listForm/lookupQuery.ts
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import type { DatabaseColumnDto } from '@/proxy/sql-query-manager/models'
|
||||
|
||||
const IS_DELETED_COLUMN = 'IsDeleted'
|
||||
|
||||
export function tableHasIsDeletedColumn(columns: DatabaseColumnDto[]) {
|
||||
return columns.some(
|
||||
(column) => column.columnName.toLowerCase() === IS_DELETED_COLUMN.toLowerCase(),
|
||||
)
|
||||
}
|
||||
|
||||
export function buildLookupQuery({
|
||||
keyColumn,
|
||||
nameColumn,
|
||||
tableName,
|
||||
columns,
|
||||
}: {
|
||||
keyColumn: string
|
||||
nameColumn: string
|
||||
tableName?: string
|
||||
columns: DatabaseColumnDto[]
|
||||
}) {
|
||||
const whereClause = tableHasIsDeletedColumn(columns) ? ` WHERE "${IS_DELETED_COLUMN}" = 0` : ''
|
||||
|
||||
return `SELECT "${keyColumn}" AS "Key", "${nameColumn}" AS "Name" FROM "${tableName}"${whereClause} ORDER BY "${nameColumn}";`
|
||||
}
|
||||
|
|
@ -30,6 +30,7 @@ import {
|
|||
FaCode,
|
||||
} from 'react-icons/fa'
|
||||
import { UiLookupDataSourceTypeEnum } from '@/proxy/form/models'
|
||||
import { buildLookupQuery } from '../lookupQuery'
|
||||
|
||||
// ─── Types ────────────────────────────────────────────────────────────────────
|
||||
export interface WizardGroupItem {
|
||||
|
|
@ -516,14 +517,24 @@ function SortableItem({
|
|||
</div>
|
||||
{pickerKeyCol && pickerNameCol && (
|
||||
<div className="rounded bg-gray-50 dark:bg-gray-800 px-2 py-1.5 text-[10px] font-mono text-gray-500 dark:text-gray-400 break-all">
|
||||
{`SELECT "${pickerKeyCol}" AS "Key", "${pickerNameCol}" AS "Name" FROM "${pickerTable?.tableName}" ORDER BY "${pickerNameCol}";`}
|
||||
{buildLookupQuery({
|
||||
keyColumn: pickerKeyCol,
|
||||
nameColumn: pickerNameCol,
|
||||
tableName: pickerTable?.tableName,
|
||||
columns: pickerColumns,
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
<button
|
||||
type="button"
|
||||
disabled={!pickerKeyCol || !pickerNameCol}
|
||||
onClick={() => {
|
||||
const q = `SELECT "${pickerKeyCol}" AS "Key", "${pickerNameCol}" AS "Name" FROM "${pickerTable?.tableName}" ORDER BY "${pickerNameCol}";`
|
||||
const q = buildLookupQuery({
|
||||
keyColumn: pickerKeyCol,
|
||||
nameColumn: pickerNameCol,
|
||||
tableName: pickerTable?.tableName,
|
||||
columns: pickerColumns,
|
||||
})
|
||||
onLookupQueryChange(q)
|
||||
setIsTablePickerOpen(false)
|
||||
}}
|
||||
|
|
|
|||
Loading…
Reference in a new issue