Changeset View
Changeset View
Standalone View
Standalone View
lib/app/base-chips/field-types/value-not-existing-in-collection.js
const assert = require("assert"); | const assert = require("assert"); | ||||
module.exports = app => { | module.exports = app => { | ||||
return { | return { | ||||
name: "value-not-existing-in-collection", | name: "value-not-existing-in-collection", | ||||
extends: "value-existing-in-collection", | extends: "value-existing-in-collection", | ||||
is_proper_value: async (context, params, new_value) => { | is_proper_value: async (_context, params, new_value) => { | ||||
assert.equal(typeof params.field, "string"); | assert.equal(typeof params.field, "string"); | ||||
assert( | assert( | ||||
typeof params.include_forbidden === "boolean" || | typeof params.include_forbidden === "boolean" || | ||||
params.include_forbidden === undefined | params.include_forbidden === undefined | ||||
); | ); | ||||
const collection = params.collection; | const collection = params.collection; | ||||
assert(collection instanceof app.Sealious.Collection); | assert(collection instanceof app.Sealious.Collection); | ||||
await collection.fields[params.field].is_proper_value( | await collection.fields[params.field].is_proper_value( | ||||
context, | _context, | ||||
new_value | new_value | ||||
); | ); | ||||
let context = _context; | |||||
if (params.include_forbidden) { | if (params.include_forbidden) { | ||||
context = new app.Sealious.SuperContext(); | context = new app.Sealious.SuperContext(); | ||||
} | } | ||||
const matches = (await app.run_action( | const matches = (await app.run_action( | ||||
context, | context, | ||||
["collections", collection.name], | ["collections", collection.name], | ||||
"show", | "show", | ||||
{ filter: { [params.field]: new_value } } | { filter: { [params.field]: new_value } } | ||||
Show All 11 Lines |