AndreyAttr / Evo

Evo repo
MIT License
0 stars 1 forks source link

found how to do full(deep) copy of instance(Angular or TS described how to do that) #65

Closed AndreyAttr closed 7 years ago

AndreyAttr commented 7 years ago

Actually we need this improvement into gene-editor.component:

        //TODO: Angular/TS allows to do copies simplier - find it
        //Note: Using local LET variable to prevent setting all the this.gene properties to NULL when we reset the form
        let gene = new Gene(this.gene.name, [this.currentChosenSite], this.gene.description);

gene-mutation.component.ts: //this.submittedEvent.emit(ObjectHelper.deepTreeCopy(this.gene)); //TODO: need to implement deep copy for tree structure(better if as overload for deepCopy(and overload for arrays too!)) &

private prepareChanges():Gene{
        const formModel = this.mutationForm.value;
        const mutatedSites: Site[] = ObjectHelper.deepCopyArray<Site>(formModel.formGroups);    //Error: formModel.formGroups.controls
        const gene:Gene = {
            name: this.gene.name,
            id: this.gene.id,
            sites: this.gene.sites,
            isMutated: this.gene.isMutated,             //Workaround: gene.isMutated is computable. It's bad approach to reinitialize it here
            //mutationSites: formModel.formGroups,      //TODO: Bad - need deep copy
            mutationSites: mutatedSites,                //Done
            description: formModel.description as string
        };
        return gene;
    }
AndreyAttr commented 7 years ago

It is described here: https://angular.io/guide/reactive-forms#save

AndreyAttr commented 7 years ago

Need to cherry pick the commit above to angular branch from mutation

AndreyAttr commented 7 years ago

cherry picked. Can continue working with it on angular branch

AndreyAttr commented 7 years ago

The logic for this has been fully uploaded into mutation branch, see https://github.com/AndreyAttr/Evo/issues/76. Need to wait merge with angular branch. We need to do appropriate changes into gene-editor.component, as described here above & into DictionaryArray(mixins, deepCopy).

tapy-lappy commented 7 years ago

merged into angular branch

AndreyAttr commented 7 years ago

still connected with a #76