Closed AndreyAttr closed 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
Still need to:
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
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')),
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
@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));
@tapy-lappy , fixed
Need to allow user to add new genes into dropbox