mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
(core) Make Attachments columns get treated like RefLists more
Summary: Treat the column type 'Attachments' as equivalent to 'RefList:_grist_Attachments' in a few places, because that's essentially what it is. The main goal was to fix parsing strings representing attachments (reflists). Also removed an unused function. Test Plan: Tested manually that pasting a CSV/JSON string representation of an attachments reflists works now. Reviewers: paulfitz Reviewed By: paulfitz Subscribers: paulfitz Differential Revision: https://phab.getgrist.com/D3338
This commit is contained in:
parent
24522e61ff
commit
06956f84a5
@ -220,6 +220,7 @@ export const valueParserClasses: { [type: string]: typeof ValueParser } = {
|
|||||||
ChoiceList: ChoiceListParser,
|
ChoiceList: ChoiceListParser,
|
||||||
Ref: ReferenceParser,
|
Ref: ReferenceParser,
|
||||||
RefList: ReferenceListParser,
|
RefList: ReferenceListParser,
|
||||||
|
Attachments: ReferenceListParser,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -56,6 +56,9 @@ export function getDefaultForType(colType: string, options: {sqlFormatted?: bool
|
|||||||
* object.
|
* object.
|
||||||
*/
|
*/
|
||||||
export function extractInfoFromColType(colType: string): GristTypeInfo {
|
export function extractInfoFromColType(colType: string): GristTypeInfo {
|
||||||
|
if (colType === "Attachments") {
|
||||||
|
return {type: "RefList", tableId: "_grist_Attachments"};
|
||||||
|
}
|
||||||
const colon = colType.indexOf(':');
|
const colon = colType.indexOf(':');
|
||||||
const [type, arg] = (colon === -1) ? [colType] : [colType.slice(0, colon), colType.slice(colon + 1)];
|
const [type, arg] = (colon === -1) ? [colType] : [colType.slice(0, colon), colType.slice(colon + 1)];
|
||||||
return (type === 'Ref') ? {type, tableId: String(arg)} :
|
return (type === 'Ref') ? {type, tableId: String(arg)} :
|
||||||
@ -223,17 +226,6 @@ export function extractTypeFromColType(type: string): string {
|
|||||||
return (colon === -1 ? type : type.slice(0, colon));
|
return (colon === -1 ? type : type.slice(0, colon));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert pureType to Grist python type name, e.g. 'Ref' to 'Reference'.
|
|
||||||
*/
|
|
||||||
export function getGristType(pureType: string): string {
|
|
||||||
switch (pureType) {
|
|
||||||
case 'Ref': return 'Reference';
|
|
||||||
case 'RefList': return 'ReferenceList';
|
|
||||||
default: return pureType;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enum for values of columns' recalcWhen property, corresponding to Python definitions in
|
* Enum for values of columns' recalcWhen property, corresponding to Python definitions in
|
||||||
* schema.py.
|
* schema.py.
|
||||||
@ -331,11 +323,14 @@ export function sequelizeToGristType(sqlType: string): GristType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getReferencedTableId(type: string) {
|
export function getReferencedTableId(type: string) {
|
||||||
|
if (type === "Attachments") {
|
||||||
|
return "_grist_Attachments";
|
||||||
|
}
|
||||||
return removePrefix(type, "Ref:") || removePrefix(type, "RefList:");
|
return removePrefix(type, "Ref:") || removePrefix(type, "RefList:");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isRefListType(type: string) {
|
export function isRefListType(type: string) {
|
||||||
return type.startsWith('RefList:');
|
return type === "Attachments" || type.startsWith('RefList:');
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isFullReferencingType(type: string) {
|
export function isFullReferencingType(type: string) {
|
||||||
|
Loading…
Reference in New Issue
Block a user