AndreyAttr / Evo

Evo repo
MIT License
0 stars 1 forks source link

Add *edit gene* component #49

Closed AndreyAttr closed 7 years ago

AndreyAttr commented 7 years ago

Need to allow user to add new genes into dropbox

AndreyAttr commented 7 years ago

TODO: We need directive OptionSelected to allow [attr.selected] adds only ONE selected attribute to HTMLElement to mark neccessary chosen item into select tag list chosen by default: [attr.selected]="currentChosenSite?.site === site?.site"

Updated: see two last commits - directive is useless to solve this problem. It exists, but it does nothing

AndreyAttr commented 7 years ago

Still need to:

  1. display some error message when user adds gene which already added(impossible to add);
  2. allowing user to choose more than one site by adding several dropboxes(issue #58 for this purpose)
  3. TODO problem solving & refactoring:
    remove(gene: Gene){
        // if(this._genes.some(g => g.name === gene.name))
        //     this.arrayHelper.removeFrom(gene, this._genes);
        if(this.contains(gene))
            this._genes[gene.name] = undefined;         //TODO: need to fully remove key-value pair, not leaving key-undefined
        return this;
    }

    and

    //TODO: we need better solution than having two genes collections: array & dictionary
    get genesIndexed(){return this._genes;}
    get genes(): Gene[]{...

    and private gene: Gene = new Gene('', [], ''); //TODO: create DI factory to initialize constructor of Gene with this empty values and then use it in component's constructor

AndreyAttr commented 7 years ago

With a new DictionaryArray it's possible to remove GJB2 gene, but it's not possible to remove ALDH2/ALDH2.

Updated: the problem is: GJB2 is added by using add() but ALDH2/ALDH2 persist into initial array which we send to constructor:

availableGenes: new GeneStorage(
        //TODO: find a way to map/transform SiteEnum to Site
        new Gene('HFE', [new Site(SiteEnum.A), new Site(SiteEnum.C), new Site(SiteEnum.G), new Site(SiteEnum.C), new Site(SiteEnum.U), new Site(SiteEnum.C)], 'Excess of iron in the body'),  //Surplus
        new Gene('ALDH2', [new Site(SiteEnum.G), new Site(SiteEnum.T),new Site(SiteEnum.U), new Site(SiteEnum.A), new Site(SiteEnum.C), new Site(SiteEnum.G)], 'Alcohol intolerance')
    ).add(new Gene('GJB2', [new Site(SiteEnum.A), new Site(SiteEnum.C), new Site(SiteEnum.G), new Site(SiteEnum.T), new Site(SiteEnum.U)], 'Deafness')),
AndreyAttr commented 7 years ago

Fixed: With a new DictionaryArray it's possible to remove GJB2 gene, but it's not possible to remove ALDH2/ALDH2 Solution: applying mapper for collection items if initializer is Array. Still there is a source of mistake: need to declare that mapper function must be used only with Array initializer.

tapy-lappy commented 7 years ago

@AndreyAttr, I found that your condition to fill up source is always return false and so, never execute:

if(array instanceof Array)
      array.map(item => mapper(item)).forEach(keyValuePair => this.add(keyValuePair));
AndreyAttr commented 7 years ago

@tapy-lappy , fixed