fix: filter developer mode with isTruly/isFalsy

This commit is contained in:
chenos 2021-01-04 13:14:45 +08:00
parent 10b2199e54
commit 74600f0eb5
3 changed files with 30 additions and 23 deletions

View File

@ -19,7 +19,7 @@ export default async (ctx, next) => {
const options = Tab.parseApiJson({
filter: {
enabled: true,
developerMode: ctx.state.developerMode,
developerMode: ctx.state.developerMode ? {'$isTruly': true} : {'$isFalsy': true},
},
fields: {
appends: ['associationField'],

View File

@ -42,7 +42,7 @@ export default async function getRoutes(ctx, next) {
const Collection = database.getModel('collections');
let pages = await Page.findAll(Page.parseApiJson({
filter: {
'developerMode': ctx.state.developerMode,
developerMode: ctx.state.developerMode ? {'$isTruly': true} : {'$isFalsy': true},
},
sort: ['sort'],
}));
@ -52,7 +52,7 @@ export default async function getRoutes(ctx, next) {
if (page.get('path') === '/collections') {
const collections = await Collection.findAll(Collection.parseApiJson({
filter: {
developerMode: ctx.state.developerMode,
developerMode: ctx.state.developerMode ? {'$isTruly': true} : {'$isFalsy': true},
showInDataMenu: true,
},
sort: ['sort'],

View File

@ -38,13 +38,14 @@ const transforms = {
}
if (field.get('name') === 'filter' && field.get('collection_name') === 'views') {
const { values } = ctx.action.params;
const all = await Field.findAll({
where: {
const options = Field.parseApiJson({
filter: {
collection_name: get(values, 'associatedKey'),
developerMode: ctx.state.developerMode,
developerMode: ctx.state.developerMode ? {'$isTruly': true} : {'$isFalsy': true},
},
order: [['sort', 'asc']],
sort: 'sort',
});
const all = await Field.findAll(options);
set(prop, 'x-component-props.fields', all.filter(f => f.get('filterable')));
}
if (type === 'select') {
@ -160,20 +161,22 @@ export default async (ctx, next) => {
name: resourceName,
},
});
const where: any = {
developerMode: ctx.state.developerMode,
// const where: any = {
// developerMode: ctx.state.developerMode,
// }
const filter: any = {
developerMode: ctx.state.developerMode ? {'$isTruly': true} : {'$isFalsy': true},
}
if (!view.get('draggable')) {
where.type = {
[Op.not]: 'sort',
filter.type = {
not: 'sort',
};
}
let fields = await collection.getFields({
where,
order: [
['sort', 'asc'],
]
const fieldOptions = Field.parseApiJson({
filter,
sort: 'sort',
});
let fields = await collection.getFields(fieldOptions);
fields = fields.filter(field => {
if (field.get('interface') === 'linkTo') {
if (throughName && throughName === field.get('through')) {
@ -182,18 +185,18 @@ export default async (ctx, next) => {
}
return true;
})
const actions = await collection.getActions({
where: {
developerMode: ctx.state.developerMode,
const options = Action.parseApiJson({
filter: {
developerMode: ctx.state.developerMode ? {'$isTruly': true} : {'$isFalsy': true},
},
order: [
['sort', 'asc'],
]
sort: 'sort',
});
const actions = await collection.getActions(options);
let actionNames = view.get('actionNames') || [];
if (actionNames.length === 0) {
actionNames = ['filter', 'create', 'destroy'];
}
if (view.get('type') === 'table') {
const defaultTabs = await collection.getTabs({
where: {
@ -206,6 +209,10 @@ export default async (ctx, next) => {
if (view.get('type') === 'table') {
view.setDataValue('rowViewName', 'form');
}
if (view.get('type') === 'calendar') {
view.setDataValue('template', 'Calendar');
view.setDataValue('rowViewName', 'form');
}
if (view.get('updateViewName')) {
view.setDataValue('rowViewName', view.get('updateViewName'));
}