mirror of https://github.com/nocodb/nocodb
Muhammed Mustafa
1 year ago
47 changed files with 2380 additions and 383 deletions
Before Width: | Height: | Size: 643 B After Width: | Height: | Size: 643 B |
@ -1,53 +0,0 @@
|
||||
<script lang="ts" setup> |
||||
const { isRightSidebarOpen: _isRightSidebarOpen } = storeToRefs(useSidebarStore()) |
||||
const isRightSidebarOpen = ref(_isRightSidebarOpen.value) |
||||
|
||||
watch(_isRightSidebarOpen, (val) => { |
||||
if (val) { |
||||
isRightSidebarOpen.value = true |
||||
} else { |
||||
setTimeout(() => { |
||||
isRightSidebarOpen.value = false |
||||
}, 300) |
||||
} |
||||
}) |
||||
|
||||
const onClick = () => { |
||||
if (_isRightSidebarOpen.value) return |
||||
|
||||
_isRightSidebarOpen.value = !_isRightSidebarOpen.value |
||||
} |
||||
</script> |
||||
|
||||
<template> |
||||
<NcTooltip |
||||
placement="bottomLeft" |
||||
hide-on-click |
||||
class="transition-all duration-100" |
||||
:class="{ |
||||
'!w-0 !opacity-0': isRightSidebarOpen, |
||||
'!w-8 !opacity-100 mr-2': !isRightSidebarOpen, |
||||
}" |
||||
> |
||||
<template #title> |
||||
{{ |
||||
isRightSidebarOpen |
||||
? `${$t('general.hide')} ${$t('objects.sidebar').toLowerCase()}` |
||||
: `${$t('general.show')} ${$t('objects.sidebar').toLowerCase()}` |
||||
}} |
||||
</template> |
||||
<NcButton |
||||
type="text" |
||||
size="small" |
||||
class="nc-sidebar-right-toggle-icon !text-gray-600 !hover:text-gray-800" |
||||
:class="{ |
||||
'invisible !w-0': isRightSidebarOpen, |
||||
}" |
||||
@click="onClick" |
||||
> |
||||
<div class="flex items-center text-inherit"> |
||||
<GeneralIcon icon="doubleLeftArrow" class="duration-150 transition-all !text-lg -mt-0.25" /> |
||||
</div> |
||||
</NcButton> |
||||
</NcTooltip> |
||||
</template> |
@ -0,0 +1,163 @@
|
||||
import { RelationTypes, UITypes } from 'nocodb-sdk'; |
||||
import type LookupColumn from '../models/LookupColumn'; |
||||
import type { BaseModelSqlv2 } from '~/db/BaseModelSqlv2'; |
||||
import type { |
||||
Column, |
||||
FormulaColumn, |
||||
LinkToAnotherRecordColumn, |
||||
Model, |
||||
RollupColumn, |
||||
} from '~/models'; |
||||
import formulaQueryBuilderv2 from '~/db/formulav2/formulaQueryBuilderv2'; |
||||
import genRollupSelectv2 from '~/db/genRollupSelectv2'; |
||||
import { NcError } from '~/helpers/catchError'; |
||||
|
||||
export default async function generateBTLookupSelectQuery({ |
||||
column, |
||||
baseModelSqlv2, |
||||
alias, |
||||
model, |
||||
}: { |
||||
column: Column; |
||||
baseModelSqlv2: BaseModelSqlv2; |
||||
alias: string; |
||||
model: Model; |
||||
}): Promise<any> { |
||||
const knex = baseModelSqlv2.dbDriver; |
||||
|
||||
const rootAlias = alias; |
||||
|
||||
{ |
||||
let aliasCount = 0, |
||||
selectQb; |
||||
const alias = `__nc_lk_${aliasCount++}`; |
||||
const lookup = await column.getColOptions<LookupColumn>(); |
||||
{ |
||||
const relationCol = await lookup.getRelationColumn(); |
||||
const relation = |
||||
await relationCol.getColOptions<LinkToAnotherRecordColumn>(); |
||||
|
||||
// if not belongs to then throw error as we don't support
|
||||
if (relation.type !== RelationTypes.BELONGS_TO) |
||||
NcError.badRequest('HasMany/ManyToMany lookup is not supported'); |
||||
|
||||
const childColumn = await relation.getChildColumn(); |
||||
const parentColumn = await relation.getParentColumn(); |
||||
const childModel = await childColumn.getModel(); |
||||
await childModel.getColumns(); |
||||
const parentModel = await parentColumn.getModel(); |
||||
await parentModel.getColumns(); |
||||
|
||||
selectQb = knex( |
||||
`${baseModelSqlv2.getTnPath(parentModel.table_name)} as ${alias}`, |
||||
).where( |
||||
`${alias}.${parentColumn.column_name}`, |
||||
knex.raw(`??`, [ |
||||
`${rootAlias || baseModelSqlv2.getTnPath(childModel.table_name)}.${ |
||||
childColumn.column_name |
||||
}`,
|
||||
]), |
||||
); |
||||
} |
||||
let lookupColumn = await lookup.getLookupColumn(); |
||||
let prevAlias = alias; |
||||
while (lookupColumn.uidt === UITypes.Lookup) { |
||||
const nestedAlias = `__nc_lk_nested_${aliasCount++}`; |
||||
const nestedLookup = await lookupColumn.getColOptions<LookupColumn>(); |
||||
const relationCol = await nestedLookup.getRelationColumn(); |
||||
const relation = |
||||
await relationCol.getColOptions<LinkToAnotherRecordColumn>(); |
||||
|
||||
// if any of the relation in nested lookup is
|
||||
// not belongs to then throw error as we don't support
|
||||
if (relation.type !== RelationTypes.BELONGS_TO) |
||||
NcError.badRequest('HasMany/ManyToMany lookup is not supported'); |
||||
|
||||
const childColumn = await relation.getChildColumn(); |
||||
const parentColumn = await relation.getParentColumn(); |
||||
const childModel = await childColumn.getModel(); |
||||
await childModel.getColumns(); |
||||
const parentModel = await parentColumn.getModel(); |
||||
await parentModel.getColumns(); |
||||
|
||||
selectQb.join( |
||||
`${baseModelSqlv2.getTnPath(parentModel.table_name)} as ${nestedAlias}`, |
||||
`${nestedAlias}.${parentColumn.column_name}`, |
||||
`${prevAlias}.${childColumn.column_name}`, |
||||
); |
||||
|
||||
lookupColumn = await nestedLookup.getLookupColumn(); |
||||
prevAlias = nestedAlias; |
||||
} |
||||
|
||||
switch (lookupColumn.uidt) { |
||||
case UITypes.Links: |
||||
case UITypes.Rollup: |
||||
{ |
||||
const builder = ( |
||||
await genRollupSelectv2({ |
||||
baseModelSqlv2, |
||||
knex, |
||||
columnOptions: |
||||
(await lookupColumn.getColOptions()) as RollupColumn, |
||||
alias: prevAlias, |
||||
}) |
||||
).builder; |
||||
selectQb.select(builder); |
||||
} |
||||
break; |
||||
case UITypes.LinkToAnotherRecord: |
||||
{ |
||||
const nestedAlias = `__nc_sort${aliasCount++}`; |
||||
const relation = |
||||
await lookupColumn.getColOptions<LinkToAnotherRecordColumn>(); |
||||
if (relation.type !== 'bt') return; |
||||
|
||||
const colOptions = |
||||
(await column.getColOptions()) as LinkToAnotherRecordColumn; |
||||
const childColumn = await colOptions.getChildColumn(); |
||||
const parentColumn = await colOptions.getParentColumn(); |
||||
const childModel = await childColumn.getModel(); |
||||
await childModel.getColumns(); |
||||
const parentModel = await parentColumn.getModel(); |
||||
await parentModel.getColumns(); |
||||
|
||||
selectQb |
||||
.join( |
||||
`${baseModelSqlv2.getTnPath( |
||||
parentModel.table_name, |
||||
)} as ${nestedAlias}`,
|
||||
`${nestedAlias}.${parentColumn.column_name}`, |
||||
`${prevAlias}.${childColumn.column_name}`, |
||||
) |
||||
.select(parentModel?.displayValue?.column_name); |
||||
} |
||||
break; |
||||
case UITypes.Formula: |
||||
{ |
||||
const builder = ( |
||||
await formulaQueryBuilderv2( |
||||
baseModelSqlv2, |
||||
( |
||||
await column.getColOptions<FormulaColumn>() |
||||
).formula, |
||||
null, |
||||
model, |
||||
column, |
||||
) |
||||
).builder; |
||||
|
||||
selectQb.select(builder); |
||||
} |
||||
break; |
||||
default: |
||||
{ |
||||
selectQb.select(`${prevAlias}.${lookupColumn.column_name}`); |
||||
} |
||||
|
||||
break; |
||||
} |
||||
|
||||
return { builder: selectQb }; |
||||
} |
||||
} |
@ -0,0 +1,35 @@
|
||||
#!/bin/bash |
||||
# this script is intended to run in ci/cd job |
||||
# it checks if node and pnpm is installed |
||||
# and sets github env variable to skip installation |
||||
# this is suitable for self-hosted runners with |
||||
# docker image created from /Users/rajanishgj/Documents/GitHub/nocohub/tests/docker/Dockerfile |
||||
# |
||||
|
||||
NC_REQ_NODE_V="18.17.1" |
||||
NC_REQ_PNPM_V="8.8.0" |
||||
|
||||
NODE_PATH="/home/docker/actions-runner/_work/_tool/node/${NC_REQ_NODE_V}/x64/bin/node" |
||||
PNPM_PATH="/root/setup-pnpm/node_modules/.bin/pnpm" |
||||
|
||||
NC_NODE_V=$($NODE_PATH -v || echo "error") |
||||
NC_PNPM_V=$($PNPM_PATH -v || echo "error") |
||||
|
||||
if [[ $NC_NODE_V == *$NC_REQ_NODE_V* ]]; then |
||||
PATH=$PATH:$(dirname $NODE_PATH) |
||||
SETUP_NODE=false |
||||
fi |
||||
|
||||
if [[ $NC_PNPM_V == $NC_REQ_PNPM_V ]]; then |
||||
PATH=$PATH:$(dirname $PNPM_PATH) |
||||
SETUP_PNPM=false |
||||
fi |
||||
|
||||
echo "SETUP_NODE=${SETUP_NODE:-true}" >> $GITHUB_ENV |
||||
echo "SETUP_PNPM=${SETUP_PNPM:-true}" >> $GITHUB_ENV |
||||
echo "NC_REQ_NODE_V=${NC_REQ_NODE_V}" >> $GITHUB_ENV |
||||
echo "NC_REQ_PNPM_V=${NC_REQ_PNPM_V}" >> $GITHUB_ENV |
||||
echo "NC_NODE_V=${NC_NODE_V}" >> $GITHUB_ENV |
||||
echo "NC_PNPM_V=${NC_PNPM_V}" >> $GITHUB_ENV |
||||
echo "PATH=${PATH}" >> $GITHUB_ENV |
||||
echo "completed check node and pnpm installation" |
@ -0,0 +1,35 @@
|
||||
#!/bin/bash |
||||
# this script is intended to run in ci/cd job |
||||
# it checks if node and pnpm is installed |
||||
# and sets github env variable to skip installation |
||||
# this is suitable for self-hosted runners with |
||||
# docker image created from /Users/rajanishgj/Documents/GitHub/nocohub/tests/docker/Dockerfile |
||||
# |
||||
|
||||
NC_REQ_NODE_V="18.17.1" |
||||
NC_REQ_PNPM_V="8.8.0" |
||||
|
||||
NODE_PATH="/home/docker/actions-runner/_work/_tool/node/${NC_REQ_NODE_V}/x64/bin/node" |
||||
PNPM_PATH="/root/setup-pnpm/node_modules/.bin/pnpm" |
||||
|
||||
NC_NODE_V=$($NODE_PATH -v || echo "error") |
||||
NC_PNPM_V=$($PNPM_PATH -v || echo "error") |
||||
|
||||
if [[ $NC_NODE_V == *$NC_REQ_NODE_V* ]]; then |
||||
PATH=$PATH:$(dirname $NODE_PATH) |
||||
SETUP_NODE=false |
||||
fi |
||||
|
||||
if [[ $NC_PNPM_V == $NC_REQ_PNPM_V ]]; then |
||||
PATH=$PATH:$(dirname $PNPM_PATH) |
||||
SETUP_PNPM=false |
||||
fi |
||||
|
||||
echo "SETUP_NODE=${SETUP_NODE:-true}" >> $GITHUB_ENV |
||||
echo "SETUP_PNPM=${SETUP_PNPM:-true}" >> $GITHUB_ENV |
||||
echo "NC_REQ_NODE_V=${NC_REQ_NODE_V}" >> $GITHUB_ENV |
||||
echo "NC_REQ_PNPM_V=${NC_REQ_PNPM_V}" >> $GITHUB_ENV |
||||
echo "NC_NODE_V=${NC_NODE_V}" >> $GITHUB_ENV |
||||
echo "NC_PNPM_V=${NC_PNPM_V}" >> $GITHUB_ENV |
||||
echo "PATH=${PATH}" >> $GITHUB_ENV |
||||
echo "completed check node and pnpm installation" |
Loading…
Reference in new issue