aboutsummaryrefslogtreecommitdiff
path: root/src/new_fields
diff options
context:
space:
mode:
Diffstat (limited to 'src/new_fields')
-rw-r--r--src/new_fields/ObjectField.ts3
-rw-r--r--src/new_fields/SchemaHeaderField.ts38
-rw-r--r--src/new_fields/URLField.ts3
3 files changed, 31 insertions, 13 deletions
diff --git a/src/new_fields/ObjectField.ts b/src/new_fields/ObjectField.ts
index 5f4a6f8fb..65ada91c0 100644
--- a/src/new_fields/ObjectField.ts
+++ b/src/new_fields/ObjectField.ts
@@ -1,6 +1,7 @@
import { Doc } from "./Doc";
import { RefField } from "./RefField";
import { OnUpdate, Parent, Copy, ToScriptString } from "./FieldSymbols";
+import { Scripting } from "../client/util/Scripting";
export abstract class ObjectField {
protected [OnUpdate](diff?: any) { }
@@ -15,3 +16,5 @@ export namespace ObjectField {
return field[Copy]();
}
}
+
+Scripting.addGlobal(ObjectField); \ No newline at end of file
diff --git a/src/new_fields/SchemaHeaderField.ts b/src/new_fields/SchemaHeaderField.ts
index d5da56b10..23605cfb0 100644
--- a/src/new_fields/SchemaHeaderField.ts
+++ b/src/new_fields/SchemaHeaderField.ts
@@ -6,7 +6,7 @@ import { scriptingGlobal, Scripting } from "../client/util/Scripting";
import { ColumnType } from "../client/views/collections/CollectionSchemaView";
export const PastelSchemaPalette = new Map<string, string>([
- ["pink1", "#FFB4E8"],
+ // ["pink1", "#FFB4E8"],
["pink2", "#ff9cee"],
["pink3", "#ffccf9"],
["pink4", "#fcc2ff"],
@@ -15,7 +15,7 @@ export const PastelSchemaPalette = new Map<string, string>([
["purple2", "#c5a3ff"],
["purple3", "#d5aaff"],
["purple4", "#ecd4ff"],
- ["purple5", "#fb34ff"],
+ // ["purple5", "#fb34ff"],
["purple6", "#dcd3ff"],
["purple7", "#a79aff"],
["purple8", "#b5b9ff"],
@@ -25,17 +25,18 @@ export const PastelSchemaPalette = new Map<string, string>([
["bluegreen3", "#c4faf8"],
["bluegreen4", "#85e3ff"],
["bluegreen5", "#ace7ff"],
- ["bluegreen6", "#6eb5ff"],
+ // ["bluegreen6", "#6eb5ff"],
["bluegreen7", "#bffcc6"],
["bluegreen8", "#dbffd6"],
["yellow1", "#f3ffe3"],
["yellow2", "#e7ffac"],
["yellow3", "#ffffd1"],
["yellow4", "#fff5ba"],
- ["red1", "#ffc9de"],
+ // ["red1", "#ffc9de"],
["red2", "#ffabab"],
["red3", "#ffbebc"],
["red4", "#ffcbc1"],
+ ["orange1", "#ffd5b3"],
]);
export const RandomPastel = () => Array.from(PastelSchemaPalette.values())[Math.floor(Math.random() * PastelSchemaPalette.size)];
@@ -45,20 +46,23 @@ export const RandomPastel = () => Array.from(PastelSchemaPalette.values())[Math.
export class SchemaHeaderField extends ObjectField {
@serializable(primitive())
heading: string;
+ @serializable(primitive())
color: string;
+ @serializable(primitive())
type: number;
+ @serializable(primitive())
+ width: number;
+ @serializable(primitive())
+ desc: boolean | undefined; // boolean determines sort order, undefined when no sort
- constructor(heading: string = "", color?: string, type?: ColumnType) {
+ constructor(heading: string = "", color: string = RandomPastel(), type?: ColumnType, width?: number, desc?: boolean) {
super();
this.heading = heading;
- this.color = color === "" || color === undefined ? RandomPastel() : color;
- if (type) {
- this.type = type;
- }
- else {
- this.type = 0;
- }
+ this.color = color;
+ this.type = type ? type : 0;
+ this.width = width ? width : -1;
+ this.desc = desc;
}
setHeading(heading: string) {
@@ -76,6 +80,16 @@ export class SchemaHeaderField extends ObjectField {
this[OnUpdate]();
}
+ setWidth(width: number) {
+ this.width = width;
+ this[OnUpdate]();
+ }
+
+ setDesc(desc: boolean | undefined) {
+ this.desc = desc;
+ this[OnUpdate]();
+ }
+
[Copy]() {
return new SchemaHeaderField(this.heading, this.color, this.type);
}
diff --git a/src/new_fields/URLField.ts b/src/new_fields/URLField.ts
index d935a61af..b9ad96450 100644
--- a/src/new_fields/URLField.ts
+++ b/src/new_fields/URLField.ts
@@ -42,4 +42,5 @@ export abstract class URLField extends ObjectField {
@scriptingGlobal @Deserializable("image") export class ImageField extends URLField { }
@scriptingGlobal @Deserializable("video") export class VideoField extends URLField { }
@scriptingGlobal @Deserializable("pdf") export class PdfField extends URLField { }
-@scriptingGlobal @Deserializable("web") export class WebField extends URLField { } \ No newline at end of file
+@scriptingGlobal @Deserializable("web") export class WebField extends URLField { }
+@scriptingGlobal @Deserializable("youtube") export class YoutubeField extends URLField { }