Changeset View
Changeset View
Standalone View
Standalone View
lib/chip-types/field.js
"use strict"; | "use strict"; | ||||
const locreq = require("locreq")(__dirname); | const locreq = require("locreq")(__dirname); | ||||
const default_methods = require("./field-type-default-methods.js"); | const default_methods = require("./field-type-default-methods.js"); | ||||
const FieldType = locreq("lib/chip-types/field-type.js"); | const FieldType = locreq("lib/chip-types/field-type.js"); | ||||
function Field(app, declaration, collection) { | function Field(app, declaration, collection) { | ||||
this.name = declaration.name; | this.name = declaration.name; | ||||
this.declaration = declaration; | this.declaration = declaration; | ||||
this.type = new FieldType(app, declaration.type); | this.type = new FieldType(app, declaration.type); | ||||
this.value_path = | this.value_path = this.name + (this.type.value_path_after_field_name || ""); | ||||
"body." + this.name + (this.type.value_path_after_field_name || ""); | |||||
this.required = declaration.required || false; | this.required = declaration.required || false; | ||||
this.params = declaration.params || {}; | this.params = declaration.params || {}; | ||||
this.type.init(collection, declaration.name, this.params); | this.type.init(collection, declaration.name, this.params); | ||||
const self = this; | const self = this; | ||||
for (const method_name in default_methods) { | for (const method_name in default_methods) { | ||||
this[method_name] = (function(method_name) { | this[method_name] = (function(method_name) { | ||||
Show All 30 Lines |