Browse Source

feat: combinetable & views, allow disabling views

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/847/head
Pranav C 3 years ago
parent
commit
2f54fb14eb
  1. 2
      packages/nc-gui/components/ProjectTreeView.vue
  2. 19
      packages/nc-gui/components/project/projectMetadata/uiAcl/toggleTableUIAcl.vue
  3. 1
      packages/nc-gui/components/project/spreadsheet/components/spreadsheetNavDrawer.vue
  4. 9
      packages/nc-gui/helpers/treeViewDataSerializer.js
  5. 2
      packages/nc-gui/store/project.js
  6. 6
      packages/nc-gui/store/sqlMgr.js
  7. 3
      packages/nc-gui/store/tabs.js
  8. 2
      packages/nocodb/src/lib/noco/meta/NcMetaIOImpl.ts
  9. 100
      packages/nocodb/src/lib/noco/meta/NcMetaMgr.ts

2
packages/nc-gui/components/ProjectTreeView.vue

@ -229,6 +229,7 @@
<v-icon small class="nc-child-draggable-icon">
mdi-drag-vertical
</v-icon>
<v-list-item-icon>
<v-icon
v-if="icons[child._nodes.type].openIcon"
@ -716,6 +717,7 @@ export default {
dlgLabelSubmitCancel,
},
data: () => ({
drag:false,
dragOptions:{
animation: 200,
group: "description",

19
packages/nc-gui/components/project/projectMetadata/uiAcl/toggleTableUIAcl.vue

@ -49,10 +49,13 @@
<v-simple-table dense style="min-width: 400px">
<thead>
<tr>
<th>
<th class="caption">
Models
</th>
<th v-for="role in roles" :key="role">
<th class="caption">
Parent
</th>
<th v-for="role in roles" :key="role" class="caption">
{{ role }}
</th>
</tr>
@ -68,11 +71,17 @@
<td>
<v-tooltip bottom>
<template #activator="{on}">
<span v-on="on">{{ table._tn }}</span>
<v-icon small :color="viewIcons[table.show_as || table.type].color" v-on="on">
{{ viewIcons[table.show_as || table.type].icon }}
</v-icon> <span class="caption ml-2" v-on="on">{{ table._tn }}</span>
</template>
<span class="caption">{{ table.tn }}</span>
</v-tooltip>
</td>
<td>
<span v-if="table.ptn" class="caption">{{ table.ptn }}</span>
<!-- {{ table.show_as || table.type }}-->
</td>
<td v-for="role in roles" :key="`${table.tn}-${role}`">
<v-tooltip bottom>
<template #activator="{on}">
@ -81,7 +90,9 @@
>
<v-checkbox
v-model="table.disabled[role]"
class="pt-0 mt-0"
dense
hide-details
:true-value="false"
:false-value="true"
@change="$set(table,'edited',true)"
@ -107,12 +118,14 @@
<script>
import { mapGetters } from 'vuex'
import viewIcons from '~/helpers/viewIcons'
export default {
name: 'ToggleTableUiAcl',
components: {},
props: ['nodes', 'db'],
data: () => ({
viewIcons,
models: null,
updating: false,
dbsTab: 0,

1
packages/nc-gui/components/project/spreadsheet/components/spreadsheetNavDrawer.vue

@ -552,6 +552,7 @@ export default {
showSystemFields: Boolean
},
data: () => ({
drag: false,
dragOptions: {
animation: 200,
group: 'description',

9
packages/nc-gui/helpers/treeViewDataSerializer.js

@ -87,7 +87,7 @@ function dbparser(data, envKey, env) {
json.children.push(tableParser(db.tables, dbKey, env, db.meta.dbAlias, db));
// enable extra
json.children.push(viewsParser(db.views, dbKey, env, db.meta.dbAlias, db));
// json.children.push(viewsParser(db.views, dbKey, env, db.meta.dbAlias, db));
// if (db.client !== 'sqlite3')
// json.children.push(functionsParser(db.functions, dbKey, env, db.meta.dbAlias, db));
@ -341,8 +341,9 @@ function tableParser(data = [], dbKey, env, dbAlias, dbConnection) {
for (let i = 0; i < data.length; i++) {
const table = data[i];
const tableKey = `${tableDirKey}.${i}`;
const json = {
type: "table",
let json;
json= {
type: table.type,
name: table._tn,
tn: table.tn,
_tn: table._tn,
@ -351,7 +352,7 @@ function tableParser(data = [], dbKey, env, dbAlias, dbConnection) {
children: [],
_nodes: {
key: tableKey,
type: "table",
type: table.type,
env,
dbAlias,
tableDirKey: tableDirKey,

2
packages/nc-gui/store/project.js

@ -313,7 +313,7 @@ export const actions = {
env: data._nodes.env,
dbAlias: data._nodes.dbAlias
},
"tableList", {includeM2M: rootState.windows.includeM2M}
"xcTableAndViewList", {includeM2M: rootState.windows.includeM2M}
], {root: true});

6
packages/nc-gui/store/sqlMgr.js

@ -27,6 +27,12 @@ function translateUiToLibCall(args, op, opArgs) {
data.title = 'list'
data.module = 'table'
break
case 'xcTableAndViewList':
data.api = 'DB_TABLE_VIEW_LIST'
data.type = 'List'
data.title = 'list'
data.module = 'table'
break
case 'tableUpdate':
data.type = 'Update'
data.title = opArgs._tn || opArgs.tn

3
packages/nc-gui/store/tabs.js

@ -364,12 +364,13 @@ export const actions = {
commit('list', tabs)
},
ActAddTab({ commit, state, rootState }, item) {
async ActAddTab({ commit, state, rootState }, item) {
if (rootState.users.ui_ability.rules.maxTabs <= state.list.length) {
this.commit('snackbar/setSnack', `Free plan limits to ${rootState.users.ui_ability.rules.maxTabs} tabs. Please <a href="https://nocodb.com/pricing" style="color: white;font-weight: bold;">upgrade</a> your plan for unlimited tabs.`)
return
}
commit('add', item)
await Vue.nextTick()
const index = state.list.length - 1
if (state.activeTab !== 0 && state.activeTab === index) {
commit('active', index - 1)

2
packages/nocodb/src/lib/noco/meta/NcMetaIOImpl.ts

@ -234,6 +234,8 @@ export default class NcMetaIOImpl extends NcMetaIO {
query.select(...args.fields);
}
console.log('======', query.toQuery());
return query;
}

100
packages/nocodb/src/lib/noco/meta/NcMetaMgr.ts

@ -1481,8 +1481,8 @@ export default class NcMetaMgr {
result = await this.xcVisibilityMetaSetAll(args);
break;
case 'tableList':
result = await this.xcTableList(req, args);
case 'xcTableAndViewList':
result = await this.xcTableAndViewList(req, args);
break;
case 'columnList':
@ -4819,13 +4819,13 @@ export default class NcMetaMgr {
xcCondition: {
_or: [
{
type: 'table'
type: { eq: 'table' }
},
{
type: 'view'
type: { eq: 'view' }
},
{
type: 'vtable'
type: { eq: 'vtable' }
}
]
}
@ -4839,7 +4839,8 @@ export default class NcMetaMgr {
order: table.order,
disabled: { ...defaultDisabled },
type: table.type,
show_as: table.show_as
show_as: table.show_as,
ptn: table.parent_model_title
};
return obj;
}, {});
@ -4852,13 +4853,13 @@ export default class NcMetaMgr {
xcCondition: {
_or: [
{
type: 'table'
type: { eq: 'table' }
},
{
type: 'view'
type: { eq: 'view' }
},
{
type: 'vtable'
type: { eq: 'vtable' }
}
]
}
@ -4876,6 +4877,70 @@ export default class NcMetaMgr {
);
}
break;
case 'table_view':
{
const models = await this.xcMeta.metaList(
this.getProjectId(args),
this.getDbAlias(args),
'nc_models',
{
condition: {
...(args?.args?.includeM2M ? {} : { mm: null })
},
xcCondition: {
_or: [
{
type: { eq: 'table' }
},
{
type: { eq: 'view' }
}
]
},
orderBy: {
order: 'asc'
}
}
);
const result = models.reduce((obj, table) => {
obj[table.title] = {
tn: table.title,
_tn: table.alias || table.title,
order: table.order,
disabled: { ...defaultDisabled },
type: table.type,
show_as: table.show_as,
ptn: table.parent_model_title
};
return obj;
}, {});
const disabledList = await this.xcMeta.metaList(
args.project_id,
this.getDbAlias(args),
'nc_disabled_models_for_role',
{
xcCondition: {
_or: [
{
type: { eq: 'table' }
},
{
type: { eq: 'view' }
}
]
}
}
);
for (const d of disabledList) {
result[d.title].disabled[d.role] = !!d.disabled;
}
return Object.values(result);
}
break;
}
} catch (e) {
throw e;
@ -5230,6 +5295,23 @@ export default class NcMetaMgr {
};
}
protected async xcTableAndViewList(req, args): Promise<any> {
const roles = req.session?.passport?.user?.roles;
let tables = await this.xcVisibilityMetaGet({
...args,
args: { type: 'table_view', ...args.args }
});
tables = tables.filter((table: any) => {
return Object.keys(roles).some(
role => roles[role] && !table.disabled[role]
);
});
return { data: { list: tables } };
}
protected async xcVirtualTableList(args, req): Promise<any> {
const roles = (await this.xcMeta.metaList('', '', 'nc_roles'))
.map(r => r.title)

Loading…
Cancel
Save