mirror of https://github.com/nocodb/nocodb
Pranav C
3 years ago
22 changed files with 589 additions and 100 deletions
@ -0,0 +1,71 @@ |
|||||||
|
export const state = () => ({ |
||||||
|
metas: {}, |
||||||
|
loading: {} |
||||||
|
}); |
||||||
|
|
||||||
|
export const mutations = { |
||||||
|
MutMeta(state, {key, value}) { |
||||||
|
state.metas = {...state.metas, [key]: value}; |
||||||
|
}, |
||||||
|
MutLoading(state, {key, value}) { |
||||||
|
state.loading = {...state.loading, [key]: value}; |
||||||
|
}, |
||||||
|
MutClear(state) { |
||||||
|
state.metas = {}; |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
export const actions = { |
||||||
|
async ActLoadMeta({state, commit, dispatch}, {tn, env, dbAlias}) { |
||||||
|
if (state.loading[tn]) { |
||||||
|
return await new Promise(resolve => { |
||||||
|
const unsubscribe = this.app.store.subscribe(s => { |
||||||
|
if (s.type === 'meta/MutLoading' && s.payload.key === tn && !s.payload.value) { |
||||||
|
unsubscribe(); |
||||||
|
resolve(state.metas[tn]) |
||||||
|
} |
||||||
|
}) |
||||||
|
}) |
||||||
|
} |
||||||
|
if (state.metas[tn]) { |
||||||
|
return state.metas[tn]; |
||||||
|
} |
||||||
|
commit('MutLoading', { |
||||||
|
key: tn, |
||||||
|
value: true |
||||||
|
}) |
||||||
|
const model = await dispatch('sqlMgr/ActSqlOp', [{env, dbAlias}, 'tableXcModelGet', {tn}], {root: true}); |
||||||
|
commit('MutMeta', { |
||||||
|
key: tn, |
||||||
|
value: JSON.parse(model.meta) |
||||||
|
}) |
||||||
|
commit('MutLoading', { |
||||||
|
key: tn, |
||||||
|
value: undefined |
||||||
|
}) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* @copyright Copyright (c) 2021, Xgene Cloud Ltd |
||||||
|
* |
||||||
|
* @author Naveen MR <oof1lab@gmail.com> |
||||||
|
* @author Pranav C Balan <pranavxc@gmail.com> |
||||||
|
* |
||||||
|
* @license GNU AGPL version 3 or any later version |
||||||
|
* |
||||||
|
* This program is free software: you can redistribute it and/or modify |
||||||
|
* it under the terms of the GNU Affero General Public License as |
||||||
|
* published by the Free Software Foundation, either version 3 of the |
||||||
|
* License, or (at your option) any later version. |
||||||
|
* |
||||||
|
* This program is distributed in the hope that it will be useful, |
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||||
|
* GNU Affero General Public License for more details. |
||||||
|
* |
||||||
|
* You should have received a copy of the GNU Affero General Public License |
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
* |
||||||
|
*/ |
@ -0,0 +1,36 @@ |
|||||||
|
import {BaseModelSql} from "../../dataMapper"; |
||||||
|
|
||||||
|
export const m2mNotChildren = ({models = {}}: { models: { [key: string]: BaseModelSql } }) => { |
||||||
|
return async (args) => { |
||||||
|
return models[args?.parent]?.m2mNotChildren(args); |
||||||
|
} |
||||||
|
} |
||||||
|
export const m2mNotChildrenCount = ({models = {}}: { models: { [key: string]: BaseModelSql } }) => { |
||||||
|
return async (args) => { |
||||||
|
return models[args?.parent]?.m2mNotChildrenCount(args); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* @copyright Copyright (c) 2021, Xgene Cloud Ltd |
||||||
|
* |
||||||
|
* @author Naveen MR <oof1lab@gmail.com> |
||||||
|
* @author Pranav C Balan <pranavxc@gmail.com> |
||||||
|
* |
||||||
|
* @license GNU AGPL version 3 or any later version |
||||||
|
* |
||||||
|
* This program is free software: you can redistribute it and/or modify |
||||||
|
* it under the terms of the GNU Affero General Public License as |
||||||
|
* published by the Free Software Foundation, either version 3 of the |
||||||
|
* License, or (at your option) any later version. |
||||||
|
* |
||||||
|
* This program is distributed in the hope that it will be useful, |
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||||
|
* GNU Affero General Public License for more details. |
||||||
|
* |
||||||
|
* You should have received a copy of the GNU Affero General Public License |
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
||||||
|
* |
||||||
|
*/ |
@ -0,0 +1,32 @@ |
|||||||
|
import BaseRender from "../../BaseRender"; |
||||||
|
|
||||||
|
class BaseGqlXcTsSchema extends BaseRender { |
||||||
|
|
||||||
|
/** |
||||||
|
* |
||||||
|
* @param dir |
||||||
|
* @param filename |
||||||
|
* @param ct |
||||||
|
* @param ctx.tn |
||||||
|
* @param ctx.columns |
||||||
|
* @param ctx.relations |
||||||
|
*/ |
||||||
|
constructor({dir, filename, ctx}) { |
||||||
|
super({dir, filename, ctx}); |
||||||
|
} |
||||||
|
|
||||||
|
protected generateManyToManyTypeProps(args: any): string { |
||||||
|
if (!args.manyToMany?.length) { |
||||||
|
return ''; |
||||||
|
} |
||||||
|
let str = '\r\n'; |
||||||
|
for (const mm of args.manyToMany) { |
||||||
|
str += `\t\t${mm._rtn}MMList: [${mm._rtn}]\r\n`; |
||||||
|
} |
||||||
|
return str; |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
export default BaseGqlXcTsSchema; |
Loading…
Reference in new issue