aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2023-07-10 20:30:39 -0400
committerbobzel <zzzman@gmail.com>2023-07-10 20:30:39 -0400
commitbf2eb58ec337eb32f4bdcca1db08c43d5a97f15a (patch)
treec8fccb56e0c09fa082693ce2c71684dd120979e0
parent2f4c55bf026a249910e90451a173234934ebca01 (diff)
fixed acl groups from disappearing when new account is made.
-rw-r--r--src/client/documents/DocumentTypes.ts1
-rw-r--r--src/client/documents/Documents.ts18
-rw-r--r--src/client/util/ScriptManager.ts38
3 files changed, 17 insertions, 40 deletions
diff --git a/src/client/documents/DocumentTypes.ts b/src/client/documents/DocumentTypes.ts
index cdc8c275c..6cd8de87a 100644
--- a/src/client/documents/DocumentTypes.ts
+++ b/src/client/documents/DocumentTypes.ts
@@ -42,7 +42,6 @@ export enum DocumentType {
COMPARISON = 'comparison',
GROUP = 'group',
- LINKDB = 'linkdb', // database of links ??? why do we have this
SCRIPTDB = 'scriptdb', // database of scripts
GROUPDB = 'groupdb', // database of groups
}
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index 18e8b5940..f1ba852f9 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -543,14 +543,6 @@ export namespace Docs {
},
],
[
- DocumentType.LINKDB,
- {
- data: new List<Doc>(),
- layout: { view: EmptyBox, dataField: defaultDataKey },
- options: { title: 'Global Link Database' },
- },
- ],
- [
DocumentType.SCRIPTDB,
{
data: new List<Doc>(),
@@ -667,7 +659,6 @@ export namespace Docs {
[
DocumentType.GROUPDB,
{
- data: new List<Doc>(),
layout: { view: EmptyBox, dataField: defaultDataKey },
options: { title: 'Global Group Database' },
},
@@ -722,7 +713,7 @@ export namespace Docs {
.filter(type => type !== DocumentType.NONE)
.map(type => type + suffix);
// fetch the actual prototype documents from the server
- const actualProtos = Docs.newAccount ? {} : await DocServer.GetRefFields(prototypeIds);
+ const actualProtos = await DocServer.GetRefFields(prototypeIds);
// update this object to include any default values: DocumentOptions for all prototypes
prototypeIds.map(id => {
const existing = actualProtos[id] as Doc;
@@ -747,13 +738,6 @@ export namespace Docs {
}
/**
- * A collection of all links in the database. Ideally, this would be a search, but for now all links are cached here.
- */
- export function MainLinkDocument() {
- return Prototypes.get(DocumentType.LINKDB);
- }
-
- /**
* A collection of all scripts in the database
*/
export function MainScriptDocument() {
diff --git a/src/client/util/ScriptManager.ts b/src/client/util/ScriptManager.ts
index 42a6493ea..87509f2ea 100644
--- a/src/client/util/ScriptManager.ts
+++ b/src/client/util/ScriptManager.ts
@@ -1,12 +1,11 @@
-import { Doc, DocListCast } from "../../fields/Doc";
-import { List } from "../../fields/List";
-import { listSpec } from "../../fields/Schema";
-import { Cast, StrCast } from "../../fields/Types";
-import { Docs } from "../documents/Documents";
-import { ScriptingGlobals } from "./ScriptingGlobals";
+import { Doc, DocListCast } from '../../fields/Doc';
+import { List } from '../../fields/List';
+import { listSpec } from '../../fields/Schema';
+import { Cast, StrCast } from '../../fields/Types';
+import { Docs } from '../documents/Documents';
+import { ScriptingGlobals } from './ScriptingGlobals';
export class ScriptManager {
-
static _initialized = false;
private static _instance: ScriptManager;
public static get Instance(): ScriptManager {
@@ -24,11 +23,7 @@ export class ScriptManager {
}
public getAllScripts(): Doc[] {
const sdoc = ScriptManager.Instance.ScriptManagerDoc;
- if (sdoc) {
- const docs = DocListCast(sdoc.data);
- return docs;
- }
- return [];
+ return sdoc ? DocListCast(sdoc.data) : [];
}
public addScript(scriptDoc: Doc): boolean {
@@ -59,36 +54,35 @@ export class ScriptManager {
}
public static addScriptToGlobals(scriptDoc: Doc): void {
-
ScriptingGlobals.removeGlobal(StrCast(scriptDoc.name));
- const params = Cast(scriptDoc["data-params"], listSpec("string"), []);
+ const params = Cast(scriptDoc['data-params'], listSpec('string'), []);
const paramNames = params.reduce((o: string, p: string) => {
if (params.indexOf(p) === params.length - 1) {
- o = o + p.split(":")[0].trim();
+ o = o + p.split(':')[0].trim();
} else {
- o = o + p.split(":")[0].trim() + ",";
+ o = o + p.split(':')[0].trim() + ',';
}
return o;
- }, "" as string);
+ }, '' as string);
const f = new Function(paramNames, StrCast(scriptDoc.script));
Object.defineProperty(f, 'name', { value: StrCast(scriptDoc.name), writable: false });
- let parameters = "(";
+ let parameters = '(';
params.forEach((element: string, i: number) => {
if (i === params.length - 1) {
- parameters = parameters + element + ")";
+ parameters = parameters + element + ')';
} else {
- parameters = parameters + element + ", ";
+ parameters = parameters + element + ', ';
}
});
- if (parameters === "(") {
+ if (parameters === '(') {
ScriptingGlobals.add(f, StrCast(scriptDoc.description));
} else {
ScriptingGlobals.add(f, StrCast(scriptDoc.description), parameters);
}
}
-} \ No newline at end of file
+}