misc.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. /**
  2. * Copyright (c) 2018-2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
  3. *
  4. * @author David Sehnal <david.sehnal@gmail.com>
  5. */
  6. import { StateTransformer } from '../../../mol-state';
  7. import { shallowEqualObjects } from '../../../mol-util';
  8. import { ParamDefinition as PD } from '../../../mol-util/param-definition';
  9. import { PluginStateObject as SO, PluginStateTransform } from '../objects';
  10. export { CreateGroup };
  11. type CreateGroup = typeof CreateGroup
  12. const CreateGroup = PluginStateTransform.BuiltIn({
  13. name: 'create-group',
  14. display: { name: 'Parse CIF', description: 'Parse CIF from String or Binary data' },
  15. from: [],
  16. to: SO.Group,
  17. params: {
  18. label: PD.Text('Group'),
  19. description: PD.Optional(PD.Text(''))
  20. }
  21. })({
  22. apply({ params }) {
  23. return new SO.Group({}, params);
  24. },
  25. update({ oldParams, newParams, b }) {
  26. if (shallowEqualObjects(oldParams, newParams)) return StateTransformer.UpdateResult.Unchanged;
  27. b.label = newParams.label;
  28. b.description = newParams.description;
  29. return StateTransformer.UpdateResult.Updated;
  30. }
  31. });