Skip to content
Snippets Groups Projects
Commit fd6aac51 authored by David Sehnal's avatar David Sehnal
Browse files

mol-plugin: Group

parent 118daa2b
No related branches found
No related tags found
No related merge requests found
/**
* Copyright (c) 2018-2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author David Sehnal <david.sehnal@gmail.com>
*/
import { StateTransformer } from 'mol-state';
import { shallowEqual } from 'mol-util';
import { ParamDefinition as PD } from 'mol-util/param-definition';
import { PluginStateObject as SO, PluginStateTransform } from '../objects';
export { CreateGroup };
type CreateGroup = typeof CreateGroup
const CreateGroup = PluginStateTransform.BuiltIn({
name: 'create-group',
display: { name: 'Parse CIF', description: 'Parse CIF from String or Binary data' },
from: [],
to: SO.Group,
params: {
label: PD.Text('Group'),
description: PD.makeOptional(PD.Text(''))
}
})({
apply({ params }) {
return new SO.Group({}, params);
},
update({ oldParams, newParams, b }) {
if (shallowEqual(oldParams, newParams)) return StateTransformer.UpdateResult.Unchanged;
b.label = newParams.label;
b.description = newParams.description;
return StateTransformer.UpdateResult.Updated;
}
});
\ No newline at end of file
......@@ -70,6 +70,13 @@ namespace StateBuilder {
return new To(this.state, t.ref, this.root);
}
/**
* A helper to greate a group-like state object and keep the current type.
*/
group<T extends StateTransformer<A, any, any>>(tr: T, params?: StateTransformer.Params<T>, options?: Partial<StateTransform.Options>, initialCellState?: Partial<StateObjectCell.State>): To<A> {
return this.apply(tr, params, options, initialCellState) as To<A>;
}
/**
* Inserts a new transform that does not change the object type and move the original children to it.
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment