Преглед на файлове

adding an index to download files name

Yana Rose преди 4 години
родител
ревизия
1017356479
променени са 1 файла, в които са добавени 3 реда и са изтрити 2 реда
  1. 3 2
      src/viewer/helpers/export.ts

+ 3 - 2
src/viewer/helpers/export.ts

@@ -47,13 +47,14 @@ function getDecorator(plugin: PluginContext, root: string): string {
 function extractStructureDataFromState(plugin: PluginContext): { [k: string]: Structure } {
     const content: { [k: string]: Structure } = {};
     const cells = plugin.state.data.select(StateSelection.Generators.rootsOfType(PluginStateObject.Molecule.Structure));
-    for (const c of cells) {
+    for (let i=0; i<cells.length; i++) {
+        const c = cells[i];
         const nodeRef = getDecorator(plugin, c.transform.ref);
         const children = plugin.state.data.select(StateSelection.Generators.byRef(nodeRef))
             .map(child => child.obj!.data);
         const sele = StructureSelection.Sequence(c.obj!.data, children);
         const structure = StructureSelection.unionStructure(sele);
-        const name = structure.model.entryId;
+        const name = `${i+1}-${structure.model.entryId}`;
         content[name] = structure;
     }
     return content;