diff --git a/src/mol-plugin/state/actions/basic.ts b/src/mol-plugin/state/actions/basic.ts index b8acbafe85cc39c3dec72a9fc35368f2c7ca6b77..85c3814a820fdf824e5050c403d02f3ce0990cca 100644 --- a/src/mol-plugin/state/actions/basic.ts +++ b/src/mol-plugin/state/actions/basic.ts @@ -22,7 +22,7 @@ export const CreateStructureFromPDBe = StateAction.create<PluginStateObject.Root definition: () => ({ id: PD.Text('PDB id', '', '1grm'), }), - validate: p => !p.id || !p.id.trim() ? [['Enter id.', 'id']] : void 0 + // validate: p => !p.id || !p.id.trim() ? [['Enter id.', 'id']] : void 0 }, apply({ params, state }) { const url = `http://www.ebi.ac.uk/pdbe/static/entry/${params.id.toLowerCase()}_updated.cif`; diff --git a/src/mol-plugin/state/transforms/data.ts b/src/mol-plugin/state/transforms/data.ts index 2f3e631cf59919520481560d1f8dfa9bc3fc5eff..3c7c043fd1f8f391a7012db9c19aded2bfe0d2f3 100644 --- a/src/mol-plugin/state/transforms/data.ts +++ b/src/mol-plugin/state/transforms/data.ts @@ -31,7 +31,7 @@ const Download = PluginStateTransform.Create<SO.Root, SO.Data.String | SO.Data.B label: PD.Text('Label', '', ''), isBinary: PD.Boolean('Binary', 'If true, download data as binary (string otherwise)', false) }), - validate: p => !p.url || !p.url.trim() ? [['Enter url.', 'url']] : void 0 + // validate: p => !p.url || !p.url.trim() ? [['Enter url.', 'url']] : void 0 }, apply({ params: p }, globalCtx: PluginContext) { return Task.create('Download', async ctx => { diff --git a/src/mol-plugin/state/transforms/visuals.ts b/src/mol-plugin/state/transforms/visuals.ts index 6bc0aa12e53040daca08c7f2309635f0c94ebd60..62eb11bc4131934636cf293c91294c60018e06f6 100644 --- a/src/mol-plugin/state/transforms/visuals.ts +++ b/src/mol-plugin/state/transforms/visuals.ts @@ -14,7 +14,10 @@ import { ParamDefinition as PD } from 'mol-util/param-definition'; export { CreateStructureRepresentation } namespace CreateStructureRepresentation { export interface Params { - type: { name: string, params: any /** todo is there "common type" */ } + type: { name: string, params: any /** todo is there "common type" */ }, + // TODO + // colorTheme: { name: string, params: any /** todo is there "common type" */ } + // sizeTheme: { name: string, params: any /** todo is there "common type" */ } } } const CreateStructureRepresentation = PluginStateTransform.Create<SO.Molecule.Structure, SO.Molecule.Representation3D, CreateStructureRepresentation.Params>({ diff --git a/src/mol-plugin/ui/state/parameters.tsx b/src/mol-plugin/ui/state/parameters.tsx index 81f3e591508199bab726d277561c581859f9092d..86d6727bdb10fee6e0eef30e4dba2bccd6dbfa92 100644 --- a/src/mol-plugin/ui/state/parameters.tsx +++ b/src/mol-plugin/ui/state/parameters.tsx @@ -4,7 +4,7 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import { StateObject, State, Transform, StateObjectCell } from 'mol-state'; +import { StateObject, State, Transform, StateObjectCell, Transformer } from 'mol-state'; import { shallowEqual } from 'mol-util/object'; import * as React from 'react'; import { PurePluginComponent } from '../base'; @@ -23,11 +23,14 @@ class StateTransformParameters extends PurePluginComponent<StateTransformParamet } validate(params: any) { - const validate = this.props.info.definition.validate; - if (!validate) return void 0; - const result = validate(params, this.props.info.source, this.plugin); - if (!result || result.length === 0) return void 0; - return result.map(r => r[0]); + // TODO + return void 0; + + // const validate = this.props.info.definition.validate; + // if (!validate) return void 0; + // const result = validate(params, this.props.info.source, this.plugin); + // if (!result || result.length === 0) return void 0; + // return result.map(r => r[0]); } areInitial(params: any) { @@ -50,7 +53,7 @@ class StateTransformParameters extends PurePluginComponent<StateTransformParamet namespace StateTransformParameters { export interface Props { info: { - definition: PD.Provider, + definition: Transformer.ParamsProvider, params: PD.Params, initialValues: any, source: StateObject, diff --git a/src/mol-state/action.ts b/src/mol-state/action.ts index 4898eb6be775af4fb07fa6e5ab52ffad16212f7d..a4e6fb42ba7902578998fed632c2ff5ec181c5b2 100644 --- a/src/mol-state/action.ts +++ b/src/mol-state/action.ts @@ -46,7 +46,7 @@ namespace StateAction { */ apply(params: ApplyParams<A, P>, globalCtx: unknown): T | Task<T>, - readonly params?: PD.Provider<A, P, unknown> + readonly params?: Transformer.ParamsProvider<A, P> /** Test if the transform can be applied to a given node */ isApplicable?(a: A, globalCtx: unknown): boolean diff --git a/src/mol-state/transformer.ts b/src/mol-state/transformer.ts index 1bf6aaceef3ed8a28140113c1223e0bf7d56e4fe..e9b8acfa27dc1071441ced6c820889c5bf253315 100644 --- a/src/mol-state/transformer.ts +++ b/src/mol-state/transformer.ts @@ -47,6 +47,15 @@ export namespace Transformer { export enum UpdateResult { Unchanged, Updated, Recreate } + export interface ParamsProvider<A extends StateObject = StateObject, P = any> { + /** Check the parameters and return a list of errors if the are not valid. */ + default?(a: A, globalCtx: unknown): P, + /** Specify default control descriptors for the parameters */ + definition?(a: A, globalCtx: unknown): { [K in keyof P]?: PD.Any }, + /** Optional custom parameter equality. Use shallow structural equal by default. */ + areEqual?(oldParams: P, newParams: P): boolean + } + export interface Definition<A extends StateObject = StateObject, B extends StateObject = StateObject, P = unknown> { readonly name: string, readonly from: StateObject.Ctor[], @@ -66,7 +75,7 @@ export namespace Transformer { */ update?(params: UpdateParams<A, B, P>, globalCtx: unknown): Task<UpdateResult> | UpdateResult, - readonly params?: PD.Provider<A, P, unknown>, + readonly params?: ParamsProvider<A, P>, /** Test if the transform can be applied to a given node */ isApplicable?(a: A, globalCtx: unknown): boolean, diff --git a/src/mol-util/param-definition.ts b/src/mol-util/param-definition.ts index ffc2d93f582aafbf6c5cf2a433e950650ea5e7a7..c77857660e8fa64f4b2ab51d3d3480741cdc4195 100644 --- a/src/mol-util/param-definition.ts +++ b/src/mol-util/param-definition.ts @@ -135,14 +135,8 @@ export namespace ParamDefinition { */ export type ParamErrors = [string, string | string[]][] - export interface Provider<A = any, P = any, Ctx = any> { - /** Check the parameters and return a list of errors if the are not valid. */ - default?(a: A, globalCtx: Ctx): P, - /** Specify default control descriptors for the parameters */ - definition?(a: A, globalCtx: Ctx): { [K in keyof P]?: Any }, - /** Check the parameters and return a list of errors if the are not valid. */ - validate?(params: P, a: A, globalCtx: unknown): ParamErrors | undefined, - /** Optional custom parameter equality. Use shallow structural equal by default. */ - areEqual?(oldParams: P, newParams: P): boolean + export function validate(params: Params, values: any): ParamErrors | undefined { + // TODO + return void 0; } } \ No newline at end of file