nav tabs on admin dashboard

This commit is contained in:
2019-03-07 00:20:34 -06:00
parent f73d6ae228
commit e4f473f376
11661 changed files with 216240 additions and 1544253 deletions

View File

@@ -5,54 +5,82 @@
"use strict";
class BasicEvaluatedExpression {
const TypeUnknown = 0;
const TypeNull = 1;
const TypeString = 2;
const TypeNumber = 3;
const TypeBoolean = 4;
const TypeRegExp = 5;
const TypeConditional = 6;
const TypeArray = 7;
const TypeConstArray = 8;
const TypeIdentifier = 9;
const TypeWrapped = 10;
const TypeTemplateString = 11;
class BasicEvaluatedExpression {
constructor() {
this.type = TypeUnknown;
this.range = null;
this.falsy = false;
this.truthy = false;
this.bool = null;
this.number = null;
this.regExp = null;
this.string = null;
this.quasis = null;
this.parts = null;
this.array = null;
this.items = null;
this.options = null;
this.prefix = null;
this.postfix = null;
this.wrappedInnerExpressions = null;
this.expression = null;
}
isNull() {
return !!this.null;
return this.type === TypeNull;
}
isString() {
return Object.prototype.hasOwnProperty.call(this, "string");
return this.type === TypeString;
}
isNumber() {
return Object.prototype.hasOwnProperty.call(this, "number");
return this.type === TypeNumber;
}
isBoolean() {
return Object.prototype.hasOwnProperty.call(this, "bool");
return this.type === TypeBoolean;
}
isRegExp() {
return Object.prototype.hasOwnProperty.call(this, "regExp");
return this.type === TypeRegExp;
}
isConditional() {
return Object.prototype.hasOwnProperty.call(this, "options");
return this.type === TypeConditional;
}
isArray() {
return Object.prototype.hasOwnProperty.call(this, "items");
return this.type === TypeArray;
}
isConstArray() {
return Object.prototype.hasOwnProperty.call(this, "array");
return this.type === TypeConstArray;
}
isIdentifier() {
return Object.prototype.hasOwnProperty.call(this, "identifier");
return this.type === TypeIdentifier;
}
isWrapped() {
return Object.prototype.hasOwnProperty.call(this, "prefix") || Object.prototype.hasOwnProperty.call(this, "postfix");
return this.type === TypeWrapped;
}
isTemplateString() {
return Object.prototype.hasOwnProperty.call(this, "quasis");
return this.type === TypeTemplateString;
}
isTruthy() {
@@ -64,112 +92,133 @@ class BasicEvaluatedExpression {
}
asBool() {
if(this.truthy) return true;
else if(this.falsy) return false;
else if(this.isBoolean()) return this.bool;
else if(this.isNull()) return false;
else if(this.isString()) return !!this.string;
else if(this.isNumber()) return !!this.number;
else if(this.isRegExp()) return true;
else if(this.isArray()) return true;
else if(this.isConstArray()) return true;
else if(this.isWrapped()) return this.prefix && this.prefix.asBool() || this.postfix && this.postfix.asBool() ? true : undefined;
else if(this.isTemplateString()) {
if(this.quasis.length === 1) return this.quasis[0].asBool();
for(let i = 0; i < this.quasis.length; i++) {
if(this.quasis[i].asBool()) return true;
}
// can't tell if string will be empty without executing
if (this.truthy) return true;
if (this.falsy) return false;
if (this.isBoolean()) return this.bool;
if (this.isNull()) return false;
if (this.isString()) return this.string !== "";
if (this.isNumber()) return this.number !== 0;
if (this.isRegExp()) return true;
if (this.isArray()) return true;
if (this.isConstArray()) return true;
if (this.isWrapped()) {
return (this.prefix && this.prefix.asBool()) ||
(this.postfix && this.postfix.asBool())
? true
: undefined;
}
if (this.isTemplateString()) {
const str = this.asString();
if (typeof str === "string") return str !== "";
}
return undefined;
}
setString(str) {
if(str === null)
delete this.string;
else
this.string = str;
asString() {
if (this.isBoolean()) return `${this.bool}`;
if (this.isNull()) return "null";
if (this.isString()) return this.string;
if (this.isNumber()) return `${this.number}`;
if (this.isRegExp()) return `${this.regExp}`;
if (this.isArray()) {
let array = [];
for (const item of this.items) {
const itemStr = item.asString();
if (itemStr === undefined) return undefined;
array.push(itemStr);
}
return `${array}`;
}
if (this.isConstArray()) return `${this.array}`;
if (this.isTemplateString()) {
let str = "";
for (const part of this.parts) {
const partStr = part.asString();
if (partStr === undefined) return undefined;
str += partStr;
}
return str;
}
return undefined;
}
setString(string) {
this.type = TypeString;
this.string = string;
return this;
}
setNull() {
this.null = true;
this.type = TypeNull;
return this;
}
setNumber(num) {
if(num === null)
delete this.number;
else
this.number = num;
setNumber(number) {
this.type = TypeNumber;
this.number = number;
return this;
}
setBoolean(bool) {
if(bool === null)
delete this.bool;
else
this.bool = bool;
this.type = TypeBoolean;
this.bool = bool;
return this;
}
setRegExp(regExp) {
if(regExp === null)
delete this.regExp;
else
this.regExp = regExp;
this.type = TypeRegExp;
this.regExp = regExp;
return this;
}
setIdentifier(identifier) {
if(identifier === null)
delete this.identifier;
else
this.identifier = identifier;
this.type = TypeIdentifier;
this.identifier = identifier;
return this;
}
setWrapped(prefix, postfix) {
setWrapped(prefix, postfix, innerExpressions) {
this.type = TypeWrapped;
this.prefix = prefix;
this.postfix = postfix;
return this;
}
unsetWrapped() {
delete this.prefix;
delete this.postfix;
this.wrappedInnerExpressions = innerExpressions;
return this;
}
setOptions(options) {
if(options === null)
delete this.options;
else
this.options = options;
this.type = TypeConditional;
this.options = options;
return this;
}
addOptions(options) {
if (!this.options) {
this.type = TypeConditional;
this.options = [];
}
for (const item of options) {
this.options.push(item);
}
return this;
}
setItems(items) {
if(items === null)
delete this.items;
else
this.items = items;
this.type = TypeArray;
this.items = items;
return this;
}
setArray(array) {
if(array === null)
delete this.array;
else
this.array = array;
this.type = TypeConstArray;
this.array = array;
return this;
}
setTemplateString(quasis) {
if(quasis === null)
delete this.quasis;
else
this.quasis = quasis;
setTemplateString(quasis, parts, kind) {
this.type = TypeTemplateString;
this.quasis = quasis;
this.parts = parts;
this.templateStringKind = kind;
return this;
}
@@ -185,19 +234,15 @@ class BasicEvaluatedExpression {
return this;
}
addOptions(options) {
if(!this.options) this.options = [];
options.forEach(item => {
this.options.push(item);
}, this);
return this;
}
setRange(range) {
this.range = range;
return this;
}
setExpression(expression) {
this.expression = expression;
return this;
}
}
module.exports = BasicEvaluatedExpression;