sorting: SortingFiled = {} as SortingFiled;
private icon = AppIcons.AppSortIcon;
activeName: SortingObjFieldsTypes = this.name;
active: CatalogSortingObjFields;
constructor(public name: SortingObjFields) {
this.initSortingFields(name);
this.sorting[Symbol.iterator] = function*(): IterableIterator<CatalogSortingObjFields> {
const values = Object.keys(SortingObjFields);
for (let i = 0; i < values.length; i++) {
const val = this[values[i]];
yield val;
}
};
}
onClick(name: SortingObjFieldsTypes) {
if (this.sorting[name].value) {
this.sorting[name].checked = !this.sorting[name].checked;
this.sorting[name].value = this.sorting[name].checked ? 'DESC' : 'ASC';
} else {
this.initSortingFields(name);
}
}
private initSortingFields(name: SortingObjFieldsTypes) {
for (const key in SortingObjFields) {
if (SortingObjFields.hasOwnProperty(key)) {
this.sorting[key] = {};
this.sorting[key].name = key;
this.sorting[key].textRu = SortingObjFieldsLiteralRu[key];
if (key === name) {
this.activeName = name;
this.active = this.sorting[name];
this.sorting[key].value = 'ASC';
this.sorting[key].checked = false;
this.sorting[key].icon = this.icon;
} else {
this.sorting[key].value = null;
this.sorting[key].checked = null;
this.sorting[key].icon = null;
}
}
}
}
toJSON() {
const res = {};
const values = Object.keys(SortingObjFields);
for (let i = 0; i < values.length; i++) {
if (SortingObjFields.hasOwnProperty(values[i])) {
if (this.sorting[values[i]].value) {
res[values[i]] = this.sorting[values[i]].value;
}
}
}
return res;
}
}
в телеге — нисколько
в телеге примерно ни хрена не читаемый и ни хрена не понятный. оформи куда-нибудь по-человечески
Обсуждают сегодня